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