• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeutils API Reference
  • KDE Home
  • Contact Us
 

filelight

  • sources
  • kde-4.12
  • kdeutils
  • filelight
  • src
  • part
settingsDialog.cpp
Go to the documentation of this file.
1 /***********************************************************************
2 * Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
3 * Copyright 2008-2009 Martin Sandsmark <martin.sandsmark@kde.org>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License or (at your option) version 3 or any later version
9 * accepted by the membership of KDE e.V. (or its successor approved
10 * by the membership of KDE e.V.), which shall act as a proxy
11 * defined in Section 14 of version 3 of the license.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ***********************************************************************/
21 
22 #include "settingsDialog.h"
23 #include "Config.h"
24 
25 #include <KDirSelectDialog>
26 #include <KLocale>
27 #include <KMessageBox>
28 
29 #include <QtGui/QRadioButton>
30 #include <QtGui/QCloseEvent>
31 #include <QtCore/QDir>
32 
33 SettingsDialog::SettingsDialog(QWidget *parent) : KDialog(parent)
34 {
35  setButtons(KDialog::Reset | KDialog::Close);
36 
37  setupUi(this->mainWidget());
38  QVBoxLayout *vbox = new QVBoxLayout;
39  //colourSchemeGroup->setFrameShape(QFrame::NoFrame);
40 
41  vbox->addWidget(new QRadioButton(i18n("Rainbow"), this), Filelight::Rainbow);
42  vbox->addWidget(new QRadioButton(i18n("System Colors"), this), Filelight::KDE);
43  vbox->addWidget(new QRadioButton(i18n("High Contrast"), this), Filelight::HighContrast);
44 
45  colourSchemeGroup->setLayout(vbox);
46 
47  //read in settings before you make all those nasty connections!
48  reset(); //makes dialog reflect global settings
49 
50  connect(&m_timer, SIGNAL(timeout()), SIGNAL(mapIsInvalid()));
51 
52  connect(m_addButton, SIGNAL(clicked()), SLOT(addFolder()));
53  connect(m_removeButton, SIGNAL(clicked()), SLOT(removeFolder()));
54  connect(this, SIGNAL(resetClicked()), SLOT(reset()));
55  connect(this, SIGNAL(closeClicked()), SLOT(close()));
56 
57  connect(colourSchemeGroup, SIGNAL(clicked(int)), SLOT(changeScheme(int)));
58  connect(contrastSlider, SIGNAL(valueChanged(int)), SLOT(changeContrast(int)));
59  connect(contrastSlider, SIGNAL(sliderReleased()), SLOT(slotSliderReleased()));
60 
61  connect(scanAcrossMounts, SIGNAL(toggled(bool)), SLOT(startTimer()));
62  connect(dontScanRemoteMounts, SIGNAL(toggled(bool)), SLOT(startTimer()));
63  connect(dontScanRemovableMedia, SIGNAL(toggled(bool)), SLOT(startTimer()));
64  connect(scanAcrossMounts, SIGNAL(toggled(bool)),
65  SLOT(toggleScanAcrossMounts(bool)));
66  connect(dontScanRemoteMounts, SIGNAL(toggled(bool)),
67  SLOT(toggleDontScanRemoteMounts(bool)));
68  connect(dontScanRemovableMedia, SIGNAL(toggled(bool)),
69  SLOT(toggleDontScanRemovableMedia(bool)));
70 
71  connect(useAntialiasing, SIGNAL(toggled(bool)), SLOT(toggleUseAntialiasing(bool)));
72  connect(varyLabelFontSizes, SIGNAL(toggled(bool)), SLOT(toggleVaryLabelFontSizes(bool)));
73  connect(showSmallFiles, SIGNAL(toggled(bool)), SLOT(toggleShowSmallFiles(bool)));
74 
75  connect(minFontPitch, SIGNAL (valueChanged(int)), SLOT(changeMinFontPitch(int)));
76 
77  m_addButton->setIcon(KIcon(QLatin1String( "folder-open" )));
78  m_removeButton->setIcon(KIcon(QLatin1String( "list-remove" )));
79 }
80 
81 
82 void SettingsDialog::closeEvent(QCloseEvent*)
83 {
84  //if an invalidation is pending, force it now!
85  if (m_timer.isActive()) m_timer.setInterval(0);
86 
87  Config::write();
88 
89  deleteLater();
90 }
91 
92 
93 void SettingsDialog::reset()
94 {
95  Config::read();
96 
97  //tab 1
98  scanAcrossMounts->setChecked(Config::scanAcrossMounts);
99  dontScanRemoteMounts->setChecked(!Config::scanRemoteMounts);
100  dontScanRemovableMedia->setChecked(!Config::scanRemovableMedia);
101 
102  dontScanRemoteMounts->setEnabled(Config::scanAcrossMounts);
103  // dontScanRemovableMedia.setEnabled(Config::scanAcrossMounts);
104 
105  m_listBox->clear();
106  m_listBox->addItems(Config::skipList);
107  m_listBox->setCurrentRow(0);
108 
109  m_removeButton->setEnabled(m_listBox->count() > 0);
110 
111  //tab 2
112  if (colourSchemeGroup->selected() != Config::scheme) //TODO: This is probably wrong
113  {
114  qobject_cast<QRadioButton*>(colourSchemeGroup->layout()->itemAt(Config::scheme)->widget())->setChecked(true);
115  //colourSchemeGroup->setSelected(Config::scheme);
116  //setButton doesn't call a single QButtonGroup signal!
117  //so we need to call this ourselves (and hence the detection above)
118  changeScheme(Config::scheme);
119  }
120  contrastSlider->setValue(Config::contrast);
121 
122  useAntialiasing->setChecked(Config::antialias);
123 
124  varyLabelFontSizes->setChecked(Config::varyLabelFontSizes);
125  minFontPitchLabel->setEnabled(Config::varyLabelFontSizes);
126  minFontPitch->setEnabled(Config::varyLabelFontSizes);
127  minFontPitch->setValue(Config::minFontPitch);
128  showSmallFiles->setChecked(Config::showSmallFiles);
129 }
130 
131 
132 
133 void SettingsDialog::toggleScanAcrossMounts(bool b)
134 {
135  Config::scanAcrossMounts = b;
136 
137  dontScanRemoteMounts->setEnabled(b);
138  //dontScanRemovableMedia.setEnabled(b);
139 }
140 
141 void SettingsDialog::toggleDontScanRemoteMounts(bool b)
142 {
143  Config::scanRemoteMounts = !b;
144 }
145 
146 void SettingsDialog::toggleDontScanRemovableMedia(bool b)
147 {
148  Config::scanRemovableMedia = !b;
149 }
150 
151 
152 
153 void SettingsDialog::addFolder()
154 {
155  const KUrl url = KDirSelectDialog::selectDirectory(KUrl(QDir::rootPath()), false, this, i18n( "Select Folder to Scan" ));
156 
157  //TODO error handling!
158  //TODO wrong protocol handling!
159 
160  if (!url.isEmpty())
161  {
162  const QString path = url.path(KUrl::AddTrailingSlash);
163 
164  if (!Config::skipList.contains(path))
165  {
166  Config::skipList.append(path);
167  m_listBox->addItem(path);
168  if (m_listBox->currentItem() == 0) m_listBox->setCurrentRow(0);
169  m_removeButton->setEnabled(true);
170  }
171  else KMessageBox::sorry(this, i18n("That folder is already set to be excluded from scans"));
172  }
173 }
174 
175 
176 void SettingsDialog::removeFolder()
177 {
178  Config::skipList.removeAll(m_listBox->currentItem()->text()); //removes all entries that match
179 
180  //safest method to ensure consistency
181  m_listBox->clear();
182  m_listBox->addItems(Config::skipList);
183 
184  m_removeButton->setEnabled(m_listBox->count() > 0);
185  if (m_listBox->count() > 0) m_listBox->setCurrentRow(0);
186 }
187 
188 
189 void SettingsDialog::startTimer()
190 {
191  m_timer.setSingleShot(true);
192  m_timer.start(TIMEOUT);
193 }
194 
195 void SettingsDialog::changeScheme(int s)
196 {
197  Config::scheme = (Filelight::MapScheme)s;
198  emit canvasIsDirty(1);
199 }
200 void SettingsDialog::changeContrast(int c)
201 {
202  Config::contrast = c;
203  emit canvasIsDirty(3);
204 }
205 void SettingsDialog::toggleUseAntialiasing(bool b)
206 {
207  Config::antialias = b;
208  emit canvasIsDirty(2);
209 }
210 void SettingsDialog::toggleVaryLabelFontSizes(bool b)
211 {
212  Config::varyLabelFontSizes = b;
213  minFontPitchLabel->setEnabled(b);
214  minFontPitch->setEnabled(b);
215  emit canvasIsDirty(0);
216 }
217 void SettingsDialog::changeMinFontPitch(int p)
218 {
219  Config::minFontPitch = p;
220  emit canvasIsDirty(0);
221 }
222 void SettingsDialog::toggleShowSmallFiles(bool b)
223 {
224  Config::showSmallFiles = b;
225  emit canvasIsDirty(1);
226 }
227 
228 
229 void SettingsDialog::slotSliderReleased()
230 {
231  emit canvasIsDirty(2);
232 }
233 
234 
235 void SettingsDialog::reject()
236 {
237  //called when escape is pressed
238  reset();
239  KDialog::reject(); //**** doesn't change back scheme so far
240 }
241 
242 #include "settingsDialog.moc"
SettingsDialog::addFolder
void addFolder()
Definition: settingsDialog.cpp:153
Filelight::KDE
Definition: Config.h:31
SettingsDialog::SettingsDialog
SettingsDialog(QWidget *=0)
Definition: settingsDialog.cpp:33
Filelight::Rainbow
Definition: Config.h:31
QWidget
SettingsDialog::reset
void reset()
Definition: settingsDialog.cpp:93
SettingsDialog::toggleVaryLabelFontSizes
void toggleVaryLabelFontSizes(bool)
Definition: settingsDialog.cpp:210
SettingsDialog::removeFolder
void removeFolder()
Definition: settingsDialog.cpp:176
KDialog
Config.h
SettingsDialog::toggleDontScanRemovableMedia
void toggleDontScanRemovableMedia(bool)
Definition: settingsDialog.cpp:146
Filelight::HighContrast
Definition: Config.h:31
SettingsDialog::canvasIsDirty
void canvasIsDirty(int)
SettingsDialog::changeMinFontPitch
void changeMinFontPitch(int)
Definition: settingsDialog.cpp:217
SettingsDialog::mapIsInvalid
void mapIsInvalid()
settingsDialog.h
SettingsDialog::toggleScanAcrossMounts
void toggleScanAcrossMounts(bool)
Definition: settingsDialog.cpp:133
Filelight::MapScheme
MapScheme
Definition: Config.h:31
SettingsDialog::toggleShowSmallFiles
void toggleShowSmallFiles(bool)
Definition: settingsDialog.cpp:222
Filelight::parent
http QObject * parent
Definition: part.cpp:74
SettingsDialog::changeScheme
void changeScheme(int)
Definition: settingsDialog.cpp:195
SettingsDialog::toggleUseAntialiasing
void toggleUseAntialiasing(bool=true)
Definition: settingsDialog.cpp:205
SettingsDialog::startTimer
void startTimer()
Definition: settingsDialog.cpp:189
SettingsDialog::toggleDontScanRemoteMounts
void toggleDontScanRemoteMounts(bool)
Definition: settingsDialog.cpp:141
SettingsDialog::reject
virtual void reject()
Definition: settingsDialog.cpp:235
SettingsDialog::changeContrast
void changeContrast(int)
Definition: settingsDialog.cpp:200
SettingsDialog::closeEvent
virtual void closeEvent(QCloseEvent *)
Definition: settingsDialog.cpp:82
SettingsDialog::slotSliderReleased
void slotSliderReleased()
Definition: settingsDialog.cpp:229
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:08:08 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

filelight

Skip menu "filelight"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeutils API Reference

Skip menu "kdeutils API Reference"
  • ark
  • filelight
  • kcalc
  • kcharselect
  • kdf
  • kfloppy
  • kgpg
  • kremotecontrol
  • ktimer
  • kwallet
  • superkaramba
  • sweeper

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal