diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2025-08-28 22:44:34 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2025-08-31 23:30:34 +0900 |
commit | f9abd9d505434c9244c03eac708e29a0ca042f6b (patch) | |
tree | 30a197ab4c413849188bc131ff859212e636c821 /src/app/Konfigurator | |
parent | 14d42d284de233f9937becf3fc9ee0dabede3b21 (diff) | |
download | krusader-r14.1.x.tar.gz krusader-r14.1.x.zip |
Restructure source foldersr14.1.x
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
(cherry picked from commit 086012dcad8a976a0dabbb7cbc20c9cb612cdfa9)
Diffstat (limited to 'src/app/Konfigurator')
33 files changed, 6398 insertions, 0 deletions
diff --git a/src/app/Konfigurator/Makefile.am b/src/app/Konfigurator/Makefile.am new file mode 100644 index 0000000..9f1776c --- /dev/null +++ b/src/app/Konfigurator/Makefile.am @@ -0,0 +1,23 @@ +noinst_LIBRARIES = libKonfigurator.a + +INCLUDES = -I$(top_builddir)/src/app/GUI $(all_includes) + +libKonfigurator_a_METASOURCES = AUTO + +libKonfigurator_a_SOURCES = \ + kgcolors.cpp \ + kgdependencies.cpp \ + konfiguratorpage.cpp \ + konfiguratoritems.cpp \ + konfigurator.cpp \ + kgwelcome.cpp \ + kgstartup.cpp \ + kglookfeel.cpp \ + kggeneral.cpp \ + kgarchives.cpp \ + kgadvanced.cpp \ + kguseractions.cpp \ + kgprotocols.cpp \ + krresulttable.cpp \ + krresulttabledialog.cpp \ + searchobject.cpp diff --git a/src/app/Konfigurator/kgadvanced.cpp b/src/app/Konfigurator/kgadvanced.cpp new file mode 100644 index 0000000..e6b753b --- /dev/null +++ b/src/app/Konfigurator/kgadvanced.cpp @@ -0,0 +1,133 @@ +/*************************************************************************** + kgadvanced.cpp - description + ------------------- + copyright : (C) 2004 + by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "kgadvanced.h" +#include "../defaults.h" +#include <tdelocale.h> +#include <tqhbox.h> +#include <tqwhatsthis.h> +#include <sys/param.h> +#include <tdeversion.h> +#include <kprotocolinfo.h> + +KgAdvanced::KgAdvanced( bool first, TQWidget* parent, const char* name ) : + KonfiguratorPage( first, parent, name ) +{ + TQGridLayout *kgAdvancedLayout = new TQGridLayout( parent ); + kgAdvancedLayout->setSpacing( 6 ); + + // -------------------------- GENERAL GROUPBOX ---------------------------------- + + TQGroupBox *generalGrp = createFrame( i18n( "General" ), parent, "kgAdvGeneralGrp" ); + TQGridLayout *generalGrid = createGridLayout( generalGrp->layout() ); + +#if KDE_IS_VERSION( 3,5,1 ) + bool dontUseMedia = false; +#else + bool dontUseMedia = true; +#endif + + bool isMediaProtocolPresent = KProtocolInfo::isKnownProtocol( TQString( "media" ) ); + if( !isMediaProtocolPresent ) + dontUseMedia = true; + + KONFIGURATOR_CHECKBOX_PARAM generalSettings[] = + // cfg_class cfg_name default text restart tooltip + {{"Advanced","PreserveAttributes", _PreserveAttributes, i18n( "Preserve attributes for local copy/move (slower)" ), false, i18n( "Krusader will try to preserve all attributes (time, owner, group) of the local files according to the source depending on your permissions:<ul><li>User preserving if you are root</li><li>Group preserving if you are root or member of the group</li><li>Preserving the timestamp</li></ul><b>Note</b>: This can slow down the copy process." ) }, + {"Advanced","AutoMount", _AutoMount, i18n( "Automount filesystems" ), false, i18n( "When stepping into a directory which is defined as a mount point in the <b>fstab</b>, try mounting it with the defined parameters." )}, + {"Advanced","DontUseMediaProt", dontUseMedia, i18n( "Don't use TDE's media protocol for media button (if it's buggy or missing)" ), false, i18n( "Select if your media protocol is buggy (in some older TDE versions), or not present (no tdebase package installed)." )}}; + + KonfiguratorCheckBoxGroup *generals = createCheckBoxGroup( 1, 0, generalSettings, 3, generalGrp ); + + if( !isMediaProtocolPresent ) + generals->find( "DontUseMediaProt" )->setEnabled( false ); + + generalGrid->addWidget( generals, 1, 0 ); + + addLabel( generalGrid, 2, 0, i18n( "MountMan won't (un)mount the following mount-points:" ), + generalGrp, "KgAdvLabel2" ); + KonfiguratorEditBox *nonMountPoints = createEditBox( "Advanced", "Nonmount Points", _NonMountPoints, generalGrp, false ); + generalGrid->addWidget( nonMountPoints, 2, 1 ); + + +#ifdef BSD + generals->find( "AutoMount" )->setEnabled( false ); /* disable AutoMount on BSD */ +#endif + + kgAdvancedLayout->addWidget( generalGrp, 0 ,0 ); + + // ----------------------- CONFIRMATIONS GROUPBOX ------------------------------- + + TQGroupBox *confirmGrp = createFrame( i18n( "Confirmations" ), parent, "confirmGrp" ); + TQGridLayout *confirmGrid = createGridLayout( confirmGrp->layout() ); + + addLabel( confirmGrid, 0, 0, "\n"+i18n( "Request user confirmation for the following operations:" )+"\n", + confirmGrp, "KgAdvLabel1" ); + + KONFIGURATOR_CHECKBOX_PARAM confirmations[] = + // cfg_class cfg_name default text restart ToolTip + {{"Advanced","Confirm Unempty Dir", _ConfirmUnemptyDir, i18n( "Deleting non-empty directories" ), false, ""}, + {"Advanced","Confirm Delete", _ConfirmDelete, i18n( "Deleting files" ), false, ""}, + {"Advanced","Confirm Copy", _ConfirmCopy, i18n( "Copying files" ), false, ""}, + {"Advanced","Confirm Move", _ConfirmMove, i18n( "Moving files" ), false, ""}, + {"Advanced","Confirm Feed to Listbox", _ConfirmFeedToListbox, i18n( "Confirm feed to listbox" ), false, i18n("Ask for a result name when feeding items to the listbox. By default the standard value is used.")}, + {"Notification Messages","Confirm Remove UserAction", true, i18n( "Removing Useractions" ), false, ""}}; + + KonfiguratorCheckBoxGroup *confWnd = createCheckBoxGroup( 2, 0, confirmations, 6, confirmGrp ); + + confirmGrid->addWidget( confWnd, 1, 0 ); + + kgAdvancedLayout->addWidget( confirmGrp, 1 ,0 ); + + + // ------------------------ FINE-TUNING GROUPBOX -------------------------------- + + TQGroupBox *fineTuneGrp = createFrame( i18n( "Fine-Tuning" ), parent, "kgFineTuneGrp" ); + TQGridLayout *fineTuneGrid = createGridLayout( fineTuneGrp->layout() ); + fineTuneGrid->setAlignment( TQt::AlignLeft | TQt::AlignTop ); + + TQLabel *label = new TQLabel( i18n( "Icon cache size (KB):" ), fineTuneGrp, "iconCacheLabel" ); + TQWhatsThis::add( label, i18n( "The icon cache size influences how fast the contents of a panel can be displayed. However, too large a cache might consume your memory." ) ); + fineTuneGrid->addWidget( label, 0, 0 ); + KonfiguratorSpinBox *spinBox = createSpinBox( "Advanced", "Icon Cache Size", _IconCacheSize, + 1, 8192, fineTuneGrp, false ); + TQWhatsThis::add( spinBox, i18n( "The icon cache size influences how fast the contents of a panel can be displayed. However, too large a cache might consume your memory." ) ); + spinBox->setSizePolicy( TQSizePolicy::Fixed, TQSizePolicy::Fixed); + fineTuneGrid->addWidget( spinBox, 0, 1 ); + + addLabel( fineTuneGrid, 1, 0, i18n( "Arguments of updatedb:" ), + fineTuneGrp, "KgAdvLabel1" ); + KonfiguratorEditBox *updatedbArgs = createEditBox( "Locate", "UpdateDB Arguments", "", fineTuneGrp, false ); + fineTuneGrid->addWidget( updatedbArgs, 1, 1 ); + + kgAdvancedLayout->addWidget( fineTuneGrp, 2 ,0 ); +} + +#include "kgadvanced.moc" diff --git a/src/app/Konfigurator/kgadvanced.h b/src/app/Konfigurator/kgadvanced.h new file mode 100644 index 0000000..1066c06 --- /dev/null +++ b/src/app/Konfigurator/kgadvanced.h @@ -0,0 +1,45 @@ +/*************************************************************************** + kgadvanced.h - description + ------------------- + copyright : (C) 2004 by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + H e a d e r F i l e + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef __KGADVANCED_H__ +#define __KGADVANCED_H__ + +#include "konfiguratorpage.h" + +class KgAdvanced : public KonfiguratorPage +{ + TQ_OBJECT + + +public: + KgAdvanced( bool first, TQWidget* parent=0, const char* name=0 ); +}; + +#endif /* __KGADVANCED_H__ */ diff --git a/src/app/Konfigurator/kgarchives.cpp b/src/app/Konfigurator/kgarchives.cpp new file mode 100644 index 0000000..950aed1 --- /dev/null +++ b/src/app/Konfigurator/kgarchives.cpp @@ -0,0 +1,157 @@ +/*************************************************************************** + kgarchives.cpp - description + ------------------- + copyright : (C) 2004 by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include <tqhbox.h> +#include <tqpushbutton.h> + +#include "kgarchives.h" +#include "krresulttable.h" +#include "krresulttabledialog.h" + +#include "searchobject.h" +#include "../defaults.h" +#include "../krusader.h" +#include "../VFS/krarchandler.h" + +KgArchives::KgArchives( bool first, TQWidget* parent, const char* name ) : + KonfiguratorPage( first, parent, name ) +{ + TQGridLayout *kgArchivesLayout = new TQGridLayout( parent ); + kgArchivesLayout->setSpacing( 6 ); + + // -------------------------- GENERAL GROUPBOX ---------------------------------- + + TQGroupBox *generalGrp = createFrame( i18n( "General" ), parent, "generalGrp" ); + TQGridLayout *generalGrid = createGridLayout( generalGrp->layout() ); + + addLabel( generalGrid, 0, 0, i18n( "Krusader transparently handles the following types of archives:" ), + generalGrp, "KgLabel1" ); + + KONFIGURATOR_CHECKBOX_PARAM packers[] = + // cfg_class cfg_name default text restart tooltip + {{"Archives","Do Tar", _DoTar, i18n( "Tar" ), false, ""}, + {"Archives","Do GZip", _DoGZip, i18n( "GZip" ), false, ""}, + {"Archives","Do BZip2", _DoBZip2, i18n( "BZip2" ), false, ""}, + {"Archives","Do UnZip", _DoUnZip, i18n( "Zip" ), false, ""}, + {"Archives","Do UnRar", _DoUnRar, i18n( "Rar" ), false, ""}, + {"Archives","Do Unarj", _DoArj, i18n( "Arj" ), false, ""}, + {"Archives","Do RPM", _DoRPM, i18n( "Rpm" ), false, ""}, + {"Archives","Do UnAce", _DoUnAce, i18n( "Ace" ), false, ""}, + {"Archives","Do Lha", _DoLha, i18n( "Lha" ), false, ""}, + {"Archives","Do DEB", _DoDEB, i18n( "Deb" ), false, ""}, + {"Archives","Do 7z", _Do7z, i18n( "7zip" ), false, ""}, + {"Archives","Do Xz", _DoXz, i18n( "Xz" ), false, ""} + }; + + cbs = createCheckBoxGroup( 3, 0, packers, 12, generalGrp ); + generalGrid->addWidget( cbs, 1, 0 ); + + addLabel( generalGrid, 2, 0, i18n( "The archives that are \"greyed-out\" were unavailable on your\nsystem last time Krusader checked. If you wish Krusader to\nsearch again, click the 'Auto Configure' button." ), + generalGrp, "KgLabel2" ); + + TQHBox *hbox = new TQHBox( generalGrp ); + createSpacer( hbox, "spacer1" ); + TQPushButton *btnAutoConfigure = new TQPushButton( i18n( "Auto Configure" ), hbox, "kgAutoConfigure" ); + createSpacer( hbox, "spacer2" ); + generalGrid->addWidget( hbox, 3, 0 ); + connect( btnAutoConfigure, TQ_SIGNAL( clicked() ), this, TQ_SLOT( slotAutoConfigure() ) ); + + kgArchivesLayout->addWidget( generalGrp, 0 ,0 ); + + // ------------------------ FINE-TUNING GROUPBOX -------------------------------- + + TQGroupBox *fineTuneGrp = createFrame( i18n( "Fine-Tuning" ), parent, "fineTuneGrp" ); + TQGridLayout *fineTuneGrid = createGridLayout( fineTuneGrp->layout() ); + + KONFIGURATOR_CHECKBOX_PARAM finetuners[] = + // cfg_class cfg_name default text restart ToolTip + {//{"Archives","Allow Move Into Archive", _MoveIntoArchive, i18n( "Allow moving into archives" ), false, i18n( "This action can be tricky, since system failure during the process\nmight result in misplaced files. If this happens,\nthe files are stored in a temp directory inside /tmp." )}, + {"Archives","Test Archives", _TestArchives, i18n( "Test archive after packing" ), false, i18n( "Check the archive's integrity after packing it." )}, + {"Archives","Test Before Unpack", _TestBeforeUnpack,i18n( "Test archive before unpacking" ), false, i18n( "Some corrupted archives might cause a crash; therefore, testing is suggested." )}}; + + KonfiguratorCheckBoxGroup *finetunes = createCheckBoxGroup( 1, 0, finetuners, 2, fineTuneGrp ); + + disableNonExistingPackers(); + fineTuneGrid->addWidget( finetunes, 1, 0 ); + + kgArchivesLayout->addWidget( fineTuneGrp, 1 ,0 ); + + if( first ) + slotAutoConfigure(); + +} + + +void KgArchives::slotAutoConfigure() +{ + KrResultTableDialog* dia = new KrResultTableDialog(this, KrResultTableDialog::Archiver, i18n("Search results"), i18n("Searching for packers..."), + "package", i18n("Make sure to install new packers in your <code>$PATH</code> (e.g. /usr/bin)")); + dia->exec(); + + disableNonExistingPackers(); +} + +void KgArchives::disableNonExistingPackers() +{ + #define PS(x) lst.contains(x)>0 + + TQStringList lst=KRarcHandler::supportedPackers(); // get list of availble packers + cbs->find( "Do Tar" )->setEnabled(PS("tar")); + cbs->find( "Do GZip" )->setEnabled(PS("gzip")); + cbs->find( "Do BZip2" )->setEnabled(PS("bzip2")); + cbs->find( "Do UnZip" )->setEnabled(PS("unzip")); + cbs->find( "Do Lha" )->setEnabled(PS("lha")); + cbs->find( "Do RPM" )->setEnabled(PS("rpm") || PS("cpio")); + cbs->find( "Do UnRar" )->setEnabled(PS("unrar") || PS("rar") ); + cbs->find( "Do UnAce" )->setEnabled(PS("unace")); + cbs->find( "Do Unarj" )->setEnabled(PS("unarj") || PS("arj") ); + cbs->find( "Do DEB" )->setEnabled(PS("dpkg") && PS("tar") ); + cbs->find( "Do 7z" )->setEnabled( PS("7z") ); + cbs->find( "Do Xz" )->setEnabled(PS("xz")); + + krConfig->setGroup( "Archives" ); + krConfig->writeEntry( "Supported Packers", lst ); +} + +bool KgArchives::apply() +{ + krConfig->setGroup( "Archives" ); + krConfig->writeEntry("Supported Packers",KRarcHandler::supportedPackers()); + return KonfiguratorPage::apply(); +} + +void KgArchives::setDefaults() +{ + krConfig->setGroup( "Archives" ); + krConfig->writeEntry("Supported Packers",KRarcHandler::supportedPackers()); + return KonfiguratorPage::setDefaults(); +} + +#include "kgarchives.moc" diff --git a/src/app/Konfigurator/kgarchives.h b/src/app/Konfigurator/kgarchives.h new file mode 100644 index 0000000..600c617 --- /dev/null +++ b/src/app/Konfigurator/kgarchives.h @@ -0,0 +1,55 @@ +/*************************************************************************** + kgarchives.h - description + ------------------- + copyright : (C) 2004 by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + H e a d e r F i l e + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef __KGARCHIVES_H__ +#define __KGARCHIVES_H__ + +#include "konfiguratorpage.h" + +class KgArchives : public KonfiguratorPage +{ + TQ_OBJECT + + +public: + KgArchives( bool first, TQWidget* parent=0, const char* name=0 ); + virtual bool apply(); + virtual void setDefaults(); + +public slots: + void slotAutoConfigure(); + +protected: + KonfiguratorCheckBoxGroup *cbs; + + void disableNonExistingPackers(); +}; + +#endif /* __KGARCHIVES_H__ */ diff --git a/src/app/Konfigurator/kgcolors.cpp b/src/app/Konfigurator/kgcolors.cpp new file mode 100644 index 0000000..06f3905 --- /dev/null +++ b/src/app/Konfigurator/kgcolors.cpp @@ -0,0 +1,633 @@ +/*************************************************************************** + kgcolors.cpp - description + ------------------- + copyright : (C) 2004 + by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "kgcolors.h" +#include "../defaults.h" +#include "../Panel/krcolorcache.h" +#include <tdemessagebox.h> +#include <tdelocale.h> +#include <tdefiledialog.h> +#include <tdeglobalsettings.h> +#include <kstandarddirs.h> +#include <tqhbox.h> +#include <tqheader.h> +#include <tqtabwidget.h> + +KgColors::KgColors( bool first, TQWidget* parent, const char* name ) : + KonfiguratorPage( first, parent, name ), offset( 0 ) +{ + TQGridLayout *kgColorsLayout = new TQGridLayout( parent ); + kgColorsLayout->setSpacing( 6 ); + + // -------------------------- GENERAL GROUPBOX ---------------------------------- + + TQGroupBox *generalGrp = createFrame( i18n( "General" ), parent, "kgColorsGeneralGrp" ); + TQGridLayout *generalGrid = createGridLayout( generalGrp->layout() ); + + generalGrid->setSpacing( 0 ); + generalGrid->setMargin( 5 ); + + KONFIGURATOR_CHECKBOX_PARAM generalSettings[] = + // cfg_class cfg_name default text restart tooltip + {{"Colors","KDE Default", _KDEDefaultColors, i18n( "Use the default TDE colors" ), false, "<p><img src='toolbar|kcontrol'></p>" + i18n( "<p>Use TDE's global color configuration.</p><p><i>Trinity Control Center -> Appearance & Themes -> Colors</i></p>") }, + {"Colors","Enable Alternate Background", _AlternateBackground, i18n( "Use alternate background color" ), false, i18n( "<p>The <b>background color</b> and the <b>alternate background</b> color alternates line by line.</p><p>When you don't use the <i>TDE default colors</i>, you can configure the alternate colors in the <i>colors</i> box.</p>") }, + {"Colors","Show Current Item Always", _ShowCurrentItemAlways, i18n( "Show current item even if not focused" ), false, i18n( "<p>Shows the last cursor position in the non active list panel.</p><p>This option is only available when you don't use the <i>TDE default colors</i>.</p>" ) }, + {"Colors","Dim Inactive Colors", _DimInactiveColors, i18n( "Dim the colors of the inactive panel" ), false, i18n( "<p>The colors of the inactive panel are calculated by a dim color and a dim factor.</p>" ) }}; + + generals = createCheckBoxGroup( 0, 2, generalSettings, sizeof(generalSettings)/sizeof(generalSettings[0]), generalGrp ); + generalGrid->addWidget( generals, 1, 0 ); + + generals->layout()->setSpacing( 5 ); + + connect( generals->find( "KDE Default" ), TQ_SIGNAL( stateChanged( int ) ), this, TQ_SLOT( slotDisable() ) ); + connect( generals->find( "Enable Alternate Background" ), TQ_SIGNAL( stateChanged( int ) ), this, TQ_SLOT( generatePreview() ) ); + connect( generals->find( "Show Current Item Always" ), TQ_SIGNAL( stateChanged( int ) ), this, TQ_SLOT( slotDisable() ) ); + connect( generals->find( "Dim Inactive Colors" ), TQ_SIGNAL( stateChanged( int ) ), this, TQ_SLOT( slotDisable() ) ); + + kgColorsLayout->addMultiCellWidget( generalGrp, 0 ,0, 0, 2 ); + TQHBox *hbox = new TQHBox( parent ); + + // -------------------------- COLORS GROUPBOX ---------------------------------- + + TQGroupBox *colorsFrameGrp = createFrame( i18n( "Colors" ), hbox, "kgColorsColorsGrp" ); + TQGridLayout *colorsFrameGrid = createGridLayout( colorsFrameGrp->layout() ); + colorsFrameGrid->setSpacing( 0 ); + colorsFrameGrid->setMargin( 3 ); + + colorTabWidget = new TQTabWidget( colorsFrameGrp, "colorTabWidget" ); + + connect( colorTabWidget, TQ_SIGNAL( currentChanged ( TQWidget * ) ), this, TQ_SLOT( generatePreview() ) ); + + colorsGrp = new TQWidget( colorTabWidget, "colorTab" ); + colorTabWidget->insertTab( colorsGrp, i18n( "Active" ) ); + + colorsGrid = new TQGridLayout( colorsGrp ); + colorsGrid->setSpacing( 0 ); + colorsGrid->setMargin( 2 ); + + ADDITIONAL_COLOR transparent = { i18n("Transparent"), TQt::white, "transparent" }; + + addColorSelector( "Foreground", i18n( "Foreground:" ), TDEGlobalSettings::textColor() ); + addColorSelector( "Directory Foreground", i18n( "Directory foreground:" ), getColorSelector( "Foreground" )->getColor(), i18n( "Same as foreground" ) ); + addColorSelector( "Executable Foreground", i18n( "Executable foreground:" ), getColorSelector( "Foreground" )->getColor(), i18n( "Same as foreground" ) ); + addColorSelector( "Symlink Foreground", i18n( "Symbolic link foreground:" ), getColorSelector( "Foreground" )->getColor(), i18n( "Same as foreground" ) ); + addColorSelector( "Invalid Symlink Foreground", i18n( "Invalid symlink foreground:" ), getColorSelector( "Foreground" )->getColor(), i18n( "Same as foreground" ) ); + addColorSelector( "Background", i18n( "Background:" ), TDEGlobalSettings::baseColor() ); + ADDITIONAL_COLOR sameAsBckgnd = { i18n("Same as background"), getColorSelector( "Background" )->getColor(), "Background" }; + addColorSelector( "Alternate Background", i18n( "Alternate background:" ), TDEGlobalSettings::alternateBackgroundColor(),"", &sameAsBckgnd, 1 ); + addColorSelector( "Marked Foreground", i18n( "Selected foreground:" ), TDEGlobalSettings::highlightedTextColor(), "", &transparent, 1 ); + addColorSelector( "Marked Background", i18n( "Selected background:" ), TDEGlobalSettings::highlightColor(), "", &sameAsBckgnd, 1 ); + ADDITIONAL_COLOR sameAsAltern = { i18n("Same as alt. background"), getColorSelector( "Alternate Background" )->getColor(), "Alternate Background" }; + addColorSelector( "Alternate Marked Background",i18n( "Alternate selected background:" ), getColorSelector( "Marked Background" )->getColor(), i18n( "Same as selected background" ), &sameAsAltern, 1 ); + addColorSelector( "Current Foreground", i18n( "Current foreground:" ), TQt::white, i18n( "Not used" ) ); + ADDITIONAL_COLOR sameAsMarkedForegnd = { i18n("Same as selected foreground"), getColorSelector( "Marked Foreground" )->getColor(), "Marked Foreground" }; + addColorSelector( "Marked Current Foreground", i18n( "Selected current foreground:" ), TQt::white, i18n( "Not used" ), &sameAsMarkedForegnd, 1); + addColorSelector( "Current Background", i18n( "Current background:" ), TQt::white, i18n( "Not used" ), &sameAsBckgnd, 1 ); + + colorsGrid->addWidget(createSpacer(colorsGrp, ""), itemList.count() - offset, 1); + + connect( getColorSelector( "Foreground" ), TQ_SIGNAL( colorChanged() ), this, TQ_SLOT( slotForegroundChanged() ) ); + connect( getColorSelector( "Background" ), TQ_SIGNAL( colorChanged() ), this, TQ_SLOT( slotBackgroundChanged() ) ); + connect( getColorSelector( "Alternate Background" ), TQ_SIGNAL( colorChanged() ), this, TQ_SLOT( slotAltBackgroundChanged() ) ); + connect( getColorSelector( "Marked Background" ), TQ_SIGNAL( colorChanged() ), this, TQ_SLOT( slotMarkedBackgroundChanged() ) ); + + inactiveColorStack = new TQWidgetStack( colorTabWidget, "colorTab2" ); + colorTabWidget->insertTab( inactiveColorStack, i18n( "Inactive" ) ); + + colorsGrp = normalInactiveWidget = new TQWidget( inactiveColorStack, "colorTab2" ); + + colorsGrid = new TQGridLayout( normalInactiveWidget ); + colorsGrid->setSpacing( 0 ); + colorsGrid->setMargin( 2 ); + + offset = endOfActiveColors = itemList.count(); + + addColorSelector( "Inactive Foreground", i18n( "Foreground:" ), getColorSelector( "Foreground" )->getColor(), i18n( "Same as active" ) ); + ADDITIONAL_COLOR sameAsInactForegnd = { i18n("Same as foreground"), getColorSelector( "Inactive Foreground" )->getColor(), "Inactive Foreground" }; + addColorSelector( "Inactive Directory Foreground", i18n( "Directory foreground:" ), getColorSelector( "Directory Foreground" )->getColor(), i18n( "Same as active" ), &sameAsInactForegnd, 1 ); + addColorSelector( "Inactive Executable Foreground", i18n( "Executable foreground:" ), getColorSelector( "Executable Foreground" )->getColor(), i18n( "Same as active" ), &sameAsInactForegnd, 1 ); + addColorSelector( "Inactive Symlink Foreground", i18n( "Symbolic link foreground:" ), getColorSelector( "Symlink Foreground" )->getColor(), i18n( "Same as active" ), &sameAsInactForegnd, 1 ); + addColorSelector( "Inactive Invalid Symlink Foreground", i18n( "Invalid symlink foreground:" ), getColorSelector( "Invalid Symlink Foreground" )->getColor(), i18n( "Same as active" ), &sameAsInactForegnd, 1 ); + addColorSelector( "Inactive Background", i18n( "Background:" ), getColorSelector( "Background" )->getColor(), i18n( "Same as active" ) ); + ADDITIONAL_COLOR sameAsInactBckgnd = { i18n("Same as background"), getColorSelector( "Inactive Background" )->getColor(), "Inactive Background" }; + addColorSelector( "Inactive Alternate Background", i18n( "Alternate background:" ), getColorSelector( "Alternate Background" )->getColor(), i18n( "Same as active" ), &sameAsInactBckgnd, 1 ); + addColorSelector( "Inactive Marked Foreground", i18n( "Selected foreground:" ), getColorSelector( "Marked Foreground" )->getColor(), i18n( "Same as active" ), &transparent, 1 ); + addColorSelector( "Inactive Marked Background", i18n( "Selected background:" ), getColorSelector( "Marked Background" )->getColor(), i18n( "Same as active" ), &sameAsInactBckgnd, 1 ); + ADDITIONAL_COLOR sameAsInactAltern[] = {{ i18n("Same as alt. background"), getColorSelector( "Inactive Alternate Background" )->getColor(), "Inactive Alternate Background" }, + { i18n("Same as selected background"), getColorSelector( "Inactive Marked Background" )->getColor(), "Inactive Marked Background" } }; + addColorSelector( "Inactive Alternate Marked Background", i18n( "Alternate selected background:" ), getColorSelector( "Alternate Marked Background" )->getColor(), i18n( "Same as active" ), sameAsInactAltern, 2 ); + addColorSelector( "Inactive Current Foreground", i18n( "Current foreground:" ), getColorSelector( "Current Foreground" )->getColor(), i18n( "Same as active" ) ); + ADDITIONAL_COLOR sameAsInactMarkedForegnd = { i18n("Same as selected foreground"), getColorSelector( "Inactive Marked Foreground" )->getColor(), "Inactive Marked Foreground" }; + addColorSelector( "Inactive Marked Current Foreground", i18n( "Selected current foreground:" ), getColorSelector( "Marked Current Foreground" )->getColor(), i18n( "Same as active" ), &sameAsInactMarkedForegnd, 1 ); + addColorSelector( "Inactive Current Background", i18n( "Current background:" ), getColorSelector( "Current Background" )->getColor(), i18n( "Same as active" ), &sameAsInactBckgnd, 1 ); + + colorsGrid->addWidget(createSpacer(normalInactiveWidget, ""), itemList.count() - offset, 1); + + connect( getColorSelector( "Inactive Foreground" ), TQ_SIGNAL( colorChanged() ), this, TQ_SLOT( slotInactiveForegroundChanged() ) ); + connect( getColorSelector( "Inactive Background" ), TQ_SIGNAL( colorChanged() ), this, TQ_SLOT( slotInactiveBackgroundChanged() ) ); + connect( getColorSelector( "Inactive Alternate Background" ), TQ_SIGNAL( colorChanged() ), this, TQ_SLOT( slotInactiveAltBackgroundChanged() ) ); + connect( getColorSelector( "Inactive Marked Background" ), TQ_SIGNAL( colorChanged() ), this, TQ_SLOT( slotInactiveMarkedBackgroundChanged() ) ); + + offset = endOfPanelColors = itemList.count(); + + inactiveColorStack->addWidget( normalInactiveWidget ); + + colorsGrp = dimmedInactiveWidget = new TQWidget( inactiveColorStack, "colorTab2dimmed" ); + + colorsGrid = new TQGridLayout( dimmedInactiveWidget ); + colorsGrid->setSpacing( 0 ); + colorsGrid->setMargin( 2 ); + + addColorSelector( "Dim Target Color", i18n( "Dim target color:" ), TQt::white); + + int index = itemList.count() - offset; + labelList.append( addLabel( colorsGrid, index, 0, i18n("Dim factor:"), colorsGrp, TQString( "ColorsLabel%1" ).arg( index ).ascii() ) ); + dimFactor = createSpinBox("Colors", "Dim Factor", 100, 0, 100, colorsGrp); + dimFactor->setSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Fixed ); + connect( dimFactor, TQ_SIGNAL( valueChanged( int ) ), this, TQ_SLOT( generatePreview() ) ); + colorsGrid->addWidget( dimFactor, index++, 1 ); + + colorsGrid->addWidget(createSpacer(dimmedInactiveWidget, ""), itemList.count() + 1 - offset, 1); + + inactiveColorStack->addWidget( dimmedInactiveWidget ); + + inactiveColorStack->raiseWidget( normalInactiveWidget ); + + colorsGrp = new TQWidget( colorTabWidget, "colorTab3" ); + colorTabWidget->insertTab( colorsGrp, i18n( "Synchronizer" ) ); + + colorsGrid = new TQGridLayout( colorsGrp ); + colorsGrid->setSpacing( 0 ); + colorsGrid->setMargin( 2 ); + + ADDITIONAL_COLOR KDEDefaultBase = { i18n("TDE default"), TDEGlobalSettings::baseColor(), "KDE default" }; + ADDITIONAL_COLOR KDEDefaultFore = { i18n("TDE default"), TDEGlobalSettings::textColor(), "KDE default" }; + + offset = endOfPanelColors = itemList.count(); + + addColorSelector( "Synchronizer Equals Foreground", i18n( "Equals foreground:" ), TQt::black, TQString(), &KDEDefaultFore, 1 ); + addColorSelector( "Synchronizer Equals Background", i18n( "Equals background:" ), TDEGlobalSettings::baseColor(), TQString(), &KDEDefaultBase, 1 ); + addColorSelector( "Synchronizer Differs Foreground", i18n( "Differing foreground:" ), TQt::red, TQString(), &KDEDefaultFore, 1 ); + addColorSelector( "Synchronizer Differs Background", i18n( "Differing background:" ), TDEGlobalSettings::baseColor(), TQString(), &KDEDefaultBase, 1 ); + addColorSelector( "Synchronizer LeftCopy Foreground", i18n( "Copy to left foreground:" ), TQt::blue, TQString(), &KDEDefaultFore, 1 ); + addColorSelector( "Synchronizer LeftCopy Background", i18n( "Copy to left background:" ), TDEGlobalSettings::baseColor(), TQString(), &KDEDefaultBase, 1 ); + addColorSelector( "Synchronizer RightCopy Foreground", i18n( "Copy to right foreground:" ), TQt::darkGreen, TQString(), &KDEDefaultFore, 1 ); + addColorSelector( "Synchronizer RightCopy Background", i18n( "Copy to right background:" ), TDEGlobalSettings::baseColor(), TQString(), &KDEDefaultBase, 1 ); + addColorSelector( "Synchronizer Delete Foreground", i18n( "Delete foreground:" ), TQt::white, TQString(), &KDEDefaultFore, 1 ); + addColorSelector( "Synchronizer Delete Background", i18n( "Delete background:" ), TQt::red, TQString(), &KDEDefaultBase, 1 ); + + colorsGrid->addWidget(createSpacer(colorsGrp, ""), itemList.count() - offset, 1); + + colorsFrameGrid->addWidget( colorTabWidget, 0, 0 ); + + // -------------------------- PREVIEW GROUPBOX ---------------------------------- + + previewGrp = createFrame( i18n( "Preview" ), hbox, "kgColorsPreviewGrp" ); + previewGrid = createGridLayout( previewGrp->layout() ); + + preview = new TQListView( previewGrp, "colorPreView" ); + + preview->setShowSortIndicator(false); + preview->setSorting(-1); + preview->setEnabled( false ); + + preview->addColumn( i18n("Colors") ); + preview->header()->setStretchEnabled( true, 0 ); + + previewGrid->addWidget( preview, 0 ,0 ); + + kgColorsLayout->addMultiCellWidget( hbox, 1 ,1, 0, 2 ); + + importBtn = new KPushButton(i18n("Import color-scheme"),parent); + kgColorsLayout->addWidget(importBtn,2,0); + exportBtn = new KPushButton(i18n("Export color-scheme"),parent); + kgColorsLayout->addWidget(exportBtn,2,1); + kgColorsLayout->addWidget(createSpacer(parent, ""), 2,2); + connect(importBtn, TQ_SIGNAL(clicked()), this, TQ_SLOT(slotImportColors())); + connect(exportBtn, TQ_SIGNAL(clicked()), this, TQ_SLOT(slotExportColors())); + + slotDisable(); +} + +int KgColors::addColorSelector( TQString cfgName, TQString name, TQColor dflt, TQString dfltName, + ADDITIONAL_COLOR *addColor, int addColNum ) +{ + int index = itemList.count() - offset; + + labelList.append( addLabel( colorsGrid, index, 0, name, colorsGrp, TQString( "ColorsLabel%1" ).arg( index ).ascii() ) ); + KonfiguratorColorChooser *chooser = createColorChooser( "Colors", cfgName, dflt, colorsGrp, false, addColor, addColNum ); + chooser->setSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Fixed ); + + if( !dfltName.isEmpty() ) + chooser->setDefaultText( dfltName ); + + colorsGrid->addWidget( chooser, index, 1 ); + + connect( chooser, TQ_SIGNAL( colorChanged() ), this, TQ_SLOT( generatePreview() ) ); + if( !offset ) + connect( chooser, TQ_SIGNAL( colorChanged() ), this, TQ_SLOT( slotActiveChanged() ) ); + + itemList.append( chooser ); + itemNames.append( cfgName ); + + return index; +} + +KonfiguratorColorChooser *KgColors::getColorSelector( TQString name ) +{ + TQValueList<TQString>::iterator it; + int position = 0; + + for( it = itemNames.begin(); it != itemNames.end(); it++, position++ ) + if( *it == name ) + return itemList.at( position ); + + return 0; +} + +TQLabel *KgColors::getSelectorLabel( TQString name ) +{ + TQValueList<TQString>::iterator it; + int position = 0; + + for( it = itemNames.begin(); it != itemNames.end(); it++, position++ ) + if( *it == name ) + return labelList.at( position ); + + return 0; +} + +void KgColors::slotDisable() +{ + bool enabled = generals->find( "KDE Default" )->isChecked(); + + importBtn->setEnabled(!enabled); + exportBtn->setEnabled(!enabled); + + for( int i = 0; labelList.at( i ) && i < endOfPanelColors ; i++ ) + labelList.at( i )->setEnabled( !enabled ); + + for( int j = 0; itemList.at( j ) && j < endOfPanelColors ; j++ ) + itemList.at( j )->setEnabled( !enabled ); + + generals->find("Enable Alternate Background")->setEnabled( enabled ); + generals->find("Show Current Item Always")->setEnabled( !enabled ); + generals->find("Dim Inactive Colors")->setEnabled( !enabled ); + + bool dimmed = !enabled && generals->find("Dim Inactive Colors")->isChecked(); + if( dimmed ) + inactiveColorStack->raiseWidget( dimmedInactiveWidget ); + else + inactiveColorStack->raiseWidget( normalInactiveWidget ); + + enabled = enabled || !generals->find( "Show Current Item Always" )->isChecked(); + + getColorSelector( "Inactive Current Foreground" )->setEnabled( !enabled ); + getColorSelector( "Inactive Current Background" )->setEnabled( !enabled ); + + generatePreview(); +} + +void KgColors::slotActiveChanged() +{ + for( int i = 0; i != endOfActiveColors; i++ ) + itemList.at( endOfActiveColors + i )->setDefaultColor( itemList.at( i )->getColor() ); +} + +void KgColors::slotForegroundChanged() +{ + TQColor color = getColorSelector( "Foreground" )->getColor(); + + getColorSelector( "Directory Foreground" )->setDefaultColor( color ); + getColorSelector( "Executable Foreground" )->setDefaultColor( color ); + getColorSelector( "Symlink Foreground" )->setDefaultColor( color ); + getColorSelector( "Invalid Symlink Foreground" )->setDefaultColor( color ); +} + +void KgColors::slotBackgroundChanged() +{ + TQColor color = getColorSelector( "Background" )->getColor(); + + getColorSelector( "Alternate Background" )->changeAdditionalColor( 0, color ); + getColorSelector( "Marked Background" )->changeAdditionalColor( 0, color ); + getColorSelector( "Current Background" )->changeAdditionalColor( 0, color ); +} + +void KgColors::slotAltBackgroundChanged() +{ + TQColor color = getColorSelector( "Alternate Background" )->getColor(); + getColorSelector( "Alternate Marked Background" )->changeAdditionalColor( 0, color ); +} + +void KgColors::slotMarkedBackgroundChanged() +{ + TQColor color = getColorSelector( "Marked Background" )->getColor(); + getColorSelector( "Alternate Marked Background" )->setDefaultColor( color ); +} + +void KgColors::slotInactiveForegroundChanged() +{ + TQColor color = getColorSelector( "Inactive Foreground" )->getColor(); + + getColorSelector( "Inactive Directory Foreground" )->changeAdditionalColor( 0, color ); + getColorSelector( "Inactive Executable Foreground" )->changeAdditionalColor( 0, color ); + getColorSelector( "Inactive Symlink Foreground" )->changeAdditionalColor( 0, color ); + getColorSelector( "Inactive Invalid Symlink Foreground" )->changeAdditionalColor( 0, color ); +} + +void KgColors::slotInactiveBackgroundChanged() +{ + TQColor color = getColorSelector( "Inactive Background" )->getColor(); + + getColorSelector( "Inactive Alternate Background" )->changeAdditionalColor( 0, color ); + getColorSelector( "Inactive Marked Background" )->changeAdditionalColor( 0, color ); + getColorSelector( "Inactive Current Background" )->changeAdditionalColor( 0, color ); +} + +void KgColors::slotInactiveAltBackgroundChanged() +{ + TQColor color = getColorSelector( "Inactive Alternate Background" )->getColor(); + getColorSelector( "Inactive Alternate Marked Background" )->changeAdditionalColor( 0, color ); +} + +void KgColors::slotInactiveMarkedBackgroundChanged() +{ + TQColor color = getColorSelector( "Inactive Marked Background" )->getColor(); + getColorSelector( "Inactive Alternate Marked Background" )->changeAdditionalColor( 1, color ); +} + +void KgColors::setColorWithDimming(PreviewItem * item, TQColor foreground, TQColor background, bool dimmed ) +{ + if ( dimmed && dimFactor->value() < 100) + { + int dim = dimFactor->value(); + TQColor dimColor = getColorSelector("Dim Target Color")->getColor(); + + foreground = TQColor((dimColor.red() * (100 - dim) + foreground.red() * dim) / 100, + (dimColor.green() * (100 - dim) + foreground.green() * dim) / 100, + (dimColor.blue() * (100 - dim) + foreground.blue() * dim) / 100); + background = TQColor((dimColor.red() * (100 - dim) + background.red() * dim) / 100, + (dimColor.green() * (100 - dim) + background.green() * dim) / 100, + (dimColor.blue() * (100 - dim) + background.blue() * dim) / 100); + } + item->setColor(foreground, background); +} + +void KgColors::generatePreview() +{ + int currentPage = colorTabWidget->currentPageIndex(); + + preview->clear(); + + if( currentPage == 0 || currentPage == 1 ) + { + PreviewItem *pwMarkCur = new PreviewItem( preview, i18n( "Selected + Current" ) ); + PreviewItem *pwMark2 = new PreviewItem( preview, i18n( "Selected 2" ) ); + PreviewItem *pwMark1 = new PreviewItem( preview, i18n( "Selected 1" ) ); + PreviewItem *pwCurrent = new PreviewItem( preview, i18n( "Current" ) ); + PreviewItem *pwInvLink = new PreviewItem( preview, i18n( "Invalid symlink" ) ); + PreviewItem *pwSymLink = new PreviewItem( preview, i18n( "Symbolic link" ) ); + PreviewItem *pwApp = new PreviewItem( preview, i18n( "Application" ) ); + PreviewItem *pwFile = new PreviewItem( preview, i18n( "File" ) ); + PreviewItem *pwDir = new PreviewItem( preview, i18n( "Directory" ) ); + + bool isActive = currentPage == 0; + + // create local color cache instance, which does NOT affect the color cache instance using to paint the panels + KrColorCache colCache; + + // create local color settings instance, which initially contains the setings from krConfig + KrColorSettings colorSettings; + + // copy over local settings to color settings instance, which does not affect the persisted krConfig settings + TQValueList<TQString> names = KrColorSettings::getColorNames(); + for ( TQStringList::Iterator it = names.begin(); it != names.end(); ++it ) + { + KonfiguratorColorChooser * chooser = getColorSelector( *it ); + if (!chooser) + continue; + colorSettings.setColorTextValue( *it, chooser->getValue()); + if (chooser->isValueRGB()) + colorSettings.setColorValue( *it, chooser->getColor()); + else + colorSettings.setColorValue( *it, TQColor()); + } + + colorSettings.setBoolValue("KDE Default", generals->find( "KDE Default" )->isChecked()); + colorSettings.setBoolValue("Enable Alternate Background", generals->find( "Enable Alternate Background" )->isChecked()); + colorSettings.setBoolValue("Show Current Item Always", generals->find( "Show Current Item Always" )->isChecked()); + colorSettings.setBoolValue("Dim Inactive Colors", generals->find( "Dim Inactive Colors" )->isChecked()); + colorSettings.setNumValue("Dim Factor", dimFactor->value()); + + // let the color cache use the local color settings + colCache.setColors( colorSettings ); + + // ask the local color cache for certain color groups and use them to color the preview + TQColorGroup cg; + colCache.getColors(cg, KrColorItemType(KrColorItemType::Directory, false, isActive, false, false)); + pwDir->setColor( cg.text(), cg.background() ); + colCache.getColors(cg, KrColorItemType(KrColorItemType::File, true, isActive, false, false)); + pwFile->setColor( cg.text(), cg.background() ); + colCache.getColors(cg, KrColorItemType(KrColorItemType::Executable, false, isActive, false, false)); + pwApp->setColor( cg.text(), cg.background() ); + colCache.getColors(cg, KrColorItemType(KrColorItemType::Symlink, true, isActive, false, false)); + pwSymLink->setColor( cg.text(), cg.background() ); + colCache.getColors(cg, KrColorItemType(KrColorItemType::InvalidSymlink, false, isActive, false, false)); + pwInvLink->setColor( cg.text(), cg.background() ); + colCache.getColors(cg, KrColorItemType(KrColorItemType::File, true, isActive, true, false)); + pwCurrent->setColor( cg.highlightedText(), cg.highlight() ); + colCache.getColors(cg, KrColorItemType(KrColorItemType::File, false, isActive, false, true)); + pwMark1->setColor( cg.highlightedText(), cg.highlight() ); + colCache.getColors(cg, KrColorItemType(KrColorItemType::File, true, isActive, false, true)); + pwMark2->setColor( cg.highlightedText(), cg.highlight() ); + colCache.getColors(cg, KrColorItemType(KrColorItemType::File, false, isActive, true, true)); + pwMarkCur->setColor( cg.highlightedText(), cg.highlight() ); + }else if( currentPage == 2 ) + { + PreviewItem *pwDelete = new PreviewItem( preview, i18n( "Delete" ) ); + PreviewItem *pwRightCopy = new PreviewItem( preview, i18n( "Copy to right" ) ); + PreviewItem *pwLeftCopy = new PreviewItem( preview, i18n( "Copy to left" ) ); + PreviewItem *pwDiffers = new PreviewItem( preview, i18n( "Differing" ) ); + PreviewItem *pwEquals = new PreviewItem( preview, i18n( "Equals" ) ); + + pwEquals->setColor( getColorSelector( "Synchronizer Equals Foreground" )->getColor(), + getColorSelector( "Synchronizer Equals Background" )->getColor() ); + pwDiffers->setColor( getColorSelector( "Synchronizer Differs Foreground" )->getColor(), + getColorSelector( "Synchronizer Differs Background" )->getColor() ); + pwLeftCopy->setColor ( getColorSelector( "Synchronizer LeftCopy Foreground" )->getColor(), + getColorSelector( "Synchronizer LeftCopy Background" )->getColor() ); + pwRightCopy->setColor( getColorSelector( "Synchronizer RightCopy Foreground" )->getColor(), + getColorSelector( "Synchronizer RightCopy Background" )->getColor() ); + pwDelete->setColor( getColorSelector( "Synchronizer Delete Foreground" )->getColor(), + getColorSelector( "Synchronizer Delete Background" )->getColor() ); + } +} + +bool KgColors::apply() +{ + bool result = KonfiguratorPage::apply(); + KrColorCache::getColorCache().refreshColors(); + return result; +} + +void KgColors::slotImportColors() { + // find $TDEDIR/share/apps/krusader + TQString basedir = TDEGlobal::dirs()->findResourceDir("appdata", "total_commander.keymap"); + // let the user select a file to load + TQString file = KFileDialog::getOpenFileName(basedir, "*.color", 0, i18n("Select a color-scheme file")); + if (file == TQString()) return; + TQFile f(file); + if (!f.open(IO_ReadOnly)) { + KMessageBox::error(this, i18n("Error: unable to read from file"), i18n("Error")); + return; + } + TQDataStream stream(&f); + // ok, import away + deserialize(stream); + generatePreview(); +} + +void KgColors::slotExportColors() { + TQString file = KFileDialog::getSaveFileName(TQString(), "*", 0, i18n("Select a color scheme file")); + if (file == TQString()) return; + TQFile f(file); + if (f.exists() && KMessageBox::warningContinueCancel(this, + i18n("File ")+file+i18n(" already exists. Are you sure you want to overwrite it?"), + i18n("Warning"), i18n("Overwrite")) != KMessageBox::Continue) return; + if (!f.open(IO_WriteOnly)) { + KMessageBox::error(this, i18n("Error: unable to write to file"), i18n("Error")); + return; + } + TQDataStream stream(&f); + serialize(stream); +} + +void KgColors::serialize(TQDataStream & stream) +{ + serializeItem(stream, "Alternate Background"); + serializeItem(stream, "Alternate Marked Background"); + serializeItem(stream, "Background"); + serializeItem(stream, "Current Background"); + serializeItem(stream, "Current Foreground"); + serializeItem(stream, "Enable Alternate Background"); + serializeItem(stream, "Foreground"); + serializeItem(stream, "Directory Foreground"); + serializeItem(stream, "Executable Foreground"); + serializeItem(stream, "Symlink Foreground"); + serializeItem(stream, "Invalid Symlink Foreground"); + serializeItem(stream, "Inactive Alternate Background"); + serializeItem(stream, "Inactive Alternate Marked Background"); + serializeItem(stream, "Inactive Background"); + serializeItem(stream, "Inactive Current Foreground"); + serializeItem(stream, "Inactive Current Background"); + serializeItem(stream, "Inactive Marked Background"); + serializeItem(stream, "Inactive Marked Current Foreground"); + serializeItem(stream, "Inactive Marked Foreground"); + serializeItem(stream, "Inactive Foreground"); + serializeItem(stream, "Inactive Directory Foreground"); + serializeItem(stream, "Inactive Executable Foreground"); + serializeItem(stream, "Inactive Symlink Foreground"); + serializeItem(stream, "Inactive Invalid Symlink Foreground"); + serializeItem(stream, "Dim Inactive Colors"); + serializeItem(stream, "Dim Target Color"); + serializeItem(stream, "Dim Factor"); + serializeItem(stream, "KDE Default"); + serializeItem(stream, "Marked Background"); + serializeItem(stream, "Marked Current Foreground"); + serializeItem(stream, "Marked Foreground"); + serializeItem(stream, "Show Current Item Always"); + serializeItem(stream, "Synchronizer Equals Foreground"); + serializeItem(stream, "Synchronizer Equals Background"); + serializeItem(stream, "Synchronizer Differs Foreground"); + serializeItem(stream, "Synchronizer Differs Background"); + serializeItem(stream, "Synchronizer LeftCopy Foreground"); + serializeItem(stream, "Synchronizer LeftCopy Background"); + serializeItem(stream, "Synchronizer RightCopy Foreground"); + serializeItem(stream, "Synchronizer RightCopy Background"); + serializeItem(stream, "Synchronizer Delete Foreground"); + serializeItem(stream, "Synchronizer Delete Background"); + stream << TQString("") << TQString(""); +} + +void KgColors::deserialize(TQDataStream & stream) +{ + for (;;) + { + TQString name, value; + stream >> name >> value; + if (name == "") + break; + + if (name == "KDE Default" || name == "Enable Alternate Background" || + name == "Show Current Item Always" || name == "Dim Inactive Colors" ) + { + bool bValue = false; + value = value.lower(); + if( value == "true" || value == "yes" || value == "on" || value == "1" ) + bValue = true; + + generals->find( name )->setChecked( bValue ); + continue; + } + + if( name == "Dim Factor" ) + { + dimFactor->setValue( value.toInt() ); + continue; + } + + KonfiguratorColorChooser *selector = getColorSelector( name ); + if( selector == 0 ) + break; + selector->setValue( value ); + } +} + +void KgColors::serializeItem(class TQDataStream & stream, const char * name) +{ + stream << TQString(name); + if( (strcmp( name, "KDE Default") == 0) + || (strcmp( name, "Enable Alternate Background") == 0) + || (strcmp( name, "Show Current Item Always") == 0) + || (strcmp( name, "Dim Inactive Colors") == 0) ) + { + bool bValue = generals->find( name )->isChecked(); + stream << TQString( bValue ? "true" : "false" ); + } + else if( strcmp( name, "Dim Factor") == 0 ) + stream << TQString::number(dimFactor->value()); + else + { + KonfiguratorColorChooser *selector = getColorSelector( name ); + stream << selector->getValue(); + } +} + +#include "kgcolors.moc" diff --git a/src/app/Konfigurator/kgcolors.h b/src/app/Konfigurator/kgcolors.h new file mode 100644 index 0000000..054cb47 --- /dev/null +++ b/src/app/Konfigurator/kgcolors.h @@ -0,0 +1,140 @@ +/*************************************************************************** + kgcolors.h - description + ------------------- + copyright : (C) 2004 + by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + H e a d e r F i l e + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef __KGCOLORS_H__ +#define __KGCOLORS_H__ + +#include "konfiguratorpage.h" +#include <tqptrlist.h> +#include <tqvaluelist.h> +#include <tqlistview.h> +#include <tqwidgetstack.h> + +class KgColors : public KonfiguratorPage +{ + TQ_OBJECT + + +public: + KgColors( bool first, TQWidget* parent=0, const char* name=0 ); + + bool apply(); + +public slots: + void slotDisable(); + void slotForegroundChanged(); + void slotBackgroundChanged(); + void slotAltBackgroundChanged(); + void slotActiveChanged(); + void slotMarkedBackgroundChanged(); + void slotInactiveForegroundChanged(); + void slotInactiveBackgroundChanged(); + void slotInactiveAltBackgroundChanged(); + void slotInactiveMarkedBackgroundChanged(); + void generatePreview(); + +protected slots: + void slotImportColors(); + void slotExportColors(); + +private: + class PreviewItem; + + int addColorSelector( TQString cfgName, TQString name, TQColor dflt, TQString dfltName = TQString(), + ADDITIONAL_COLOR *addColor = 0, int addColNum = 0); + KonfiguratorColorChooser *getColorSelector( TQString name ); + TQLabel *getSelectorLabel( TQString name ); + void serialize(class TQDataStream &); + void deserialize(class TQDataStream &); + void serializeItem(class TQDataStream &, const char * name); + void setColorWithDimming(PreviewItem * item, TQColor foreground, TQColor background, bool dimmed ); + +private: + TQWidget *colorsGrp; + TQGridLayout *colorsGrid; + int offset; + int endOfActiveColors; + int endOfPanelColors; + + TQGroupBox *previewGrp; + TQGridLayout *previewGrid; + TQTabWidget *colorTabWidget; + + TQWidgetStack *inactiveColorStack; + TQWidget *normalInactiveWidget; + TQWidget *dimmedInactiveWidget; + KonfiguratorSpinBox *dimFactor; + + KonfiguratorCheckBoxGroup *generals; + + TQPtrList<TQLabel> labelList; + TQPtrList<KonfiguratorColorChooser> itemList; + TQValueList<TQString> itemNames; + + TQListView *preview; + KPushButton *importBtn, *exportBtn; + + class PreviewItem : public TQListViewItem + { + private: + TQColor defaultBackground; + TQColor defaultForeground; + TQString label; + + public: + PreviewItem( TQListView * parent, TQString name ) : TQListViewItem( parent, name ) + { + defaultBackground = TQColor( 255, 255, 255 ); + defaultForeground = TQColor( 0, 0, 0 ); + label = name; + } + + void setColor( TQColor foregnd, TQColor backgnd ) + { + defaultForeground = foregnd; + defaultBackground = backgnd; + listView()->repaintItem( this ); + } + + TQString text() + { + return label; + } + + void paintCell ( TQPainter * p, const TQColorGroup & cg, int column, int width, int align ) + { + TQColorGroup _cg( cg ); + _cg.setColor( TQColorGroup::Base, defaultBackground ); + _cg.setColor( TQColorGroup::Text, defaultForeground ); + TQListViewItem::paintCell(p, _cg, column, width, align); + } + }; +}; +#endif /* __KGCOLORS_H__ */ diff --git a/src/app/Konfigurator/kgdependencies.cpp b/src/app/Konfigurator/kgdependencies.cpp new file mode 100644 index 0000000..b7f6f9f --- /dev/null +++ b/src/app/Konfigurator/kgdependencies.cpp @@ -0,0 +1,170 @@ +/*************************************************************************** + kgdependencies.cpp - description + ------------------- + copyright : (C) 2004 by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "kgdependencies.h" +#include "../krservices.h" +#include "../krusader.h" +#include <tqtabwidget.h> +#include <tdelocale.h> +#include <tqhbox.h> +#include <tdemessagebox.h> + +#define PAGE_GENERAL 0 +#define PAGE_PACKERS 1 +#define PAGE_CHECKSUM 2 + +KgDependencies::KgDependencies( bool first, TQWidget* parent, const char* name ) : + KonfiguratorPage( first, parent, name ) +{ + TQGridLayout *kgDependenciesLayout = new TQGridLayout( parent ); + kgDependenciesLayout->setSpacing( 6 ); + + // ---------------------------- GENERAL TAB ------------------------------------- + tabWidget = new TQTabWidget( parent, "tabWidget" ); + + TQWidget *general_tab = new TQWidget( tabWidget, "tab" ); + tabWidget->insertTab( general_tab, i18n( "General" ) ); + + TQGridLayout *pathsGrid = new TQGridLayout( general_tab ); + pathsGrid->setSpacing( 6 ); + pathsGrid->setMargin( 11 ); + pathsGrid->setAlignment( TQt::AlignTop ); + + addApplication( "df", pathsGrid, 0, general_tab, PAGE_GENERAL ); + addApplication( "eject", pathsGrid, 1, general_tab, PAGE_GENERAL ); + addApplication( "tdesu", pathsGrid, 2, general_tab, PAGE_GENERAL ); + addApplication( "kget", pathsGrid, 3, general_tab, PAGE_GENERAL ); + addApplication( "kmail", pathsGrid, 4, general_tab, PAGE_GENERAL ); + addApplication( "diff utility", pathsGrid, 5, general_tab, PAGE_GENERAL ); + addApplication( "krename", pathsGrid, 6, general_tab, PAGE_GENERAL ); + addApplication( "krusader", pathsGrid, 7, general_tab, PAGE_GENERAL ); + addApplication( "locate", pathsGrid, 8, general_tab, PAGE_GENERAL ); + addApplication( "mount", pathsGrid, 9, general_tab, PAGE_GENERAL ); + addApplication( "umount", pathsGrid,10, general_tab, PAGE_GENERAL ); + addApplication( "updatedb", pathsGrid,11, general_tab, PAGE_GENERAL ); + + // ---------------------------- PACKERS TAB ------------------------------------- + TQWidget *packers_tab = new TQWidget( tabWidget, "tab_3" ); + tabWidget->insertTab( packers_tab, i18n( "Packers" ) ); + + TQGridLayout *archGrid1 = new TQGridLayout( packers_tab ); + archGrid1->setSpacing( 6 ); + archGrid1->setMargin( 11 ); + archGrid1->setAlignment( TQt::AlignTop ); + + addApplication( "7z", archGrid1, 0, packers_tab, PAGE_PACKERS, "7za" ); + addApplication( "arj", archGrid1, 1, packers_tab, PAGE_PACKERS ); + addApplication( "bzip2", archGrid1, 2, packers_tab, PAGE_PACKERS ); + addApplication( "cpio", archGrid1, 3, packers_tab, PAGE_PACKERS ); + addApplication( "dpkg", archGrid1, 4, packers_tab, PAGE_PACKERS ); + addApplication( "gzip", archGrid1, 5, packers_tab, PAGE_PACKERS ); + addApplication( "lha", archGrid1, 6, packers_tab, PAGE_PACKERS ); + addApplication( "rar", archGrid1, 7, packers_tab, PAGE_PACKERS ); + addApplication( "tar", archGrid1, 8, packers_tab, PAGE_PACKERS ); + addApplication( "unace", archGrid1, 9, packers_tab, PAGE_PACKERS ); + addApplication( "unarj", archGrid1,10, packers_tab, PAGE_PACKERS ); + addApplication( "unrar", archGrid1,11, packers_tab, PAGE_PACKERS ); + addApplication( "unzip", archGrid1,12, packers_tab, PAGE_PACKERS ); + addApplication( "zip", archGrid1,13, packers_tab, PAGE_PACKERS ); + addApplication( "xz", archGrid1,14, packers_tab, PAGE_PACKERS ); + + // ---------------------------- CHECKSUM TAB ------------------------------------- + TQWidget *checksum_tab = new TQWidget( tabWidget, "tab_4" ); + tabWidget->insertTab( checksum_tab, i18n( "Checksum Utilities" ) ); + + TQGridLayout *archGrid2 = new TQGridLayout( checksum_tab ); + archGrid2->setSpacing( 6 ); + archGrid2->setMargin( 11 ); + archGrid2->setAlignment( TQt::AlignTop ); + + addApplication( "md5sum", archGrid2, 0, checksum_tab, PAGE_CHECKSUM ); + addApplication( "sha1sum", archGrid2, 1, checksum_tab, PAGE_CHECKSUM ); + addApplication( "sha224sum", archGrid2, 2, checksum_tab, PAGE_CHECKSUM ); + addApplication( "sha256sum", archGrid2, 3, checksum_tab, PAGE_CHECKSUM ); + addApplication( "sha384sum", archGrid2, 4, checksum_tab, PAGE_CHECKSUM ); + addApplication( "sha512sum", archGrid2, 5, checksum_tab, PAGE_CHECKSUM ); + addApplication( "md5deep", archGrid2, 6, checksum_tab, PAGE_CHECKSUM ); + addApplication( "sha1deep", archGrid2, 7, checksum_tab, PAGE_CHECKSUM ); + addApplication( "sha256deep", archGrid2, 8, checksum_tab, PAGE_CHECKSUM ); + addApplication( "tigerdeep", archGrid2, 9, checksum_tab, PAGE_CHECKSUM ); + addApplication( "whirlpooldeep", archGrid2, 10, checksum_tab, PAGE_CHECKSUM ); + addApplication( "cfv", archGrid2, 11, checksum_tab, PAGE_CHECKSUM ); + + kgDependenciesLayout->addWidget( tabWidget, 0, 0 ); +} + +void KgDependencies::addApplication( TQString name, TQGridLayout *grid, int row, TQWidget *parent, int page, TQString additionalList ) +{ + TQString dflt = KrServices::fullPathName( name ); /* try to autodetect the full path name */ + + if( dflt.isEmpty() ) { + TQStringList list = TQStringList::split( ',', additionalList ); + for( unsigned i=0; i != list.count(); i++ ) + if( !KrServices::fullPathName( list[ i ] ).isEmpty() ) { + dflt = KrServices::fullPathName( list[ i ] ); + break; + } + } + + addLabel( grid, row, 0, name, parent, (TQString( "label:" )+name).ascii() ); + + KonfiguratorURLRequester *fullPath = createURLRequester( "Dependencies", name, dflt, parent, false, page ); + connect( fullPath->extension(), TQ_SIGNAL( applyManually( TQObject *, TQString, TQString ) ), + this, TQ_SLOT( slotApply( TQObject *, TQString, TQString ) ) ); + grid->addWidget( fullPath, row, 1 ); +} + +void KgDependencies::slotApply( TQObject *obj, TQString cls, TQString name ) +{ + KonfiguratorURLRequester *urlRequester = (KonfiguratorURLRequester *) obj; + + krConfig->setGroup( cls ); + krConfig->writeEntry( name, urlRequester->url() ); + + TQString usedPath = KrServices::fullPathName( name ); + + if( urlRequester->url() != usedPath ) + { + krConfig->writeEntry( name, usedPath ); + if( usedPath.isEmpty() ) + KMessageBox::error( this, i18n( "The %1 path is incorrect, no valid path found." ) + .arg( urlRequester->url() ) ); + else + KMessageBox::error( this, i18n( "The %1 path is incorrect, %2 used instead." ) + .arg( urlRequester->url() ).arg( usedPath ) ); + urlRequester->setURL( usedPath ); + } +} + +int KgDependencies::activeSubPage() { + return tabWidget->currentPageIndex(); +} + +#include "kgdependencies.moc" diff --git a/src/app/Konfigurator/kgdependencies.h b/src/app/Konfigurator/kgdependencies.h new file mode 100644 index 0000000..9593c1e --- /dev/null +++ b/src/app/Konfigurator/kgdependencies.h @@ -0,0 +1,59 @@ +/*************************************************************************** + kgdependencies.h - description + ------------------- + copyright : (C) 2004 by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef __KGDEPENDENCIES_H__ +#define __KGDEPENDENCIES_H__ + +#include "konfiguratorpage.h" + +class TQTabWidget; + + +class KgDependencies : public KonfiguratorPage +{ + TQ_OBJECT + + +public: + KgDependencies( bool first, TQWidget* parent=0, const char* name=0 ); + + virtual int activeSubPage(); + +private: + void addApplication( TQString name, TQGridLayout *grid, int row, TQWidget *parent, int page, TQString additionalList=TQString() ); + +public slots: + void slotApply( TQObject *obj, TQString cls, TQString name ); + +private: + TQTabWidget *tabWidget; +}; + +#endif /* __KGDEPENDENCIES_H__ */ diff --git a/src/app/Konfigurator/kggeneral.cpp b/src/app/Konfigurator/kggeneral.cpp new file mode 100644 index 0000000..390b912 --- /dev/null +++ b/src/app/Konfigurator/kggeneral.cpp @@ -0,0 +1,214 @@ +/*************************************************************************** + kggeneral.cpp - description + ------------------- + copyright : (C) 2004 by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include <tqlabel.h> +#include <tqhbox.h> +#include <tqvbox.h> +#include <tqfontmetrics.h> +#include <tdelocale.h> +#include <tdemessagebox.h> +#include <kinputdialog.h> +#include "krresulttabledialog.h" +#include "kggeneral.h" +#include "../defaults.h" +#include "../krusader.h" +#include "../kicons.h" + +KgGeneral::KgGeneral( bool first, TQWidget* parent, const char* name ) : + KonfiguratorPage( first, parent, name ) +{ +if( first ) + slotFindTools(); + + TQGridLayout *kgGeneralLayout = new TQGridLayout( parent ); + kgGeneralLayout->setSpacing( 6 ); + + // -------------------------- GENERAL GROUPBOX ---------------------------------- + + TQGroupBox *generalGrp = createFrame( i18n( "General" ), parent, "kgGenGeneralGrp" ); + TQGridLayout *generalGrid = createGridLayout( generalGrp->layout() ); + + KONFIGURATOR_NAME_VALUE_TIP deleteMode[] = + // name value tooltip + {{ i18n( "Delete files" ), "false", i18n( "Files will be permanently deleted." ) }, + { i18n( "Move to trash" ), "true", i18n( "Files will be moved to trash when deleted." ) }}; + + KonfiguratorRadioButtons *trashRadio = createRadioButtonGroup( "General", "Move To Trash", + _MoveToTrash ? "true" : "false", 2, 0, deleteMode, 2, generalGrp, "myRadio", false ); + generalGrid->addMultiCellWidget( trashRadio, 0, 0, 0, 1 ); + + KonfiguratorCheckBox *checkBox = createCheckBox( "General", "Mimetype Magic", _MimetypeMagic, + i18n( "Use mimetype magic" ), generalGrp, false, + i18n( "Mimetype magic allows better distinction of file types, but is slower." ) ); + generalGrid->addMultiCellWidget( checkBox, 1, 1, 0, 1 ); + + TQFrame *line1 = createLine( generalGrp, "line1" ); + generalGrid->addMultiCellWidget( line1, 2, 2, 0, 1 ); + + // editor + TQLabel *label1 = new TQLabel( i18n( "Editor:" ), generalGrp, "EditorLabel" ); + generalGrid->addWidget( label1, 3, 0 ); + KonfiguratorURLRequester *urlReq = createURLRequester( "General", "Editor", "internal editor", + generalGrp, false ); + generalGrid->addWidget( urlReq, 3, 1 ); + + TQLabel *label2 = new TQLabel( i18n( "Hint: use 'internal editor' if you want to use Krusader's fast built-in editor" ), generalGrp, "EditorLabel" ); + generalGrid->addMultiCellWidget( label2, 4, 4, 0, 1 ); + +TQFrame *line2 = createLine( generalGrp, "line2" ); + generalGrid->addMultiCellWidget( line2, 5, 5, 0, 1 ); + + // viewer + + TQHBox * hbox2 = new TQHBox( generalGrp ); + TQVBox * vbox = new TQVBox( hbox2 ); + + new TQLabel( i18n("Default viewer mode:"), vbox); + + KONFIGURATOR_NAME_VALUE_TIP viewMode[] = + // name value tooltip + {{ i18n( "Generic mode" ), "generic", i18n( "Use the system's default viewer" ) }, + { i18n( "Text mode" ), "text", i18n( "View the file in text-only mode" ) }, + { i18n( "Hex mode" ), "hex", i18n( "View the file in hex-mode (better for binary files)" ) } }; + createRadioButtonGroup( "General", "Default Viewer Mode", + "generic", 0, 3, viewMode, 3, vbox, "myRadio2", false ); + + createCheckBox( "General", "View In Separate Window", _ViewInSeparateWindow, + i18n( "Internal editor and viewer opens each file in a separate window" ), vbox, false, + i18n( "If checked, each file will open in a separate window, otherwise, the viewer will work in a single, tabbed mode" ) ); + + generalGrid->addMultiCellWidget(hbox2, 6, 8, 0, 1); + + // atomic extensions + TQFrame * frame21 = createLine( hbox2, "line2.1", true ); + frame21->setMinimumWidth( 15 ); + TQVBox * vbox2 = new TQVBox( hbox2 ); + + TQHBox * hbox3 = new TQHBox( vbox2 ); + TQLabel * atomLabel = new TQLabel( i18n("Atomic extensions:"), hbox3); + + int size = TQFontMetrics( atomLabel->font() ).height(); + + TQToolButton *addButton = new TQToolButton( hbox3, "addBtnList" ); + TQPixmap icon = krLoader->loadIcon("add",TDEIcon::Desktop, size ); + addButton->setFixedSize( icon.width() + 4, icon.height() + 4 ); + addButton->setPixmap( icon ); + connect( addButton, TQ_SIGNAL( clicked() ), this, TQ_SLOT( slotAddExtension() ) ); + + TQToolButton *removeButton = new TQToolButton( hbox3, "removeBtnList" ); + icon = krLoader->loadIcon("remove",TDEIcon::Desktop, size ); + removeButton->setFixedSize( icon.width() + 4, icon.height() + 4 ); + removeButton->setPixmap( icon ); + connect( removeButton, TQ_SIGNAL( clicked() ), this, TQ_SLOT( slotRemoveExtension() ) ); + + TQStringList defaultAtomicExtensions; + defaultAtomicExtensions += ".tar.gz"; + defaultAtomicExtensions += ".tar.bz2"; + defaultAtomicExtensions += ".moc.cpp"; + defaultAtomicExtensions += ".tar.xz"; + + listBox = createListBox( "Look&Feel", "Atomic Extensions", + defaultAtomicExtensions, vbox2, true, false ); + + TQFrame *line3 = createLine( generalGrp, "line3" ); + generalGrid->addMultiCellWidget( line3, 9, 9, 0, 1 ); + + // terminal + TQLabel *label3 = new TQLabel( i18n( "Terminal:" ), generalGrp, "TerminalLabel" ); + generalGrid->addWidget( label3, 10, 0 ); + KonfiguratorURLRequester *urlReq2 = createURLRequester( "General", "Terminal", "konsole", + generalGrp, false ); + generalGrid->addWidget( urlReq2, 10, 1 ); + + KonfiguratorCheckBox *checkBox1 = createCheckBox( "General", "Send CDs", _SendCDs, + i18n( "Terminal Emulator sends Chdir on panel change" ), generalGrp, false, + i18n( "When checked, whenever the panel is changed (for example, by pressing TAB), krusader changes the current directory in the terminal emulator." ) ); + generalGrid->addMultiCellWidget( checkBox1, 11, 11, 0, 1 ); + + TQFrame *line31 = createLine( generalGrp, "line4" ); + generalGrid->addMultiCellWidget( line31, 12, 12, 0, 1 ); + + // temp dir + TQHBox *hbox = new TQHBox( generalGrp, "hbox" ); + new TQLabel( i18n( "Temp Directory:" ), hbox, "TempDirectory" ); + KonfiguratorURLRequester *urlReq3 = createURLRequester( "General", "Temp Directory", "/tmp/krusader.tmp", + hbox, false ); + urlReq3->setMode( KFile::Directory ); + connect( urlReq3->extension(), TQ_SIGNAL( applyManually(TQObject *,TQString, TQString) ), + this, TQ_SLOT( applyTempDir(TQObject *,TQString, TQString) ) ); + generalGrid->addMultiCellWidget( hbox, 13, 13, 0, 1 ); + + TQLabel *label4 = new TQLabel( i18n( "Note: you must have full permissions for the temporary directory!" ), + generalGrp, "NoteLabel" ); + generalGrid->addMultiCellWidget( label4, 14, 14, 0, 1 ); + + + kgGeneralLayout->addWidget( generalGrp, 0 ,0 ); +} + +void KgGeneral::applyTempDir(TQObject *obj,TQString cls, TQString name) +{ + KonfiguratorURLRequester *urlReq = (KonfiguratorURLRequester *)obj; + TQString value = TQDir(urlReq->url()).path(); + + krConfig->setGroup( cls ); + krConfig->writeEntry( name, value ); +} + +void KgGeneral::slotFindTools() +{ + KrResultTableDialog* dia = new KrResultTableDialog(this, KrResultTableDialog::Tool, i18n("Search results"), i18n("Searching for tools..."), + "package_settings", i18n("Make sure to install new tools in your <code>$PATH</code> (e.g. /usr/bin)")); + dia->exec(); +} + +void KgGeneral::slotAddExtension() +{ + bool ok; + TQString atomExt = + KInputDialog::getText( i18n( "Add new atomic extension" ), i18n( "Extension: " ), TQString(), &ok ); + + if( ok ) + { + if( !atomExt.startsWith( "." ) || atomExt.find( '.', 1 ) == -1 ) + KMessageBox::error(krApp, i18n("Atomic extensions must start with '.'\n and must contain at least one more '.' character"), i18n("Error")); + else + listBox->addItem( atomExt ); + } +} + +void KgGeneral::slotRemoveExtension() +{ + TQListBoxItem * item = listBox->selectedItem(); + if( item ) + listBox->removeItem( item->text() ); +} + +#include "kggeneral.moc" diff --git a/src/app/Konfigurator/kggeneral.h b/src/app/Konfigurator/kggeneral.h new file mode 100644 index 0000000..0a83863 --- /dev/null +++ b/src/app/Konfigurator/kggeneral.h @@ -0,0 +1,55 @@ +/*************************************************************************** + kgadvanced.h - description + ------------------- + copyright : (C) 2004 by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + H e a d e r F i l e + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef __KGGENERAL_H__ +#define __KGGENERAL_H__ + +#include "konfiguratorpage.h" + +class KgGeneral : public KonfiguratorPage +{ + TQ_OBJECT + + +public: + KgGeneral( bool first, TQWidget* parent=0, const char* name=0 ); + +public slots: + void applyTempDir(TQObject *,TQString, TQString); + void slotFindTools(); + + void slotAddExtension(); + void slotRemoveExtension(); + +private: + KonfiguratorListBox *listBox; +}; + +#endif /* __KGGENERAL_H__ */ diff --git a/src/app/Konfigurator/kglookfeel.cpp b/src/app/Konfigurator/kglookfeel.cpp new file mode 100644 index 0000000..aa852ca --- /dev/null +++ b/src/app/Konfigurator/kglookfeel.cpp @@ -0,0 +1,373 @@ +/*************************************************************************** + kglookfeel.cpp - description + ------------------- + copyright : (C) 2003 by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "kglookfeel.h" +#include "../krusader.h" +#include "../defaults.h" +#include "../Dialogs/krdialogs.h" +#include <tqtabwidget.h> +#include <tdelocale.h> +#include <tqwhatsthis.h> +#include <tqvalidator.h> +#include <tqlistview.h> +#include <tdemessagebox.h> +#include <tdefiledialog.h> +#include <tdeglobal.h> +#include <kstandarddirs.h> +#include "../Panel/krselectionmode.h" +#include "../Panel/listpanel.h" + +#define PAGE_OPERATION 0 +#define PAGE_PANEL 1 +#define PAGE_PANELTOOLBAR 2 +#define PAGE_MOUSE 3 + +KgLookFeel::KgLookFeel( bool first, TQWidget* parent, const char* name ) : + KonfiguratorPage( first, parent, name ) +{ + TQGridLayout *kgLookAndFeelLayout = new TQGridLayout( parent ); + kgLookAndFeelLayout->setSpacing( 6 ); + + tabWidget = new TQTabWidget( parent, "tabWidget" ); + + setupOperationTab(); + setupPanelTab(); + setupPanelToolbarTab(); + setupMouseModeTab(); + + kgLookAndFeelLayout->addWidget( tabWidget, 0, 0 ); +} + +// --------------------------------------------------------------------------------------- +// ---------------------------- OPERATION TAB ------------------------------------- +// --------------------------------------------------------------------------------------- +void KgLookFeel::setupOperationTab() { + TQWidget *tab = new TQWidget( tabWidget, "tab_operation" ); + tabWidget->insertTab( tab, i18n( "Operation" ) ); + + TQGridLayout *lookAndFeelLayout = new TQGridLayout( tab ); + lookAndFeelLayout->setSpacing( 6 ); + lookAndFeelLayout->setMargin( 11 ); + + // -------------- General ----------------- + TQGroupBox *lookFeelGrp = createFrame( i18n( "Look && Feel" ), tab, "kgLookAndFeelGrp" ); + TQGridLayout *lookFeelGrid = createGridLayout( lookFeelGrp->layout() ); + + KONFIGURATOR_CHECKBOX_PARAM settings[] = + { // cfg_class cfg_name default text restart tooltip + {"Look&Feel","Warn On Exit", _WarnOnExit, i18n( "Warn on exit" ), false, i18n( "Display a warning when trying to close the main window." ) }, // KDE4: move warn on exit to the other confirmations + {"Look&Feel","Minimize To Tray", _MinimizeToTray, i18n( "Minimize to tray" ), false, i18n( "The icon will appear in the system tray instead of the taskbar, when Krusader is minimized." ) }, + {"Look&Feel","Mark Dirs", _MarkDirs, i18n( "Autoselect directories" ), false, i18n( "When matching the select criteria, not only files will be selected, but also directories." ) }, + {"Look&Feel","Rename Selects Extension",true, i18n( "Rename selects extension" ), false, i18n( "When renaming a file, the whole text is selected. If you want Total-Commander like renaming of just the name, without extension, uncheck this option." ) }, + {"Look&Feel","Fullpath Tab Names", _FullPathTabNames, i18n( "Use full path tab names" ), true , i18n( "Display the full path in the folder tabs. By default only the last part of the path is displayed." ) }, + {"Look&Feel","Fullscreen Terminal Emulator", false, i18n( "Fullscreen terminal (mc-style)" ), false, i18n( "Terminal is shown instead of the Krusader window (full screen).") }, + }; + + cbs = createCheckBoxGroup( 2, 0, settings, 6 /*count*/, lookFeelGrp, 0, PAGE_OPERATION ); + lookFeelGrid->addWidget( cbs, 0, 0 ); + + lookAndFeelLayout->addWidget( lookFeelGrp, 0, 0 ); + + // -------------- Quicksearch ----------------- + TQGroupBox *quicksearchGroup = createFrame( i18n( "Quicksearch" ), tab, "kgQuicksearchGrp" ); + TQGridLayout *quicksearchGrid = createGridLayout( quicksearchGroup->layout() ); + + KONFIGURATOR_CHECKBOX_PARAM quicksearch[] = + { // cfg_class cfg_name default text restart tooltip + {"Look&Feel","New Style Quicksearch", _NewStyleQuicksearch, i18n( "New style quicksearch" ), false, i18n( "Opens a quick search dialog box." ) }, + {"Look&Feel","Case Sensitive Quicksearch", _CaseSensitiveQuicksearch, i18n( "Case sensitive quicksearch" ), false, i18n( "All files beginning with capital letters appear before files beginning with non-capital letters (UNIX default)." ) }, + }; + + quicksearchCheckboxes = createCheckBoxGroup( 2, 0, quicksearch, 2 /*count*/, quicksearchGroup, 0, PAGE_OPERATION ); + quicksearchGrid->addWidget( quicksearchCheckboxes, 0, 0 ); + connect( quicksearchCheckboxes->find( "New Style Quicksearch" ), TQ_SIGNAL( stateChanged( int ) ), this, TQ_SLOT( slotDisable() ) ); + slotDisable(); + + lookAndFeelLayout->addWidget( quicksearchGroup, 1, 0 ); +} + +// ---------------------------------------------------------------------------------- +// ---------------------------- PANEL TAB ------------------------------------- +// ---------------------------------------------------------------------------------- +void KgLookFeel::setupPanelTab() { + TQWidget* tab_panel = new TQWidget( tabWidget, "tab_panel" ); + tabWidget->insertTab( tab_panel, i18n( "Panel" ) ); + + TQGridLayout *panelLayout = new TQGridLayout( tab_panel ); + panelLayout->setSpacing( 6 ); + panelLayout->setMargin( 11 ); + TQGroupBox *panelGrp = createFrame( i18n( "Panel settings" ), tab_panel, "kgPanelGrp" ); + TQGridLayout *panelGrid = createGridLayout( panelGrp->layout() ); + + TQHBox *hbox = new TQHBox( panelGrp, "lookAndFeelHBox1" ); + new TQLabel( i18n( "Panel font:" ), hbox, "lookAndFeelLabel" ); + createFontChooser( "Look&Feel", "Filelist Font", _FilelistFont, hbox, true, PAGE_PANEL ); + createSpacer ( hbox ); + panelGrid->addWidget( hbox, 0, 0 ); + + TQHBox *hbox2 = new TQHBox( panelGrp, "lookAndFeelHBox2" ); + TQLabel *lbl1 = new TQLabel( i18n( "Filelist icon size:" ), hbox2, "lookAndFeelLabel2" ); + lbl1->setMinimumWidth( 230 ); + KONFIGURATOR_NAME_VALUE_PAIR iconSizes[] = + {{ i18n( "16" ), "16" }, + { i18n( "22" ), "22" }, + { i18n( "32" ), "32" }, + { i18n( "48" ), "48" }}; + KonfiguratorComboBox *iconCombo = createComboBox( "Look&Feel", "Filelist Icon Size", _FilelistIconSize, iconSizes, 4, hbox2, true, true, PAGE_PANEL ); + iconCombo->lineEdit()->setValidator( new TQRegExpValidator( TQRegExp( "[1-9]\\d{0,1}" ), iconCombo ) ); + createSpacer ( hbox2 ); + panelGrid->addWidget( hbox2, 1, 0 ); + + panelGrid->addWidget( createLine( panelGrp, "lookSep3" ), 2, 0 ); + + KONFIGURATOR_CHECKBOX_PARAM panelSettings[] = + // cfg_class cfg_name default text restart tooltip + { + {"Look&Feel","With Icons", _WithIcons, i18n( "Use icons in the filenames" ), true , i18n( "Show the icons for filenames and folders." ) }, + {"Look&Feel","Human Readable Size", _HumanReadableSize, i18n( "Use human-readable file size" ), true , i18n( "File sizes are displayed in B, KB, MB and GB, not just in bytes." ) }, + {"Look&Feel","Show Hidden", _ShowHidden, i18n( "Show hidden files" ), false, i18n( "Display files beginning with a dot." ) }, + {"Look&Feel","Case Sensative Sort", _CaseSensativeSort, i18n( "Case sensitive sorting" ), true , i18n( "All files beginning with capital letters appear before files beginning with non-capital letters (UNIX default)." ) }, + {"Look&Feel","Always sort dirs by name", false, i18n( "Always sort dirs by name" ), true, i18n( "Directories are sorted by name, regardless of the sort column.") }, + {"Look&Feel","Numeric permissions", _NumericPermissions, i18n( "Numeric Permissions" ), true, i18n( "Show octal numbers (0755) instead of the standard permissions (rwxr-xr-x) in the permission column.") }, + }; + + KonfiguratorCheckBoxGroup *panelSett = createCheckBoxGroup( 2, 0, panelSettings, 6 /*count*/, panelGrp, 0, PAGE_PANEL ); + + panelGrid->addWidget( panelSett, 3, 0 ); + +// ---------------------------------------------------------------------------------- +// ---------------------------- DEFAULT PANEL TYPE ------------------------------------- +// ---------------------------------------------------------------------------------- + + panelGrid->addWidget( createLine( panelGrp, "lookSep4" ), 4, 0 ); + + TQHBox *hbox3 = new TQHBox( panelGrp, "lookAndFeelHBox3" ); + TQLabel *lbl2 = new TQLabel( i18n( "Default panel type:" ), hbox3, "lookAndFeelLabel3" ); + KONFIGURATOR_NAME_VALUE_PAIR panelTypes[] = + {{ i18n( "Detailed" ), "Detailed" }, + { i18n( "Brief" ), "Brief" }}; + KonfiguratorComboBox *panelCombo = createComboBox( "Look&Feel", "Default Panel Type", _DefaultPanelType, panelTypes, 2, hbox3, false, false, PAGE_PANEL ); + createSpacer ( hbox3 ); + panelGrid->addWidget( hbox3, 5, 0 ); + + panelLayout->addWidget( panelGrp, 0, 0 ); +} + +// ----------------------------------------------------------------------------------- +// -------------------------- Panel Toolbar TAB ---------------------------------- +// ----------------------------------------------------------------------------------- +void KgLookFeel::setupPanelToolbarTab() { + TQWidget *tab_4 = new TQWidget( tabWidget, "tab_4" ); + tabWidget->insertTab( tab_4, i18n( "Panel Toolbar" ) ); + + TQBoxLayout * panelToolbarVLayout = new TQVBoxLayout( tab_4 ); + panelToolbarVLayout->setSpacing( 6 ); + panelToolbarVLayout->setMargin( 11 ); + + KONFIGURATOR_CHECKBOX_PARAM panelToolbarActiveCheckbox[] = + // cfg_class cfg_name default text restart tooltip + {{"Look&Feel", "Panel Toolbar visible", _PanelToolBar, i18n( "Show Panel Toolbar" ), true, i18n( "The panel toolbar will be visible." ) } + }; + + panelToolbarActive = createCheckBoxGroup( 1, 0, panelToolbarActiveCheckbox, 1, tab_4, "panelToolbarActive", PAGE_PANELTOOLBAR); + connect( panelToolbarActive->find( "Panel Toolbar visible" ), TQ_SIGNAL( stateChanged( int ) ), this, TQ_SLOT( slotEnablePanelToolbar() ) ); + + TQGroupBox * panelToolbarGrp = createFrame( i18n( "Visible Panel Toolbar buttons" ), tab_4, "panelToolbarGrp"); + TQGridLayout * panelToolbarGrid = createGridLayout( panelToolbarGrp->layout() ); + + KONFIGURATOR_CHECKBOX_PARAM panelToolbarCheckboxes[] = + { + // cfg_class cfg_name default text restart tooltip + {"Look&Feel", "Clear Location Bar Visible", _ClearLocation, i18n( "Clear location bar button" ), true , i18n( "Clears the location bar" ) }, + {"Look&Feel", "Open Button Visible", _Open, i18n( "Open button" ), true , i18n( "Opens the directory browser." ) }, + {"Look&Feel", "Equal Button Visible", _cdOther, i18n( "Equal button (=)" ),true , i18n( "Changes the panel directory to the other panel directory." ) }, + {"Look&Feel", "Up Button Visible", _cdUp, i18n( "Up button (..)" ), true , i18n( "Changes the panel directory to the parent directory." ) }, + {"Look&Feel", "Home Button Visible", _cdHome, i18n( "Home button (~)" ), true , i18n( "Changes the panel directory to the home directory." ) }, + {"Look&Feel", "Root Button Visible", _cdRoot, i18n( "Root button (/)" ), true , i18n( "Changes the panel directory to the root directory." ) }, + {"Look&Feel", "SyncBrowse Button Visible", _syncBrowseButton, i18n( "Toggle-button for sync-browsing" ), true , i18n( "Each directory change in the panel is also performed in the other panel." ) }, + }; + + + pnlcbs = createCheckBoxGroup(1, 0, panelToolbarCheckboxes, 7, + panelToolbarGrp, "panelToolbarChecks", PAGE_PANELTOOLBAR); + + panelToolbarVLayout->addWidget( panelToolbarActive, 0, 0 ); + panelToolbarGrid->addWidget( pnlcbs, 0, 0 ); + panelToolbarVLayout->addWidget( panelToolbarGrp, 1, 0 ); + + // Enable panel toolbar checkboxes + slotEnablePanelToolbar(); +} + +// --------------------------------------------------------------------------- +// -------------------------- Mouse TAB ---------------------------------- +// --------------------------------------------------------------------------- +void KgLookFeel::setupMouseModeTab() { + TQWidget *tab_mouse = new TQWidget( tabWidget, "tab_mouse" ); + tabWidget->insertTab( tab_mouse, i18n( "Selection Mode" ) ); + TQGridLayout *mouseLayout = new TQGridLayout( tab_mouse ); + mouseLayout->setSpacing( 6 ); + mouseLayout->setMargin( 11 ); + + // -------------- General ----------------- + TQGroupBox *mouseGeneralGroup = createFrame( i18n( "General" ), tab_mouse, "mouseGeneralGroup" ); + TQGridLayout *mouseGeneralGrid = createGridLayout( mouseGeneralGroup->layout() ); + mouseGeneralGrid->setSpacing( 0 ); + mouseGeneralGrid->setMargin( 5 ); + + KONFIGURATOR_NAME_VALUE_TIP mouseSelection[] = + { + // name value tooltip + { i18n( "Krusader Mode" ), "0", i18n( "Both keys allow selecting files. To select more than one file, hold the Ctrl key and click the left mouse button. Right-click menu is invoked using a short click on the right mouse button." ) }, + { i18n( "Konqueror Mode" ), "1", i18n( "Pressing the left mouse button selects files - you can click and select multiple files. Right-click menu is invoked using a short click on the right mouse button." ) }, + { i18n( "Total-Commander Mode" ), "2", i18n( "The left mouse button does not select, but sets the current file without affecting the current selection. The right mouse button selects multiple files and the right-click menu is invoked by pressing and holding the right mouse button." ) }, + { i18n( "Custom Selection Mode" ), "3", i18n( "Design your own selection mode!" ) } + }; + mouseRadio = createRadioButtonGroup( "Look&Feel", "Mouse Selection", "0", 2, 2, mouseSelection, 4, mouseGeneralGroup, "myLook&FeelRadio", true, PAGE_MOUSE ); + mouseRadio->layout()->setMargin( 0 ); + mouseGeneralGrid->addWidget( mouseRadio, 0, 0 ); + connect( mouseRadio, TQ_SIGNAL( clicked(int) ), TQ_SLOT( slotSelectionModeChanged() ) ); + + mouseLayout->addMultiCellWidget( mouseGeneralGroup, 0,0, 0,1 ); + + // -------------- Details ----------------- + TQGroupBox *mouseDetailGroup = createFrame( i18n( "Details" ), tab_mouse, "mouseDetailGroup" ); + TQGridLayout *mouseDetailGrid = createGridLayout( mouseDetailGroup->layout() ); + mouseDetailGrid->setSpacing( 0 ); + mouseDetailGrid->setMargin( 5 ); + + KONFIGURATOR_NAME_VALUE_TIP singleOrDoubleClick[] = + { + // name value tooltip + { i18n( "Double-click selects (classic)" ), "0", i18n( "A single click on a file will select and focus, a double click opens the file or steps into the directory." ) }, + { i18n( "Obey TDE's global selection policy" ), "1", i18n( "<p>Use TDE's global setting:</p><p><i>Trinity Control Center -> Peripherals -> Mouse</i></p>" ) } + }; + KonfiguratorRadioButtons *clickRadio = createRadioButtonGroup( "Look&Feel", "Single Click Selects", "0", 1, 0, singleOrDoubleClick, 2, mouseDetailGroup, "myLook&FeelRadio0", true, PAGE_MOUSE ); + clickRadio->layout()->setMargin( 0 ); + mouseDetailGrid->addWidget( clickRadio, 0, 0 ); + + KONFIGURATOR_CHECKBOX_PARAM mouseCheckboxesParam[] = + { + // {cfg_class, cfg_name, default + // text, restart, + // tooltip } + {"Custom Selection Mode", "TQt Selection", _TQtSelection, + i18n( "Based on TDE's selection mode" ), true, + i18n( "If checked, use a mode based on TDE's style." ) }, + {"Custom Selection Mode", "Left Selects", _LeftSelects, + i18n( "Left mouse button selects" ), true, + i18n( "If checked, left clicking an item will select it." ) }, + {"Custom Selection Mode", "Left Preserves", _LeftPreserves, + i18n( "Left mouse button preserves selection" ), true, + i18n( "If checked, left clicking an item will select it, but will not unselect other, already selected items." ) }, + {"Custom Selection Mode", "ShiftCtrl Left Selects", _ShiftCtrlLeft, + i18n( "Shift/Ctrl-Left mouse button selects" ), true, + i18n( "If checked, shift/ctrl left clicking will select items. \nNote: This is meaningless if 'Left Button Selects' is checked." ) }, + {"Custom Selection Mode", "Right Selects", _RightSelects, + i18n( "Right mouse button selects" ), true, + i18n( "If checked, right clicking an item will select it." ) }, + {"Custom Selection Mode", "Right Preserves", _RightPreserves, + i18n( "Right mouse button preserves selection" ), true, + i18n( "If checked, right clicking an item will select it, but will not unselect other, already selected items." ) }, + {"Custom Selection Mode", "ShiftCtrl Right Selects", _ShiftCtrlRight, + i18n( "Shift/Ctrl-Right mouse button selects" ), true, + i18n( "If checked, shift/ctrl right clicking will select items. \nNote: This is meaningless if 'Right Button Selects' is checked." ) }, + {"Custom Selection Mode", "Space Moves Down", _SpaceMovesDown, + i18n( "Spacebar moves down" ), true, + i18n( "If checked, pressing the spacebar will select the current item and move down. \nOtherwise, current item is selected, but remains the current item." ) }, + {"Custom Selection Mode", "Space Calc Space", _SpaceCalcSpace, + i18n( "Spacebar calculates disk space" ), true, + i18n( "If checked, pressing the spacebar while the current item is a folder, will (except from selecting the folder) \ncalculate space occupied by the folder (recursively)." ) }, + {"Custom Selection Mode", "Insert Moves Down", _InsertMovesDown, + i18n( "Insert moves down" ), true, + i18n( "If checked, pressing INSERT will select the current item, and move down to the next item. \nOtherwise, current item is not changed." ) }, + {"Custom Selection Mode", "Immediate Context Menu", _ImmediateContextMenu, + i18n( "Right clicking pops context menu immediately" ), true, + i18n( "If checked, right clicking will result in an immediate showing of the context menu. \nOtherwise, user needs to click and hold the right mouse button for 500ms." ) }, + }; + + + mouseCheckboxes = createCheckBoxGroup(1, 0, mouseCheckboxesParam, 11 /*count*/, mouseDetailGroup, "customMouseModeChecks", PAGE_MOUSE); + mouseDetailGrid->addWidget( mouseCheckboxes, 1, 0 ); + + mouseLayout->addWidget( mouseDetailGroup, 1,0 ); + + // Disable the details-button if not in custom-mode + slotSelectionModeChanged(); + + // -------------- Preview ----------------- + TQGroupBox *mousePreviewGroup = createFrame( i18n( "Preview" ), tab_mouse, "mousePreviewGroup" ); + TQGridLayout *mousePreviewGrid = createGridLayout( mousePreviewGroup->layout() ); + // TODO preview + mousePreview = new TQListView( mousePreviewGroup, "mousePreview" ); + mousePreviewGrid->addWidget( mousePreview, 0 ,0 ); + mousePreviewGroup->setEnabled(false); // TODO re-enable once the preview is implemented + // ------------------------------------------ + mouseLayout->addWidget( mousePreviewGroup, 1,1 ); +} + +void KgLookFeel::slotDisable() +{ + bool isNewStyleQuickSearch = quicksearchCheckboxes->find( "New Style Quicksearch" )->isChecked(); + quicksearchCheckboxes->find( "Case Sensitive Quicksearch" )->setEnabled( isNewStyleQuickSearch ); +} + +void KgLookFeel::slotEnablePanelToolbar() +{ + bool enableTB = panelToolbarActive->find("Panel Toolbar visible")->isChecked(); + pnlcbs->find( "Root Button Visible" )->setEnabled(enableTB); + pnlcbs->find( "Home Button Visible" )->setEnabled(enableTB); + pnlcbs->find( "Up Button Visible" )->setEnabled(enableTB); + pnlcbs->find( "Equal Button Visible" )->setEnabled(enableTB); + pnlcbs->find( "Open Button Visible" )->setEnabled(enableTB); + pnlcbs->find("SyncBrowse Button Visible")->setEnabled(enableTB); +} + +void KgLookFeel::slotSelectionModeChanged() { + bool enable = mouseRadio->find( i18n("Custom Selection Mode") )->isChecked(); + mouseCheckboxes->find( "TQt Selection" )->setEnabled( enable ); + mouseCheckboxes->find( "Left Selects" )->setEnabled( enable ); + mouseCheckboxes->find( "Left Preserves" )->setEnabled( enable ); + mouseCheckboxes->find( "ShiftCtrl Left Selects" )->setEnabled( enable ); + mouseCheckboxes->find( "Right Selects" )->setEnabled( enable ); + mouseCheckboxes->find( "Right Preserves" )->setEnabled( enable ); + mouseCheckboxes->find( "ShiftCtrl Right Selects" )->setEnabled( enable ); + mouseCheckboxes->find( "Space Moves Down" )->setEnabled( enable ); + mouseCheckboxes->find( "Space Calc Space" )->setEnabled( enable ); + mouseCheckboxes->find( "Insert Moves Down" )->setEnabled( enable ); + mouseCheckboxes->find( "Immediate Context Menu" )->setEnabled( enable ); +} + +int KgLookFeel::activeSubPage() { + return tabWidget->currentPageIndex(); +} + +#include "kglookfeel.moc" + diff --git a/src/app/Konfigurator/kglookfeel.h b/src/app/Konfigurator/kglookfeel.h new file mode 100644 index 0000000..dea119a --- /dev/null +++ b/src/app/Konfigurator/kglookfeel.h @@ -0,0 +1,70 @@ +/*************************************************************************** + kglookfeel.h - description + ------------------- + copyright : (C) 2003 by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + H e a d e r F i l e + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef __KGLOOKFEEL_H__ +#define __KGLOOKFEEL_H__ + +#include "konfiguratorpage.h" + +class TQListView; + +class KgLookFeel : public KonfiguratorPage +{ + TQ_OBJECT + + +public: + KgLookFeel( bool first, TQWidget* parent=0, const char* name=0 ); + + virtual int activeSubPage(); + +protected: + KonfiguratorCheckBoxGroup *cbs; + KonfiguratorCheckBoxGroup* quicksearchCheckboxes; + KonfiguratorCheckBoxGroup *pnlcbs; + KonfiguratorCheckBoxGroup *panelToolbarActive; + KonfiguratorRadioButtons *mouseRadio; + KonfiguratorCheckBoxGroup *mouseCheckboxes; + TQListView* mousePreview; + +protected slots: + void slotDisable(); + void slotEnablePanelToolbar(); + void slotSelectionModeChanged(); + +private: + void setupOperationTab(); + void setupPanelTab(); + void setupPanelToolbarTab(); + void setupMouseModeTab(); + TQTabWidget *tabWidget; +}; + +#endif /* __KGLOOKFEEL_H__ */ diff --git a/src/app/Konfigurator/kgprotocols.cpp b/src/app/Konfigurator/kgprotocols.cpp new file mode 100644 index 0000000..1dcc81f --- /dev/null +++ b/src/app/Konfigurator/kgprotocols.cpp @@ -0,0 +1,419 @@ +/*************************************************************************** + KgProtocols.cpp - description + ------------------- + copyright : (C) 2004 by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "kgprotocols.h" +#include "../krusader.h" +#include "../krservices.h" +#include <tdelocale.h> +#include <kprotocolinfo.h> +#include <kmimetype.h> +#include <tqvbox.h> +#include <tqheader.h> +#include <kiconloader.h> +#include <tqwhatsthis.h> + +TQString KgProtocols::defaultProtocols = "krarc,iso,tar"; +TQString KgProtocols::defaultIsoMimes = "application/x-iso"; +TQString KgProtocols::defaultKrarcMimes = "application/x-7z,application/x-7z-compressed," + "application/x-ace,application/x-ace-compressed," + "application/x-arj,application/x-arj-compressed," + "application/x-bzip2," + "application/x-cpio,application/x-deb," + "application/x-debian-package," + "application/x-gzip,application/x-jar," + "application/x-lha,application/x-lha-compressed," + "application/x-rar," + "application/x-rpm," + "application/x-xz," + "application/x-zip"; +TQString KgProtocols::defaultTarMimes = "application/x-tar,application/x-tarz," + "application/x-compressed-tar," + "application/x-tbz,application/x-tgz,application/x-txz"; + +KgProtocols::KgProtocols( bool first, TQWidget* parent, const char* name ) : + KonfiguratorPage( first, parent, name ) +{ + TQGridLayout *KgProtocolsLayout = new TQGridLayout( parent ); + KgProtocolsLayout->setSpacing( 6 ); + + // -------------------------- LINK VIEW ---------------------------------- + + TQGroupBox *linkGrp = createFrame( i18n( "Links" ), parent, "linkGrp" ); + TQGridLayout *linkGrid = createGridLayout( linkGrp->layout() ); + + linkList = new TQListView( linkGrp, "linkList" ); + linkList->addColumn( i18n( "Defined Links" ) ); + linkList->header()->setStretchEnabled( true, 0 ); + linkList->setRootIsDecorated( true ); + + linkGrid->addWidget( linkList, 0, 0 ); + KgProtocolsLayout->addMultiCellWidget( linkGrp, 0 ,1, 0, 0 ); + + // -------------------------- BUTTONS ---------------------------------- + + TQVBox *vbox1 = new TQVBox( parent, "vbox1" ) ; + + addSpacer( vbox1 ); + btnAddProtocol = new TQPushButton( vbox1, "btnAddProtocolButton" ); + btnAddProtocol->setPixmap( krLoader->loadIcon( "1leftarrow", TDEIcon::Small ) ); + TQWhatsThis::add( btnAddProtocol, i18n( "Add protocol to the link list." ) ); + btnRemoveProtocol = new TQPushButton( vbox1, "btnRemoveProtocolButton" ); + btnRemoveProtocol->setPixmap( krLoader->loadIcon( "1rightarrow", TDEIcon::Small ) ); + TQWhatsThis::add( btnRemoveProtocol, i18n( "Remove protocol from the link list." ) ); + addSpacer( vbox1 ); + + KgProtocolsLayout->addWidget( vbox1, 0 ,1 ); + + TQVBox *vbox2 = new TQVBox( parent, "vbox2" ) ; + + addSpacer( vbox2 ); + btnAddMime = new TQPushButton( vbox2, "btnAddMimeButton" ); + btnAddMime->setPixmap( krLoader->loadIcon( "1leftarrow", TDEIcon::Small ) ); + TQWhatsThis::add( btnAddMime, i18n( "Add mime to the selected protocol on the link list." ) ); + btnRemoveMime = new TQPushButton( vbox2, "btnRemoveMimeButton" ); + btnRemoveMime->setPixmap( krLoader->loadIcon( "1rightarrow", TDEIcon::Small ) ); + TQWhatsThis::add( btnRemoveMime, i18n( "Remove mime from the link list." ) ); + addSpacer( vbox2 ); + + KgProtocolsLayout->addWidget( vbox2, 1 ,1 ); + + // -------------------------- PROTOCOLS LISTBOX ---------------------------------- + + TQGroupBox *protocolGrp = createFrame( i18n( "Protocols" ), parent, "protocolGrp" ); + TQGridLayout *protocolGrid = createGridLayout( protocolGrp->layout() ); + + protocolList = new TQListBox( protocolGrp, "protocolList" ); + loadListCapableProtocols(); + protocolGrid->addWidget( protocolList, 0, 0 ); + + KgProtocolsLayout->addWidget( protocolGrp, 0 ,2 ); + + // -------------------------- MIMES LISTBOX ---------------------------------- + + TQGroupBox *mimeGrp = createFrame( i18n( "Mimes" ), parent, "mimeGrp" ); + TQGridLayout *mimeGrid = createGridLayout( mimeGrp->layout() ); + + mimeList = new TQListBox( mimeGrp, "protocolList" ); + loadMimes(); + mimeGrid->addWidget( mimeList, 0, 0 ); + + KgProtocolsLayout->addWidget( mimeGrp, 1 ,2 ); + + // -------------------------- CONNECT TABLE ---------------------------------- + + connect( protocolList, TQ_SIGNAL( selectionChanged() ), this, TQ_SLOT( slotDisableButtons() ) ); + connect( linkList, TQ_SIGNAL( selectionChanged() ), this, TQ_SLOT( slotDisableButtons() ) ); + connect( mimeList, TQ_SIGNAL( selectionChanged() ), this, TQ_SLOT( slotDisableButtons() ) ); + connect( linkList, TQ_SIGNAL( currentChanged( TQListViewItem *) ), this, TQ_SLOT( slotDisableButtons() ) ); + connect( btnAddProtocol, TQ_SIGNAL( clicked() ) , this, TQ_SLOT( slotAddProtocol() ) ); + connect( btnRemoveProtocol, TQ_SIGNAL( clicked() ) , this, TQ_SLOT( slotRemoveProtocol() ) ); + connect( btnAddMime, TQ_SIGNAL( clicked() ) , this, TQ_SLOT( slotAddMime() ) ); + connect( btnRemoveMime, TQ_SIGNAL( clicked() ) , this, TQ_SLOT( slotRemoveMime() ) ); + + loadInitialValues(); + slotDisableButtons(); +} + +TQWidget* KgProtocols::addSpacer( TQWidget *parent, const char *widgetName ) +{ + TQWidget *widget = new TQWidget( parent, widgetName ); + TQVBoxLayout *vboxlayout = new TQVBoxLayout( widget ); + TQSpacerItem* spacer = new TQSpacerItem( 20, 20, TQSizePolicy::Minimum, TQSizePolicy::Expanding ); + vboxlayout->addItem( spacer ); + return widget; +} + +void KgProtocols::loadListCapableProtocols() +{ + TQStringList protocols = KProtocolInfo::protocols(); + protocols.sort(); + + for ( TQStringList::Iterator it = protocols.begin(); it != protocols.end();) + { + if( !KProtocolInfo::supportsListing( *it ) ) + { + it = protocols.remove( it ); + continue; + } + ++it; + } + protocolList->insertStringList( protocols ); +} + +void KgProtocols::loadMimes() +{ + KMimeType::List mimes = KMimeType::allMimeTypes(); + + for( TQValueListIterator<KMimeType::Ptr> it = mimes.begin(); it != mimes.end(); it++ ) + mimeList->insertItem( (*it)->name() ); + + mimeList->sort(); +} + +void KgProtocols::slotDisableButtons() +{ + btnAddProtocol->setEnabled( protocolList->selectedItem() != 0 ); + TQListViewItem *listViewItem = linkList->currentItem(); + bool isProtocolSelected = ( listViewItem == 0 ? false : listViewItem->parent() == 0 ); + btnRemoveProtocol->setEnabled( isProtocolSelected ); + btnAddMime->setEnabled( listViewItem != 0 && mimeList->selectedItem() != 0 ); + btnRemoveMime->setEnabled( listViewItem == 0 ? false : listViewItem->parent() != 0 ); + + if( linkList->currentItem() == 0 && linkList->firstChild() != 0 ) + linkList->setCurrentItem( linkList->firstChild() ); + if( linkList->selectedItem() == 0 && linkList->currentItem() != 0 ) + linkList->setSelected( linkList->currentItem(), true ); +} + +void KgProtocols::slotAddProtocol() +{ + TQListBoxItem *item = protocolList->selectedItem(); + if( item ) + { + addProtocol( item->text(), true ); + slotDisableButtons(); + emit sigChanged(); + } +} + +void KgProtocols::addProtocol( TQString name, bool changeCurrent ) +{ + TQListBoxItem *item = protocolList->findItem( name, ExactMatch ); + if( item ) + { + protocolList->removeItem( protocolList->index( item ) ); + TQListViewItem *listViewItem = new TQListViewItem( linkList, name ); + listViewItem->setPixmap( 0, krLoader->loadIcon( "application-x-executable", TDEIcon::Small ) ); + + if( changeCurrent ) + linkList->setCurrentItem( listViewItem ); + } +} + +void KgProtocols::slotRemoveProtocol() +{ + TQListViewItem *item = linkList->currentItem(); + if( item ) + { + removeProtocol( item->text( 0 ) ); + slotDisableButtons(); + emit sigChanged(); + } +} + +void KgProtocols::removeProtocol( TQString name ) +{ + TQListViewItem *item = linkList->findItem( name, 0 ); + if( item ) + { + while( item->childCount() != 0 ) + removeMime( item->firstChild()->text( 0 ) ); + + linkList->takeItem( item ); + protocolList->insertItem( name ); + protocolList->sort(); + } +} + +void KgProtocols::slotAddMime() +{ + TQListBoxItem *item = mimeList->selectedItem(); + if( item && linkList->currentItem() != 0 ) + { + TQListViewItem *itemToAdd = linkList->currentItem(); + if( itemToAdd->parent() ) + itemToAdd = itemToAdd->parent(); + + addMime( item->text(), itemToAdd->text( 0 ) ); + slotDisableButtons(); + emit sigChanged(); + } +} + +void KgProtocols::addMime( TQString name, TQString protocol ) +{ + TQListBoxItem *item = mimeList->findItem( name, ExactMatch ); + TQListViewItem *currentListItem = linkList->findItem( protocol, 0 ); + + if( item && currentListItem && currentListItem->parent() == 0 ) + { + mimeList->removeItem( mimeList->index( item ) ); + TQListViewItem *listViewItem = new TQListViewItem( currentListItem, name ); + listViewItem->setPixmap( 0, krLoader->loadIcon( "mime", TDEIcon::Small ) ); + currentListItem->setOpen( true ); + } +} + +void KgProtocols::slotRemoveMime() +{ + TQListViewItem *item = linkList->currentItem(); + if( item ) + { + removeMime( item->text( 0 ) ); + slotDisableButtons(); + emit sigChanged(); + } +} + +void KgProtocols::removeMime( TQString name ) +{ + TQListViewItem *currentMimeItem = linkList->findItem( name, 0 ); + + if( currentMimeItem && currentMimeItem->parent() != 0 ) + { + mimeList->insertItem( currentMimeItem->text( 0 ) ); + mimeList->sort(); + currentMimeItem->parent()->takeItem( currentMimeItem ); + } +} + +void KgProtocols::loadInitialValues() +{ + while( linkList->childCount() != 0 ) + removeProtocol( linkList->firstChild()->text( 0 ) ); + + krConfig->setGroup( "Protocols" ); + TQStringList protList = krConfig->readListEntry( "Handled Protocols" ); + + for( TQStringList::Iterator it = protList.begin(); it != protList.end(); it++ ) + { + addProtocol( *it ); + + TQStringList mimes = krConfig->readListEntry( TQString( "Mimes For %1" ).arg( *it ) ); + + for( TQStringList::Iterator it2 = mimes.begin(); it2 != mimes.end(); it2++ ) + addMime( *it2, *it ); + } + + if( linkList->firstChild() != 0 ) + linkList->setCurrentItem( linkList->firstChild() ); + slotDisableButtons(); +} + +void KgProtocols::setDefaults() +{ + while( linkList->childCount() != 0 ) + removeProtocol( linkList->firstChild()->text( 0 ) ); + + addProtocol( "iso" ); + addMime( "application/x-iso", "iso" ); + + addProtocol( "krarc" ); + TQStringList krarcMimes = TQStringList::split( ',', defaultKrarcMimes ); + for( TQStringList::Iterator it = krarcMimes.begin(); it != krarcMimes.end(); it++ ) + addMime( *it, "krarc" ); + + addProtocol( "tar" ); + TQStringList tarMimes = TQStringList::split( ',', defaultTarMimes ); + for( TQStringList::Iterator it = tarMimes.begin(); it != tarMimes.end(); it++ ) + addMime( *it, "tar" ); + + slotDisableButtons(); + + if( isChanged() ) + emit sigChanged(); +} + +bool KgProtocols::isChanged() +{ + krConfig->setGroup( "Protocols" ); + TQStringList protList = krConfig->readListEntry( "Handled Protocols" ); + + if( (int)protList.count() != linkList->childCount() ) + return true; + + TQListViewItem *item = linkList->firstChild(); + while( item ) + { + if( !protList.contains( item->text( 0 ) ) ) + return true; + + TQStringList mimes = krConfig->readListEntry( TQString( "Mimes For %1" ).arg( item->text( 0 ) ) ); + + if( (int)mimes.count() != item->childCount() ) + return true; + TQListViewItem *childs = item->firstChild(); + while( childs ) + { + if( !mimes.contains( childs->text( 0 ) ) ) + return true; + childs = childs->nextSibling(); + } + + item = item->nextSibling(); + } + + return false; +} + +bool KgProtocols::apply() +{ + krConfig->setGroup( "Protocols" ); + + TQStringList protocolList; + + TQListViewItem *item = linkList->firstChild(); + while( item ) + { + protocolList.append( item->text( 0 ) ); + + TQStringList mimes; + TQListViewItem *childs = item->firstChild(); + while( childs ) + { + mimes.append( childs->text( 0 ) ); + childs = childs->nextSibling(); + } + krConfig->writeEntry( TQString( "Mimes For %1" ).arg( item->text( 0 ) ), mimes ); + + item = item->nextSibling(); + } + krConfig->writeEntry( "Handled Protocols", protocolList ); + krConfig->sync(); + + KrServices::clearProtocolCache(); + + emit sigChanged(); + return false; +} + +void KgProtocols::init() +{ + if( !krConfig->groupList().contains( "Protocols" ) ) + { + krConfig->setGroup( "Protocols" ); + krConfig->writeEntry( "Handled Protocols", defaultProtocols ); + krConfig->writeEntry( "Mimes For iso", defaultIsoMimes ); + krConfig->writeEntry( "Mimes For krarc", defaultKrarcMimes ); + krConfig->writeEntry( "Mimes For tar", defaultTarMimes ); + } +} + +#include "kgprotocols.moc" diff --git a/src/app/Konfigurator/kgprotocols.h b/src/app/Konfigurator/kgprotocols.h new file mode 100644 index 0000000..c1734b2 --- /dev/null +++ b/src/app/Konfigurator/kgprotocols.h @@ -0,0 +1,87 @@ +/*************************************************************************** + KgProtocols.h - description + ------------------- + copyright : (C) 2004 by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + H e a d e r F i l e + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef __KgProtocols_H__ +#define __KgProtocols_H__ + +#include "konfiguratorpage.h" +#include <tqlistbox.h> +#include <tqpushbutton.h> +#include <tqlistview.h> + +class KgProtocols : public KonfiguratorPage +{ + TQ_OBJECT + + +public: + KgProtocols( bool first, TQWidget* parent=0, const char* name=0 ); + + virtual void loadInitialValues(); + virtual void setDefaults(); + virtual bool apply(); + virtual bool isChanged(); + + static void init(); + +public slots: + void slotDisableButtons(); + void slotAddProtocol(); + void slotRemoveProtocol(); + void slotAddMime(); + void slotRemoveMime(); + +protected: + void loadListCapableProtocols(); + void loadMimes(); + TQWidget* addSpacer( TQWidget *parent, const char *widgetName = 0); + + void addProtocol( TQString name, bool changeCurrent = false ); + void removeProtocol( TQString name ); + void addMime( TQString name, TQString protocol ); + void removeMime( TQString name ); + + TQListView *linkList; + + TQListBox *protocolList; + TQListBox *mimeList; + + TQPushButton *btnAddProtocol; + TQPushButton *btnRemoveProtocol; + TQPushButton *btnAddMime; + TQPushButton *btnRemoveMime; + + static TQString defaultProtocols; + static TQString defaultIsoMimes; + static TQString defaultKrarcMimes; + static TQString defaultTarMimes; +}; + +#endif /* __KgProtocols_H__ */ diff --git a/src/app/Konfigurator/kgstartup.cpp b/src/app/Konfigurator/kgstartup.cpp new file mode 100644 index 0000000..3da548e --- /dev/null +++ b/src/app/Konfigurator/kgstartup.cpp @@ -0,0 +1,117 @@ +/*************************************************************************** + kgstartup.cpp - description + ------------------- + copyright : (C) 2004 by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "kgstartup.h" +#include "../defaults.h" +#include "../GUI/profilemanager.h" +#include "../krusader.h" +#include <tdelocale.h> +#include <klineedit.h> +#include <tqwhatsthis.h> + +KgStartup::KgStartup( bool first, TQWidget* parent, const char* name ) : + KonfiguratorPage( first, parent, name ), profileCombo( 0 ) +{ + TQGridLayout *kgStartupLayout = new TQGridLayout( parent ); + kgStartupLayout->setSpacing( 6 ); + + // --------------------------- PANELS GROUPBOX ---------------------------------- + + TQGroupBox *panelsGrp = createFrame( i18n( "General" ), parent, "panelsGrp" ); + TQGridLayout *panelsGrid = createGridLayout( panelsGrp->layout() ); + + TQString s = "<p><img src='toolbar|kr_profile'></p>" + i18n( "Defines the panel profile used at startup. A panel profile contains:<ul><li>all the tabs paths</li><li>the current tab</li><li>the active panel</li></ul><b><Last session></b> is a special panel profile which is saved automatically when Krusader is closed."); + TQLabel *label = addLabel( panelsGrid, 0, 0, i18n( "Startup profile:" ), panelsGrp, "Startup session" ); + TQWhatsThis::add( label, s ); + TQWhatsThis::add( panelsGrp, s ); + + TQStringList profileList = ProfileManager::availableProfiles( "Panel" ); + profileList.push_front( "<" + i18n( "Last session" ) + ">" ); + + KONFIGURATOR_NAME_VALUE_PAIR comboItems[ profileList.count() ]; + for(unsigned int i=0; i != profileList.count(); i++ ) + comboItems[ i ].text = comboItems[ i ].value = profileList [ i ]; + comboItems[ 0 ].value = ""; + + profileCombo = createComboBox( "Startup", "Starter Profile Name", comboItems[ 0 ].value, comboItems, profileList.count(), panelsGrp, false, false ); + profileCombo->setSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Fixed); + panelsGrid->addWidget( profileCombo, 0, 1 ); + + //------------------------------------------------ + panelsGrid->addMultiCellWidget( createLine( panelsGrp, "lookSep3" ), 1, 1, 0, 1 ); + + KONFIGURATOR_CHECKBOX_PARAM settings[] = + { // cfg_class cfg_name default text restart tooltip + {"Look&Feel","Show splashscreen", _ShowSplashScreen, i18n( "Show splashscreen" ), false, i18n( "Display a splashscreen when starting krusader.") }, + {"Look&Feel","Single Instance Mode", _SingleInstanceMode, i18n( "Single instance mode" ), false, i18n( "Only one Krusader instance is allowed to run.") } + }; + + KonfiguratorCheckBoxGroup* cbs = createCheckBoxGroup( 2, 0, settings, 2 /* settings count */, panelsGrp ); + panelsGrid->addMultiCellWidget( cbs, 2, 2, 0, 1 ); + + kgStartupLayout->addWidget( panelsGrp, 0, 0 ); + + // ------------------------ USERINTERFACE GROUPBOX ------------------------------ + + TQGroupBox *uiGrp = createFrame( i18n( "User Interface" ), parent, "uiGrp" ); + TQGridLayout *uiGrid = createGridLayout( uiGrp->layout() ); + + KONFIGURATOR_CHECKBOX_PARAM uiCheckBoxes[] = + { // cfg_class cfg_name default text restart ToolTip + {"Startup","UI Save Settings", _UiSave, i18n( "Save settings on exit" ), false, i18n( "Check the state of the user interface components and restore them to their condition when last shutdown." ) }, + {"Startup","Show tool bar", _ShowToolBar, i18n( "Show toolbar" ), false, i18n( "Toolbar will be visible after startup." ) }, + {"Startup","Show status bar", _ShowStatusBar, i18n( "Show statusbar" ), false, i18n( "Statusbar will be visible after startup." ) }, + {"Startup","Show FN Keys", _ShowFNkeys, i18n( "Show function keys" ), false, i18n( "Function keys will be visible after startup." ) }, + {"Startup","Show Cmd Line", _ShowCmdline, i18n( "Show command line" ), false, i18n( "Command line will be visible after startup." ) }, + {"Startup","Show Terminal Emulator",_ShowTerminalEmulator, i18n( "Show terminal emulator" ), false, i18n( "Terminal emulator will be visible after startup." ) }, + {"Startup","Remember Position", _RememberPos, i18n( "Save last position, size and panel settings" ), false, i18n( "<p>At startup, the main window will resize itself to the size it was when last shutdown. It will also appear in the same location of the screen, having panels sorted and aligned as they were before.</p><p>If this option is disabled, you can use the menu <i>Window -> Save Position</i> option to manually set the main window's size and position at startup.</p>" ) }, + {"Startup","Start To Tray", _StartToTray, i18n( "Start to tray" ), false, i18n( "Krusader starts to tray (if minimize to tray is set), without showing the main window" ) }, + }; + + uiCbGroup = createCheckBoxGroup( 2, 0, uiCheckBoxes, 8, uiGrp ); + connect( uiCbGroup->find( "UI Save Settings" ), TQ_SIGNAL( stateChanged( int ) ), this, TQ_SLOT( slotDisable() ) ); + + uiGrid->addWidget( uiCbGroup, 1, 0 ); + + slotDisable(); + + kgStartupLayout->addWidget( uiGrp, 1, 0 ); +} + +void KgStartup::slotDisable() +{ + bool isUiSave = !uiCbGroup->find( "UI Save Settings" )->isChecked(); + + int i=1; + while( uiCbGroup->find( i ) ) + uiCbGroup->find( i++ )->setEnabled( isUiSave ); +} + +#include "kgstartup.moc" diff --git a/src/app/Konfigurator/kgstartup.h b/src/app/Konfigurator/kgstartup.h new file mode 100644 index 0000000..3376cad --- /dev/null +++ b/src/app/Konfigurator/kgstartup.h @@ -0,0 +1,53 @@ +/*************************************************************************** + kgstartup.h - description + ------------------- + copyright : (C) 2004 by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + H e a d e r F i l e + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef __KGSTARTUP_H__ +#define __KGSTARTUP_H__ + +#include "konfiguratorpage.h" + +class KgStartup : public KonfiguratorPage +{ + TQ_OBJECT + + +public: + KgStartup( bool first, TQWidget* parent=0, const char* name=0 ); + +public slots: + void slotDisable(); + +protected: + KonfiguratorRadioButtons *saveRadio; + KonfiguratorCheckBoxGroup *uiCbGroup; + KonfiguratorComboBox *profileCombo; +}; + +#endif /* __KGSTARTUP_H__ */ diff --git a/src/app/Konfigurator/kguseractions.cpp b/src/app/Konfigurator/kguseractions.cpp new file mode 100644 index 0000000..ba7436f --- /dev/null +++ b/src/app/Konfigurator/kguseractions.cpp @@ -0,0 +1,106 @@ +/*************************************************************************** + kguseractions.cpp - description + ------------------- + copyright : (C) 2004 by Jonas B�r + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "kguseractions.h" +#include "../defaults.h" +#include "../krusader.h" +#include "../ActionMan/actionman.h" + +#include <tdelocale.h> +#include <kpushbutton.h> +#include <kdebug.h> + + +KgUserActions::KgUserActions( bool first, TQWidget* parent, const char* name ) : + KonfiguratorPage( first, parent, name ) +{ + TQGridLayout *kgUserActionLayout = new TQGridLayout( parent, 2, 1, + 0 /* margin */, 6 /* spacing */, "kgUserActionLayout" ); + + // ============= Info Group ============= + TQGroupBox *InfoGroup = createFrame( i18n( "Information" ), parent, "kgUserActionInfoGroup" ); + TQGridLayout *InfoGrid = createGridLayout( InfoGroup->layout() ); + + // terminal for the UserActions + TQLabel *labelInfo = new TQLabel( i18n( + "Here you can configure settings about useractions.\n" + "To set up, configure and manage your useractions please use ActionMan." + ), InfoGroup, "InformationLabel" ); + InfoGrid->addWidget( labelInfo, 0, 0 ); + KPushButton *actionmanButton = new KPushButton( i18n("Start ActionMan"), InfoGroup, "actionmanButton"); + connect( actionmanButton, TQ_SIGNAL( clicked() ), TQ_SLOT( startActionMan() ) ); + InfoGrid->addWidget( actionmanButton, 1, 0 ); + + kgUserActionLayout->addWidget( InfoGroup, 0 ,0 ); + + // ============= Terminal Group ============= + TQGroupBox *terminalGroup = createFrame( i18n( "Terminal execution" ), parent, "kgUserActionTerminalGroup" ); + TQGridLayout *terminalGrid = createGridLayout( terminalGroup->layout() ); + + // terminal for the UserActions + TQLabel *labelTerminal = new TQLabel( i18n( "Terminal for UserActions:" ), + terminalGroup, "TerminalLabel" ); + terminalGrid->addWidget( labelTerminal, 0, 0 ); + KonfiguratorURLRequester *urlReqUserActions = createURLRequester( "UserActions", + "Terminal", _UserActions_Terminal, terminalGroup, false ); + terminalGrid->addWidget( urlReqUserActions, 0, 1 ); + + kgUserActionLayout->addWidget( terminalGroup, 1 ,0 ); + + // ============= Outputcollection Group ============= + TQGroupBox *outputGroup = createFrame( i18n( "Output collection" ), parent, "kgUserActionOutputGroup" ); + TQGridLayout *outputGrid = createGridLayout( outputGroup->layout() ); + + TQHBox *hbox; + hbox = new TQHBox( outputGroup, "HBoxNormalFont" ); + new TQLabel( i18n( "Normal font:" ), hbox, "NormalFontLabel" ); + createFontChooser( "UserActions", "Normal Font", _UserActions_NormalFont, hbox ); + createSpacer ( hbox ); + outputGrid->addWidget( hbox, 2, 0 ); + + hbox = new TQHBox( outputGroup, "HBoxFixedFont" ); + new TQLabel( i18n( "Font with fixed width:" ), hbox, "FixedFontLabel" ); + createFontChooser( "UserActions", "Fixed Font", _UserActions_FixedFont, hbox ); + createSpacer ( hbox ); + outputGrid->addWidget( hbox, 3, 0 ); + + KonfiguratorCheckBox *useFixed = createCheckBox( "UserActions", "Use Fixed Font", _UserActions_UseFixedFont, + i18n("Use fixed width font as default"), outputGroup ); + outputGrid->addWidget( useFixed, 4, 0 ); + + kgUserActionLayout->addWidget( outputGroup, 2 ,0 ); +} + +void KgUserActions::startActionMan() { + ActionMan actionMan( static_cast<TQWidget*>(parent()) ); +} + + +#include "kguseractions.moc" diff --git a/src/app/Konfigurator/kguseractions.h b/src/app/Konfigurator/kguseractions.h new file mode 100644 index 0000000..12b265c --- /dev/null +++ b/src/app/Konfigurator/kguseractions.h @@ -0,0 +1,52 @@ +/*************************************************************************** + kguseractions.h - description + ------------------- + copyright : (C) 2004 by Jonas B�r + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + H e a d e r F i l e + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef __KGUSERACTIONS_H__ +#define __KGUSERACTIONS_H__ + +#include "konfiguratorpage.h" + +class KPushButton; +class ActionProperty; +class UserActionListView; + +class KgUserActions : public KonfiguratorPage +{ + TQ_OBJECT + + +public: + KgUserActions( bool first, TQWidget* parent=0, const char* name=0 ); + +public slots: + void startActionMan(); +}; + +#endif /* __KGUSERACTIONS_H__ */ diff --git a/src/app/Konfigurator/kgwelcome.cpp b/src/app/Konfigurator/kgwelcome.cpp new file mode 100644 index 0000000..d8a0a62 --- /dev/null +++ b/src/app/Konfigurator/kgwelcome.cpp @@ -0,0 +1,50 @@ +/*************************************************************************** + kgwelcome.cpp - description + ------------------- + copyright : (C) 2004 by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "kgwelcome.h" +#include <kstandarddirs.h> + +KgWelcome::KgWelcome( bool first, TQWidget* parent, const char* name ) : + KonfiguratorPage( first, parent, name ) +{ + TQGridLayout *kgWelcomeLayout = new TQGridLayout( parent ); + kgWelcomeLayout->setSpacing( 6 ); + + TQString pix=TDEGlobal::dirs()->findResource("appdata","konfig_small.jpg"); + TQPixmap image0( pix ); + + TQLabel *pixmapLabel = new TQLabel( parent, "pixmapLabel" ); + pixmapLabel->setPixmap( image0 ); + pixmapLabel->setScaledContents( true ); + + kgWelcomeLayout->addWidget( pixmapLabel, 0, 0 ); +} + +#include "kgwelcome.moc" diff --git a/src/app/Konfigurator/kgwelcome.h b/src/app/Konfigurator/kgwelcome.h new file mode 100644 index 0000000..e584150 --- /dev/null +++ b/src/app/Konfigurator/kgwelcome.h @@ -0,0 +1,45 @@ +/*************************************************************************** + kgwelcome.h - description + ------------------- + copyright : (C) 2004 by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + H e a d e r F i l e + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef __KGWELCOME_H__ +#define __KGWELCOME_H__ + +#include "konfiguratorpage.h" + +class KgWelcome : public KonfiguratorPage +{ + TQ_OBJECT + + +public: + KgWelcome( bool first, TQWidget* parent=0, const char* name=0 ); +}; + +#endif /* __KGWELCOME_H__ */ diff --git a/src/app/Konfigurator/konfigurator.cpp b/src/app/Konfigurator/konfigurator.cpp new file mode 100644 index 0000000..0dd09e3 --- /dev/null +++ b/src/app/Konfigurator/konfigurator.cpp @@ -0,0 +1,220 @@ +/*************************************************************************** + konfigurator.cpp + ------------------- + copyright : (C) 2000 by Shie Erlich & Rafi Yanai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + + + +#include "konfigurator.h" +#include "../krusader.h" +#include "../Dialogs/krdialogs.h" +#include "../kicons.h" + +#include <tdefiledialog.h> +#include <tqwidget.h> +#include <tdelocale.h> +#include <tdeglobal.h> +#include <kstandarddirs.h> +#include <tdemessagebox.h> +#include "../defaults.h" +#include "../krusaderview.h" +#include "../GUI/kfnkeys.h" + +// the frames +#include "kgwelcome.h" +#include "kgstartup.h" +#include "kglookfeel.h" +#include "kggeneral.h" +#include "kgadvanced.h" +#include "kgarchives.h" +#include "kgdependencies.h" +#include "kgcolors.h" +#include "kguseractions.h" +#include "kgprotocols.h" + +Konfigurator::Konfigurator( bool f, int startPage ) : KDialogBase(0,0,true,"Konfigurator", + KDialogBase::Help | KDialogBase::User1 | KDialogBase::Apply | KDialogBase::Cancel, + KDialogBase::User1, false, i18n("Defaults") ), firstTime(f), internalCall( false ), + restartGUI( false ) +{ + setPlainCaption(i18n("Konfigurator - Creating Your Own Krusader")); + kgFrames.setAutoDelete(true); + widget=new KJanusWidget(this,0,KJanusWidget::IconList); + + setButtonCancel(i18n("Close")); + + setHelp("konfigurator"); + + connect( widget, TQ_SIGNAL( aboutToShowPage(TQWidget *) ), this, TQ_SLOT( slotPageSwitch() ) ); + connect( &restoreTimer, TQ_SIGNAL(timeout()), this, TQ_SLOT(slotRestorePage())); + + createLayout( startPage ); + setMainWidget(widget); + exec(); +} + +void Konfigurator::newContent(KonfiguratorPage *page) +{ + kgFrames.append(page); + connect( page, TQ_SIGNAL( sigChanged() ), this, TQ_SLOT( slotApplyEnable() ) ); +} + +void Konfigurator::createLayout( int startPage ) +{ + // startup + newContent(new KgStartup(firstTime, widget->addPage(i18n("Startup"), + i18n("Krusader's settings upon startup"),TQPixmap(krLoader->loadIcon("kfm_home", + TDEIcon::Desktop,32))))); + // look n' feel + newContent(new KgLookFeel(firstTime, widget->addPage(i18n("Look & Feel"), + i18n("Look & Feel"),TQPixmap(krLoader->loadIcon("preferences-desktop",TDEIcon::Desktop,32))))); + // colors + newContent(new KgColors(firstTime, widget->addPage(i18n("Colors"), + i18n("Colors"),TQPixmap(krLoader->loadIcon("colors",TDEIcon::Desktop,32))))); + // general + newContent(new KgGeneral(firstTime, widget->addPage(i18n("General"), + i18n("Basic Operations"),TQPixmap(krLoader->loadIcon("configure",TDEIcon::Desktop,32))))); + // advanced + newContent(new KgAdvanced(firstTime, widget->addPage(i18n("Advanced"), + i18n("Be sure you know what you're doing!"), + TQPixmap(krLoader->loadIcon("messagebox_warning",TDEIcon::Desktop,32))))); + // archives + newContent(new KgArchives(firstTime, widget->addPage(i18n("Archives"),i18n("Customize the way Krusader deals with archives"), + TQPixmap(krLoader->loadIcon("application-x-tarz",TDEIcon::Desktop,32))))); + // dependencies + newContent(new KgDependencies(firstTime, widget->addPage(i18n("Dependencies"),i18n("Set the full path of the external applications"), + TQPixmap(krLoader->loadIcon("kr_dependencies",TDEIcon::Desktop,32))))); + // useractions + newContent(new KgUserActions(firstTime, widget->addPage(i18n("User Actions"),i18n("Configure your personal actions"), + TQPixmap(krLoader->loadIcon("kr_useractions",TDEIcon::Desktop,32))))); + // protocols + newContent(new KgProtocols(firstTime, widget->addPage(i18n("Protocols"), + i18n("Link mimes to protocols"), TQPixmap(krLoader->loadIcon("about_kde",TDEIcon::Desktop,32))))); + + widget->showPage( widget->pageIndex( kgFrames.at( startPage )->parentWidget() ) ); + slotApplyEnable(); +} + +void Konfigurator::slotUser1() +{ + int ndx = searchPage( lastPage = widget->activePageIndex() ); + kgFrames.at( ndx )->setDefaults(); +} +#include <kdebug.h> +void Konfigurator::slotApply() +{ + int ndx = searchPage( lastPage = widget->activePageIndex() ); + if( kgFrames.at( ndx )->apply() ) + { + restartGUI = true; +// KMessageBox::information(this,i18n("Changes to the GUI will be updated next time you run Krusader."), +// TQString(),"konfigGUInotify"); + } + + // really ugly, but reload the Fn keys just in case - csaba: any better idea? + krApp->mainView->fnKeys->updateShortcuts(); +} + +void Konfigurator::slotCancel() +{ + lastPage = widget->activePageIndex(); + if( slotPageSwitch() ) + reject(); +} + +int Konfigurator::searchPage( int pageNum ) +{ + KonfiguratorPage *page; + int i=0; + + while( ( page = kgFrames.at( i ) ) ) + { + if( pageNum == widget->pageIndex( page->parentWidget() ) ) + return i; + + i++; + } + + return 0; +} + +void Konfigurator::slotApplyEnable() +{ + int ndx = searchPage( lastPage = widget->activePageIndex() ); + enableButtonApply( kgFrames.at( ndx )->isChanged() ); +} + +bool Konfigurator::slotPageSwitch() +{ + int ndx = searchPage( lastPage ); + KonfiguratorPage *currentPage = kgFrames.at( ndx ); + + if( internalCall ) + { + internalCall = false; + return true; + } + + if( currentPage->isChanged() ) + { + int result = KMessageBox::questionYesNoCancel( 0, i18n("The current page has been changed. Do you want to apply changes?" )); + + switch( result ) + { + case KMessageBox::No: + currentPage->loadInitialValues(); + break; + case KMessageBox::Yes: + if( currentPage->apply() ) + { + restartGUI = true; +// KMessageBox::information(this,i18n("Changes to the GUI will be updated next time you run Krusader."), +// TQString(),"konfigGUInotify"); + } + break; + default: + restoreTimer.start( 0, true ); + return false; + } + } + + enableButtonApply( currentPage->isChanged() ); + lastPage = widget->activePageIndex(); + return true; +} + +void Konfigurator::slotRestorePage() +{ + if( lastPage != widget->activePageIndex() ) + { + internalCall = true; + widget->showPage( lastPage ); + } +} + +#include "konfigurator.moc" diff --git a/src/app/Konfigurator/konfigurator.h b/src/app/Konfigurator/konfigurator.h new file mode 100644 index 0000000..8fa884c --- /dev/null +++ b/src/app/Konfigurator/konfigurator.h @@ -0,0 +1,82 @@ +/*************************************************************************** + konfigurator.h + ------------------- + begin : Thu May 4 2000 + copyright : (C) 2000 by Shie Erlich & Rafi Yanai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + H e a d e r F i l e + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + + +#ifndef KONFIGURATOR_H +#define KONFIGURATOR_H + +#include "konfiguratorpage.h" +#include <tqwidget.h> +#include <kdialogbase.h> +#include <kjanuswidget.h> +#include <tqtimer.h> + +class TQLineEdit; +class TQString; + +class Konfigurator : public KDialogBase +{ + TQ_OBJECT + + +public: + Konfigurator( bool f=false, int startPage = 0 ); // true if Konfigurator is run for the first time + ~Konfigurator() {}; + + bool isGUIRestartNeeded() { return restartGUI; } + +protected: + void newContent(KonfiguratorPage *widget);// adds widget into newPage and connects to slot + void createLayout( int startPage ); + +protected slots: + void slotUser1(); + void slotApply(); // actually used for defaults + void slotCancel(); + void slotApplyEnable(); + bool slotPageSwitch(); + void slotRestorePage(); + +private: + int searchPage( int pageNum ); + +private: + TQPtrList<KonfiguratorPage> kgFrames; + KJanusWidget *widget; + bool firstTime; + int lastPage; + bool internalCall; + TQTimer restoreTimer; + bool restartGUI; +}; + +#endif + diff --git a/src/app/Konfigurator/konfiguratoritems.cpp b/src/app/Konfigurator/konfiguratoritems.cpp new file mode 100644 index 0000000..4bbfdb4 --- /dev/null +++ b/src/app/Konfigurator/konfiguratoritems.cpp @@ -0,0 +1,815 @@ +/*************************************************************************** + konfiguratoritems.cpp - description + ------------------- + copyright : (C) 2003 by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + H e a d e r F i l e + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "konfiguratoritems.h" +#include "../krusader.h" +#include <tdelocale.h> +#include <tqpainter.h> +#include <tqpen.h> +#include <tqcolordialog.h> +#include <kiconloader.h> + +KonfiguratorExtension::KonfiguratorExtension( TQObject *obj, TQString cfgClass, TQString cfgName, bool rst, int pg) : + TQObject(), objectPtr( obj ), applyConnected( false ), setDefaultsConnected( false ), + changed( false ), restartNeeded( rst ), subpage(pg), configClass( cfgClass ), configName( cfgName ) +{ +} + +void KonfiguratorExtension::connectNotify( const char *signal ) +{ + TQString signalString = TQString( signal ).replace( " ", "" ); + TQString applyString = TQString( TQ_SIGNAL( applyManually(TQObject *,TQString, TQString) ) ).replace( " ", "" ); + TQString defaultsString = TQString( TQ_SIGNAL( setDefaultsManually(TQObject *) ) ).replace( " ", "" ); + + if( signalString == applyString ) + applyConnected = true; + else if ( signalString == defaultsString ) + setDefaultsConnected = true; + + TQObject::connectNotify( signal ); +} + +bool KonfiguratorExtension::apply() +{ + if( !changed ) + return false; + + if( applyConnected ) + emit applyManually( objectPtr, configClass, configName ); + else + emit applyAuto( objectPtr, configClass, configName ); + + setChanged( false ); + return restartNeeded; +} + +void KonfiguratorExtension::setDefaults() +{ + if( setDefaultsConnected ) + emit setDefaultsManually( objectPtr ); + else + emit setDefaultsAuto( objectPtr ); +} + +void KonfiguratorExtension::loadInitialValue() +{ + emit setInitialValue( objectPtr ); +} + +bool KonfiguratorExtension::isChanged() +{ + return changed; +} + +// KonfiguratorCheckBox class +/////////////////////////////// + +KonfiguratorCheckBox::KonfiguratorCheckBox( TQString cls, TQString name, bool dflt, TQString text, + TQWidget *parent, const char *widgetName, bool rst, int pg ) : TQCheckBox( text, parent, widgetName ), + defaultValue( dflt ) +{ + ext = new KonfiguratorExtension( this, cls, name, rst, pg ); + connect( ext, TQ_SIGNAL( applyAuto(TQObject *,TQString, TQString) ), this, TQ_SLOT( slotApply(TQObject *,TQString, TQString) ) ); + connect( ext, TQ_SIGNAL( setDefaultsAuto(TQObject *) ), this, TQ_SLOT( slotSetDefaults(TQObject *) ) ); + connect( ext, TQ_SIGNAL( setInitialValue(TQObject *) ), this, TQ_SLOT( loadInitialValue() ) ); + + connect( this, TQ_SIGNAL( stateChanged( int ) ), ext, TQ_SLOT( setChanged() ) ); + loadInitialValue(); +} + +KonfiguratorCheckBox::~KonfiguratorCheckBox() +{ + delete ext; +} + +void KonfiguratorCheckBox::loadInitialValue() +{ + krConfig->setGroup( ext->getCfgClass() ); + setChecked( krConfig->readBoolEntry( ext->getCfgName(), defaultValue ) ); + ext->setChanged( false ); +} + +void KonfiguratorCheckBox::slotApply(TQObject *,TQString cls, TQString name) +{ + krConfig->setGroup( cls ); + krConfig->writeEntry( name, isChecked() ); +} + +void KonfiguratorCheckBox::slotSetDefaults(TQObject *) +{ + if( isChecked() != defaultValue ) + setChecked( defaultValue ); +} + +// KonfiguratorSpinBox class +/////////////////////////////// + +KonfiguratorSpinBox::KonfiguratorSpinBox( TQString cls, TQString name, int dflt, int min, int max, + TQWidget *parent, const char *widgetName, bool rst, int pg ) : TQSpinBox( parent, widgetName ), + defaultValue( dflt ) +{ + ext = new KonfiguratorExtension( this, cls, name, rst, pg ); + connect( ext, TQ_SIGNAL( applyAuto(TQObject *,TQString, TQString) ), this, TQ_SLOT( slotApply(TQObject *,TQString, TQString) ) ); + connect( ext, TQ_SIGNAL( setDefaultsAuto(TQObject *) ), this, TQ_SLOT( slotSetDefaults(TQObject *) ) ); + connect( ext, TQ_SIGNAL( setInitialValue(TQObject *) ), this, TQ_SLOT( loadInitialValue() ) ); + + connect( this, TQ_SIGNAL( valueChanged(int) ), ext, TQ_SLOT( setChanged() ) ); + + setMinValue( min ); + setMaxValue( max ); + + loadInitialValue(); +} + +KonfiguratorSpinBox::~KonfiguratorSpinBox() +{ + delete ext; +} + +void KonfiguratorSpinBox::loadInitialValue() +{ + krConfig->setGroup( ext->getCfgClass() ); + setValue( krConfig->readNumEntry( ext->getCfgName(), defaultValue ) ); + ext->setChanged( false ); +} + +void KonfiguratorSpinBox::slotApply(TQObject *,TQString cls, TQString name) +{ + krConfig->setGroup( cls ); + krConfig->writeEntry( name, value() ); +} + +void KonfiguratorSpinBox::slotSetDefaults(TQObject *) +{ + if( value() != defaultValue ) + setValue( defaultValue ); +} + +// KonfiguratorCheckBoxGroup class +/////////////////////////////// + +void KonfiguratorCheckBoxGroup::add( KonfiguratorCheckBox *checkBox ) +{ + checkBoxList.append( checkBox ); +} + +KonfiguratorCheckBox * KonfiguratorCheckBoxGroup::find( int index ) +{ + return checkBoxList.at( index ); +} + +KonfiguratorCheckBox * KonfiguratorCheckBoxGroup::find( TQString name ) +{ + KonfiguratorCheckBox *checkBox = checkBoxList.first(); + + while( checkBox ) + { + if( checkBox->extension()->getCfgName() == name ) + return checkBox; + checkBox = checkBoxList.next(); + } + + return 0; +} + + +// KonfiguratorRadioButtons class +/////////////////////////////// + +KonfiguratorRadioButtons::KonfiguratorRadioButtons( TQString cls, TQString name, + TQString dflt, TQWidget *parent, const char *widgetName, bool rst, int pg ) : + TQButtonGroup( parent, widgetName ), defaultValue( dflt ) +{ + ext = new KonfiguratorExtension( this, cls, name, rst, pg ); + connect( ext, TQ_SIGNAL( applyAuto(TQObject *,TQString, TQString) ), this, TQ_SLOT( slotApply(TQObject *,TQString, TQString) ) ); + connect( ext, TQ_SIGNAL( setDefaultsAuto(TQObject *) ), this, TQ_SLOT( slotSetDefaults(TQObject *) ) ); + connect( ext, TQ_SIGNAL( setInitialValue(TQObject *) ), this, TQ_SLOT( loadInitialValue() ) ); +} + +KonfiguratorRadioButtons::~KonfiguratorRadioButtons() +{ + delete ext; +} + +void KonfiguratorRadioButtons::addRadioButton( TQRadioButton *radioWidget, TQString name, TQString value ) +{ + radioButtons.append( radioWidget ); + radioNames.push_back( name ); + radioValues.push_back( value ); + + connect( radioWidget, TQ_SIGNAL( stateChanged(int) ), ext, TQ_SLOT( setChanged() ) ); +} + +TQRadioButton * KonfiguratorRadioButtons::find( int index ) +{ + return radioButtons.at( index ); +} + +TQRadioButton * KonfiguratorRadioButtons::find( TQString name ) +{ + int index = radioNames.findIndex( name ); + if( index == -1 ) + return 0; + + return radioButtons.at( index ); +} + +void KonfiguratorRadioButtons::selectButton( TQString value ) +{ + int cnt = 0; + TQRadioButton *btn = radioButtons.first(); + + while( btn ) + { + if( value == radioValues[ cnt ] ) + { + btn->setChecked( true ); + return; + } + + btn = radioButtons.next(); + cnt++; + } + + if( radioButtons.first() ) + radioButtons.first()->setChecked( true ); +} + +void KonfiguratorRadioButtons::loadInitialValue() +{ + krConfig->setGroup( ext->getCfgClass() ); + TQString initValue = krConfig->readEntry( ext->getCfgName(), defaultValue ); + + selectButton( initValue ); + ext->setChanged( false ); +} + +void KonfiguratorRadioButtons::slotApply(TQObject *,TQString cls, TQString name) +{ + TQRadioButton *btn = radioButtons.first(); + int cnt = 0; + + while( btn ) + { + if( btn->isChecked() ) + { + krConfig->setGroup( cls ); + krConfig->writeEntry( name, radioValues[ cnt ] ); + break; + } + + btn = radioButtons.next(); + cnt++; + } +} + +void KonfiguratorRadioButtons::slotSetDefaults(TQObject *) +{ + selectButton( defaultValue ); +} + +// KonfiguratorEditBox class +/////////////////////////////// + +KonfiguratorEditBox::KonfiguratorEditBox( TQString cls, TQString name, TQString dflt, + TQWidget *parent, const char *widgetName, bool rst, int pg ) : TQLineEdit( parent, widgetName ), + defaultValue( dflt ) +{ + ext = new KonfiguratorExtension( this, cls, name, rst, pg ); + connect( ext, TQ_SIGNAL( applyAuto(TQObject *,TQString, TQString) ), this, TQ_SLOT( slotApply(TQObject *,TQString, TQString) ) ); + connect( ext, TQ_SIGNAL( setDefaultsAuto(TQObject *) ), this, TQ_SLOT( slotSetDefaults(TQObject *) ) ); + connect( ext, TQ_SIGNAL( setInitialValue(TQObject *) ), this, TQ_SLOT( loadInitialValue() ) ); + + connect( this, TQ_SIGNAL( textChanged(const TQString &) ), ext, TQ_SLOT( setChanged() ) ); + + loadInitialValue(); +} + +KonfiguratorEditBox::~KonfiguratorEditBox() +{ + delete ext; +} + +void KonfiguratorEditBox::loadInitialValue() +{ + krConfig->setGroup( ext->getCfgClass() ); + setText( krConfig->readEntry( ext->getCfgName(), defaultValue ) ); + ext->setChanged( false ); +} + +void KonfiguratorEditBox::slotApply(TQObject *,TQString cls, TQString name) +{ + krConfig->setGroup( cls ); + krConfig->writeEntry( name, text() ); +} + +void KonfiguratorEditBox::slotSetDefaults(TQObject *) +{ + if( text() != defaultValue ) + setText( defaultValue ); +} + + +// KonfiguratorURLRequester class +/////////////////////////////// + +KonfiguratorURLRequester::KonfiguratorURLRequester( TQString cls, TQString name, TQString dflt, + TQWidget *parent, const char *widgetName, bool rst, int pg ) : KURLRequester( parent, widgetName ), + defaultValue( dflt ) +{ + ext = new KonfiguratorExtension( this, cls, name, rst, pg ); + connect( ext, TQ_SIGNAL( applyAuto(TQObject *,TQString, TQString) ), this, TQ_SLOT( slotApply(TQObject *,TQString, TQString) ) ); + connect( ext, TQ_SIGNAL( setDefaultsAuto(TQObject *) ), this, TQ_SLOT( slotSetDefaults(TQObject *) ) ); + connect( ext, TQ_SIGNAL( setInitialValue(TQObject *) ), this, TQ_SLOT( loadInitialValue() ) ); + + connect( this, TQ_SIGNAL( textChanged(const TQString &) ), ext, TQ_SLOT( setChanged() ) ); + + button()->setIconSet( SmallIcon( "document-open" ) ); + loadInitialValue(); +} + +KonfiguratorURLRequester::~KonfiguratorURLRequester() +{ + delete ext; +} + +void KonfiguratorURLRequester::loadInitialValue() +{ + krConfig->setGroup( ext->getCfgClass() ); + setURL( krConfig->readEntry( ext->getCfgName(), defaultValue ) ); + ext->setChanged( false ); +} + +void KonfiguratorURLRequester::slotApply(TQObject *,TQString cls, TQString name) +{ + krConfig->setGroup( cls ); + krConfig->writeEntry( name, url() ); +} + +void KonfiguratorURLRequester::slotSetDefaults(TQObject *) +{ + if( url() != defaultValue ) + setURL( defaultValue ); +} + +// KonfiguratorFontChooser class +/////////////////////////////// + +KonfiguratorFontChooser::KonfiguratorFontChooser( TQString cls, TQString name, TQFont *dflt, + TQWidget *parent, const char *widgetName, bool rst, int pg ) : TQHBox ( parent, widgetName ), + defaultValue( dflt ) +{ + ext = new KonfiguratorExtension( this, cls, name, rst, pg ); + connect( ext, TQ_SIGNAL( applyAuto(TQObject *,TQString, TQString) ), this, TQ_SLOT( slotApply(TQObject *,TQString, TQString) ) ); + connect( ext, TQ_SIGNAL( setDefaultsAuto(TQObject *) ), this, TQ_SLOT( slotSetDefaults(TQObject *) ) ); + connect( ext, TQ_SIGNAL( setInitialValue(TQObject *) ), this, TQ_SLOT( loadInitialValue() ) ); + + pLabel = new TQLabel( this ); + pLabel->setMinimumWidth( 150 ); + pToolButton = new TQToolButton( this ); + + connect( pToolButton, TQ_SIGNAL( clicked() ), this, TQ_SLOT( slotBrowseFont() ) ); + + pToolButton->setIconSet( SmallIcon( "document-open" ) ); + + loadInitialValue(); +} + +KonfiguratorFontChooser::~KonfiguratorFontChooser() +{ + delete ext; +} + +void KonfiguratorFontChooser::loadInitialValue() +{ + krConfig->setGroup( ext->getCfgClass() ); + font = krConfig->readFontEntry( ext->getCfgName(), defaultValue ); + ext->setChanged( false ); + setFont(); +} + +void KonfiguratorFontChooser::setFont() +{ + pLabel->setFont( font ); + pLabel->setText( font.family()+TQString(", %1").arg(font.pointSize()) ); +} + +void KonfiguratorFontChooser::slotApply(TQObject *,TQString cls, TQString name) +{ + krConfig->setGroup( cls ); + krConfig->writeEntry( name, font ); +} + +void KonfiguratorFontChooser::slotSetDefaults(TQObject *) +{ + font = *defaultValue; + ext->setChanged(); + setFont(); +} + +void KonfiguratorFontChooser::slotBrowseFont() +{ + int ok=TDEFontDialog::getFont( font ); + if (ok!=1) return; // cancelled by the user + ext->setChanged(); + setFont(); +} + +// KonfiguratorComboBox class +/////////////////////////////// + +KonfiguratorComboBox::KonfiguratorComboBox( TQString cls, TQString name, TQString dflt, + KONFIGURATOR_NAME_VALUE_PAIR *listIn, int listInLen, TQWidget *parent, + const char *widgetName, bool rst, bool editable, int pg ) : TQComboBox ( parent, widgetName ), + defaultValue( dflt ), listLen( listInLen ) +{ + list = new KONFIGURATOR_NAME_VALUE_PAIR[ listInLen ]; + + for( int i=0; i != listLen; i++ ) + { + list[i] = listIn[i]; + insertItem( list[i].text ); + } + + ext = new KonfiguratorExtension( this, cls, name, rst, pg ); + connect( ext, TQ_SIGNAL( applyAuto(TQObject *,TQString, TQString) ), this, TQ_SLOT( slotApply(TQObject *,TQString, TQString) ) ); + connect( ext, TQ_SIGNAL( setDefaultsAuto(TQObject *) ), this, TQ_SLOT( slotSetDefaults(TQObject *) ) ); + connect( ext, TQ_SIGNAL( setInitialValue(TQObject *) ), this, TQ_SLOT( loadInitialValue() ) ); + +// connect( this, TQ_SIGNAL( highlighted(int) ), ext, TQ_SLOT( setChanged() ) ); /* Removed because of startup combo failure */ + connect( this, TQ_SIGNAL( activated(int) ), ext, TQ_SLOT( setChanged() ) ); + connect( this, TQ_SIGNAL( textChanged ( const TQString & ) ), ext, TQ_SLOT( setChanged() ) ); + + setEditable( editable ); + loadInitialValue(); +} + +KonfiguratorComboBox::~KonfiguratorComboBox() +{ + delete []list; + delete ext; +} + +void KonfiguratorComboBox::loadInitialValue() +{ + krConfig->setGroup( ext->getCfgClass() ); + TQString select = krConfig->readEntry( ext->getCfgName(), defaultValue ); + selectEntry( select ); + ext->setChanged( false ); +} + +void KonfiguratorComboBox::slotApply(TQObject *,TQString cls, TQString name) +{ + TQString text = editable() ? lineEdit()->text() : currentText(); + TQString value = text; + + for( int i=0; i != listLen; i++ ) + if( list[i].text == text ) { + value = list[i].value; + break; + } + + krConfig->setGroup( cls ); + krConfig->writeEntry( name, value ); +} + +void KonfiguratorComboBox::selectEntry( TQString entry ) +{ + for( int i=0; i != listLen; i++ ) + if( list[i].value == entry ) + { + setCurrentItem( i ); + return; + } + + if( editable() ) + lineEdit()->setText( entry ); + else + setCurrentItem( 0 ); +} + +void KonfiguratorComboBox::slotSetDefaults(TQObject *) +{ + selectEntry( defaultValue ); +} + + +// KonfiguratorColorChooser class +/////////////////////////////// + +KonfiguratorColorChooser::KonfiguratorColorChooser( TQString cls, TQString name, TQColor dflt, + TQWidget *parent, const char *widgetName, bool rst, ADDITIONAL_COLOR *addColPtr, + int addColNum, int pg ) : TQComboBox ( parent, widgetName ), + defaultValue( dflt ), disableColorChooser( true ) +{ + ext = new KonfiguratorExtension( this, cls, name, rst, pg ); + + connect( ext, TQ_SIGNAL( applyAuto(TQObject *,TQString, TQString) ), this, TQ_SLOT( slotApply(TQObject *,TQString, TQString) ) ); + connect( ext, TQ_SIGNAL( setDefaultsAuto(TQObject *) ), this, TQ_SLOT( slotSetDefaults(TQObject *) ) ); + connect( ext, TQ_SIGNAL( setInitialValue(TQObject *) ), this, TQ_SLOT( loadInitialValue() ) ); + + addColor( i18n("Custom color" ), TQColor( 255, 255, 255 ) ); + addColor( i18n("Default" ), defaultValue ); + + for( int i=0; i != addColNum; i++ ) + { + additionalColors.push_back( addColPtr[i] ); + addColor( addColPtr[i].name, addColPtr[i].color ); + } + + addColor( i18n("Red" ), TQt::red ); + addColor( i18n("Green" ), TQt::green ); + addColor( i18n("Blue" ), TQt::blue ); + addColor( i18n("Cyan" ), TQt::cyan ); + addColor( i18n("Magenta" ), TQt::magenta ); + addColor( i18n("Yellow" ), TQt::yellow ); + addColor( i18n("Dark Red" ), TQt::darkRed ); + addColor( i18n("Dark Green" ), TQt::darkGreen ); + addColor( i18n("Dark Blue" ), TQt::darkBlue ); + addColor( i18n("Dark Cyan" ), TQt::darkCyan ); + addColor( i18n("Dark Magenta" ), TQt::darkMagenta ); + addColor( i18n("Dark Yellow" ), TQt::darkYellow ); + addColor( i18n("White" ), TQt::white ); + addColor( i18n("Light Gray" ), TQt::lightGray ); + addColor( i18n("Gray" ), TQt::gray ); + addColor( i18n("Dark Gray" ), TQt::darkGray ); + addColor( i18n("Black" ), TQt::black ); + + connect( this, TQ_SIGNAL( activated(int) ), this, TQ_SLOT( slotCurrentChanged( int ) ) ); + + loadInitialValue(); +} + +KonfiguratorColorChooser::~KonfiguratorColorChooser() +{ + delete ext; +} + +TQPixmap KonfiguratorColorChooser::createPixmap( TQColor color ) +{ + TQPainter painter; + TQPen pen; + int size = TQFontMetrics(font()).height()*3/4; + TQRect rect( 0, 0, size, size ); + TQPixmap pixmap( rect.width(), rect.height() ); + + pen.setColor( TQt::black ); + + painter.begin( &pixmap ); + TQBrush brush( color ); + painter.fillRect( rect, brush ); + painter.setPen( pen ); + painter.drawRect( rect ); + painter.end(); + + pixmap.detach(); + return pixmap; +} + +void KonfiguratorColorChooser::addColor( TQString text, TQColor color ) +{ + insertItem( createPixmap(color), text ); + palette.push_back( color ); +} + +void KonfiguratorColorChooser::loadInitialValue() +{ + krConfig->setGroup( ext->getCfgClass() ); + TQString selected = krConfig->readEntry( ext->getCfgName(), "" ); + setValue( selected ); + ext->setChanged( false ); +} + +void KonfiguratorColorChooser::setDefaultColor( TQColor dflt ) +{ + defaultValue = dflt; + palette[1] = defaultValue; + changeItem( createPixmap( defaultValue ), text( 1 ), 1 ); + + if( currentItem() == 1 ) + emit colorChanged(); +} + +void KonfiguratorColorChooser::changeAdditionalColor( unsigned int num, TQColor color ) +{ + if( num < additionalColors.size() ) + { + palette[2+num] = color; + additionalColors[num].color = color; + changeItem( createPixmap( color ), text( 2+num ), 2+num ); + + if( (unsigned int)currentItem() == 2+num ) + emit colorChanged(); + } +} + +void KonfiguratorColorChooser::setDefaultText( TQString text ) +{ + changeItem( createPixmap( defaultValue ), text, 1 ); +} + +void KonfiguratorColorChooser::slotApply(TQObject *,TQString cls, TQString name) +{ + krConfig->setGroup( cls ); + krConfig->writeEntry( name, getValue() ); +} + +void KonfiguratorColorChooser::setValue( TQString value ) +{ + disableColorChooser = true; + + if( value.isEmpty() ) + { + setCurrentItem( 1 ); + customValue = defaultValue; + } + else + { + bool found = false; + + for( unsigned j=0; j != additionalColors.size(); j++ ) + if( additionalColors[j].value == value ) + { + setCurrentItem( 2 + j ); + found = true; + break; + } + + if( ! found ) + { + krConfig->setGroup( ext->getCfgClass() ); + krConfig->writeEntry( "TmpColor", value ); + TQColor color = krConfig->readColorEntry( "TmpColor", &defaultValue ); + customValue = color; + krConfig->deleteEntry( "TmpColor" ); + + setCurrentItem( 0 ); + for( unsigned i= 2+additionalColors.size(); i != palette.size(); i++ ) + if( palette[i] == color ) + { + setCurrentItem( i ); + break; + } + } + } + + palette[0] = customValue; + changeItem( createPixmap( customValue ), text( 0 ), 0 ); + + ext->setChanged(); + emit colorChanged(); + disableColorChooser = false; +} + +TQString KonfiguratorColorChooser::getValue() +{ + TQColor color = palette[ currentItem() ]; + if( currentItem() == 1 ) /* it's the default value? */ + return ""; + else if( currentItem() >= 2 && (unsigned)currentItem() < 2 + additionalColors.size() ) + return additionalColors[ currentItem() - 2 ].value; + else + return TQString( "%1,%2,%3" ).arg( color.red() ).arg( color.green() ).arg( color.blue() ); +} + +bool KonfiguratorColorChooser::isValueRGB() +{ + return !( currentItem() >= 1 && (unsigned)currentItem() < 2 + additionalColors.size() ); +} + +void KonfiguratorColorChooser::slotSetDefaults(TQObject *) +{ + ext->setChanged(); + setCurrentItem( 1 ); + emit colorChanged(); +} + +void KonfiguratorColorChooser::slotCurrentChanged( int number ) +{ + ext->setChanged(); + if( number == 0 && !disableColorChooser ) + { + TQColor color = TQColorDialog::getColor ( customValue, this, "ColorDialog" ); + if( color.isValid() ) + { + disableColorChooser = true; + customValue = color; + palette[0] = customValue; + changeItem( createPixmap( customValue ), text( 0 ), 0 ); + disableColorChooser = false; + } + } + + emit colorChanged(); +} + +TQColor KonfiguratorColorChooser::getColor() +{ + return palette[ currentItem() ]; +} + +// KonfiguratorListBox class +/////////////////////////////// + +KonfiguratorListBox::KonfiguratorListBox( TQString cls, TQString name, TQStringList dflt, + TQWidget *parent, const char *widgetName, bool rst, int pg ) : TQListBox( parent, widgetName ), + defaultValue( dflt ) +{ + ext = new KonfiguratorExtension( this, cls, name, rst, pg ); + connect( ext, TQ_SIGNAL( applyAuto(TQObject *,TQString, TQString) ), this, TQ_SLOT( slotApply(TQObject *,TQString, TQString) ) ); + connect( ext, TQ_SIGNAL( setDefaultsAuto(TQObject *) ), this, TQ_SLOT( slotSetDefaults(TQObject *) ) ); + connect( ext, TQ_SIGNAL( setInitialValue(TQObject *) ), this, TQ_SLOT( loadInitialValue() ) ); + + loadInitialValue(); +} + +KonfiguratorListBox::~KonfiguratorListBox() +{ + delete ext; +} + +void KonfiguratorListBox::loadInitialValue() +{ + krConfig->setGroup( ext->getCfgClass() ); + setList( krConfig->readListEntry( ext->getCfgName().ascii(), defaultValue ) ); + ext->setChanged( false ); +} + +void KonfiguratorListBox::slotApply(TQObject *,TQString cls, TQString name) +{ + krConfig->setGroup( cls ); + krConfig->writeEntry( name, list() ); +} + +void KonfiguratorListBox::slotSetDefaults(TQObject *) +{ + if( list() != defaultValue ) + { + ext->setChanged(); + setList( defaultValue ); + } +} + +void KonfiguratorListBox::setList( TQStringList list ) +{ + clear(); + insertStringList( list ); +} + +TQStringList KonfiguratorListBox::list() +{ + TQStringList lst; + + for( unsigned i=0; i != count(); i++ ) + lst += text( i ); + + return lst; +} + +void KonfiguratorListBox::addItem( const TQString & item ) +{ + if( !list().contains( item ) ) + { + insertItem( item ); + ext->setChanged(); + } +} + +void KonfiguratorListBox::removeItem( const TQString & item ) +{ + TQListBoxItem * listItem = findItem( item ); + if( listItem != 0 ) + { + takeItem( listItem ); + ext->setChanged(); + } +} + +#include "konfiguratoritems.moc" diff --git a/src/app/Konfigurator/konfiguratoritems.h b/src/app/Konfigurator/konfiguratoritems.h new file mode 100644 index 0000000..3348a71 --- /dev/null +++ b/src/app/Konfigurator/konfiguratoritems.h @@ -0,0 +1,428 @@ +/*************************************************************************** + konfiguratoritems.h - description + ------------------- + copyright : (C) 2003 by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef __KONFIGURATOR_ITEMS_H__ +#define __KONFIGURATOR_ITEMS_H__ + +#include <tqobject.h> +#include <tqstring.h> +#include <tqcheckbox.h> +#include <tqspinbox.h> +#include <tqpushbutton.h> +#include <tqradiobutton.h> +#include <tqptrlist.h> +#include <tqvaluelist.h> +#include <tqvaluevector.h> +#include <tqbuttongroup.h> +#include <tqlineedit.h> +#include <kurlrequester.h> +#include <tqhbox.h> +#include <tdefontdialog.h> +#include <tqlabel.h> +#include <tqfont.h> +#include <tqtoolbutton.h> +#include <tqcombobox.h> + +#define FIRST_PAGE 0 + +class KonfiguratorExtension : public TQObject +{ + TQ_OBJECT + + +public: + KonfiguratorExtension(TQObject *obj, TQString cfgClass, TQString cfgName, bool rst = false, int pg=FIRST_PAGE ); + + virtual void loadInitialValue(); + virtual bool apply(); + virtual void setDefaults(); + virtual bool isChanged(); + virtual void setSubPage(int pg) {subpage = pg;} + virtual int subPage() {return subpage;} + + inline TQObject *object() {return objectPtr;} + + inline TQString getCfgClass() {return configClass;} + inline TQString getCfgName() {return configName;} + +public slots: + void setChanged() {emit sigChanged( changed = true);} + void setChanged( bool chg ) {emit sigChanged( changed = chg);} + +signals: + void applyManually(TQObject *,TQString, TQString); + void applyAuto(TQObject *,TQString, TQString); + void setDefaultsManually(TQObject *); + void setDefaultsAuto(TQObject *); + void setInitialValue(TQObject *); + void sigChanged( bool ); + +protected: + TQObject *objectPtr; + + bool applyConnected; + bool setDefaultsConnected; + bool changed; + bool restartNeeded; + int subpage; + + TQString configClass; + TQString configName; + + virtual void connectNotify( const char *signal ); +}; + + +// KonfiguratorCheckBox class +/////////////////////////////// + +class KonfiguratorCheckBox : public TQCheckBox +{ + TQ_OBJECT + + +public: + KonfiguratorCheckBox( TQString cls, TQString name, bool dflt, TQString text, + TQWidget *parent=0, const char *widgetName=0, bool rst=false, int pg=FIRST_PAGE ); + ~KonfiguratorCheckBox(); + + inline KonfiguratorExtension *extension() {return ext;} + +public slots: + virtual void loadInitialValue(); + void slotApply(TQObject *,TQString, TQString); + void slotSetDefaults(TQObject *); + +protected: + bool defaultValue; + KonfiguratorExtension *ext; +}; + +// KonfiguratorSpinBox class +/////////////////////////////// + +class KonfiguratorSpinBox : public TQSpinBox +{ + TQ_OBJECT + + +public: + KonfiguratorSpinBox( TQString cls, TQString name, int dflt, int min, int max, + TQWidget *parent=0, const char *widgetName=0, bool rst=false, int pg=FIRST_PAGE ); + ~KonfiguratorSpinBox(); + + inline KonfiguratorExtension *extension() {return ext;} + +public slots: + virtual void loadInitialValue(); + void slotApply(TQObject *,TQString, TQString); + void slotSetDefaults(TQObject *); + +protected: + int defaultValue; + KonfiguratorExtension *ext; +}; + +// KonfiguratorCheckBoxGroup class +/////////////////////////////// + +class KonfiguratorCheckBoxGroup : public TQWidget +{ +public: + KonfiguratorCheckBoxGroup( TQWidget * parent = 0, const char * name = 0 ) : + TQWidget( parent, name ) {}; + + void add( KonfiguratorCheckBox * ); + KonfiguratorCheckBox * find( int index ); + KonfiguratorCheckBox * find( TQString name ); + +private: + TQPtrList<KonfiguratorCheckBox> checkBoxList; +}; + +// KonfiguratorRadioButtons class +/////////////////////////////// + +class KonfiguratorRadioButtons : public TQButtonGroup +{ + TQ_OBJECT + + +public: + KonfiguratorRadioButtons( TQString cls, TQString name, TQString dflt, TQWidget *parent=0, + const char *widgetName=0, bool rst=false, int pg=FIRST_PAGE ); + ~KonfiguratorRadioButtons(); + + inline KonfiguratorExtension *extension() {return ext;} + + void addRadioButton( TQRadioButton *radioWidget, TQString name, TQString value ); + + void selectButton( TQString value ); + + TQRadioButton* find( int index ); + TQRadioButton* find( TQString name ); + +public slots: + virtual void loadInitialValue(); + void slotApply(TQObject *,TQString, TQString); + void slotSetDefaults(TQObject *); + +protected: + TQPtrList<TQRadioButton> radioButtons; + TQValueList<TQString> radioValues; + TQValueList<TQString> radioNames; + + TQString defaultValue; + TQButtonGroup *buttonGroup; + + KonfiguratorExtension *ext; +}; + +// KonfiguratorEditBox class +/////////////////////////////// + +class KonfiguratorEditBox : public TQLineEdit +{ + TQ_OBJECT + + +public: + KonfiguratorEditBox( TQString cls, TQString name, TQString dflt, TQWidget *parent=0, + const char *widgetName=0, bool rst=false, int pg=FIRST_PAGE ); + ~KonfiguratorEditBox(); + + inline KonfiguratorExtension *extension() {return ext;} + +public slots: + virtual void loadInitialValue(); + void slotApply(TQObject *,TQString, TQString); + void slotSetDefaults(TQObject *); + +protected: + TQString defaultValue; + KonfiguratorExtension *ext; +}; + + +// KonfiguratorURLRequester class +/////////////////////////////// + +class KonfiguratorURLRequester : public KURLRequester +{ + TQ_OBJECT + + +public: + KonfiguratorURLRequester( TQString cls, TQString name, TQString dflt, TQWidget *parent=0, + const char *widgetName=0, bool rst=false, int pg=FIRST_PAGE ); + ~KonfiguratorURLRequester(); + + inline KonfiguratorExtension *extension() {return ext;} + +public slots: + virtual void loadInitialValue(); + void slotApply(TQObject *,TQString, TQString); + void slotSetDefaults(TQObject *); + +protected: + TQString defaultValue; + KonfiguratorExtension *ext; +}; + +// KonfiguratorFontChooser class +/////////////////////////////// + +class KonfiguratorFontChooser : public TQHBox +{ + TQ_OBJECT + + +public: + KonfiguratorFontChooser( TQString cls, TQString name, TQFont *dflt, TQWidget *parent=0, + const char *widgetName=0, bool rst=false, int pg=FIRST_PAGE ); + ~KonfiguratorFontChooser(); + + inline KonfiguratorExtension *extension() {return ext;} + +public slots: + virtual void loadInitialValue(); + void slotApply(TQObject *,TQString, TQString); + void slotSetDefaults(TQObject *); + void slotBrowseFont(); + +protected: + TQFont * defaultValue; + TQFont font; + KonfiguratorExtension *ext; + + TQLabel * pLabel; + TQToolButton * pToolButton; + + void setFont(); +}; + +// KONFIGURATOR_NAME_VALUE_PAIR structure +/////////////////////////////// + +struct KONFIGURATOR_NAME_VALUE_PAIR +{ + TQString text; + TQString value; +}; + +// KONFIGURATOR_NAME_VALUE_TIP structure +/////////////////////////////// + +struct KONFIGURATOR_NAME_VALUE_TIP +{ + TQString text; + TQString value; + TQString tooltip; +}; + +// KonfiguratorComboBox class +/////////////////////////////// + +class KonfiguratorComboBox : public TQComboBox +{ + TQ_OBJECT + + +public: + KonfiguratorComboBox( TQString cls, TQString name, TQString dflt, + KONFIGURATOR_NAME_VALUE_PAIR *listIn, int listInLen, + TQWidget *parent=0, const char *widgetName=0, + bool rst=false, bool editable=false, int pg=FIRST_PAGE ); + ~KonfiguratorComboBox(); + + inline KonfiguratorExtension *extension() {return ext;} + +public slots: + virtual void loadInitialValue(); + void slotApply(TQObject *,TQString, TQString); + void slotSetDefaults(TQObject *); + +protected: + TQString defaultValue; + KONFIGURATOR_NAME_VALUE_PAIR *list; + int listLen; + KonfiguratorExtension *ext; + + void selectEntry( TQString entry ); +}; + + +// KonfiguratorColorChooser class +/////////////////////////////// + +typedef struct +{ + TQString name; + TQColor color; + TQString value; +} ADDITIONAL_COLOR; + +class KonfiguratorColorChooser : public TQComboBox +{ + TQ_OBJECT + + +public: + KonfiguratorColorChooser( TQString cls, TQString name, TQColor dflt, + TQWidget *parent=0, const char *widgetName=0, bool rst=false, + ADDITIONAL_COLOR *addColPtr = 0, int addColNum = 0, int pg=FIRST_PAGE ); + ~KonfiguratorColorChooser(); + + inline KonfiguratorExtension *extension() {return ext;} + + void setDefaultColor( TQColor dflt ); + void setDefaultText( TQString text ); + TQColor getColor(); + void changeAdditionalColor( unsigned int num, TQColor color ); + TQString getValue(); + bool isValueRGB(); + void setValue( TQString value ); + +public slots: + virtual void loadInitialValue(); + void slotApply(TQObject *,TQString, TQString); + void slotSetDefaults(TQObject *); + void slotCurrentChanged( int number ); + +signals: + void colorChanged(); + +private: + void addColor( TQString text, TQColor color ); + TQPixmap createPixmap( TQColor color ); + +protected: + TQColor defaultValue; + TQColor customValue; + TQValueVector<TQColor> palette; + TQValueVector<ADDITIONAL_COLOR> additionalColors; + KonfiguratorExtension *ext; + bool disableColorChooser; +}; + +// KonfiguratorListBox class +/////////////////////////////// + +class KonfiguratorListBox : public TQListBox +{ + TQ_OBJECT + + +public: + KonfiguratorListBox( TQString cls, TQString name, TQStringList dflt, + TQWidget *parent=0, const char *widgetName=0, + bool rst=false, int pg=FIRST_PAGE ); + ~KonfiguratorListBox(); + + inline KonfiguratorExtension *extension() {return ext;} + + void addItem( const TQString & ); + void removeItem( const TQString & ); + +public slots: + virtual void loadInitialValue(); + void slotApply(TQObject *,TQString, TQString); + void slotSetDefaults(TQObject *); + +protected: + TQStringList list(); + void setList( TQStringList ); + + TQStringList defaultValue; + KonfiguratorExtension *ext; +}; + +#endif /* __KONFIGURATOR_ITEMS_H__ */ + diff --git a/src/app/Konfigurator/konfiguratorpage.cpp b/src/app/Konfigurator/konfiguratorpage.cpp new file mode 100644 index 0000000..2f33029 --- /dev/null +++ b/src/app/Konfigurator/konfiguratorpage.cpp @@ -0,0 +1,334 @@ +/* ************************************************************************** + konfiguratorpage.cpp - description + ------------------- + copyright : (C) 2003 by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "konfiguratorpage.h" +#include <tqlayout.h> +#include "../krusader.h" +#include <tqwhatsthis.h> + +KonfiguratorPage::KonfiguratorPage( bool firstTime, TQWidget* parent, const char* name ) : + TQFrame( parent, name ), firstCall( firstTime ) +{ +} + +bool KonfiguratorPage::apply() +{ + bool restartNeeded = false; + + KonfiguratorExtension *item = itemList.first(); + + while( item ) + { + restartNeeded = item->apply() || restartNeeded; + item = itemList.next(); + } + + krConfig->sync(); + return restartNeeded; +} + +void KonfiguratorPage::setDefaults() +{ + KonfiguratorExtension *item = itemList.first(); + int activePage = activeSubPage(); + + while( item ) + { + if( item->subPage() == activePage ) + item->setDefaults(); + item = itemList.next(); + } +} + +void KonfiguratorPage::loadInitialValues() +{ + KonfiguratorExtension *item = itemList.first(); + + while( item ) + { + item->loadInitialValue(); + item = itemList.next(); + } +} + +bool KonfiguratorPage::isChanged() +{ + KonfiguratorExtension *currentItem = itemList.current(); /* save the current pointer */ + bool isChanged = false; + + KonfiguratorExtension *item = itemList.first(); + + while( item ) + { + isChanged = isChanged || item->isChanged(); + item = itemList.next(); + } + + itemList.find( currentItem ); /* restore the current pointer */ + return isChanged; +} + +KonfiguratorCheckBox* KonfiguratorPage::createCheckBox( TQString cls, TQString name, + bool dflt, TQString text, TQWidget *parent, bool rst, TQString toolTip, int pg ) +{ + KonfiguratorCheckBox *checkBox = new KonfiguratorCheckBox( cls, name, dflt, text, + parent, TQString(cls + "/" + name).ascii(), rst, pg ); + if( !toolTip.isEmpty() ) + TQWhatsThis::add( checkBox, toolTip ); + + registerObject( checkBox->extension() ); + return checkBox; +} + +KonfiguratorSpinBox* KonfiguratorPage::createSpinBox( TQString cls, TQString name, + int dflt, int min, int max, TQWidget *parent, bool rst, int pg ) +{ + KonfiguratorSpinBox *spinBox = new KonfiguratorSpinBox( cls, name, dflt, min, max, + parent, TQString(cls + "/" + name).ascii(), rst, pg ); + + registerObject( spinBox->extension() ); + return spinBox; +} + +KonfiguratorEditBox* KonfiguratorPage::createEditBox( TQString cls, TQString name, + TQString dflt, TQWidget *parent, bool rst, int pg ) +{ + KonfiguratorEditBox *editBox = new KonfiguratorEditBox( cls, name, dflt, parent, + TQString(cls + "/" + name).ascii(), rst, pg ); + + registerObject( editBox->extension() ); + return editBox; +} + +KonfiguratorListBox* KonfiguratorPage::createListBox( TQString cls, TQString name, + TQStringList dflt, TQWidget *parent, bool rst, int pg ) +{ + KonfiguratorListBox *listBox = new KonfiguratorListBox( cls, name, dflt, parent, + TQString(cls + "/" + name).ascii(), rst, pg ); + + registerObject( listBox->extension() ); + return listBox; +} + +KonfiguratorURLRequester* KonfiguratorPage::createURLRequester( TQString cls, TQString name, + TQString dflt, TQWidget *parent, bool rst, int pg ) +{ + KonfiguratorURLRequester *urlRequester = new KonfiguratorURLRequester( cls, name, dflt, + parent, TQString(cls + "/" + name).ascii(), rst, pg ); + + registerObject( urlRequester->extension() ); + return urlRequester; +} + +TQGroupBox* KonfiguratorPage::createFrame( TQString text, TQWidget *parent, + const char *widgetName ) +{ + TQGroupBox *groupBox = new TQGroupBox( parent, widgetName ); + groupBox->setFrameShape( TQGroupBox::Box ); + groupBox->setFrameShadow( TQGroupBox::Sunken ); + if( !text.isNull() ) + groupBox->setTitle( text ); + groupBox->setColumnLayout(0, TQt::Vertical ); + groupBox->layout()->setSpacing( 0 ); + groupBox->layout()->setMargin( 0 ); + return groupBox; +} + +TQGridLayout* KonfiguratorPage::createGridLayout( TQLayout *parent ) +{ + TQGridLayout *gridLayout = new TQGridLayout( parent ); + gridLayout->setAlignment( TQt::AlignTop ); + gridLayout->setSpacing( 6 ); + gridLayout->setMargin( 11 ); + return gridLayout; +} + +TQLabel* KonfiguratorPage::addLabel( TQGridLayout *layout, int x, int y, TQString label, + TQWidget *parent, const char *widgetName ) +{ + TQLabel *lbl = new TQLabel( label, parent, widgetName ); + layout->addWidget( lbl, x, y ); + return lbl; +} + +TQWidget* KonfiguratorPage::createSpacer( TQWidget *parent, const char *widgetName ) +{ + TQWidget *widget = new TQWidget( parent, widgetName ); + TQHBoxLayout *hboxlayout = new TQHBoxLayout( widget ); + TQSpacerItem* spacer = new TQSpacerItem( 40, 20, TQSizePolicy::Expanding, TQSizePolicy::Minimum ); + hboxlayout->addItem( spacer ); + return widget; +} + +KonfiguratorCheckBoxGroup* KonfiguratorPage::createCheckBoxGroup( int sizex, int sizey, + KONFIGURATOR_CHECKBOX_PARAM *params, int paramNum, TQWidget *parent, + const char *widgetName, int pg ) +{ + KonfiguratorCheckBoxGroup *groupWidget = new KonfiguratorCheckBoxGroup( parent, widgetName ); + TQGridLayout *layout = new TQGridLayout( groupWidget ); + layout->setSpacing( 6 ); + layout->setMargin( 0 ); + + int x = 0, y = 0; + + for( int i=0; i != paramNum; i++ ) + { + KonfiguratorCheckBox *checkBox = createCheckBox( params[i].configClass, + params[i].configName, params[i].defaultValue, params[i].text, groupWidget, + params[i].restart, params[i].toolTip, pg ); + + groupWidget->add( checkBox ); + layout->addWidget( checkBox, y, x ); + + if( sizex ) + { + if( ++x == sizex ) + x = 0, y++; + } + else + { + if( ++y == sizey ) + y = 0, x++; + } + } + + return groupWidget; +} + +KonfiguratorRadioButtons* KonfiguratorPage::createRadioButtonGroup( TQString cls, + TQString name, TQString dflt, int sizex, int sizey, KONFIGURATOR_NAME_VALUE_TIP *params, + int paramNum, TQWidget *parent, const char *widgetName, bool rst, int pg ) +{ + KonfiguratorRadioButtons *radioWidget = new KonfiguratorRadioButtons( cls, name, dflt, parent, widgetName, rst, pg ); + radioWidget->setFrameShape( TQButtonGroup::NoFrame ); + radioWidget->setFrameShadow( TQButtonGroup::Sunken ); + radioWidget->setTitle( "" ); + radioWidget->setExclusive( true ); + radioWidget->setRadioButtonExclusive( true ); + radioWidget->setColumnLayout(0, TQt::Vertical ); + + TQGridLayout *layout = new TQGridLayout( radioWidget->layout() ); + layout->setAlignment( TQt::AlignTop ); + layout->setSpacing( 6 ); + layout->setMargin( 0 ); + + int x = 0, y = 0; + + for( int i=0; i != paramNum; i++ ) + { + TQRadioButton *radBtn = new TQRadioButton( params[i].text, radioWidget, + TQString( cls + "/" + name + "/" + params[i].value ).ascii() ); + + if( !params[i].tooltip.isEmpty() ) + TQWhatsThis::add( radBtn, params[i].tooltip ); + + layout->addWidget( radBtn, y, x ); + + radioWidget->addRadioButton( radBtn, params[i].text, params[i].value ); + + if( sizex ) + { + if( ++x == sizex ) + x = 0, y++; + } + else + { + if( ++y == sizey ) + y = 0, x++; + } + } + + radioWidget->loadInitialValue(); + registerObject( radioWidget->extension() ); + return radioWidget; +} + +KonfiguratorFontChooser *KonfiguratorPage::createFontChooser( TQString cls, TQString name, + TQFont *dflt, TQWidget *parent, bool rst, int pg ) +{ + KonfiguratorFontChooser *fontChooser = new KonfiguratorFontChooser( cls, name, dflt, parent, + TQString(cls + "/" + name).ascii(), rst, pg ); + + registerObject( fontChooser->extension() ); + return fontChooser; +} + +KonfiguratorComboBox *KonfiguratorPage::createComboBox( TQString cls, TQString name, TQString dflt, + KONFIGURATOR_NAME_VALUE_PAIR *params, int paramNum, TQWidget *parent, bool rst, bool editable, int pg ) +{ + KonfiguratorComboBox *comboBox = new KonfiguratorComboBox( cls, name, dflt, params, + paramNum, parent, TQString(cls + "/" + name).ascii(), + rst, editable, pg ); + + registerObject( comboBox->extension() ); + return comboBox; +} + +TQFrame* KonfiguratorPage::createLine( TQWidget *parent, const char *widgetName, bool vertical ) +{ + TQFrame *line = new TQFrame( parent, widgetName ); + line->setFrameStyle( ( vertical ? TQFrame::VLine : TQFrame::HLine ) | TQFrame::Sunken ); + return line; +} + +void KonfiguratorPage::registerObject( KonfiguratorExtension *item ) +{ + KonfiguratorExtension *currentItem = itemList.current(); + + itemList.append( item ); + connect( item, TQ_SIGNAL( sigChanged( bool ) ), this, TQ_SIGNAL ( sigChanged( ) ) ); + + itemList.find( currentItem ); +} + +void KonfiguratorPage::removeObject( KonfiguratorExtension *item ) +{ + if( item == itemList.current() ) + { + itemList.remove(); + if( itemList.current() != itemList.getFirst() ) + itemList.prev(); + } + else + itemList.removeRef( item ); +} + +KonfiguratorColorChooser *KonfiguratorPage::createColorChooser( TQString cls, TQString name, TQColor dflt, + TQWidget *parent, bool rst, + ADDITIONAL_COLOR *addColPtr, int addColNum, int pg ) +{ + KonfiguratorColorChooser *colorChooser = new KonfiguratorColorChooser( cls, name, dflt, parent, + TQString(cls + "/" + name).ascii(), rst, addColPtr, addColNum, pg ); + + registerObject( colorChooser->extension() ); + return colorChooser; +} + +#include "konfiguratorpage.moc" diff --git a/src/app/Konfigurator/konfiguratorpage.h b/src/app/Konfigurator/konfiguratorpage.h new file mode 100644 index 0000000..e1fcef9 --- /dev/null +++ b/src/app/Konfigurator/konfiguratorpage.h @@ -0,0 +1,523 @@ +/* ************************************************************************** + konfiguratorpage.h - description + ------------------- + copyright : (C) 2003 by Csaba Karai + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + H e a d e r F i l e + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef __KONFIGURATOR_PAGE_H__ +#define __KONFIGURATOR_PAGE_H__ + +#include "konfiguratoritems.h" +#include <tqframe.h> +#include <tqptrlist.h> +#include <tqgroupbox.h> +#include <tqlabel.h> +#include <tqlayout.h> + +struct KONFIGURATOR_CHECKBOX_PARAM; +struct KONFIGURATOR_NAME_VALUE_TIP; +struct KONFIGURATOR_NAME_VALUE_PAIR; + +/** + * KonfiguratorPage is responsible for handling pages in Konfigurator. + * It provides simple methods for create and manage Konfigurator pages. + * + * @short The base class of a page in Konfigurator + */ +class KonfiguratorPage : public TQFrame +{ + TQ_OBJECT + + +public: +/** + * The constructor of the KonfiguratorPage class. + * + * @param firstTime this parameter is true if it is the first call of Konfigurator + * @param parent reference to the parent widget + * @param name name of the newly generated Konfigurator page widget + */ + KonfiguratorPage( bool firstTime, TQWidget* parent, const char* name ); + + /** + * Applies the changes in the Konfigurator page. + * + * Writes out all relevent information to the konfiguration object and synchronizes + * it with the file storage (hard disk, krusaderrc file). This function calls the apply() + * method of each konfigurator item and finally performs the synchronization. + * + * @return a boolean value indicates that Krusader restart is needed for the correct change + */ + virtual bool apply(); + + /** + * Sets every konfigurator item to its default value on the page. + * + * This method calls the setDefaults() method of each konfigurator item. This function + * doesn't modify the current configuration, only the values of the GUI items. The + * apply() method must be called for finalizing the changes. + */ + virtual void setDefaults(); + + /** + * Reloads the original value of each konfigurator item from the configuration object. + * + * This function calls the loadInitialValue() method of each konfigurator item. + * Used to rollback the changes on the konfigurator page. Called if the user + * responds 'No' to the "Apply changes" question. + */ + virtual void loadInitialValues(); + + /** + * Checks whether the page was changed. + * + * This function calls the isChanged() method of each konfigurator item and + * performs logical OR operation on them. Actually, this function returns true + * if any of the konfigurator items was changed. + * + * @return true if at least one of the konfigurator items was changed + */ + virtual bool isChanged(); + + /** + * Flag, indicates the first call of Konfigurator + * @return true if konfigurator was started at the first time + */ + inline bool isFirst() {return firstCall;} + + /** + * This method is used to query the active subpage from the Konfigurator + * @return the active page (by default the first page) + */ + virtual int activeSubPage() {return FIRST_PAGE;} + + /** + * Adds a new checkbox item to the page. + * <br>The checkbox widget's name is TQString(cls + "/" + name).ascii()<br> + * + * Sample:<br><br> + * KonfiguratorCheckBox *myCheckBox = createCheckBox( "class", "name", false, parentWidget );<br> + * myLayout->addWidget( myCheckBox, 0, 0 ); + * + * @param cls The class name used in TDEConfig (ex. "Archives") + * @param name The item name used in TDEConfig (ex. "Do Tar") + * @param dflt The default value of the checkbox + * @param text The text field of the checkbox + * @param parent Reference to the parent widget + * @param rst The change of this parameter requires Krusader restart + * @param toolTip Tooltip used for this checkbox + * @param pg The subpage of a Konfigurator page (because of setDefaults) + * + * @return reference to the newly created checkbox + */ + KonfiguratorCheckBox *createCheckBox( TQString cls, TQString name, bool dflt, + TQString text, TQWidget *parent=0, bool rst=false, + TQString toolTip = TQString(), int pg=FIRST_PAGE ); + + /** + * Adds a new spinbox item to the page. + * <br>The spinbox widget's name is TQString(cls + "/" + name).ascii()<br> + * + * Sample:<br><br> + * KonfiguratorSpinBox *mySpinBox = createSpinBox( "class", "name", 10, 1, 100, parentWidget );<br> + * myLayout->addWidget( mySpinBox, 0, 0 ); + * + * @param cls The class name used in TDEConfig (ex. "Archives") + * @param name The item name used in TDEConfig (ex. "Do Tar") + * @param dflt The default value of the spinbox + * @param min The minimum value of the spinbox + * @param max The maximum value of the spinbox + * @param parent Reference to the parent widget + * @param rst The change of this parameter requires Krusader restart + * @param pg The subpage of a Konfigurator page (because of setDefaults) + * + * @return reference to the newly created spinbox + */ + KonfiguratorSpinBox *createSpinBox( TQString cls, TQString name, int dflt, int min, + int max, TQWidget *parent = 0, bool rst = false, int pg=FIRST_PAGE ); + + /** + * Adds a new editbox item to the page. + * <br>The editbox widget's name is TQString(cls + "/" + name).ascii()<br> + * + * Sample:<br><br> + * KonfiguratorEditBox *myEditBox = createEditBox( "class", "name", "default", parentWidget );<br> + * myLayout->addWidget( myEditBox, 0, 0 ); + * + * @param cls The class name used in TDEConfig (ex. "Archives") + * @param name The itemname used in TDEConfig (ex. "Do Tar") + * @param dflt The default value of the editbox + * @param parent Reference to the parent widget + * @param rst The change of this parameter requires Krusader restart + * @param pg The subpage of a Konfigurator page (because of setDefaults) + * + * @return reference to the newly created editbox + */ + KonfiguratorEditBox *createEditBox( TQString cls, TQString name, TQString dflt, + TQWidget *parent=0, bool rst=false, int pg=FIRST_PAGE ); + + /** + * Adds a new listbox item to the page. + * <br>The listbox widget's name is TQString(cls + "/" + name).ascii()<br> + * + * Sample:<br><br> + * TQStringList valueList;<br> + * valueList += "item";<br> + * KonfiguratorListBox *myListBox = createListBox( "class", "name", valueList, parentWidget );<br> + * myLayout->addWidget( myListBox, 0, 0 ); + * + * @param cls The class name used in TDEConfig (ex. "Archives") + * @param name The itemname used in TDEConfig (ex. "Do Tar") + * @param dflt The default value of the listbox + * @param parent Reference to the parent widget + * @param rst The change of this parameter requires Krusader restart + * @param pg The subpage of a Konfigurator page (because of setDefaults) + * + * @return reference to the newly created editbox + */ + KonfiguratorListBox *createListBox( TQString cls, TQString name, TQStringList dflt, + TQWidget *parent=0, bool rst=false, int pg=FIRST_PAGE ); + + /** + * Adds a new URL requester item to the page. + * <br>The URL requester widget's name is TQString(cls + "/" + name).ascii()<br> + * + * Sample:<br><br> + * KonfiguratorURLRequester *myURLRequester = createURLRequester( "class", "name", "default", parentWidget );<br> + * myLayout->addWidget( myURLRequester, 0, 0 ); + * + * @param cls The class name used in TDEConfig (ex. "Archives") + * @param name The itemname used in TDEConfig (ex. "Do Tar") + * @param dflt The default value of the URL requester + * @param text The text field of the URL requester + * @param parent Reference to the parent widget + * @param rst The change of this parameter requires Krusader restart + * @param pg The subpage of a Konfigurator page (because of setDefaults) + * + * @return reference to the newly created URL requester + */ + KonfiguratorURLRequester *createURLRequester( TQString cls, TQString name, + TQString dflt, TQWidget *parent, bool rst, int pg=FIRST_PAGE ); + + /** + * Adds a new font chooser item to the page. + * <br>The font chooser widget's name is TQString(cls + "/" + name).ascii()<br> + * + * Sample:<br><br> + * KonfiguratorFontChooser *myFontChooser = createFontChooser( "class", "name", new TQFont(), parentWidget );<br> + * myLayout->addWidget( myFontChooser, 0, 0 ); + * + * @param cls The class name used in TDEConfig (ex. "Archives") + * @param name The item name used in TDEConfig (ex. "Do Tar") + * @param dflt The default value of the font chooser + * @param parent Reference to the parent widget + * @param rst The change of this parameter requires Krusader restart + * @param pg The subpage of a Konfigurator page (because of setDefaults) + * + * @return reference to the newly created font chooser + */ + KonfiguratorFontChooser *createFontChooser( TQString cls, TQString name, TQFont *dflt, + TQWidget *parent=0, bool rst=false, int pg=FIRST_PAGE ); + + /** + * Adds a new combobox item to the page. + * <br>The combobox widget's name is TQString(cls + "/" + name).ascii()<br> + * + * Sample:<br><br> + * KONFIGURATOR_NAME_VALUE_PAIR comboInfo[] =<br> + * {{ i18n( "combo text1" ), "value1" },<br> + * { i18n( "combo text2" ), "value2" },<br> + * { i18n( "combo text3" ), "value3" }};<br><br> + * KonfiguratorComboBox *myComboBox = createComboBox( "class", "name", "value2", comboInfo, 3, parentWidget );<br> + * myLayout->addWidget( myComboBox, 0, 0 ); + * + * @param cls The class name used in TDEConfig (ex. "Archives") + * @param name The item name used in TDEConfig (ex. "Do Tar") + * @param dflt The default value of the combobox + * @param params Pointer to the name-value pair array (combo elements) + * @param paramNum Number of the combobox elements + * @param text The text field of the combobox + * @param parent Reference to the parent widget + * @param rst The change of this parameter requires Krusader restart + * @param editable Flag indicates that the combo can be edited + * @param pg The subpage of a Konfigurator page (because of setDefaults) + * + * @return reference to the newly created combobox + */ + KonfiguratorComboBox *createComboBox( TQString cls, TQString name, TQString dflt, + KONFIGURATOR_NAME_VALUE_PAIR *params, int paramNum, + TQWidget *parent=0, bool rst=false, bool editable=false, int pg=FIRST_PAGE ); + + /** + * Creates a frame on the page. + * + * Sample:<br><br> + * TQGroupBox *myGroup = createFrame( i18n( "MyFrameName" ), parentWidget, "frameName" );<br> + * myLayout->addWidget( myGroup, 0, 0 ); + * + * @param text The text written out onto the frame + * @param parent Reference to the parent widget + * @param widgetName The name of the widget + * + * @return reference to the newly created frame + */ + TQGroupBox *createFrame( TQString text = TQString(), TQWidget *parent=0, + const char *widgetName=0 ); + + /** + * Creates a new TQGridLayout element and sets its margins. + * + * Sample:<br><br> + * TQGroupBox *myGroup = createFrame( i18n( "MyFrameName" ), parentWidget, "frameName" );<br> + * TQGridLayout *myLayout = createGridLayout( myGroup->layout() );<br> + * myLayout->addWidget( myGroup, 0, 0 ); + * + * @param parent Reference to the parent layout + * + * @return reference to the newly created TQGridLayout + */ + TQGridLayout *createGridLayout( TQLayout *parent ); + + /** + * Adds a new label to a grid layout. + * + * Sample:<br><br> + * TQGroupBox *myGroup = createFrame( i18n( "MyFrameName" ), parentWidget, "frameName" );<br> + * TQGridLayout *myLayout = createGridLayout( myGroup->layout() );<br> + * addLabel( myLayout, 0, 0, i18n( "Hello world!" ), myGroup, "myLabel" );<br> + * mainLayout->addWidget( myGroup, 0, 0 ); + * + * @param layout The grid layout on which the item will be placed + * @param x the column to which the label will be placed + * @param y the row to which the label will be placed + * @param label the text of the label + * @param parent Reference to the parent widget + * @param widgetName The name of the newly generated label widget + * + * @return reference to the newly created label + */ + TQLabel *addLabel( TQGridLayout *layout, int x, int y, TQString label, + TQWidget *parent=0, const char *widgetName=0 ); + + /** + * Creates a spacer object (for justifying in TQHBox). + * + * Sample:<br><br> + * TQHBox *hbox = new TQHBox( myParent, "hbox" );<br> + * createSpinBox( "class", "spin", 5, 1, 10, hbox );<br> + * createSpacer( hbox, "mySpacer" );<br> + * myLayout->addWidget( hbox, 0, 0 ); + * + * @param parent Reference to the parent widget + * @param widgetName The name of the newly generated label widget + * + * @return reference to the newly created spacer widget + */ + TQWidget *createSpacer( TQWidget *parent=0, const char *widgetName=0 ); + + /** + * Creates a separator line. + * + * Sample:<br><br> + * TQFrame *myLine = createLine( myParent, "myLine" );<br> + * myLayout->addWidget( myLine, 1, 0 );<br> + * + * @param parent Reference to the parent widget + * @param widgetName The name of the newly generated label widget + * @param vertical Means vertical line + * + * @return reference to the newly created spacer widget + */ + TQFrame *createLine( TQWidget *parent=0, const char *widgetName=0, bool vertical = false ); + + /** + * Creates a checkbox group. A checkbox group contains a lot of checkboxes. + * The grouped checkboxes are embedded into one widget, which can be placed anywhere + * on the GUI. The placing of the elements can be horizontal or vertical in the group. + * At horizontal placing the sizex integer defines the maximum element number in + * one row, sizey is 0. At vertical placing sizex is 0, and sizey defines the + * maximum row number in one column. <br> + * + * One specific element can be reached by its name or index with the find methods. + * The first element is checkBoxGroup->find( 0 ), "myCb" element is checkBoxGroup->find( "myCb" ) ... + * + * Sample:<br><br> + * KONFIGURATOR_CHECKBOX_PARAM myCBArray[] =<br> + * {{"CbClass","CbName1", false, i18n( "name1" ), false, "tooltip1"},<br> + * {"CbClass","CbName2", true, i18n( "name2" ), false, "tooltip2"},<br> + * {"CbClass","CbName3", true, i18n( "name3" ), false, "tooltip3"}};<br><br> + * KonfiguratorCheckBoxGroup *myCheckBoxGroup = createCheckBoxGroup( 1, 0, myCBArray, 3, myParent, "myCheckboxGroup" );<br> + * myCheckBoxGroup->find( 0 )->setEnabled( false );<br><br> + * myLayout->addWidget( myCheckBoxGroup, 0, 0 );<br> + * + * @param sizex the maximum column number at horizontal placing + * @param sizey the maximum row number at vertical placing + * @param params pointer to the checkbox array + * @param paramNum number of the checkbox elements + * @param parent Reference to the parent widget + * @param widgetName The name of the newly created checkbox group widget + * @param pg The subpage of a Konfigurator page (because of setDefaults) + * + * @return reference to the newly created checkbox group widget + */ + KonfiguratorCheckBoxGroup *createCheckBoxGroup( int sizex, int sizey, + KONFIGURATOR_CHECKBOX_PARAM *params, int paramNum, + TQWidget *parent=0, const char *widgetName=0, int pg=FIRST_PAGE ); + /** + * Creates a radio button group. A radio button group contains a lot of radio buttons. + * The grouped buttons are embedded into one widget, which can be placed anywhere + * on the GUI. The placing of the elements can be horizontal or vertical in the group. + * At horizontal placing the sizex integer defines the maximum element number in + * one row, sizey is 0. At vertical placing sizex is 0, and sizey defines the + * maximum row number in one column.<br> + * + * The references of the buttons can be accessed by the find methods of KonfiguratorRadioButtons. + * The first element is myRadioGrp->find( 0 ), "myRadio" element is myRadioGrp->find( "myRadio" ) ... + * + * Sample:<br><br> + * KONFIGURATOR_NAME_VALUE_TIP radioInfo[] =<br> + * {{ i18n( "radio text1" ), "value1", i18n( "tooltip1" ) },<br> + * { i18n( "radio text2" ), "value2", i18n( "tooltip2" ) },<br> + * { i18n( "radio text3" ), "value3", i18n( "tooltip3" ) }};<br><br> + * KonfiguratorRadioButtons *myRadioGroup = createRadioButtonGroup( "class", "name", "value1", 1, 0, radioInfo, 3, myParent, "myRadioGroup" );<br> + * myRadioGroup->find( i18n( "radio text1" ) )->setEnabled( false );<br> + * myLayout->addWidget( myRadioGroup, 0, 0 );<br> + * + * @param cls The class name used in TDEConfig (ex. "Archives") + * @param name The item name used in TDEConfig (ex. "Do Tar") + * @param dflt The default value of the radio buttons + * @param sizex the maximum column number at horizontal placing + * @param sizey the maximum row number at vertical placing + * @param params pointer to the checkbox array + * @param paramNum number of the checkbox elements + * @param parent Reference to the parent widget + * @param widgetName The name of the newly created button group widget + * @param rst The change of this parameter requires Krusader restart + * @param pg The subpage of a Konfigurator page (because of setDefaults) + * + * @return reference to the newly created radio button group widget + */ + KonfiguratorRadioButtons *createRadioButtonGroup( TQString cls, TQString name, + TQString dflt, int sizex, int sizey, + KONFIGURATOR_NAME_VALUE_TIP *params, int paramNum, + TQWidget *parent=0, const char *widgetName=0, bool rst=false, int pg=FIRST_PAGE ); + + /** + * This function is used to insert new, unknown items into KonfiguratorPage. The + * item must be derived from KonfiguratorExtension class, which have + * isChanged(), apply(), setDefaults, loadInitialValue() methods. After that, the + * object is properly handled by Konfigurator page. + * + * + * @param item The item to be added to KonfiguratorPage + */ + void registerObject( KonfiguratorExtension *item ); + + /** + * This function is used to remove elements from KonfiguratorPage. + * + * Sample:<br><br> + * KonfiguratorEditBox *myEditBox = createEditBox( "class", "name", "default", parentWidget );<br> + * myLayout->addWidget( myEditBox, 0, 0 );<br> + * removeObject( myEditBox->extension() ); + * + * After the removeObject myEditBox will be untouched at apply(), setDefaults(), isChanged(), + * loadInitialValues() methods of the KonfiguratorPage. + * + * @param item The item to be removed from KonfiguratorPage + */ + void removeObject( KonfiguratorExtension *item ); + + /** + * Adds a new color chooser combobox item to the page. + * <br>The chooser's widget's name is TQString(cls + "/" + name).ascii()<br> + * + * Sample:<br><br> + * KonfiguratorColorChooser *myColorChooser = createColorChooser( "class", "name", TQColor( 255, 0, 255 ), parentWidget );<br> + * myLayout->addWidget( myColorChooser, 0, 0 ); + * + * @param cls The class name used in TDEConfig (ex. "Archives") + * @param name The item name used in TDEConfig (ex. "Do Tar") + * @param dflt The default value of the color chooser + * @param parent Reference to the parent widget + * @param rst The change of this parameter requires Krusader restart + * @param addColPtr The additional color values + * @param rst Number of additional colors + * @param pg The subpage of a Konfigurator page (because of setDefaults) + * + * @return reference to the newly created combobox + */ + KonfiguratorColorChooser *createColorChooser( TQString cls, TQString name, TQColor dflt, + TQWidget *parent=0, bool rst=false, + ADDITIONAL_COLOR *addColPtr = 0, int addColNum = 0, int pg=FIRST_PAGE ); +signals: + /** + * The signal is emitted if the changed flag was modified in any konfigurator item. + * Used for enabling/disabling the apply button. + */ + void sigChanged(); + +protected: + TQPtrList<KonfiguratorExtension> itemList; + +private: + bool firstCall; +}; + +/** + * KONFIGURATOR_CHECKBOX_PARAM is the basic item of checkbox arrays. It contains + * every information related to a checkbox. + */ +struct KONFIGURATOR_CHECKBOX_PARAM +{ + /** + * The class used in TDEConfig (ex. "Archives") + */ + TQString configClass; + /** + * The item name used in TDEConfig (ex. "Do Tar") + */ + TQString configName; + /** + * The default value of the checkbox + */ + bool defaultValue; + /** + * The text field of the checkbox + */ + TQString text; + /** + * The change of this parameter requires Krusader restart + */ + bool restart; + /** + * The checkbox's tooltip + */ + TQString toolTip; +}; + +#endif /* __KONFIGURATOR_PAGE_H__ */ diff --git a/src/app/Konfigurator/krresulttable.cpp b/src/app/Konfigurator/krresulttable.cpp new file mode 100644 index 0000000..3aabc8f --- /dev/null +++ b/src/app/Konfigurator/krresulttable.cpp @@ -0,0 +1,380 @@ +/*************************************************************************** + krresulttable.cpp + ------------------- + copyright : (C) 2005 by Dirk Eschler & Krusader Krew + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "krresulttable.h" +#include <iostream> +using namespace std; + +#define PS(x) _supported.contains(x)>0 + +KrResultTable::KrResultTable(TQWidget* parent) + : TQWidget(parent), + _numRows(1) +{ +} + +KrResultTable::~KrResultTable() +{ +} + + +TQGridLayout* KrResultTable::initTable() +{ + _grid = new TQGridLayout(this, _numRows, _numColumns); + _grid->setColStretch(_numColumns-1, 1); // stretch last column + + // +++ Build and add table header +++ + int column = 0; + for( TQStringList::Iterator it=_tableHeaders.begin(); it!=_tableHeaders.end(); ++it ) + { + _label = new TQLabel(*it, this); + _label->setMargin(5); + _grid->addWidget(_label, 0, column); + + // Set font + TQFont defFont = TDEGlobalSettings::generalFont(); + defFont.setPointSize(defFont.pointSize()-1); + defFont.setBold(true); + _label->setFont(defFont); + + ++column; + } + + return _grid; +} + + +void KrResultTable::adjustRow(TQGridLayout* grid) +{ + TQLayoutIterator it = grid->iterator(); + TQLayoutItem *child; + int col = 0; + + while( (child = it.current()) != 0 ) + { + // Add some space between columns + child->widget()->setMinimumWidth( child->widget()->sizeHint().width() + 15 ); + + // Paint uneven rows in alternate color + if( ((col/_numColumns)%2) ) + child->widget()->setPaletteBackgroundColor( TDEGlobalSettings::baseColor() ); + + ++it; + ++col; + } +} + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + +KrArchiverResultTable::KrArchiverResultTable(TQWidget* parent) + : KrResultTable(parent) +{ + _supported = KRarcHandler::supportedPackers(); // get list of available packers + + Archiver* tar = new Archiver("tar", "http://www.gnu.org", PS("tar"), true, true); + Archiver* gzip = new Archiver("gzip", "http://www.gnu.org", PS("gzip"), true, true); + Archiver* bzip2 = new Archiver("bzip2", "http://www.gnu.org", PS("bzip2"), true, true); + Archiver* lha = new Archiver("lha", "http://www.gnu.org", PS("lha"), true, true); + Archiver* zip = new Archiver("zip", "http://www.info-zip.org", PS("zip"), true, false); + Archiver* unzip = new Archiver("unzip", "http://www.info-zip.org", PS("unzip"), false, true); + Archiver* arj = new Archiver("arj", "http://www.arjsoftware.com", PS("arj"), true, true); + Archiver* unarj = new Archiver("unarj", "http://www.arjsoftware.com", PS("unarj"), false, true); + Archiver* unace = new Archiver("unace", "http://www.winace.com", PS("unace"), false, true); + Archiver* rar = new Archiver("rar", "http://www.rarsoft.com", PS("rar"), true, true); + Archiver* unrar = new Archiver("unrar", "http://www.rarsoft.com", PS("unrar"), false, true); + Archiver* rpm = new Archiver("rpm", "http://www.gnu.org", PS("rpm"), false, true); + Archiver* dpkg = new Archiver("dpkg", "http://www.dpkg.org", PS("dpkg"), false, true); + Archiver* _7z = new Archiver("7z", "http://www.7-zip.org", PS("7z"), true, true); + Archiver* xz = new Archiver("xz", "http://www.tukaani.org/xz", PS("xz"), true, true); + + // Special case: arj can unpack, but unarj is prefered + if(PS("arj") && PS("unarj")) + arj->setIsUnpacker(false); + if(PS("arj") && !PS("unarj")) + unarj->setNote( i18n("unarj not found, but arj found, which will be used for unpacking") ); + // Special case: rar can unpack, but unrar is prefered + if(PS("rar") && PS("unrar")) + rar->setIsUnpacker(false); + // Special case: rpm needs cpio for unpacking + if(PS("rpm") && !PS("cpio")) + rpm->setNote( i18n("rpm found, but cpio not found which is required for unpacking") ); + + _tableHeaders.append( i18n("Name") ); + _tableHeaders.append( i18n("Found") ); + _tableHeaders.append( i18n("Packing") ); + _tableHeaders.append( i18n("Unpacking") ); + _tableHeaders.append( i18n("Note") ); + _numColumns = _tableHeaders.size(); + + _grid = initTable(); + + addRow(tar, _grid); + addRow(gzip, _grid); + addRow(bzip2, _grid); + addRow(lha, _grid); + addRow(zip, _grid); + addRow(unzip, _grid); + addRow(arj, _grid); + addRow(unarj, _grid); + addRow(unace, _grid); + addRow(rar, _grid); + addRow(unrar, _grid); + addRow(rpm, _grid); + addRow(dpkg, _grid); + addRow(_7z, _grid); + addRow(xz, _grid); + + delete tar; + delete gzip; + delete bzip2; + delete lha; + delete zip; + delete unzip; + delete arj; + delete unarj; + delete unace; + delete rar; + delete unrar; + delete rpm; + delete dpkg; + delete _7z; + delete xz; +} + +KrArchiverResultTable::~KrArchiverResultTable() +{ +} + + +bool KrArchiverResultTable::addRow(SearchObject* search, TQGridLayout* grid) +{ + Archiver* arch = dynamic_cast<Archiver*>(search); + + // Name column + _label = new KURLLabel(arch->getWebsite(), arch->getSearchName(), this); + _label->setMargin(5); + _label->setAlignment(TQt::AlignTop); + grid->addWidget(_label, _numRows, 0); + connect(_label, TQ_SIGNAL(leftClickedURL(const TQString&)), + TQ_SLOT(website(const TQString&))); + + // Found column + _label = new TQLabel( arch->getPath(), this ); + _label->setMargin(5); + grid->addWidget(_label, _numRows, 1); + + // Packing column + _label = new TQLabel(this); + _label->setMargin(5); + _label->setAlignment( TQt::AlignTop ); + if( arch->getIsPacker() && arch->getFound() ) { + _label->setText( i18n("enabled") ); + _label->setPaletteForegroundColor("darkgreen"); + } else if( arch->getIsPacker() && !arch->getFound() ) { + _label->setText( i18n("disabled") ); + _label->setPaletteForegroundColor("red"); + } else + _label->setText( "" ); + grid->addWidget(_label, _numRows, 2); + + // Unpacking column + _label = new TQLabel(this); + _label->setMargin(5); + _label->setAlignment( TQt::AlignTop ); + if( arch->getIsUnpacker() && arch->getFound() ) { + _label->setText( i18n("enabled") ); + _label->setPaletteForegroundColor("darkgreen"); + } else if( arch->getIsUnpacker() && !arch->getFound() ) { + _label->setText( i18n("disabled") ); + _label->setPaletteForegroundColor("red"); + } else + _label->setText( "" ); + grid->addWidget(_label, _numRows, 3); + + // Note column + _label = new TQLabel(arch->getNote(), this); + _label->setMargin(5); + _label->setAlignment( TQt::AlignTop | TQt::WordBreak ); // wrap words + grid->addWidget(_label, _numRows, 4); + + // Apply shared design elements + adjustRow(_grid); + + // Ensure the last column takes more space + _label->setMinimumWidth(300); + + ++_numRows; + return true; +} + + +void KrArchiverResultTable::website(const TQString& url) +{ + (void) new KRun(url); +} + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + +KrToolResultTable::KrToolResultTable(TQWidget* parent) + : KrResultTable(parent) +{ + _supported = Krusader::supportedTools(); // get list of available tools + + TQValueVector<Application*> vecDiff, vecMail, vecRename, vecChecksum; + Application* kdiff3 = new Application("kdiff3", "http://kdiff3.sourceforge.net/", KrServices::cmdExist("kdiff3")); + Application* kompare = new Application("kompare", "http://www.caffeinated.me.uk/kompare/", KrServices::cmdExist("kompare")); + Application* xxdiff = new Application("xxdiff", "http://xxdiff.sourceforge.net/", KrServices::cmdExist("xxdiff")); + Application* kmail = new Application("kmail", "http://kmail.kde.org/", KrServices::cmdExist("kmail")); + Application* krename = new Application("krename", "http://www.krename.net/", KrServices::cmdExist("krename")); + Application* md5sum = new Application("md5sum", "http://www.gnu.org/software/textutils/textutils.html", KrServices::cmdExist("md5sum")); + Application* md5deep = new Application("md5deep", "http://md5deep.sourceforge.net/", KrServices::cmdExist("md5deep")); + Application* sha1deep = new Application("sha1deep", "http://md5deep.sourceforge.net/", KrServices::cmdExist("sha1deep")); + Application* sha256deep = new Application("sha256deep", "http://md5deep.sourceforge.net/", KrServices::cmdExist("sha256deep")); + Application* tigerdeep = new Application("tigerdeep", "http://md5deep.sourceforge.net/", KrServices::cmdExist("tigerdeep")); + Application* whirlpooldeep = new Application("whirlpooldeep", "http://md5deep.sourceforge.net/", KrServices::cmdExist("whirlpooldeep")); + Application* cfv = new Application("cfv", "http://cfv.sourceforge.net/", KrServices::cmdExist("cfv")); + + vecDiff.push_back(kdiff3); + vecDiff.push_back(kompare); + vecDiff.push_back(xxdiff); + vecMail.push_back(kmail); + vecRename.push_back(krename); + vecChecksum.push_back(md5sum); + vecChecksum.push_back(md5deep); + vecChecksum.push_back(sha1deep); + vecChecksum.push_back(sha256deep); + vecChecksum.push_back(tigerdeep); + vecChecksum.push_back(whirlpooldeep); + vecChecksum.push_back(cfv); + + ApplicationGroup* diff = new ApplicationGroup( i18n("diff utility"), PS("DIFF"), vecDiff); + ApplicationGroup* mail = new ApplicationGroup( i18n("email client"), PS("MAIL"), vecMail); + ApplicationGroup* rename = new ApplicationGroup( i18n("batch renamer"), PS("RENAME"), vecRename); + ApplicationGroup* checksum = new ApplicationGroup( i18n("checksum utility"), PS("MD5"), vecChecksum); + + _tableHeaders.append( i18n("Group") ); + _tableHeaders.append( i18n("Tool") ); + _tableHeaders.append( i18n("Found") ); + _tableHeaders.append( i18n("Status") ); + _numColumns = _tableHeaders.size(); + + _grid = initTable(); + + addRow(diff, _grid); + addRow(mail, _grid); + addRow(rename, _grid); + addRow(checksum, _grid); + + delete kmail; + delete kompare; + delete kdiff3; + delete xxdiff; + delete krename; + delete md5sum; + delete md5deep; + delete sha1deep; + delete sha256deep; + delete tigerdeep; + delete whirlpooldeep; + delete cfv; + + delete diff; + delete mail; + delete rename; + delete checksum; +} + +KrToolResultTable::~KrToolResultTable() +{ +} + + +bool KrToolResultTable::addRow(SearchObject* search, TQGridLayout* grid) +{ + ApplicationGroup* appGroup = dynamic_cast<ApplicationGroup*>(search); + TQValueVector<Application*> _apps = appGroup->getAppVec(); + + // Name column + _label = new TQLabel(appGroup->getSearchName(), this); + _label->setMargin(5); + _label->setAlignment( TQt::AlignTop ); + grid->addWidget(_label, _numRows, 0); + + // Tool column + TQVBox* toolBox = new TQVBox(this); + for( TQValueVector<Application*>::Iterator it=_apps.begin(); it!=_apps.end(); it++ ) + { + KURLLabel* l = new KURLLabel( (*it)->getWebsite(), (*it)->getAppName(), toolBox); + l->setAlignment(TQt::AlignLeft | TQt::AlignTop); + l->setMargin(5); + connect(l, TQ_SIGNAL(leftClickedURL(const TQString&)), + TQ_SLOT(website(const TQString&))); + } + grid->addWidget(toolBox, _numRows, 1); + + // Found column + TQVBox* vbox = new TQVBox(this); + for( TQValueVector<Application*>::Iterator it=_apps.begin(); it!=_apps.end(); it++ ) + { + _label = new TQLabel( (*it)->getPath(), vbox); + _label->setMargin(5); + _label->setAlignment( TQt::AlignTop ); + } + grid->addWidget(vbox, _numRows, 2); + + // Status column + _label = new TQLabel(this); + _label->setMargin(5); + _label->setAlignment( TQt::AlignTop ); + if( appGroup->getFoundGroup() ) { + _label->setText( i18n("enabled") ); + _label->setPaletteForegroundColor("darkgreen"); + } else { + _label->setText( i18n("disabled") ); + _label->setPaletteForegroundColor("red"); + } + grid->addWidget(_label, _numRows, 3); + + // Apply shared design elements + adjustRow(_grid); + + // Ensure the last column takes more space + _label->setMinimumWidth(300); + + ++_numRows; + return true; +} + +void KrToolResultTable::website(const TQString& url) +{ + (void) new KRun(url); +} diff --git a/src/app/Konfigurator/krresulttable.h b/src/app/Konfigurator/krresulttable.h new file mode 100644 index 0000000..b010a2b --- /dev/null +++ b/src/app/Konfigurator/krresulttable.h @@ -0,0 +1,142 @@ +/*************************************************************************** + krresulttable.h + ------------------- + copyright : (C) 2005 by Dirk Eschler & Krusader Krew + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef KRRESULTTABLE_H +#define KRRESULTTABLE_H + +#include <tqstring.h> +#include <tqlabel.h> +#include <tqlayout.h> +#include <tqhbox.h> +#include <tqvbox.h> +#include <tqgrid.h> +#include <tqstringlist.h> +#include <tqvaluevector.h> + +#include <kiconloader.h> +#include <tdeglobalsettings.h> +#include <tdelocale.h> +#include <tdelocale.h> +#include <krun.h> +#include <kseparator.h> +#include <kurllabel.h> + +#include "searchobject.h" +#include "../krusader.h" +#include "../krservices.h" +#include "../VFS/krarchandler.h" + +/** +@author Dirk Eschler <deschler@users.sourceforge.net> +*/ +class KrResultTable : public TQWidget +{ +public: + KrResultTable(TQWidget* parent); + virtual ~KrResultTable(); + + /** + * Adds a row of search results to the end of a TQGridLayout + * Each KrResultTable has to implement it + * + * @param const SearchObject* search Name of the SearchObject + * @param const TQGridLayout* grid The GridLayout where the row is inserted + * + * @return bool True if row was added successfully to rows, else false + */ + virtual bool addRow(SearchObject* search, TQGridLayout* grid) = 0; + +protected: + TQStringList _supported; + TQStringList _tableHeaders; + int _numColumns; + int _numRows; + + TQGridLayout* _grid; + TQHBox* _iconBox; + TQLabel* _label; // generic label + + /** + * Creates the main grid layout and attaches the table header + * + * @return bool Pointer to the main grid layout + */ + TQGridLayout* initTable(); + + /** + * Applies settings to each cell of the grid layout + * Supposed to be run after a row was added + * + * @param const TQGridLayout* grid The GridLayout + */ + void adjustRow(TQGridLayout* grid); +}; + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + +class KrArchiverResultTable : public KrResultTable +{ + TQ_OBJECT + +public: + KrArchiverResultTable(TQWidget* parent); + virtual ~KrArchiverResultTable(); + + bool addRow(SearchObject* search, TQGridLayout* grid); + +protected: + KURLLabel* _nameLabel; + +protected slots: + void website(const TQString&); +}; + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + +class KrToolResultTable : public KrResultTable +{ + TQ_OBJECT + +public: + KrToolResultTable(TQWidget* parent); + virtual ~KrToolResultTable(); + + bool addRow(SearchObject* search, TQGridLayout* grid); + +protected: + TQValueVector<Application*> _apps; + +protected slots: + void website(const TQString&); +}; + +#endif diff --git a/src/app/Konfigurator/krresulttabledialog.cpp b/src/app/Konfigurator/krresulttabledialog.cpp new file mode 100644 index 0000000..9225875 --- /dev/null +++ b/src/app/Konfigurator/krresulttabledialog.cpp @@ -0,0 +1,97 @@ +/*************************************************************************** + krresulttabledialog.cpp + ------------------- + copyright : (C) 2005 by Dirk Eschler & Krusader Krew + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "krresulttabledialog.h" + +KrResultTableDialog::KrResultTableDialog( TQWidget *parent, DialogType type, + const TQString& caption, const TQString& heading, const TQString& headerIcon, + const TQString& hint) + : KDialogBase( parent, "KrSearchResultDialog", true, caption, KDialogBase::Help|KDialogBase::Ok, + KDialogBase::Ok, false ) + +{ + _page = new TQWidget(this); + setMainWidget(_page); + _topLayout = new TQVBoxLayout(_page, 0, spacingHint()); + _topLayout->setAlignment( TQt::AlignTop ); + + // +++ Heading +++ + // prepare the icon + _iconBox = new TQHBox(_page, "_iconBox"); + _iconLabel = new TQLabel(_iconBox, "iconLabel"); + _iconLabel->setPixmap(krLoader->loadIcon(headerIcon, TDEIcon::Desktop, 32)); + _iconLabel->setMinimumWidth(fontMetrics().maxWidth()*20); + _iconLabel->setAlignment( TQt::AlignLeft | TQt::AlignVCenter ); + _iconLabel->setFixedSize( _iconLabel->sizeHint() ); + _headingLabel = new TQLabel(heading, _iconBox); + TQFont defFont = TDEGlobalSettings::generalFont(); + defFont.setBold(true); + _headingLabel->setFont(defFont); + _headingLabel->setIndent(10); + _topLayout->addWidget(_iconBox); + + // +++ Add some space between heading and table +++ + TQSpacerItem* hSpacer1 = new TQSpacerItem(0, 5); + _topLayout->addItem(hSpacer1); + + // +++ Table +++ + switch(type) { + case Archiver: + _resultTable = new KrArchiverResultTable(_page); + setHelp("konfig-archives"); // launch handbook at sect1-id via help button + break; + case Tool: + _resultTable = new KrToolResultTable(_page); + setHelp(""); // TODO find a good anchor + break; + default: + break; + } + _topLayout->addWidget(_resultTable); + + // +++ Separator +++ + KSeparator* hSep = new KSeparator(TQFrame::HLine, _page); + hSep->setMargin(5); + _topLayout->addWidget(hSep); + + // +++ Hint +++ + if(hint != TQString()) { + _hintLabel = new TQLabel(hint, _page); + _hintLabel->setIndent(5); + _hintLabel->setAlignment(TQt::AlignRight); + _topLayout->addWidget(_hintLabel); + } + + this->setFixedSize( this->sizeHint() ); // make non-resizeable +} + +KrResultTableDialog::~KrResultTableDialog() +{ +} diff --git a/src/app/Konfigurator/krresulttabledialog.h b/src/app/Konfigurator/krresulttabledialog.h new file mode 100644 index 0000000..152e184 --- /dev/null +++ b/src/app/Konfigurator/krresulttabledialog.h @@ -0,0 +1,84 @@ +/*************************************************************************** + krresulttabledialog.h + ------------------- + copyright : (C) 2005 by Dirk Eschler & Krusader Krew + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef KRRESULTTABLEDIALOG_H +#define KRRESULTTABLEDIALOG_H + +#include <tqlabel.h> +#include <tqvbox.h> +#include <tqhbox.h> +#include <tqlayout.h> +#include <tqstringlist.h> +#include <tqvaluevector.h> + +#include <kdialogbase.h> +#include <kiconloader.h> +#include <tdeglobalsettings.h> +#include <tdelocale.h> + +#include "../krusader.h" +#include "../Konfigurator/krresulttable.h" +#include "../Konfigurator/searchobject.h" + +/** +@author Dirk Eschler <deschler@users.sourceforge.net> +*/ +class KrResultTableDialog : public KDialogBase +{ +public: + + enum DialogType + { + Archiver = 1, + Tool = 2 + }; + + KrResultTableDialog(TQWidget *parent, DialogType type, const TQString& caption, const TQString& heading, const TQString& headerIcon=TQString(), const TQString& hint=TQString()); + virtual ~KrResultTableDialog(); + + const TQString& getHeading() const { return _heading; } + const TQString& getHint() const { return _hint; } + void setHeading(const TQString& s) { _heading = s; } + void setHint(const TQString& s) { _hint = s; } + +protected: + TQString _heading; + TQString _hint; + + TQLabel* _headingLabel; + TQLabel* _iconLabel; + TQLabel* _hintLabel; + TQHBox* _iconBox; + TQWidget* _page; + TQVBoxLayout* _topLayout; + KrResultTable* _resultTable; +}; + +#endif diff --git a/src/app/Konfigurator/searchobject.cpp b/src/app/Konfigurator/searchobject.cpp new file mode 100644 index 0000000..8976cb5 --- /dev/null +++ b/src/app/Konfigurator/searchobject.cpp @@ -0,0 +1,106 @@ +/*************************************************************************** + searchobject.cpp + ------------------- + copyright : (C) 2005 by Dirk Eschler & Krusader Krew + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "searchobject.h" + +SearchObject::SearchObject() +{ +} + +SearchObject::SearchObject(const TQString& searchName, bool found, const TQString& note) + : _searchName(searchName), + _found(found), + _note(note) +{ +} + +SearchObject::~SearchObject() +{ +} + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + +Application::Application() +{ +} + +Application::Application(const TQString& searchName, bool found, const TQString& appName, const TQString& website, const TQString& note) + : SearchObject(searchName, found, note), + _appName(appName), + _website(website), + _path(KrServices::fullPathName(appName)) +{ +} + +Application::Application(const TQString& searchName, const TQString& website, bool found, const TQString& note) + : SearchObject(searchName, found, note), + _appName(searchName), + _website(website), + _path(KrServices::fullPathName(searchName)) +{ +} + +Application::~Application() +{ +} + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + +Archiver::Archiver() + : Application() +{ +} + +Archiver::Archiver(const TQString& searchName, const TQString& website, bool found, bool isPacker, bool isUnpacker, const TQString& note) + : Application(searchName, website, found, note), + _isPacker(isPacker), + _isUnpacker(isUnpacker) +{ +} + +Archiver::~Archiver() +{ +} + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + +ApplicationGroup::ApplicationGroup(const TQString& searchName, bool foundGroup, const TQValueVector<Application*>& apps, const TQString& note) + : SearchObject(searchName, foundGroup, note), + _apps(apps), + _foundGroup(foundGroup) +{ +} + +ApplicationGroup::~ApplicationGroup() +{ +} diff --git a/src/app/Konfigurator/searchobject.h b/src/app/Konfigurator/searchobject.h new file mode 100644 index 0000000..3f1da59 --- /dev/null +++ b/src/app/Konfigurator/searchobject.h @@ -0,0 +1,131 @@ +/*************************************************************************** + searchobject.h + ------------------- + copyright : (C) 2005 by Dirk Eschler & Krusader Krew + e-mail : krusader@users.sourceforge.net + web site : http://krusader.sourceforge.net + --------------------------------------------------------------------------- + Description + *************************************************************************** + + A + + db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. + 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D + 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' + 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b + 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. + YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD + + S o u r c e F i l e + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef SEARCHOBJECT_H +#define SEARCHOBJECT_H + +#include <tqstring.h> +#include <tqvaluevector.h> +#include "../krservices.h" + +/** +@author Dirk Eschler <deschler@users.sourceforge.net> +*/ +class SearchObject +{ +public: + SearchObject(); + SearchObject(const TQString& name, bool found, const TQString& note); + virtual ~SearchObject(); + + const TQString& getSearchName() const { return _searchName; } + const TQString& getNote() const { return _note; } + const bool getFound() const { return _found; } + void setSearchName(const TQString& s) { _searchName = s; } + void setNote(const TQString& s) { _note = s; } + void setFound(const bool& b) { _found = b; } + +protected: + TQString _searchName; + bool _found; + TQString _note; +}; + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + +/** +@author Dirk Eschler <deschler@users.sourceforge.net> +*/ +class Application : public SearchObject +{ +public: + Application(); + Application(const TQString& searchName, bool found, const TQString& appName, const TQString& website=TQString(), const TQString& note=TQString()); + Application(const TQString& searchName, const TQString& website, bool found, const TQString& note=TQString()); + virtual ~Application(); + + const TQString& getWebsite() const { return _website; } + const TQString& getAppName() const { return _appName; } + const TQString& getPath() const { return _path; } + void setWebsite(const TQString& s) { _website = s; } + void setAppName(const TQString& s) { _appName = s; } + void setPath(const TQString& s) { _path = s; } + +protected: + TQString _appName; + TQString _website; + TQString _path; +}; + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + +/** +@author Dirk Eschler <deschler@users.sourceforge.net> +*/ +class Archiver : public Application +{ +public: + Archiver(); + Archiver(const TQString& searchName, const TQString& website, bool found, bool isPacker, bool isUnpacker, const TQString& note=TQString()); + ~Archiver(); + + const bool getIsPacker() const { return _isPacker; } + const bool getIsUnpacker() const { return _isUnpacker; } + void setIsPacker(const bool& b) { _isPacker = b; } + void setIsUnpacker(const bool& b) { _isUnpacker = b; } + +protected: + bool _isPacker; + bool _isUnpacker; +}; + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + +/** +@author Dirk Eschler <deschler@users.sourceforge.net> +*/ +class ApplicationGroup : public SearchObject +{ +public: + ApplicationGroup(const TQString& searchName, bool foundGroup, const TQValueVector<Application*>& apps, const TQString& note=TQString()); + ~ApplicationGroup(); + + const TQValueVector<Application*>& getAppVec() const { return _apps; } + const bool getFoundGroup() const { return _foundGroup; } + +protected: + TQValueVector<Application*> _apps; + bool _foundGroup; +}; + +#endif |