Diffstat (limited to 'noncore/todayplugins/weather/weatherconfig.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/todayplugins/weather/weatherconfig.cpp | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/noncore/todayplugins/weather/weatherconfig.cpp b/noncore/todayplugins/weather/weatherconfig.cpp new file mode 100644 index 0000000..fe10883 --- a/dev/null +++ b/noncore/todayplugins/weather/weatherconfig.cpp | |||
@@ -0,0 +1,127 @@ | |||
1 | /* | ||
2 | This file is part of the OPIE Project | ||
3 | =. | ||
4 | .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> | ||
5 | .>+-= | ||
6 | _;:, .> :=|. This file is free software; you can | ||
7 | .> <`_, > . <= redistribute it and/or modify it under | ||
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
9 | .="- .-=="i, .._ License as published by the Free Software | ||
10 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
11 | ._= =} : or (at your option) any later version. | ||
12 | .%`+i> _;_. | ||
13 | .i_,=:_. -<s. This file is distributed in the hope that | ||
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
15 | : .. .:, . . . without even the implied warranty of | ||
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | ||
18 | ..}^=.= = ; Public License for more details. | ||
19 | ++= -. .` .: | ||
20 | : = ...= . :.=- You should have received a copy of the GNU | ||
21 | -. .:....=;==+<; General Public License along with this file; | ||
22 | -_. . . )=. = see the file COPYING. If not, write to the | ||
23 | -- :-=` Free Software Foundation, Inc., | ||
24 | 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #include <stdlib.h> | ||
30 | |||
31 | #include <qcheckbox.h> | ||
32 | #include <qclipboard.h> | ||
33 | #include <qfontmetrics.h> | ||
34 | #include <qlabel.h> | ||
35 | #include <qlayout.h> | ||
36 | #include <qlineedit.h> | ||
37 | #include <qlayout.h> | ||
38 | #include <qpushbutton.h> | ||
39 | #include <qspinbox.h> | ||
40 | #include <qwhatsthis.h> | ||
41 | |||
42 | #include <qpe/config.h> | ||
43 | #include <qpe/qpeapplication.h> | ||
44 | #include <qpe/resource.h> | ||
45 | #include <opie/todayconfigwidget.h> | ||
46 | |||
47 | #include "weatherconfig.h" | ||
48 | |||
49 | WeatherPluginConfig::WeatherPluginConfig( QWidget *parent, const char* name) | ||
50 | : TodayConfigWidget(parent, name ) | ||
51 | { | ||
52 | Config config( "todayweatherplugin"); | ||
53 | config.setGroup( "Config" ); | ||
54 | |||
55 | QFontMetrics fm = fontMetrics(); | ||
56 | int fh = fm.height(); | ||
57 | |||
58 | QGridLayout *layout = new QGridLayout( this ); | ||
59 | layout->setSpacing( 4 ); | ||
60 | layout->setMargin( 4 ); | ||
61 | |||
62 | QLabel *label = new QLabel( tr( "Enter ICAO location identifier:" ), this ); | ||
63 | label->setMaximumHeight( fh + 3 ); | ||
64 | layout->addMultiCellWidget( label, 0, 0, 0, 1 ); | ||
65 | |||
66 | locationEdit = new QLineEdit( config.readEntry( "Location", "" ), this ); | ||
67 | locationEdit->setMaximumHeight( fh + 5 ); | ||
68 | locationEdit->setFocus(); | ||
69 | layout->addMultiCellWidget( locationEdit, 1, 1, 0, 1 ); | ||
70 | |||
71 | label = new QLabel( tr( "Visit http://www.nws.noaa.gov/tg/siteloc.shtml to find the nearest location." ), this ); | ||
72 | label->setAlignment( AlignHCenter | WordBreak ); | ||
73 | label->setMaximumHeight( label->height() ); | ||
74 | layout->addMultiCellWidget( label, 2, 2, 0, 1 ); | ||
75 | //layout->addWidget( label, 2, 0 ); | ||
76 | |||
77 | //QPushButton *pb = new QPushButton( Resource::loadPixmap( "copy" ), | ||
78 | //tr( "Copy link" ), this ); | ||
79 | //connect( pb, SIGNAL( clicked() ), this, SLOT( slotCopyLink() ) ); | ||
80 | //layout->addWidget( pb, 2, 1 ); | ||
81 | |||
82 | metricCB = new QCheckBox( tr( "Use metric units" ), this ); | ||
83 | metricCB->setMaximumHeight( fh + 5 ); | ||
84 | metricCB->setChecked( config.readBoolEntry( "Metric", TRUE ) ); | ||
85 | layout->addMultiCellWidget( metricCB, 3, 3, 0, 1 ); | ||
86 | |||
87 | label = new QLabel( tr( "Update frequency (in minutes):" ), this ); | ||
88 | label->setMaximumHeight( fh + 3 ); | ||
89 | layout->addWidget( label, 4, 0 ); | ||
90 | |||
91 | timerDelaySB = new QSpinBox( 1, 60, 1, this ); | ||
92 | timerDelaySB->setMaximumHeight( fh + 5 ); | ||
93 | timerDelaySB->setValue( config.readNumEntry( "Frequency", 5 ) ); | ||
94 | layout->addWidget( timerDelaySB, 4, 1 ); | ||
95 | } | ||
96 | |||
97 | |||
98 | void WeatherPluginConfig::writeConfig() | ||
99 | { | ||
100 | Config config( "todayweatherplugin"); | ||
101 | config.setGroup( "Config" ); | ||
102 | |||
103 | config.writeEntry( "Location", locationEdit->text().upper().stripWhiteSpace() ); | ||
104 | config.writeEntry( "Metric", metricCB->isChecked() ); | ||
105 | config.writeEntry( "Frequency", timerDelaySB->value() ); | ||
106 | |||
107 | config.write(); | ||
108 | } | ||
109 | |||
110 | WeatherPluginConfig::~WeatherPluginConfig() | ||
111 | { | ||
112 | } | ||
113 | |||
114 | void WeatherPluginConfig::doLookup() | ||
115 | { | ||
116 | system( "weather" ); | ||
117 | } | ||
118 | |||
119 | /* | ||
120 | |||
121 | Doesn't seem to like QPEApplication::clipboard()... | ||
122 | |||
123 | void WeatherPluginConfig::slotCopyLink() | ||
124 | { | ||
125 | QPEApplication::clipboard()->setText( "http://www.nws.noaa.gov/tg/siteloc.shtml" ); | ||
126 | } | ||
127 | */ \ No newline at end of file | ||