diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-03 01:26:04 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-03 01:26:04 +0000 |
commit | 3c7b870f367df150ea60eb9d6bb2fd41646545d7 (patch) | |
tree | ac8705b4703cebb5031f9443eafd3e429a17ac1a /src/part/settingsDialog.cpp | |
download | filelight-3c7b870f367df150ea60eb9d6bb2fd41646545d7.tar.gz filelight-3c7b870f367df150ea60eb9d6bb2fd41646545d7.zip |
Added abandoned Filelight application
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/filelight@1084392 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/part/settingsDialog.cpp')
-rw-r--r-- | src/part/settingsDialog.cpp | 214 |
1 files changed, 214 insertions, 0 deletions
diff --git a/src/part/settingsDialog.cpp b/src/part/settingsDialog.cpp new file mode 100644 index 0000000..508904a --- /dev/null +++ b/src/part/settingsDialog.cpp @@ -0,0 +1,214 @@ +//Author: Max Howell <[email protected]>, (C) 2003-4 +//Copyright: See COPYING file that comes with this distribution + +#include <qapplication.h> //Getting desktop width +#include <qcheckbox.h> +#include <qpushbutton.h> +#include <qradiobutton.h> +#include <qslider.h> +#include <qvbuttongroup.h> + +#include <kdirselectdialog.h> +#include <kiconloader.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <knuminput.h> + +#include "settingsDialog.h" +#include "Config.h" + + +SettingsDialog::SettingsDialog( QWidget *parent, const char *name ) + : Dialog( parent, name, false ) //3rd param => modal +{ + colourSchemeGroup->setFrameShape( QFrame::NoFrame ); + + colourSchemeGroup->insert( new QRadioButton( i18n("Rainbow"), colourSchemeGroup ), Filelight::Rainbow ); + colourSchemeGroup->insert( new QRadioButton( i18n("KDE Colors"), colourSchemeGroup ), Filelight::KDE ); + colourSchemeGroup->insert( new QRadioButton( i18n("High Contrast"), colourSchemeGroup ), Filelight::HighContrast ); + + //read in settings before you make all those nasty connections! + reset(); //makes dialog reflect global settings + + connect( &m_timer, SIGNAL(timeout()), SIGNAL(mapIsInvalid()) ); + + connect( m_addButton, SIGNAL( clicked() ), SLOT( addDirectory() ) ); + connect( m_removeButton, SIGNAL( clicked() ), SLOT( removeDirectory() ) ); + connect( m_resetButton, SIGNAL( clicked() ), SLOT( reset() ) ); + connect( m_closeButton, SIGNAL( clicked() ), SLOT( close() ) ); + + connect( colourSchemeGroup, SIGNAL(clicked( int )), SLOT(changeScheme( int )) ); + connect( contrastSlider, SIGNAL(valueChanged( int )), SLOT(changeContrast( int )) ); + connect( contrastSlider, SIGNAL(sliderReleased()), SLOT(slotSliderReleased()) ); + + connect( scanAcrossMounts, SIGNAL( toggled( bool ) ), SLOT( startTimer() ) ); + connect( dontScanRemoteMounts, SIGNAL( toggled( bool ) ), SLOT( startTimer() ) ); + connect( dontScanRemovableMedia, SIGNAL( toggled( bool ) ), SLOT( startTimer() ) ); + + connect( useAntialiasing, SIGNAL( toggled( bool ) ), SLOT( toggleUseAntialiasing( bool ) ) ); + connect( varyLabelFontSizes, SIGNAL( toggled( bool ) ), SLOT( toggleVaryLabelFontSizes( bool ) ) ); + connect( showSmallFiles, SIGNAL( toggled( bool ) ), SLOT( toggleShowSmallFiles( bool ) ) ); + + connect( minFontPitch, SIGNAL ( valueChanged( int ) ), SLOT( changeMinFontPitch( int ) ) ); + + m_addButton->setIconSet( SmallIcon( "fileopen" ) ); + m_resetButton->setIconSet( SmallIcon( "undo" ) ); + m_closeButton->setIconSet( SmallIcon( "fileclose" ) ); +} + + +void SettingsDialog::closeEvent( QCloseEvent* ) +{ + //if an invalidation is pending, force it now! + if( m_timer.isActive() ) m_timer.changeInterval( 0 ); + + Config::write(); + + deleteLater(); +} + + +void SettingsDialog::reset() +{ + Config::read(); + + //tab 1 + scanAcrossMounts->setChecked( Config::scanAcrossMounts ); + dontScanRemoteMounts->setChecked( !Config::scanRemoteMounts ); + dontScanRemovableMedia->setChecked( !Config::scanRemovableMedia ); + + dontScanRemoteMounts->setEnabled( Config::scanAcrossMounts ); + // dontScanRemovableMedia.setEnabled( Config::scanAcrossMounts ); + + m_listBox->clear(); + m_listBox->insertStringList( Config::skipList ); + m_listBox->setSelected( 0, true ); + + m_removeButton->setEnabled( m_listBox->count() == 0 ); + + //tab 2 + if( colourSchemeGroup->id( colourSchemeGroup->selected() ) != Config::scheme ) + { + colourSchemeGroup->setButton( Config::scheme ); + //setButton doesn't call a single QButtonGroup signal! + //so we need to call this ourselves (and hence the detection above) + changeScheme( Config::scheme ); + } + contrastSlider->setValue( Config::contrast ); + + useAntialiasing->setChecked( (Config::antiAliasFactor > 1) ? true : false ); + + varyLabelFontSizes->setChecked( Config::varyLabelFontSizes ); + minFontPitch->setEnabled( Config::varyLabelFontSizes ); + minFontPitch->setValue( Config::minFontPitch ); + showSmallFiles->setChecked( Config::showSmallFiles ); +} + + + +void SettingsDialog::toggleScanAcrossMounts( bool b ) +{ + Config::scanAcrossMounts = b; + + dontScanRemoteMounts->setEnabled( b ); + //dontScanRemovableMedia.setEnabled( b ); +} + +void SettingsDialog::toggleDontScanRemoteMounts( bool b ) +{ + Config::scanRemoteMounts = !b; +} + +void SettingsDialog::toggleDontScanRemovableMedia( bool b ) +{ + Config::scanRemovableMedia = !b; +} + + + +void SettingsDialog::addDirectory() +{ + const KURL url = KDirSelectDialog::selectDirectory( "/", false, this ); + + //TODO error handling! + //TODO wrong protocol handling! + + if( !url.isEmpty() ) + { + const QString path = url.path( 1 ); + + if( !Config::skipList.contains( path ) ) + { + Config::skipList.append( path ); + m_listBox->insertItem( path ); + m_removeButton->setEnabled( true ); + } + else KMessageBox::sorry( this, i18n("That directory is already set to be excluded from scans") ); + } +} + + +void SettingsDialog::removeDirectory() +{ + Config::skipList.remove( m_listBox->currentText() ); //removes all entries that match + + //safest method to ensure consistency + m_listBox->clear(); + m_listBox->insertStringList( Config::skipList ); + + m_removeButton->setEnabled( m_listBox->count() == 0 ); +} + + +void SettingsDialog::startTimer() +{ + m_timer.start( TIMEOUT, true ); +} + +void SettingsDialog::changeScheme( int s ) +{ + Config::scheme = (Filelight::MapScheme)s; + emit canvasIsDirty( 1 ); +} +void SettingsDialog::changeContrast( int c ) +{ + Config::contrast = c; + emit canvasIsDirty( 3 ); +} +void SettingsDialog::toggleUseAntialiasing( bool b ) +{ + Config::antiAliasFactor = b ? 2 : 1; + emit canvasIsDirty( 2 ); +} +void SettingsDialog::toggleVaryLabelFontSizes( bool b ) +{ + Config::varyLabelFontSizes = b; + minFontPitch->setEnabled( b ); + emit canvasIsDirty( 0 ); +} +void SettingsDialog::changeMinFontPitch( int p ) +{ + Config::minFontPitch = p; + emit canvasIsDirty( 0 ); +} +void SettingsDialog::toggleShowSmallFiles( bool b ) +{ + Config::showSmallFiles = b; + emit canvasIsDirty( 1 ); +} + + +void SettingsDialog::slotSliderReleased() +{ + emit canvasIsDirty( 2 ); +} + + +void SettingsDialog::reject() +{ + //called when escape is pressed + reset(); + QDialog::reject(); //**** doesn't change back scheme so far +} + +#include "settingsDialog.moc" |