summaryrefslogtreecommitdiff
authorharlekin <harlekin>2003-03-23 14:17:43 (UTC)
committer harlekin <harlekin>2003-03-23 14:17:43 (UTC)
commitdca448bad29f0afbab1fc0ffe493560fd927c1b5 (patch) (unidiff)
tree178ab4781f5952f6e333659531cb7e0db0276f24
parent013194659dde417767c62ab2fe18b09ea21558eb (diff)
downloadopie-dca448bad29f0afbab1fc0ffe493560fd927c1b5.zip
opie-dca448bad29f0afbab1fc0ffe493560fd927c1b5.tar.gz
opie-dca448bad29f0afbab1fc0ffe493560fd927c1b5.tar.bz2
a dialog now x does not save ok saves, also some layout changes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/mediummount/mainwindow.cc34
-rw-r--r--noncore/settings/mediummount/mainwindow.h7
-rw-r--r--noncore/settings/mediummount/mediumglobal.cc19
-rw-r--r--noncore/settings/mediummount/mediumglobal.h3
-rw-r--r--noncore/settings/mediummount/mediumwidget.cc10
-rw-r--r--noncore/settings/mediummount/mediumwidget.h5
6 files changed, 48 insertions, 30 deletions
diff --git a/noncore/settings/mediummount/mainwindow.cc b/noncore/settings/mediummount/mainwindow.cc
index 6d9bb80..bfd1e21 100644
--- a/noncore/settings/mediummount/mainwindow.cc
+++ b/noncore/settings/mediummount/mainwindow.cc
@@ -1,57 +1,75 @@
1 1
2 2
3#include <qtabwidget.h> 3#include <qtabwidget.h>
4#include <qlayout.h> 4#include <qlayout.h>
5#include <qtooltip.h>
6#include <qwhatsthis.h>
5 7
6#include <qpe/storage.h> 8#include <qpe/storage.h>
7 9
8#include "mediumwidget.h" 10#include "mediumwidget.h"
9#include "mediumglobal.h" 11#include "mediumglobal.h"
10 12
11#include "mainwindow.h" 13#include "mainwindow.h"
12 14
13using namespace MediumMountSetting; 15using namespace MediumMountSetting;
14 16
15 17
16MainWindow::MainWindow( QWidget *parent, const char *name, WFlags ) 18MainWindow::MainWindow( QWidget *parent, const char *name, bool modal, WFlags )
17 : QMainWindow( parent, name, WStyle_ContextHelp ) 19 : QDialog( parent, name, modal, WStyle_ContextHelp )
18 20
19{ 21{
20 setCaption ( tr( "Medium Mount Settings" )); 22 setCaption ( tr( "Medium Mount Settings" ));
21 23
22 // m_lay = new QVBoxLayout( this ); 24 m_lay = new QVBoxLayout( this );
23 m_tab = new QTabWidget( this ); 25
24 setCentralWidget( m_tab ); 26 m_tab = new QTabWidget( this );
25 init(); 27
28 m_lay->addWidget( m_tab );
29
30 init();
26} 31}
27 32
28MainWindow::~MainWindow() 33MainWindow::~MainWindow()
29{ 34{
30
31} 35}
36
32void MainWindow::init() 37void MainWindow::init()
33{ 38{
34 m_global = new MediumGlobalWidget( m_tab, "test drive" ); 39 m_global = new MediumGlobalWidget( m_tab, "test drive" );
35 m_tab->addTab( m_global, tr("Global") ); 40 m_tab->addTab( m_global, tr("Global") );
36 41
37 StorageInfo storage; 42 StorageInfo storage;
38 const QList<FileSystem> &fs = storage.fileSystems(); 43 const QList<FileSystem> &fs = storage.fileSystems();
39 QListIterator<FileSystem> it( fs ); 44 QListIterator<FileSystem> it( fs );
40 MediumMountWidget *wid; 45 MediumMountWidget *wid;
41 for( ; it.current(); ++it ){ 46 for( ; it.current(); ++it ){
42 if( (*it)->isRemovable() ){ 47 if( (*it)->isRemovable() ){
43 wid = new MediumMountWidget((*it)->path(), QPixmap(), m_tab ); 48 wid = new MediumMountWidget((*it)->path(), QPixmap(), m_tab );
44 m_mediums.append( wid ); 49 m_mediums.append( wid );
45 m_tab->addTab( wid, (*it)->name() ); 50 m_tab->addTab( wid, (*it)->name() );
46 } 51 }
47 } 52 }
48} 53}
49 54
55void MainWindow::accept()
56{
57 m_global->writeConfig();
58
59 MediumMountWidget *confWidget;
60 for ( confWidget = m_mediums.first(); confWidget != 0;
61 confWidget = m_mediums.next() ) {
62 confWidget->writeConfig();
63 }
64
65 QDialog::accept();
66}
67
50void MainWindow::slotGlobalChanged(int ) 68void MainWindow::slotGlobalChanged(int )
51{ 69{
52 70
53} 71}
54void MainWindow::slotCheckingChanged(int ) 72void MainWindow::slotCheckingChanged(int )
55{ 73{
56 74
57} 75}
diff --git a/noncore/settings/mediummount/mainwindow.h b/noncore/settings/mediummount/mainwindow.h
index ce54674..9c648ef 100644
--- a/noncore/settings/mediummount/mainwindow.h
+++ b/noncore/settings/mediummount/mainwindow.h
@@ -1,33 +1,34 @@
1 1
2 2
3#ifndef MediumMountMainwindow_h 3#ifndef MediumMountMainwindow_h
4#define MediumMountMainwindow_h 4#define MediumMountMainwindow_h
5 5
6#include <qlist.h> 6#include <qlist.h>
7#include <qmainwindow.h> 7#include <qdialog.h>
8 8
9class QVBoxLayout; 9class QVBoxLayout;
10class QTabWidget; 10class QTabWidget;
11 11
12namespace MediumMountSetting { 12namespace MediumMountSetting {
13 class MediumMountWidget; 13 class MediumMountWidget;
14 class MediumGlobalWidget; 14 class MediumGlobalWidget;
15 class MainWindow : public QMainWindow { 15 class MainWindow : public QDialog {
16 Q_OBJECT 16 Q_OBJECT
17 public: 17 public:
18 MainWindow(QWidget *parent = 0, const char *name = 0 , WFlags = 0); 18 MainWindow(QWidget *parent = 0, const char *name = 0 , bool modal = FALSE, WFlags = 0);
19 ~MainWindow(); 19 ~MainWindow();
20 20
21 private slots: 21 private slots:
22 void slotGlobalChanged(int ); 22 void slotGlobalChanged(int );
23 void slotCheckingChanged(int ); 23 void slotCheckingChanged(int );
24 void accept();
24 private: 25 private:
25 void init(); 26 void init();
26 QTabWidget *m_tab; 27 QTabWidget *m_tab;
27 QVBoxLayout *m_lay; 28 QVBoxLayout *m_lay;
28 MediumGlobalWidget *m_global; 29 MediumGlobalWidget *m_global;
29 QList<MediumMountWidget> m_mediums; 30 QList<MediumMountWidget> m_mediums;
30 }; 31 };
31}; 32};
32 33
33#endif 34#endif
diff --git a/noncore/settings/mediummount/mediumglobal.cc b/noncore/settings/mediummount/mediumglobal.cc
index fa4171c..46d3343 100644
--- a/noncore/settings/mediummount/mediumglobal.cc
+++ b/noncore/settings/mediummount/mediumglobal.cc
@@ -1,184 +1,183 @@
1 1
2 2
3#include <qlineedit.h> 3#include <qlineedit.h>
4#include <qcheckbox.h> 4#include <qcheckbox.h>
5#include <qlabel.h> 5#include <qlabel.h>
6#include <qabstractlayout.h> // spacer item 6#include <qabstractlayout.h> // spacer item
7#include <qlayout.h> 7#include <qlayout.h>
8#include <qframe.h> 8#include <qframe.h>
9#include <qgroupbox.h> 9#include <qgroupbox.h>
10#include <qwhatsthis.h> 10#include <qwhatsthis.h>
11 11
12#include <qpe/config.h> 12#include <qpe/config.h>
13 13
14#include "mediumglobal.h" 14#include "mediumglobal.h"
15 15
16using namespace MediumMountSetting; 16using namespace MediumMountSetting;
17 17
18MediumGlobalWidget::MediumGlobalWidget(QWidget *wid, const char *name ) 18MediumGlobalWidget::MediumGlobalWidget(QWidget *wid, const char *name )
19 : QWidget( wid, name ) 19 : QWidget( wid, name, WStyle_ContextHelp )
20{ 20{
21 m_config = 0; 21 m_config = 0;
22 initGUI(); 22 initGUI();
23 readConfig(); 23 readConfig();
24 24
25} 25}
26void MediumGlobalWidget::initGUI() 26void MediumGlobalWidget::initGUI()
27{ 27{
28 m_layout = new QVBoxLayout(this ); 28 m_layout = new QVBoxLayout(this );
29 m_layout->setMargin( 10 ); 29 // m_layout->setMargin( 10 );
30 m_layout->setSpacing( 10 ); 30 // m_layout->setSpacing( 10 );
31 31
32 32
33 m_label = new QLabel( this ); 33 m_label = new QLabel( this );
34 m_label->setTextFormat( Qt::RichText ); 34 m_label->setTextFormat( Qt::RichText );
35 m_label->setText( tr("") ); 35 m_label->setText( tr("") );
36 QWhatsThis::add( this, tr("If a medium gets inserted into this device Opie " 36 QWhatsThis::add( this, tr("If a medium gets inserted into this device Opie "
37 "tries to search the medium for Documents. On " 37 "tries to search the medium for Documents. On "
38 "large mediums this can take some time. You can choose " 38 "large mediums this can take some time. You can choose "
39 "if Opie should scan for Documents globally or on a " 39 "if Opie should scan for Documents globally or on a "
40 "per medium level. You're also able to reconfigure " 40 "per medium level. You're also able to reconfigure "
41 "each medium.") ); 41 "each medium.") );
42 42
43 m_layout->addWidget( m_label ); 43 m_layout->addWidget( m_label );
44 44
45 m_check = new QCheckBox( tr("Enable medium checking" ), this ); 45 m_check = new QCheckBox( tr("Enable medium checking" ), this );
46 connect( m_check, SIGNAL(stateChanged(int) ), 46 connect( m_check, SIGNAL(stateChanged(int) ),
47 this, SLOT(slotEnableChecking() ) ); 47 this, SLOT(slotEnableChecking() ) );
48 m_layout->addWidget(m_check ); 48 m_layout->addWidget(m_check );
49 49
50 m_frame = new QFrame(this, "Frame" ); 50 m_frame = new QFrame(this, "Frame" );
51 m_frame->setFrameShape( QFrame::Box ); 51 m_frame->setFrameShape( QFrame::Box );
52 m_frame->setFrameShadow( QFrame::Sunken ); 52 m_frame->setFrameShadow( QFrame::Sunken );
53 53
54 m_box = new QVBoxLayout( m_frame ); 54 m_box = new QVBoxLayout( m_frame );
55 m_box->setMargin( 5 ); 55 m_box->setMargin( 5 );
56 m_useglobal = new QCheckBox( tr("Use global settings"), m_frame ); 56 m_useglobal = new QCheckBox( tr("Use global settings"), m_frame );
57 connect( m_useglobal, SIGNAL( stateChanged(int) ), 57 connect( m_useglobal, SIGNAL( stateChanged(int) ),
58 this, SLOT( slotGlobalChanged() ) ); 58 this, SLOT( slotGlobalChanged() ) );
59 59
60 m_box->addWidget( m_useglobal ); 60 m_box->addWidget( m_useglobal );
61 61
62 m_global = new QGroupBox( tr("Which media files"), m_frame ); 62 m_global = new QGroupBox( tr("Which media files"), m_frame );
63 m_frameLay = new QGridLayout(m_global, 4, 3 ); 63 m_frameLay = new QGridLayout(m_global, 4, 3 );
64 m_frameLay->setMargin( 12 ); 64 m_frameLay->setMargin( 6 );
65 65
66 QSpacerItem *item2 = new QSpacerItem( 5, 8, 66 QSpacerItem *item2 = new QSpacerItem( 5, 8,
67 QSizePolicy::Fixed, 67 QSizePolicy::Fixed,
68 QSizePolicy::Fixed ); 68 QSizePolicy::Fixed );
69 m_audio = new QCheckBox( tr("Audio"), m_global ); 69 m_audio = new QCheckBox( tr("Audio"), m_global );
70 m_all = new QCheckBox( tr("All") , m_global ); 70 m_all = new QCheckBox( tr("All") , m_global );
71 m_image = new QCheckBox( tr("Image"), m_global ); 71 m_image = new QCheckBox( tr("Image"), m_global );
72 m_text = new QCheckBox( tr("Text") , m_global ); 72 m_text = new QCheckBox( tr("Text") , m_global );
73 m_video = new QCheckBox( tr("Video"), m_global ); 73 m_video = new QCheckBox( tr("Video"), m_global );
74 74
75 connect(m_all, SIGNAL(stateChanged(int) ), 75 connect(m_all, SIGNAL(stateChanged(int) ),
76 this, SLOT(slotAllChanged() ) ); 76 this, SLOT(slotAllChanged() ) );
77 77
78 m_frameLay->addItem( item2, 0, 0 ); 78 m_frameLay->addItem( item2, 0, 0 );
79 79
80 m_frameLay->addWidget( m_audio, 1, 0 ); 80 m_frameLay->addWidget( m_audio, 1, 0 );
81 m_frameLay->addWidget( m_image, 2, 0 ); 81 m_frameLay->addWidget( m_image, 2, 0 );
82 m_frameLay->addWidget( m_all, 3, 0 ); 82 m_frameLay->addWidget( m_all, 3, 0 );
83 83
84 m_frameLay->addWidget( m_text, 1, 2 ); 84 m_frameLay->addWidget( m_text, 1, 2 );
85 m_frameLay->addWidget( m_video, 2, 2 ); 85 m_frameLay->addWidget( m_video, 2, 2 );
86 86
87 m_frameLay->addRowSpacing( 0, 8 ); 87// m_frameLay->addRowSpacing( 0, 8 );
88 m_frameLay->addColSpacing( 1, 2 ); 88// m_frameLay->addColSpacing( 1, 2 );
89 89
90 m_box->addWidget( m_global ); 90 m_box->addWidget( m_global );
91 91
92 92
93 m_layout->addWidget( m_frame ); 93 m_layout->addWidget( m_frame );
94 94
95 QSpacerItem *item1 = new QSpacerItem( 1, 24, 95 QSpacerItem *item1 = new QSpacerItem( 1, 24,
96 QSizePolicy::Fixed, 96 QSizePolicy::Fixed,
97 QSizePolicy::Expanding ); 97 QSizePolicy::Expanding );
98 m_layout->addItem( item1 ); 98 m_layout->addItem( item1 );
99} 99}
100void MediumGlobalWidget::readConfig() 100void MediumGlobalWidget::readConfig()
101{ 101{
102 if( m_config == 0 ) 102 if( m_config == 0 )
103 m_config = new Config("medium" ); 103 m_config = new Config("medium" );
104 104
105 m_config->setGroup("main"); 105 m_config->setGroup("main");
106 m_useglobal->setChecked( m_config->readBoolEntry("global", false ) ); 106 m_useglobal->setChecked( m_config->readBoolEntry("global", false ) );
107 m_check->setChecked( m_config->readBoolEntry("use", true ) ); 107 m_check->setChecked( m_config->readBoolEntry("use", true ) );
108 108
109 m_config->setGroup("mimetypes" ); 109 m_config->setGroup("mimetypes" );
110 m_all->setChecked ( m_config->readBoolEntry("all", false ) ); 110 m_all->setChecked ( m_config->readBoolEntry("all", false ) );
111 m_audio->setChecked( m_config->readBoolEntry("audio", true ) ); 111 m_audio->setChecked( m_config->readBoolEntry("audio", true ) );
112 m_video->setChecked( m_config->readBoolEntry("video", true ) ); 112 m_video->setChecked( m_config->readBoolEntry("video", true ) );
113 m_text->setChecked ( m_config->readBoolEntry("text", true ) ); 113 m_text->setChecked ( m_config->readBoolEntry("text", true ) );
114 m_image->setChecked( m_config->readBoolEntry("image", true ) ); 114 m_image->setChecked( m_config->readBoolEntry("image", true ) );
115 115
116 slotAllChanged(); 116 slotAllChanged();
117 slotEnableChecking(); 117 slotEnableChecking();
118 slotGlobalChanged(); 118 slotGlobalChanged();
119 if( m_all->isChecked() ){ 119 if( m_all->isChecked() ){
120 m_video->setEnabled( false ); 120 m_video->setEnabled( false );
121 m_text->setEnabled( false ); 121 m_text->setEnabled( false );
122 m_audio->setEnabled( false ); 122 m_audio->setEnabled( false );
123 m_image->setEnabled( false ); 123 m_image->setEnabled( false );
124 124
125 } 125 }
126} 126}
127void MediumGlobalWidget::writeConfig() 127void MediumGlobalWidget::writeConfig()
128{ 128{
129 m_config->setGroup( "main" ); 129 m_config->setGroup( "main" );
130 m_config->writeEntry("global", m_useglobal->isChecked() ); 130 m_config->writeEntry("global", m_useglobal->isChecked() );
131 m_config->writeEntry("use", m_check->isChecked() ); 131 m_config->writeEntry("use", m_check->isChecked() );
132 132
133 m_config->setGroup("mimetypes" ); 133 m_config->setGroup("mimetypes" );
134 134
135 m_config->writeEntry("all", m_all->isChecked() ); 135 m_config->writeEntry("all", m_all->isChecked() );
136 m_config->writeEntry("audio", m_audio->isChecked() ); 136 m_config->writeEntry("audio", m_audio->isChecked() );
137 m_config->writeEntry("video", m_video->isChecked() ); 137 m_config->writeEntry("video", m_video->isChecked() );
138 m_config->writeEntry("text", m_text->isChecked() ); 138 m_config->writeEntry("text", m_text->isChecked() );
139 m_config->writeEntry("image", m_image->isChecked() ); 139 m_config->writeEntry("image", m_image->isChecked() );
140} 140}
141MediumGlobalWidget::~MediumGlobalWidget() 141MediumGlobalWidget::~MediumGlobalWidget()
142{ 142{
143 writeConfig();
144 delete m_config; 143 delete m_config;
145} 144}
146void MediumGlobalWidget::slotGlobalChanged() 145void MediumGlobalWidget::slotGlobalChanged()
147{ 146{
148 int mode = GLOBAL_DISABLED; 147 int mode = GLOBAL_DISABLED;
149 bool enabled = false; 148 bool enabled = false;
150 if( ( enabled =m_useglobal->isChecked() ) ){ 149 if( ( enabled =m_useglobal->isChecked() ) ){
151 mode = GLOBAL_ENABLED; 150 mode = GLOBAL_ENABLED;
152 }else 151 }else
153 mode = GLOBAL_DISABLED; 152 mode = GLOBAL_DISABLED;
154 qWarning("enabled = %d", enabled ); 153 qWarning("enabled = %d", enabled );
155 m_all->setEnabled ( enabled ); 154 m_all->setEnabled ( enabled );
156 m_audio->setEnabled( enabled ); 155 m_audio->setEnabled( enabled );
157 m_image->setEnabled( enabled ); 156 m_image->setEnabled( enabled );
158 m_text->setEnabled ( enabled ); 157 m_text->setEnabled ( enabled );
159 m_video->setEnabled ( enabled ); 158 m_video->setEnabled ( enabled );
160 slotAllChanged(); 159 slotAllChanged();
161 160
162 emit globalStateChanged( mode ); 161 emit globalStateChanged( mode );
163} 162}
164void MediumGlobalWidget::slotEnableChecking() 163void MediumGlobalWidget::slotEnableChecking()
165{ 164{
166 int mode = ENABLE_CHECKS; 165 int mode = ENABLE_CHECKS;
167 bool enabled = false; 166 bool enabled = false;
168 if( ( enabled = m_check->isChecked() ) ){ 167 if( ( enabled = m_check->isChecked() ) ){
169 mode = ENABLE_CHECKS; 168 mode = ENABLE_CHECKS;
170 }else{ 169 }else{
171 mode = DISABLE_CHECKS; 170 mode = DISABLE_CHECKS;
172 } 171 }
173 m_frame->setEnabled( enabled ); 172 m_frame->setEnabled( enabled );
174 slotGlobalChanged(); 173 slotGlobalChanged();
175 emit enableStateChanged( mode ); 174 emit enableStateChanged( mode );
176} 175}
177void MediumGlobalWidget::slotAllChanged() 176void MediumGlobalWidget::slotAllChanged()
178{ 177{
179 bool enable = !m_all->isChecked(); 178 bool enable = !m_all->isChecked();
180 m_audio->setEnabled( enable ); 179 m_audio->setEnabled( enable );
181 m_text->setEnabled( enable ); 180 m_text->setEnabled( enable );
182 m_video->setEnabled( enable ); 181 m_video->setEnabled( enable );
183 m_image->setEnabled( enable ); 182 m_image->setEnabled( enable );
184} 183}
diff --git a/noncore/settings/mediummount/mediumglobal.h b/noncore/settings/mediummount/mediumglobal.h
index 7b3cea0..ea1f0df 100644
--- a/noncore/settings/mediummount/mediumglobal.h
+++ b/noncore/settings/mediummount/mediumglobal.h
@@ -1,59 +1,60 @@
1 1
2 2
3#ifndef MediumGlobalWidget_H 3#ifndef MediumGlobalWidget_H
4#define MediumGlobalWidget_H 4#define MediumGlobalWidget_H
5 5
6#include <qwidget.h> 6#include <qwidget.h>
7 7
8class Config; 8class Config;
9class QCheckBox; 9class QCheckBox;
10class QGroupBox; 10class QGroupBox;
11class QFrame; 11class QFrame;
12class QLineEdit; 12class QLineEdit;
13class QVBoxLayout; 13class QVBoxLayout;
14class QGridLayout; 14class QGridLayout;
15class QLabel; 15class QLabel;
16 16
17namespace MediumMountSetting { 17namespace MediumMountSetting {
18 enum States { GLOBAL_ENABLED = 0, GLOBAL_DISABLED }; 18 enum States { GLOBAL_ENABLED = 0, GLOBAL_DISABLED };
19 enum Checks { ENABLE_CHECKS = 0, DISABLE_CHECKS }; 19 enum Checks { ENABLE_CHECKS = 0, DISABLE_CHECKS };
20 20
21 class MediumGlobalWidget : public QWidget { 21 class MediumGlobalWidget : public QWidget {
22 Q_OBJECT 22 Q_OBJECT
23 public: 23 public:
24 MediumGlobalWidget(QWidget *parent = 0, const char *name =0 ); 24 MediumGlobalWidget(QWidget *parent = 0, const char *name =0 );
25 ~MediumGlobalWidget(); 25 ~MediumGlobalWidget();
26
27 void writeConfig();
26 signals: 28 signals:
27 // the global status changed 29 // the global status changed
28 void globalStateChanged( int ); 30 void globalStateChanged( int );
29 void enableStateChanged( int ); 31 void enableStateChanged( int );
30 private slots: 32 private slots:
31 void slotGlobalChanged(); 33 void slotGlobalChanged();
32 void slotEnableChecking(); 34 void slotEnableChecking();
33 void slotAllChanged(); 35 void slotAllChanged();
34 36
35 private: 37 private:
36 void initGUI(); 38 void initGUI();
37 void readConfig(); 39 void readConfig();
38 void writeConfig();
39 Config *m_config; 40 Config *m_config;
40 QCheckBox *m_check; 41 QCheckBox *m_check;
41 QCheckBox *m_useglobal; 42 QCheckBox *m_useglobal;
42 43
43 QGroupBox *m_global; 44 QGroupBox *m_global;
44 45
45 QCheckBox *m_all; 46 QCheckBox *m_all;
46 QCheckBox *m_audio; 47 QCheckBox *m_audio;
47 QCheckBox *m_video; 48 QCheckBox *m_video;
48 QCheckBox *m_text; 49 QCheckBox *m_text;
49 QCheckBox *m_image; 50 QCheckBox *m_image;
50 51
51 QFrame *m_frame; 52 QFrame *m_frame;
52 QGridLayout *m_frameLay; 53 QGridLayout *m_frameLay;
53 QVBoxLayout *m_layout; 54 QVBoxLayout *m_layout;
54 QVBoxLayout *m_box; 55 QVBoxLayout *m_box;
55 QLabel *m_label; 56 QLabel *m_label;
56 }; 57 };
57}; 58};
58 59
59#endif 60#endif
diff --git a/noncore/settings/mediummount/mediumwidget.cc b/noncore/settings/mediummount/mediumwidget.cc
index 04e4e7c..f98e637 100644
--- a/noncore/settings/mediummount/mediumwidget.cc
+++ b/noncore/settings/mediummount/mediumwidget.cc
@@ -1,192 +1,190 @@
1 1
2 2
3#include <qcheckbox.h> 3#include <qcheckbox.h>
4#include <qgroupbox.h> 4#include <qgroupbox.h>
5#include <qhbox.h> 5#include <qhbox.h>
6#include <qlabel.h> 6#include <qlabel.h>
7#include <qabstractlayout.h> 7#include <qabstractlayout.h>
8#include <qlayout.h> 8#include <qlayout.h>
9#include <qlineedit.h> 9#include <qlineedit.h>
10#include <qpixmap.h> 10#include <qpixmap.h>
11#include <qpushbutton.h> 11#include <qpushbutton.h>
12#include <qvbox.h> 12#include <qvbox.h>
13#include <qwhatsthis.h> 13#include <qwhatsthis.h>
14 14
15 15
16#include <qpe/config.h> 16#include <qpe/config.h>
17#include <qpe/qpeapplication.h> 17#include <qpe/qpeapplication.h>
18 18
19#include "mediumwidget.h" 19#include "mediumwidget.h"
20 20
21 21
22 22
23using namespace MediumMountSetting; 23using namespace MediumMountSetting;
24 24
25MediumMountWidget::MediumMountWidget(const QString &path, 25MediumMountWidget::MediumMountWidget(const QString &path,
26 const QPixmap &pix, 26 const QPixmap &pix,
27 QWidget *parent, 27 QWidget *parent,
28 const char *name ) 28 const char *name )
29 : QWidget( parent, name ) 29 : QWidget( parent, name )
30{ 30{
31 if(parent == 0){ 31 if(parent == 0){
32 resize(QApplication::desktop()->width(), QApplication::desktop()->height() ); 32 resize(QApplication::desktop()->width(), QApplication::desktop()->height() );
33 }else{ 33 }else{
34 resize(parent->width(), parent->height() ); 34 resize(parent->width(), parent->height() );
35 } 35 }
36 m_path = path; 36 m_path = path;
37 initGUI(); 37 initGUI();
38 m_label->setPixmap(pix ); 38 m_label->setPixmap(pix );
39 m_config = 0; 39 m_config = 0;
40 40
41 readConfig(); 41 readConfig();
42} 42}
43// now we fire up the GUI 43// now we fire up the GUI
44// if I would know what I'm doing ;) 44// if I would know what I'm doing ;)
45void MediumMountWidget::initGUI() 45void MediumMountWidget::initGUI()
46{ 46{
47 //main layout 47 //main layout
48 m_box = new QVBoxLayout( this , 5, 5 ); 48 m_box = new QVBoxLayout( this , 5, 5 );
49 m_box->setSpacing( 5 ); 49 m_box->setSpacing( 5 );
50 //m_box->addStretch( -1 ); 50 //m_box->addStretch( -1 );
51 51
52 // picture + text 52 // picture + text
53 m_infoBox = new QHBox(this, "infobox" ); 53 m_infoBox = new QHBox(this, "infobox" );
54 m_infoBox->setSpacing( 4 ); 54 m_infoBox->setSpacing( 4 );
55 m_label = new QLabel(m_infoBox ); 55 m_label = new QLabel(m_infoBox );
56 m_desc = new QLabel(m_infoBox ); 56 m_desc = new QLabel(m_infoBox );
57 m_desc->setTextFormat( Qt::RichText ); 57 m_desc->setTextFormat( Qt::RichText );
58 QWhatsThis::add( this, tr("Configure this medium. The changes will" 58 QWhatsThis::add( this, tr("Configure this medium. The changes will"
59 " go into effect when the application gets" 59 " go into effect when the application gets"
60 " closed. To update the Document Tab you need" 60 " closed. To update the Document Tab you need"
61 " to remove and insert this medium.")); 61 " to remove and insert this medium."));
62 m_desc->setText("" ); 62 m_desc->setText("" );
63 m_box->addWidget( m_infoBox ); // add the widget to the layout 63 m_box->addWidget( m_infoBox ); // add the widget to the layout
64 64
65 65
66 // groupbox 66 // groupbox
67 m_group = new QGroupBox(tr("Which media files"), this, "MediaFiles" ); 67 m_group = new QGroupBox(tr("Which media files"), this, "MediaFiles" );
68 m_checks = new QGridLayout( m_group, 4, 3 ); 68 m_checks = new QGridLayout( m_group, 4, 3 );
69 m_checks->setMargin( 12 ); 69 m_checks->setMargin( 12 );
70 70
71 71
72 72
73 QSpacerItem *item2 = new QSpacerItem(5, 8, 73 QSpacerItem *item2 = new QSpacerItem(5, 8,
74 QSizePolicy::Fixed, 74 QSizePolicy::Fixed,
75 QSizePolicy::Fixed); 75 QSizePolicy::Fixed);
76 m_box->addItem( item2 ); 76 m_box->addItem( item2 );
77 77
78 m_audio = new QCheckBox( tr("Audio"), m_group ); 78 m_audio = new QCheckBox( tr("Audio"), m_group );
79 m_all = new QCheckBox( tr("All") , m_group ); 79 m_all = new QCheckBox( tr("All") , m_group );
80 m_image = new QCheckBox( tr("Image"), m_group ); 80 m_image = new QCheckBox( tr("Image"), m_group );
81 m_text = new QCheckBox( tr("Text") , m_group ); 81 m_text = new QCheckBox( tr("Text") , m_group );
82 m_video = new QCheckBox( tr("Video"), m_group ); 82 m_video = new QCheckBox( tr("Video"), m_group );
83 83
84 QSpacerItem *iti1b = new QSpacerItem(2, 10, QSizePolicy::Fixed, 84 QSpacerItem *iti1b = new QSpacerItem(2, 10, QSizePolicy::Fixed,
85 QSizePolicy::Fixed ); 85 QSizePolicy::Fixed );
86 m_checks->addItem( iti1b, 0, 0 ); 86 m_checks->addItem( iti1b, 0, 0 );
87 87
88 m_checks->addWidget(m_audio, 1, 0 ); 88 m_checks->addWidget(m_audio, 1, 0 );
89 m_checks->addWidget(m_image, 2, 0 ); 89 m_checks->addWidget(m_image, 2, 0 );
90 m_checks->addWidget(m_all , 3, 0 ); 90 m_checks->addWidget(m_all , 3, 0 );
91 91
92 m_checks->addWidget(m_text, 1, 2 ); 92 m_checks->addWidget(m_text, 1, 2 );
93 m_checks->addWidget(m_video, 2, 2 ); 93 m_checks->addWidget(m_video, 2, 2 );
94 94
95 m_checks->addRowSpacing(0, 8 ); 95 m_checks->addRowSpacing(0, 8 );
96 m_checks->addColSpacing(1, 2 ); 96 m_checks->addColSpacing(1, 2 );
97 m_checks->setColStretch(1, -2 ); 97 m_checks->setColStretch(1, -2 );
98 98
99 connect(m_all, SIGNAL(stateChanged(int) ), 99 connect(m_all, SIGNAL(stateChanged(int) ),
100 this, SLOT(slotStateChanged() ) ); 100 this, SLOT(slotStateChanged() ) );
101 101
102 m_box->addWidget( m_group ); 102 m_box->addWidget( m_group );
103 103
104 // label 104 // label
105 m_lblPath = new QLabel(tr("Limit search to:"), this ); 105 m_lblPath = new QLabel(tr("Limit search to:"), this );
106 m_box->addWidget( m_lblPath ); 106 m_box->addWidget( m_lblPath );
107 107
108 // add to 108 // add to
109 m_hboxAdd = new QHBox( this ); 109 m_hboxAdd = new QHBox( this );
110 m_hboxAdd->setSpacing( 10 ); 110 m_hboxAdd->setSpacing( 10 );
111 m_edit = new QLineEdit(m_hboxAdd ); 111 m_edit = new QLineEdit(m_hboxAdd );
112 m_add = new QPushButton(m_hboxAdd ); 112 m_add = new QPushButton(m_hboxAdd );
113 m_add->setText( tr("Add") ); 113 m_add->setText( tr("Add") );
114 114
115 m_box->addWidget(m_hboxAdd ); 115 m_box->addWidget(m_hboxAdd );
116 116
117 m_always = new QCheckBox( tr("Always check this medium"), this ); 117 m_always = new QCheckBox( tr("Always check this medium"), this );
118 118
119 m_box->addWidget( m_always ); 119 m_box->addWidget( m_always );
120 120
121 QSpacerItem *item = new QSpacerItem(5, 50, 121 QSpacerItem *item = new QSpacerItem(5, 50,
122 QSizePolicy::Fixed, 122 QSizePolicy::Fixed,
123 QSizePolicy::Expanding ); 123 QSizePolicy::Expanding );
124 m_box->addItem(item ); 124 m_box->addItem(item );
125} 125}
126 126
127void MediumMountWidget::readConfig( ) 127void MediumMountWidget::readConfig( )
128{ 128{
129 if( m_config == 0 ) 129 if( m_config == 0 )
130 m_config = new Config(m_path + "/.opiestorage.cf", Config::File ); 130 m_config = new Config(m_path + "/.opiestorage.cf", Config::File );
131 m_config->setGroup( "main" ); 131 m_config->setGroup( "main" );
132 132
133 m_always->setChecked( m_config->readBoolEntry("check", false) ); 133 m_always->setChecked( m_config->readBoolEntry("check", false) );
134 134
135 m_config->setGroup( "mimetypes" ); 135 m_config->setGroup( "mimetypes" );
136 if( m_config->readBoolEntry("all", false ) ){ 136 if( m_config->readBoolEntry("all", false ) ){
137 m_audio->setEnabled( false ); 137 m_audio->setEnabled( false );
138 m_image->setEnabled( false ); 138 m_image->setEnabled( false );
139 m_text->setEnabled ( false ); 139 m_text->setEnabled ( false );
140 m_video->setEnabled( false ); 140 m_video->setEnabled( false );
141 m_all->setChecked( true ); 141 m_all->setChecked( true );
142 }else{ 142 }else{
143 m_audio->setEnabled( true ); 143 m_audio->setEnabled( true );
144 m_image->setEnabled( true ); 144 m_image->setEnabled( true );
145 m_text->setEnabled ( true ); 145 m_text->setEnabled ( true );
146 m_all->setEnabled ( true ); 146 m_all->setEnabled ( true );
147 147
148 m_all->setChecked( false ); 148 m_all->setChecked( false );
149 149
150 m_audio->setChecked( m_config->readBoolEntry("audio", true ) ); 150 m_audio->setChecked( m_config->readBoolEntry("audio", true ) );
151 m_image->setChecked( m_config->readBoolEntry("image", true ) ); 151 m_image->setChecked( m_config->readBoolEntry("image", true ) );
152 m_text->setChecked ( m_config->readBoolEntry("text" , true ) ); 152 m_text->setChecked ( m_config->readBoolEntry("text" , true ) );
153 m_video->setChecked( m_config->readBoolEntry("video", true ) ); 153 m_video->setChecked( m_config->readBoolEntry("video", true ) );
154 }; 154 };
155} 155}
156 156
157void MediumMountWidget::writeConfig() 157void MediumMountWidget::writeConfig()
158{ 158{
159 m_config->setGroup("main"); 159 m_config->setGroup("main");
160 m_config->writeEntry("check", m_always->isChecked() ); 160 m_config->writeEntry("check", m_always->isChecked() );
161 161
162 m_config->setGroup("mimetypes" ); 162 m_config->setGroup("mimetypes" );
163 if(m_all->isChecked() ){ 163 if(m_all->isChecked() ){
164 m_config->writeEntry("all", true ); 164 m_config->writeEntry("all", true );
165 }else{ 165 }else{
166 m_config->writeEntry("audio", m_audio->isChecked() ); 166 m_config->writeEntry("audio", m_audio->isChecked() );
167 m_config->writeEntry("image", m_image->isChecked() ); 167 m_config->writeEntry("image", m_image->isChecked() );
168 m_config->writeEntry("text" , m_text->isChecked() ); 168 m_config->writeEntry("text" , m_text->isChecked() );
169 m_config->writeEntry("video", m_video->isChecked() ); 169 m_config->writeEntry("video", m_video->isChecked() );
170 } 170 }
171} 171}
172MediumMountWidget::~MediumMountWidget() 172MediumMountWidget::~MediumMountWidget()
173{ 173{
174 writeConfig();
175 delete m_config; 174 delete m_config;
176} 175}
177 176
178
179void MediumMountWidget::slotAdd() 177void MediumMountWidget::slotAdd()
180{ 178{
181 179
182} 180}
183void MediumMountWidget::slotStateChanged() 181void MediumMountWidget::slotStateChanged()
184{ 182{
185 bool state = !(m_all->isChecked()); 183 bool state = !(m_all->isChecked());
186 184
187 m_audio->setEnabled( state ); 185 m_audio->setEnabled( state );
188 m_text->setEnabled ( state ); 186 m_text->setEnabled ( state );
189 m_video->setEnabled( state ); 187 m_video->setEnabled( state );
190 m_image->setEnabled( state ); 188 m_image->setEnabled( state );
191 189
192} 190}
diff --git a/noncore/settings/mediummount/mediumwidget.h b/noncore/settings/mediummount/mediumwidget.h
index 7a801eb..7f7b755 100644
--- a/noncore/settings/mediummount/mediumwidget.h
+++ b/noncore/settings/mediummount/mediumwidget.h
@@ -1,77 +1,78 @@
1 1
2#ifndef MediumMountWidget_H 2#ifndef MediumMountWidget_H
3#define MediumMountWidget_H 3#define MediumMountWidget_H
4 4
5//#include <qpixmap.h> 5//#include <qpixmap.h>
6#include <qwidget.h> 6#include <qwidget.h>
7 7
8 8
9class QLabel; 9class QLabel;
10class QPixmap; 10class QPixmap;
11class Config; 11class Config;
12class QGridLayout; 12class QGridLayout;
13class QCheckBox; 13class QCheckBox;
14class QPushButton; 14class QPushButton;
15class QVBoxLayout; 15class QVBoxLayout;
16class QHBoxLayout; 16class QHBoxLayout;
17class QGroupBox; 17class QGroupBox;
18class QVBox; 18class QVBox;
19class QHBox; 19class QHBox;
20class QLineEdit; 20class QLineEdit;
21 21
22namespace MediumMountSetting { 22namespace MediumMountSetting {
23 23
24 class MediumMountWidget : public QWidget { 24 class MediumMountWidget : public QWidget {
25 Q_OBJECT 25 Q_OBJECT
26 public: 26 public:
27 MediumMountWidget(const QString&, const QPixmap &, QWidget *parent, const char *name = 0 ); 27 MediumMountWidget(const QString&, const QPixmap &, QWidget *parent, const char *name = 0 );
28 ~MediumMountWidget(); 28 ~MediumMountWidget();
29
30 void writeConfig();
29 31
30 private slots: 32 private slots:
31 void slotAdd(); 33 void slotAdd();
32 void slotStateChanged(); 34 void slotStateChanged();
33 35
34 private: 36 private:
35 void readConfig(); 37 void readConfig();
36 void initGUI(); 38 void initGUI();
37 void writeConfig(); 39
38
39 bool m_dirty : 1; 40 bool m_dirty : 1;
40 41
41 class MediumMountWidgetPrivate; 42 class MediumMountWidgetPrivate;
42 MediumMountWidgetPrivate *d; 43 MediumMountWidgetPrivate *d;
43 44
44 QString m_path; 45 QString m_path;
45 46
46 Config *m_config; 47 Config *m_config;
47 48
48 QHBox *m_infoBox; 49 QHBox *m_infoBox;
49 QLabel *m_label; 50 QLabel *m_label;
50 QLabel *m_desc; 51 QLabel *m_desc;
51 52
52 QLineEdit *m_edit; 53 QLineEdit *m_edit;
53 QPushButton *m_add; 54 QPushButton *m_add;
54 55
55 QVBoxLayout *m_box; 56 QVBoxLayout *m_box;
56 QGridLayout *m_checks; 57 QGridLayout *m_checks;
57 58
58 QGroupBox *m_group; 59 QGroupBox *m_group;
59 QCheckBox *m_all; 60 QCheckBox *m_all;
60 QCheckBox *m_audio; 61 QCheckBox *m_audio;
61 QCheckBox *m_image; 62 QCheckBox *m_image;
62 QCheckBox *m_text; 63 QCheckBox *m_text;
63 QCheckBox *m_video; 64 QCheckBox *m_video;
64 65
65 QCheckBox *m_always; 66 QCheckBox *m_always;
66 //QCheckBox *m_yesNo; 67 //QCheckBox *m_yesNo;
67 68
68 QHBox *m_hboxAdd; 69 QHBox *m_hboxAdd;
69 70
70 QLabel *m_lblPath; 71 QLabel *m_lblPath;
71 //////////////// 72 ////////////////
72 73
73 74
74 75
75 }; 76 };
76}; 77};
77#endif 78#endif