summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-10-01 20:57:23 (UTC)
committer harlekin <harlekin>2002-10-01 20:57:23 (UTC)
commit88bef2791f8e4c99e0e9d34ddfe518b5baa2df72 (patch) (unidiff)
tree19a3d6ee9360d5765ced9b600f1b094d2a1e3c4b
parent88c3937936dbbb13575425ce9da72d5286bd1233 (diff)
downloadopie-88bef2791f8e4c99e0e9d34ddfe518b5baa2df72.zip
opie-88bef2791f8e4c99e0e9d34ddfe518b5baa2df72.tar.gz
opie-88bef2791f8e4c99e0e9d34ddfe518b5baa2df72.tar.bz2
cleanups and gui redo with layouts
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/mediummountgui.cpp351
-rw-r--r--core/launcher/mediummountgui.h20
2 files changed, 177 insertions, 194 deletions
diff --git a/core/launcher/mediummountgui.cpp b/core/launcher/mediummountgui.cpp
index eb2308e..6d60ce4 100644
--- a/core/launcher/mediummountgui.cpp
+++ b/core/launcher/mediummountgui.cpp
@@ -1,234 +1,217 @@
1 1
2#include "mediummountgui.h" 2#include "mediummountgui.h"
3 3
4#include <qvariant.h>
5#include <qcheckbox.h> 4#include <qcheckbox.h>
6#include <qgroupbox.h> 5#include <qgroupbox.h>
7#include <qlabel.h> 6#include <qlabel.h>
8#include <qlineedit.h> 7#include <qlineedit.h>
9#include <qpushbutton.h> 8#include <qpushbutton.h>
10#include <qlayout.h> 9#include <qlayout.h>
11#include <qtooltip.h>
12#include <qwhatsthis.h>
13#include <qimage.h> 10#include <qimage.h>
14#include <qpixmap.h> 11#include <qpixmap.h>
12#include <qvbox.h>
13#include <qhbox.h>
15 14
16#include <qpe/resource.h> 15#include <qpe/resource.h>
17#include <qpe/config.h> 16#include <qpe/config.h>
18 17
19#include <qpe/config.h>
20
21
22#include <qapplication.h>
23
24 18
25MediumMountGui::MediumMountGui( Config *cfg, const QString &path ,QWidget* parent, const char* name, bool , WFlags ) 19MediumMountGui::MediumMountGui( Config *cfg, const QString &path ,QWidget* parent, const char* name, bool , WFlags )
26 : QDialog( parent, name, true ) { 20 : QDialog( parent, name, true ) {
27
28 m_cfg = cfg;
29 QWidget *d = QApplication::desktop();
30 int w=d->width();
31 int h=d->height();
32 resize( w , h );
33 setCaption( tr( "Medium inserted" ) );
34
35 mediumPath = path;
36 readConfig();
37 startGui();
38}
39 21
40void MediumMountGui::readConfig(){ 22 m_cfg = cfg;
41 23 setCaption( tr( "Medium inserted" ) );
42 //OConfig cfg (mediumPath +"/.opiestorage.cf");
43 m_cfg->setGroup("main");
44 checkagain = m_cfg->readBoolEntry("check", false);
45
46 m_cfg->setGroup("mimetypes");
47 checkmimeaudio = m_cfg->readBoolEntry("audio", true );
48 checkmimeimage = m_cfg->readBoolEntry("image", true );
49 checkmimetext = m_cfg->readBoolEntry("text" , true );
50 checkmimevideo = m_cfg->readBoolEntry("video", true );
51 checkmimeall = m_cfg->readBoolEntry("all" , false);
52
53 m_cfg->setGroup("dirs");
54 limittodirs = m_cfg->readEntry("dirs", "");
55}
56 24
57bool MediumMountGui::check() { 25 mediumPath = path;
58 return !checkagain; 26 readConfig();
59} 27 startGui();
60 28 showMaximized();
61QStringList MediumMountGui::dirs() {
62 QStringList list = QStringList::split(",", limittodirs );
63 return list;
64} 29}
65 30
66void MediumMountGui::writeConfig(bool autocheck) { 31void MediumMountGui::readConfig() {
67 32
68 //OConfig cfg (mediumPath +"/.opiestorage.cf"); 33 //OConfig cfg (mediumPath +"/.opiestorage.cf");
69 m_cfg->setGroup("main"); 34 m_cfg->setGroup( "main" );
70 m_cfg->writeEntry("check", AskBox->isChecked() ); 35 checkagain = m_cfg->readBoolEntry( "check", false );
71 m_cfg->writeEntry("autocheck", autocheck );
72 36
73 m_cfg->setGroup("mimetypes"); 37 m_cfg->setGroup( "mimetypes" );
38 checkmimeaudio = m_cfg->readBoolEntry( "audio", true );
39 checkmimeimage = m_cfg->readBoolEntry( "image", true );
40 checkmimetext = m_cfg->readBoolEntry( "text" , true );
41 checkmimevideo = m_cfg->readBoolEntry( "video", true );
42 checkmimeall = m_cfg->readBoolEntry( "all" , false );
74 43
75 m_cfg->writeEntry("audio", CheckBoxAudio->isChecked() ); 44 m_cfg->setGroup( "dirs" );
76 m_cfg->writeEntry("image",CheckBoxImage->isChecked() ); 45 limittodirs = m_cfg->readEntry( "dirs", "" );
77 m_cfg->writeEntry("text",CheckBoxImage->isChecked() ); 46}
78 m_cfg->writeEntry("video",CheckBoxVideo->isChecked() );
79 m_cfg->writeEntry("all",CheckBoxAll->isChecked() );
80 47
81 m_cfg->setGroup("dirs"); 48bool MediumMountGui::check() {
82 m_cfg->writeEntry("dirs", ""); 49 return !checkagain;
50}
83 51
52QStringList MediumMountGui::dirs() {
53 return QStringList::split( ",", limittodirs );
54}
84 55
85 // if all is checked then add only "QString::null" to the list. 56void MediumMountGui::writeConfig( bool autocheck ) {
86 if (checkmimeall) { 57
87 mimeTypeList.clear(); 58 //OConfig cfg (mediumPath +"/.opiestorage.cf");
88 mimeTypeList += QString::null; 59 m_cfg->setGroup( "main" );
89 } else { 60 m_cfg->writeEntry( "check", AskBox->isChecked() );
90 if (checkmimeaudio) { 61 m_cfg->writeEntry( "autocheck", autocheck );
91 mimeTypeList += ("audio/*"); 62
63 m_cfg->setGroup( "mimetypes" );
64
65 m_cfg->writeEntry( "audio", CheckBoxAudio->isChecked() );
66 m_cfg->writeEntry( "image", CheckBoxImage->isChecked() );
67 m_cfg->writeEntry( "text", CheckBoxImage->isChecked() );
68 m_cfg->writeEntry( "video", CheckBoxVideo->isChecked() );
69 m_cfg->writeEntry( "all", CheckBoxAll->isChecked() );
70
71 m_cfg->setGroup( "dirs" );
72 m_cfg->writeEntry( "dirs", "" );
73
74 // if all is checked then add only "QString::null" to the list.
75 if ( checkmimeall ) {
76 mimeTypeList.clear();
77 mimeTypeList += QString::null;
78 } else {
79 if ( checkmimeaudio ) {
80 mimeTypeList += ( "audio/*" );
81 }
82 if ( checkmimetext ) {
83 mimeTypeList += ( "text/*" );
84 }
85 if ( checkmimevideo ) {
86 mimeTypeList += ( "video/*" );
87 }
88 if ( checkmimeimage ) {
89 mimeTypeList += ( "image/*" );
90 }
92 } 91 }
93 if (checkmimetext) { 92 m_cfg->write(); // not really needed here but just to be sure
94 mimeTypeList += ("text/*");
95 }
96 if (checkmimevideo) {
97 mimeTypeList += ("video/*");
98 }
99 if (checkmimeimage) {
100 mimeTypeList += ("image/*");
101 }
102 }
103 m_cfg->write(); // not really needed here but just to be sure
104} 93}
105 94
106void MediumMountGui::startGui() { 95void MediumMountGui::startGui() {
107 96
108 QPixmap image = Resource::loadPixmap( "HelpBrowser"); 97 QVBoxLayout* mainLayout = new QVBoxLayout( this );
109 98
110 Text_2 = new QLabel( this ); 99 QHBoxLayout * titelBox = new QHBoxLayout( mainLayout );
111 Text_2->setGeometry( QRect( 10, 15, 40, 40 ) ); 100 Text_2 = new QLabel( this );
112 Text_2->setPixmap( image ); 101 // FIXME needs an image
113 102 Text_2->setPixmap( Resource::loadPixmap( "mediummount/mediummount" ) );
114 Text = new QLabel( this, "Text" ); 103
115 Text->setGeometry( QRect( 55, 11, this->width()-50, 50 ) ); 104 Text = new QLabel( this, "Text" );
116 Text->setText( tr( "A <b>storage medium</b> was inserted. Should it be scanned for media files?" ) ); 105 Text->setText( tr( "A <b>storage medium</b> was inserted. Should it be scanned for media files?" ) );
117 106 titelBox->addWidget( Text_2 );
118 // media box 107 titelBox->setStretchFactor( Text_2, 2 );
119 GroupBox1 = new QGroupBox( this, "GroupBox1" ); 108 titelBox->addWidget( Text );
120 GroupBox1->setGeometry( QRect( 10, 80, (this->width())-25, 80 ) ); 109 titelBox->setStretchFactor( Text, 8 );
121 GroupBox1->setTitle( tr( "Which media files" ) ); 110
122 111 // media box
123 CheckBoxAudio = new QCheckBox( GroupBox1, "CheckBoxAudio" ); 112 GroupBox1 = new QGroupBox( this, "GroupBox1" );
124 CheckBoxAudio->setGeometry( QRect( 10, 15, (GroupBox1->width()/2)-15 , 15 ) ); 113 GroupBox1->setTitle( tr( "Which media files" ) );
125 CheckBoxAudio->setText( tr( "Audio" ) ); 114
126 115 QGridLayout *mimeLayout = new QGridLayout( GroupBox1, 3, 2, 10 );
127 CheckBoxImage = new QCheckBox( GroupBox1, "CheckBoxImage" ); 116
128 CheckBoxImage->setGeometry( QRect( 10, 35,(GroupBox1->width()/2)-15, 15 ) ); 117 CheckBoxAudio = new QCheckBox( GroupBox1, "CheckBoxAudio" );
129 CheckBoxImage->setText( tr( "Image" ) ); 118 CheckBoxAudio->setText( tr( "Audio" ) );
130 119
131 CheckBoxText = new QCheckBox( GroupBox1, "CheckBoxText" ); 120 CheckBoxImage = new QCheckBox( GroupBox1, "CheckBoxImage" );
132 CheckBoxText->setGeometry( QRect((GroupBox1->width()/2) , 15, (GroupBox1->width()/2)-15, 15 ) ); 121 CheckBoxImage->setText( tr( "Image" ) );
133 CheckBoxText->setText( tr( "Text" ) ); 122
134 123 CheckBoxText = new QCheckBox( GroupBox1, "CheckBoxText" );
135 CheckBoxVideo = new QCheckBox( GroupBox1, "CheckBoxVideo" ); 124 CheckBoxText->setText( tr( "Text" ) );
136 CheckBoxVideo->setGeometry( QRect( (GroupBox1->width()/2), 35, (GroupBox1->width()/2)-15, 15 ) ); 125
137 CheckBoxVideo->setText( tr( "Video" ) ); 126 CheckBoxVideo = new QCheckBox( GroupBox1, "CheckBoxVideo" );
138 127 CheckBoxVideo->setText( tr( "Video" ) );
139 CheckBoxAll = new QCheckBox ( GroupBox1); 128
140 CheckBoxAll->setGeometry( QRect( 10, 55, (GroupBox1->width()/2)-15, 15 ) ); 129 CheckBoxAll = new QCheckBox ( GroupBox1 );
141 CheckBoxAll->setText( tr( "All" ) ); 130 CheckBoxAll->setText( tr( "All" ) );
142 QObject::connect( (QObject*)CheckBoxAll, SIGNAL( clicked() ), this, SLOT( deactivateOthers()) ); 131
143 132 CheckBoxLink = new QCheckBox ( GroupBox1 );
144 133 CheckBoxLink->setText( tr( "Link apps" ) );
145 134 // as long as the feature is not supported
146 CheckBoxLink = new QCheckBox ( GroupBox1); 135 CheckBoxLink->setEnabled( false );
147 CheckBoxLink->setGeometry( QRect( (GroupBox1->width()/2), 55, (GroupBox1->width()/2)-15, 15 ) ); 136
148 CheckBoxLink->setText( tr( "Link apps" ) ); 137 mimeLayout->addWidget( CheckBoxAudio, 0, 0 );
149 // as long as the feature is not supported 138 mimeLayout->addWidget( CheckBoxImage, 0, 1 );
150 CheckBoxLink->setEnabled(false); 139 mimeLayout->addWidget( CheckBoxText , 1, 0 );
151 140 mimeLayout->addWidget( CheckBoxVideo, 1, 1 );
152 141 mimeLayout->addWidget( CheckBoxAll, 2, 0 );
153 // select dirs 142 mimeLayout->addWidget( CheckBoxLink, 2, 1 );
154 143
155 DirSelectText = new QLabel( this, "DirSelectText" ); 144 connect( CheckBoxAll, SIGNAL( clicked() ), this, SLOT( deactivateOthers() ) );
156 DirSelectText->setGeometry( QRect( 10, 160,this->width() , 20 ) ); 145
157 DirSelectText->setText( tr( "Limit search to dir: (not used yet)" ) ); 146 QVBox* dirBox = new QVBox( this );
158 147 dirBox->setMargin( 4 );
159 LineEdit1 = new QLineEdit( this ); 148
160 LineEdit1->setGeometry( QRect( 10, 180, (this->width())-60, 20 ) ); 149 // select dirs
161 150 DirSelectText = new QLabel( dirBox, "DirSelectText" );
162 PushButton3 = new QPushButton( this ); 151 DirSelectText->setText( tr( "Limit search to dir: (not used yet)" ) );
163 PushButton3->setGeometry( QRect( (this->width())-40, 180, 30, 20 ) ); 152
164 PushButton3->setText( tr( "Add" ) ); 153 QHBox* dirLineBox = new QHBox( dirBox );
165 154 LineEdit1 = new QLineEdit( dirLineBox );
166 155 PushButton3 = new QPushButton( dirLineBox );
167 // decision 156 PushButton3->setText( tr( "Add" ) );
168 DirSelectText_2 = new QLabel( this ); 157
169 DirSelectText_2->setGeometry( QRect( 10,240,this->width(), 15 ) ); 158 // decision
170 DirSelectText_2->setText( tr( "Your decision will be stored on the medium." ) ); 159 DirSelectText_2 = new QLabel( dirBox );
171 160 DirSelectText_2->setText( tr( "Your decision will be stored on the medium." ) );
172 // ask again 161
173 AskBox = new QCheckBox( this ); 162 // ask again
174 AskBox->setGeometry( QRect( 10, 215, (this->width())-15 , 15 ) ); 163 AskBox = new QCheckBox( dirBox );
175 AskBox->setText( tr( "Do not ask again for this medium" ) ); 164 AskBox->setText( tr( "Do not ask again for this medium" ) );
176 165
177 166 AskBox->setChecked( checkagain );
178 AskBox->setChecked(checkagain); 167 CheckBoxAudio->setChecked( checkmimeaudio );
179 CheckBoxAudio->setChecked(checkmimeaudio); 168 CheckBoxImage->setChecked( checkmimeimage );
180 CheckBoxImage->setChecked(checkmimeimage); 169 CheckBoxText->setChecked( checkmimetext );
181 CheckBoxText->setChecked(checkmimetext); 170 CheckBoxVideo->setChecked( checkmimevideo );
182 CheckBoxVideo->setChecked(checkmimevideo); 171 CheckBoxAll->setChecked( checkmimeall );
183 CheckBoxAll->setChecked( checkmimeall ); 172 deactivateOthers();
184 deactivateOthers(); 173
185 // buttons 174 QHBox* buttonBox = new QHBox( this );
186 quit = new QPushButton( this ); 175 // buttons
187 quit->setGeometry( QRect( (this->width()/2)- 90 , 260, 80, 22 ) ); 176 quit = new QPushButton( buttonBox );
188 quit->setFocus(); 177 quit->setFocus();
189 quit->setText( tr( "Yes" ) ); 178 quit->setText( tr( "Yes" ) );
190 179 quit_2 = new QPushButton( buttonBox );
191 quit_2 = new QPushButton( this ); 180 quit_2->setText( tr( "No" ) );
192 quit_2->setGeometry( QRect((this->width()/2) , 260, 80, 22 ) ); 181
193 quit_2->setText( tr( "No" ) ); 182 mainLayout->addWidget( GroupBox1 );
194 183 mainLayout->addWidget( dirBox );
195 QObject::connect( (QObject*)quit, SIGNAL( clicked() ), this, SLOT(yesPressed() ) ); 184 mainLayout->addWidget( buttonBox );
196 QObject::connect( (QObject*)quit_2, SIGNAL( clicked() ), this, SLOT(noPressed() ) ); 185
197 186 connect( quit, SIGNAL( clicked() ), this, SLOT( yesPressed() ) );
198 187 connect( quit_2, SIGNAL( clicked() ), this, SLOT( noPressed() ) );
199} 188}
200 189
201 190
202void MediumMountGui::deactivateOthers() { 191void MediumMountGui::deactivateOthers() {
203 bool mod = !(CheckBoxAll->isChecked()); 192 bool mod = !( CheckBoxAll->isChecked() );
204 193 CheckBoxVideo->setEnabled( mod );
205 //if (!CheckBoxVideo->isChecked()){ 194 CheckBoxAudio->setEnabled( mod );
206 // mod = false; 195 CheckBoxText->setEnabled( mod );
207 //} else { 196 CheckBoxImage->setEnabled( mod );
208 // mod = true;
209 //}
210 CheckBoxVideo->setEnabled(mod);
211 CheckBoxAudio->setEnabled(mod);
212 CheckBoxText->setEnabled(mod);
213 CheckBoxImage->setEnabled(mod);
214} 197}
215 198
216void MediumMountGui::yesPressed() { 199void MediumMountGui::yesPressed() {
217 writeConfig(true); 200 writeConfig( true );
218 // and do something 201 // and do something
219 accept(); 202 accept();
220} 203}
221 204
222 205
223QStringList MediumMountGui::mimeTypes(){ 206QStringList MediumMountGui::mimeTypes() {
224 return mimeTypeList; 207 return mimeTypeList;
225} 208}
226 209
227void MediumMountGui::noPressed() { 210void MediumMountGui::noPressed() {
228 writeConfig(false); 211 writeConfig( false );
229 reject(); 212 reject();
230} 213}
231 214
232MediumMountGui::~MediumMountGui(){ 215MediumMountGui::~MediumMountGui() {
233} 216}
234 217
diff --git a/core/launcher/mediummountgui.h b/core/launcher/mediummountgui.h
index 8292c3a..39f9a52 100644
--- a/core/launcher/mediummountgui.h
+++ b/core/launcher/mediummountgui.h
@@ -3,9 +3,10 @@
3 3
4#include <qvariant.h> 4#include <qvariant.h>
5#include <qdialog.h> 5#include <qdialog.h>
6class QVBoxLayout; 6
7class QHBoxLayout; 7class QVBoxLayout;
8class QGridLayout; 8class QHBoxLayout;
9class QGridLayout;
9class QCheckBox; 10class QCheckBox;
10class QGroupBox; 11class QGroupBox;
11class QLabel; 12class QLabel;
@@ -13,15 +14,14 @@ class QLineEdit;
13class QPushButton; 14class QPushButton;
14class Config; 15class Config;
15 16
16class MediumMountGui : public QDialog 17class MediumMountGui : public QDialog {
17{
18 Q_OBJECT 18 Q_OBJECT
19 19
20public: 20public:
21 MediumMountGui( Config *cfg, const QString &path = "tmp/", QWidget* parent = 0, const char* name = 0, bool modal = FALSE ,WFlags fl = 0 ); 21 MediumMountGui( Config *cfg, const QString &path = "tmp/", QWidget* parent = 0, const char* name = 0, bool modal = FALSE ,WFlags fl = 0 );
22 ~MediumMountGui(); 22 ~MediumMountGui();
23 23
24protected: 24protected:
25 QPushButton* quit; 25 QPushButton* quit;
26 QPushButton* quit_2; 26 QPushButton* quit_2;
27 QLabel* DirSelectText_2; 27 QLabel* DirSelectText_2;
@@ -38,7 +38,7 @@ protected:
38 QCheckBox* CheckBoxAll; 38 QCheckBox* CheckBoxAll;
39 QCheckBox* CheckBoxLink; 39 QCheckBox* CheckBoxLink;
40 QCheckBox* AskBox; 40 QCheckBox* AskBox;
41 41
42 42
43public: 43public:
44 bool check(); 44 bool check();
@@ -47,7 +47,7 @@ public:
47private: 47private:
48 void startGui(); 48 void startGui();
49 void readConfig(); 49 void readConfig();
50 void writeConfig(bool checkagain); 50 void writeConfig( bool checkagain );
51 51
52private slots: 52private slots:
53 void yesPressed(); 53 void yesPressed();
@@ -56,7 +56,7 @@ private slots:
56 private: 56 private:
57 QString mediumPath; 57 QString mediumPath;
58 58
59 bool checkagain:1; 59 bool checkagain:1;
60 bool checkmimeaudio:1; 60 bool checkmimeaudio:1;
61 bool checkmimeimage:1; 61 bool checkmimeimage:1;
62 bool checkmimetext:1; 62 bool checkmimetext:1;
@@ -68,4 +68,4 @@ private slots:
68 68
69}; 69};
70 70
71#endif 71#endif