summaryrefslogtreecommitdiff
path: root/noncore/settings/mediummount/mediumglobal.cc
Unidiff
Diffstat (limited to 'noncore/settings/mediummount/mediumglobal.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/mediummount/mediumglobal.cc182
1 files changed, 182 insertions, 0 deletions
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}