diff --git a/krusader/Konfigurator/kgadvanced.cpp b/krusader/Konfigurator/kgadvanced.cpp index 4cf022fb..8d256089 100644 --- a/krusader/Konfigurator/kgadvanced.cpp +++ b/krusader/Konfigurator/kgadvanced.cpp @@ -1,113 +1,115 @@ /***************************************************************************** * Copyright (C) 2004 Csaba Karai * * Copyright (C) 2004-2020 Krusader Krew [https://krusader.org] * * * * This file is part of Krusader [https://krusader.org]. * * * * Krusader 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. * * * * Krusader is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * *****************************************************************************/ #include "kgadvanced.h" #include "../defaults.h" // QtWidgets #include #include #include #include KgAdvanced::KgAdvanced(bool first, QWidget* parent) : KonfiguratorPage(first, parent) { QWidget *innerWidget = new QFrame(this); setWidget(innerWidget); setWidgetResizable(true); auto *kgAdvancedLayout = new QGridLayout(innerWidget); kgAdvancedLayout->setSpacing(6); // -------------------------- GENERAL GROUPBOX ---------------------------------- QGroupBox *generalGrp = createFrame(i18n("General"), innerWidget); QGridLayout *generalGrid = createGridLayout(generalGrp); KONFIGURATOR_CHECKBOX_PARAM generalSettings[] = // cfg_class cfg_name default text restart tooltip { {"Advanced", "AutoMount", _AutoMount, i18n("Automount filesystems"), false, i18n("When stepping into a folder which is defined as a mount point in the fstab, try mounting it with the defined parameters.")} }; KonfiguratorCheckBoxGroup *generals = createCheckBoxGroup(1, 0, generalSettings, 1, generalGrp); generalGrid->addWidget(generals, 1, 0); - addLabel(generalGrid, 2, 0, i18n("MountMan will not (un)mount the following mount-points:"), + QLabel *labelNonMount = addLabel(generalGrid, 2, 0, i18n("MountMan will not (un)mount the following mount-points:"), generalGrp); - KonfiguratorEditBox *nonMountPoints = createEditBox("Advanced", "Nonmount Points", _NonMountPoints, generalGrp, false); + KonfiguratorEditBox *nonMountPoints = createEditBox("Advanced", "Nonmount Points", _NonMountPoints, + labelNonMount, 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 ------------------------------- QGroupBox *confirmGrp = createFrame(i18n("Confirmations"), innerWidget); QGridLayout *confirmGrid = createGridLayout(confirmGrp); addLabel(confirmGrid, 0, 0, i18n("\nRequest user confirmation for the following operations:\n"), confirmGrp); KONFIGURATOR_CHECKBOX_PARAM confirmations[] = // cfg_class cfg_name default text restart ToolTip {{"Advanced", "Confirm Unempty Dir", _ConfirmUnemptyDir, i18n("Deleting non-empty folders"), 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 -------------------------------- QGroupBox *fineTuneGrp = createFrame(i18n("Fine-Tuning"), innerWidget); QGridLayout *fineTuneGrid = createGridLayout(fineTuneGrp); fineTuneGrid->setAlignment(Qt::AlignLeft | Qt::AlignTop); const QString cacheTip = 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."); QLabel *label = new QLabel(i18n("Icon cache size (KB):"), fineTuneGrp); fineTuneGrid->addWidget(label, 0, 0); KonfiguratorSpinBox *spinBox = createSpinBox("Advanced", "Icon Cache Size", _IconCacheSize, 1, 8192, label, fineTuneGrp, false, cacheTip); spinBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); fineTuneGrid->addWidget(spinBox, 0, 1); - addLabel(fineTuneGrid, 1, 0, i18n("Arguments of updatedb:"), + QLabel *labelArgUpdate = addLabel(fineTuneGrid, 1, 0, i18n("Arguments of updatedb:"), fineTuneGrp); - KonfiguratorEditBox *updatedbArgs = createEditBox("Locate", "UpdateDB Arguments", "", fineTuneGrp, false); + KonfiguratorEditBox *updatedbArgs = createEditBox("Locate", "UpdateDB Arguments", "", + labelArgUpdate, fineTuneGrp, false); fineTuneGrid->addWidget(updatedbArgs, 1, 1); kgAdvancedLayout->addWidget(fineTuneGrp, 2 , 0); } diff --git a/krusader/Konfigurator/kgstartup.cpp b/krusader/Konfigurator/kgstartup.cpp index e9e3c281..2dbb29dc 100644 --- a/krusader/Konfigurator/kgstartup.cpp +++ b/krusader/Konfigurator/kgstartup.cpp @@ -1,140 +1,140 @@ /***************************************************************************** * Copyright (C) 2004 Csaba Karai * * Copyright (C) 2004-2020 Krusader Krew [https://krusader.org] * * * * This file is part of Krusader [https://krusader.org]. * * * * Krusader 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. * * * * Krusader is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * *****************************************************************************/ #include "kgstartup.h" #include "../defaults.h" #include "../GUI/profilemanager.h" // QtWidgets #include #include #include #include KgStartup::KgStartup(bool first, QWidget* parent) : KonfiguratorPage(first, parent), profileCombo(nullptr) { QWidget *innerWidget = new QFrame(this); setWidget(innerWidget); setWidgetResizable(true); auto *kgStartupLayout = new QGridLayout(innerWidget); kgStartupLayout->setSpacing(6); // --------------------------- PANELS GROUPBOX ---------------------------------- QGroupBox *panelsGrp = createFrame(i18n("General"), innerWidget); QGridLayout *panelsGrid = createGridLayout(panelsGrp); QString s = "

" + i18n("Defines the panel profile used at startup. A panel profile contains:
  • all the tabs paths
  • the current tab
  • the active panel
<Last session> is a special panel profile which is saved automatically when Krusader is closed."); QLabel *label = addLabel(panelsGrid, 0, 0, i18n("Startup profile:"), panelsGrp); panelsGrp->setWhatsThis(s); QStringList profileList = ProfileManager::availableProfiles("Panel"); profileList.push_front(i18n("")); const int profileListSize = profileList.size(); auto *comboItems = new KONFIGURATOR_NAME_VALUE_PAIR[ profileListSize ]; for (int i = 0; i != profileListSize; i++) comboItems[ i ].text = comboItems[ i ].value = profileList [ i ]; comboItems[ 0 ].value = ""; profileCombo = createComboBox("Startup", "Starter Profile Name", comboItems[ 0 ].value, comboItems, profileListSize, label, panelsGrp, false, false); profileCombo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); panelsGrid->addWidget(profileCombo, 0, 1); delete [] comboItems; //------------------------------------------------ panelsGrid->addWidget(createLine(panelsGrp), 1, 0, 1, 2); 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->addWidget(cbs, 2, 0, 1, 2); auto *iconThemeLayout = new QHBoxLayout(); QLabel *iconThemeLabel = new QLabel(i18n("Fallback Icon Theme:")); - iconThemeLabel->setWhatsThis(i18n("Whenever icon is not found in system icon theme, " - "this theme will be used as a fallback. " - "If fallback theme doesn't contain the icon, " - "Breeze or Oxygen will be used if any of these are present.")); + QString toolTip = i18n("Whenever icon is not found in system icon theme, " + "this theme will be used as a fallback. " + "If fallback theme doesn't contain the icon, " + "Breeze or Oxygen will be used if any of these are present."); iconThemeLayout->addWidget(iconThemeLabel); KonfiguratorEditBox *iconThemeEditBox = createEditBox("Startup", "Fallback Icon Theme", "", - panelsGrp, true); + iconThemeLabel, panelsGrp, true, toolTip); iconThemeLayout->addWidget(iconThemeEditBox); iconThemeLayout->addStretch(1); panelsGrid->addLayout(iconThemeLayout, 3, 0, 1, 2); kgStartupLayout->addWidget(panelsGrp, 0, 0); // ------------------------ USERINTERFACE GROUPBOX ------------------------------ QGroupBox *uiGrp = createFrame(i18n("User Interface"), innerWidget); QGridLayout *uiGrid = createGridLayout(uiGrp); KONFIGURATOR_CHECKBOX_PARAM uiSettings[] = { // cfg_class cfg_name default text restart tooltip {"Startup", "Remember Position", _RememberPos,i18n("Save last position, size and panel settings"), false, i18n("

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.

" "

If this option is disabled, you can use the menu Window -> Save Position option " "to manually set the main window's size and position at startup.

") }, {"Startup", "Update Default Panel Settings", _RememberPos, i18n("Update default panel settings"), true, i18n("When settings of a panel are changed, save them as the default for new panels of the same type.") }, {"Startup", "Start To Tray", _StartToTray, i18n("Start to tray"), false, i18n("Krusader starts to tray, without showing the main window") }, }; KonfiguratorCheckBoxGroup *uiSettingsGroup = createCheckBoxGroup(1, 0, uiSettings, 3, uiGrp); uiGrid->addWidget(uiSettingsGroup, 1, 0); KONFIGURATOR_CHECKBOX_PARAM uiCheckBoxes[] = { // cfg_class, cfg_name, default, text, restart, ToolTip {"Startup", "UI Save Settings", _UiSave, i18n("Save component settings on exit"), false, i18n("Check the state of the user interface components and restore them to their condition when last shutdown.") }, {"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 embedded terminal"), false, i18n("Embedded terminal will be visible after startup.") }, }; uiCbGroup = createCheckBoxGroup(1, 0, uiCheckBoxes, 4, uiGrp); connect(uiCbGroup->find("UI Save Settings"), &KonfiguratorCheckBox::stateChanged, this, &KgStartup::slotDisable); uiGrid->addWidget(uiCbGroup, 2, 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); } diff --git a/krusader/Konfigurator/konfiguratorpage.cpp b/krusader/Konfigurator/konfiguratorpage.cpp index c7498633..a1819dae 100644 --- a/krusader/Konfigurator/konfiguratorpage.cpp +++ b/krusader/Konfigurator/konfiguratorpage.cpp @@ -1,314 +1,317 @@ /***************************************************************************** * Copyright (C) 2003 Csaba Karai * * Copyright (C) 2004-2020 Krusader Krew [https://krusader.org] * * * * This file is part of Krusader [https://krusader.org]. * * * * Krusader 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. * * * * Krusader is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * *****************************************************************************/ #include "konfiguratorpage.h" // QtWidgets #include #include #include #include #include #include #include #include "../krglobal.h" KonfiguratorPage::KonfiguratorPage(bool firstTime, QWidget* parent) : QScrollArea(parent), firstCall(firstTime) { setFrameStyle(QFrame::NoFrame); } bool KonfiguratorPage::apply() { bool restartNeeded = false; for (auto & item : itemList) restartNeeded = item->apply() || restartNeeded; krConfig->sync(); return restartNeeded; } void KonfiguratorPage::setDefaults() { int activePage = activeSubPage(); for (auto & item : itemList) { if (item->subPage() == activePage) item->setDefaults(); } } void KonfiguratorPage::loadInitialValues() { for (auto & item : itemList) item->loadInitialValue(); } bool KonfiguratorPage::isChanged() { bool isChanged = false; for (auto & item : itemList) isChanged = isChanged || item->isChanged(); return isChanged; } KonfiguratorCheckBox* KonfiguratorPage::createCheckBox(QString configGroup, QString name, bool defaultValue, QString text, QWidget *parent, bool restart, const QString &toolTip, int page) { KonfiguratorCheckBox *checkBox = new KonfiguratorCheckBox(std::move(configGroup), std::move(name), defaultValue, std::move(text), parent, restart, page); if (!toolTip.isEmpty()) { checkBox->setWhatsThis(toolTip); checkBox->setToolTip(toolTip); } registerObject(checkBox->extension()); return checkBox; } KonfiguratorSpinBox* KonfiguratorPage::createSpinBox(QString configGroup, QString configName, int defaultValue, int min, int max, QLabel *label, QWidget *parent, bool restart, const QString &toolTip, int page) { KonfiguratorSpinBox *spinBox = new KonfiguratorSpinBox(std::move(configGroup), std::move(configName), defaultValue, min, max, parent, restart, page); if (!toolTip.isEmpty()) { label->setWhatsThis(toolTip); label->setToolTip(toolTip); spinBox->setWhatsThis(toolTip); spinBox->setToolTip(toolTip); } registerObject(spinBox->extension()); return spinBox; } KonfiguratorEditBox* KonfiguratorPage::createEditBox(QString configGroup, QString name, - QString defaultValue, QWidget *parent, bool restart, const QString &toolTip, int page) + QString defaultValue, QLabel *label, QWidget *parent, bool restart, + const QString &toolTip, int page) { KonfiguratorEditBox *editBox = new KonfiguratorEditBox(std::move(configGroup), std::move(name), std::move(defaultValue), parent, restart, page); if (!toolTip.isEmpty()) { + label->setWhatsThis(toolTip); + label->setToolTip(toolTip); editBox->setWhatsThis(toolTip); editBox->setToolTip(toolTip); } registerObject(editBox->extension()); return editBox; } KonfiguratorListBox* KonfiguratorPage::createListBox(QString configGroup, QString name, QStringList defaultValue, QWidget *parent, bool restart, const QString &toolTip, int page) { KonfiguratorListBox *listBox = new KonfiguratorListBox(std::move(configGroup), std::move(name), std::move(defaultValue), parent, restart, page); if (!toolTip.isEmpty()) { listBox->setWhatsThis(toolTip); listBox->setToolTip(toolTip); } registerObject(listBox->extension()); return listBox; } KonfiguratorURLRequester* KonfiguratorPage::createURLRequester(QString configGroup, QString name, QString defaultValue, QWidget *parent, bool restart, const QString &toolTip, int page, bool expansion) { KonfiguratorURLRequester *urlRequester = new KonfiguratorURLRequester(std::move(configGroup), std::move(name), std::move(defaultValue), parent, restart, page, expansion); if (!toolTip.isEmpty()) { urlRequester->setWhatsThis(toolTip); urlRequester->setToolTip(toolTip); } registerObject(urlRequester->extension()); return urlRequester; } QGroupBox* KonfiguratorPage::createFrame(const QString& text, QWidget *parent) { auto *groupBox = new QGroupBox(parent); if (!text.isNull()) groupBox->setTitle(text); return groupBox; } QGridLayout* KonfiguratorPage::createGridLayout(QWidget *parent) { auto *gridLayout = new QGridLayout(parent); gridLayout->setAlignment(Qt::AlignTop); gridLayout->setSpacing(6); gridLayout->setContentsMargins(11, 11, 11, 11); return gridLayout; } QLabel* KonfiguratorPage::addLabel(QGridLayout *layout, int x, int y, const QString& label, QWidget *parent) { QLabel *lbl = new QLabel(label, parent); layout->addWidget(lbl, x, y); return lbl; } QWidget* KonfiguratorPage::createSpacer(QWidget *parent) { QWidget *widget = new QWidget(parent); auto *hboxlayout = new QHBoxLayout(widget); auto* spacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); hboxlayout->addItem(spacer); return widget; } KonfiguratorCheckBoxGroup* KonfiguratorPage::createCheckBoxGroup(int sizex, int sizey, KONFIGURATOR_CHECKBOX_PARAM *params, int paramNum, QWidget *parent, int page) { auto *groupWidget = new KonfiguratorCheckBoxGroup(parent); auto *layout = new QGridLayout(groupWidget); layout->setSpacing(6); layout->setContentsMargins(0, 0, 0, 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, page); 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(QString configGroup, QString name, QString defaultValue, int sizex, int sizey, KONFIGURATOR_NAME_VALUE_TIP *params, int paramNum, QWidget *parent, bool restart, int page) { KonfiguratorRadioButtons *radioWidget = new KonfiguratorRadioButtons(std::move(configGroup), std::move(name), std::move(defaultValue), parent, restart, page); auto *layout = new QGridLayout(radioWidget); layout->setAlignment(Qt::AlignTop); layout->setSpacing(6); layout->setContentsMargins(0, 0, 0, 0); int x = 0, y = 0; for (int i = 0; i != paramNum; i++) { auto *radBtn = new QRadioButton(params[i].text, radioWidget); if (!params[i].tooltip.isEmpty()) { radBtn->setWhatsThis(params[i].tooltip); radBtn->setToolTip(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(QString configGroup, QString name, const QFont& defaultValue, QWidget *parent, bool restart, int page) { KonfiguratorFontChooser *fontChooser = new KonfiguratorFontChooser(std::move(configGroup), std::move(name), defaultValue, parent, restart, page); registerObject(fontChooser->extension()); return fontChooser; } KonfiguratorComboBox *KonfiguratorPage::createComboBox(QString configGroup, QString name, QString defaultValue, KONFIGURATOR_NAME_VALUE_PAIR *params, int paramNum, QLabel *label, QWidget *parent, bool restart, bool editable, const QString &toolTip, int page) { KonfiguratorComboBox *comboBox = new KonfiguratorComboBox(std::move(configGroup), std::move(name), std::move(defaultValue), params, paramNum, parent, restart, editable, page); if (!toolTip.isEmpty()) { label->setWhatsThis(toolTip); label->setToolTip(toolTip); comboBox->setWhatsThis(toolTip); comboBox->setToolTip(toolTip); } registerObject(comboBox->extension()); return comboBox; } QFrame* KonfiguratorPage::createLine(QWidget *parent, bool vertical) { QFrame *line = new QFrame(parent); line->setFrameStyle((vertical ? QFrame::VLine : QFrame::HLine) | QFrame::Sunken); return line; } void KonfiguratorPage::registerObject(KonfiguratorExtension *item) { itemList.push_back(item); connect(item, SIGNAL(sigChanged(bool)), this, SIGNAL(sigChanged())); } void KonfiguratorPage::removeObject(KonfiguratorExtension *item) { int ndx = itemList.indexOf(item); if (ndx != -1) { QList::iterator it = itemList.begin() + ndx; delete *it; itemList.erase(it); } } KonfiguratorColorChooser *KonfiguratorPage::createColorChooser(QString configGroup, QString name, QColor defaultValue, QWidget *parent, bool restart, ADDITIONAL_COLOR *addColPtr, int addColNum, int page) { KonfiguratorColorChooser *colorChooser = new KonfiguratorColorChooser(std::move(configGroup), std::move(name), std::move(defaultValue), parent, restart, addColPtr, addColNum, page); registerObject(colorChooser->extension()); return colorChooser; } diff --git a/krusader/Konfigurator/konfiguratorpage.h b/krusader/Konfigurator/konfiguratorpage.h index ac00aa87..49847f25 100644 --- a/krusader/Konfigurator/konfiguratorpage.h +++ b/krusader/Konfigurator/konfiguratorpage.h @@ -1,521 +1,522 @@ /***************************************************************************** * Copyright (C) 2003 Csaba Karai * * Copyright (C) 2004-2020 Krusader Krew [https://krusader.org] * * * * This file is part of Krusader [https://krusader.org]. * * * * Krusader 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. * * * * Krusader is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * *****************************************************************************/ #ifndef KONFIGURATORPAGE_H #define KONFIGURATORPAGE_H // QtWidgets #include #include #include #include #include #include "konfiguratoritems.h" struct KONFIGURATOR_CHECKBOX_PARAM; /** * 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 QScrollArea { Q_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 */ KonfiguratorPage(bool firstTime, QWidget *parent); /** * Applies the changes in the Konfigurator page. * * Writes out all relevant information to the configuration 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. *
The checkbox widget's name is QString(configGroup + "/" + name).ascii()
* * Sample:

* KonfiguratorCheckBox *myCheckBox = createCheckBox( "class", "name", false, parentWidget);
* myLayout->addWidget( myCheckBox, 0, 0 ); * * @param configGroup The class name used in KConfig (ex. "Archives") * @param name The item name used in KConfig (ex. "Do Tar") * @param defaultValue The default value of the checkbox * @param text The text field of the checkbox * @param parent Reference to the parent widget * @param restart The change of this parameter requires Krusader restart * @param toolTip Tooltip used for this checkbox * @param page The subpage of a Konfigurator page (because of setDefaults) * * @return reference to the newly created checkbox */ KonfiguratorCheckBox *createCheckBox(QString configGroup, QString name, bool defaultValue, QString text, QWidget *parent = nullptr, bool restart = false, const QString &toolTip = QString(), int page = FIRST_PAGE); /** * Adds a new spinbox item to the page. *
The spinbox widget's name is QString(configGroup + "/" + name).ascii()
* * Sample:

* KonfiguratorSpinBox *mySpinBox = createSpinBox( "class", "name", 10, 1, 100, parentWidget);
* myLayout->addWidget( mySpinBox, 0, 0 ); * * @param configGroup The class name used in KConfig (ex. "Archives") * @param configName The item name used in KConfig (ex. "Do Tar") * @param defaultValue The default value of the spinbox * @param min The minimum value of the spinbox * @param max The maximum value of the spinbox * @param label The label that is associated to the spinbox * @param parent Reference to the parent widget * @param restart The change of this parameter requires Krusader restart * @param toolTip Tooltip used for this spinbox * @param page The subpage of a Konfigurator page (because of setDefaults) * * @return reference to the newly created spinbox */ KonfiguratorSpinBox *createSpinBox(QString configGroup, QString configName, int defaultValue, int min, int max, QLabel *label, QWidget *parent = nullptr, bool restart = false, const QString &toolTip = QString(), int page = FIRST_PAGE); /** * Adds a new editbox item to the page. *
The editbox widget's name is QString(configGroup + "/" + name).ascii()
* * Sample:

* KonfiguratorEditBox *myEditBox = createEditBox( "class", "name", "default", parentWidget);
* myLayout->addWidget( myEditBox, 0, 0 ); * * @param configGroup The class name used in KConfig (ex. "Archives") * @param name The itemname used in KConfig (ex. "Do Tar") * @param defaultValue The default value of the editbox + * @param label The label that is associated to the editbox * @param parent Reference to the parent widget * @param restart The change of this parameter requires Krusader restart * @param toolTip Tooltip used for this editbox * @param page The subpage of a Konfigurator page (because of setDefaults) * * @return reference to the newly created editbox */ KonfiguratorEditBox *createEditBox(QString configGroup, QString name, QString defaultValue, - QWidget *parent = nullptr, bool restart = false, + QLabel *label, QWidget *parent = nullptr, bool restart = false, const QString &toolTip = QString(), int page = FIRST_PAGE); /** * Adds a new listbox item to the page. *
The listbox widget's name is QString(configGroup + "/" + name).ascii()
* * Sample:

* QStringList valueList;
* valueList += "item";
* KonfiguratorListBox *myListBox = createListBox( "class", "name", valueList, parentWidget);
* myLayout->addWidget( myListBox, 0, 0 ); * * @param configGroup The class name used in KConfig (ex. "Archives") * @param name The itemname used in KConfig (ex. "Do Tar") * @param defaultValue The default value of the listbox * @param parent Reference to the parent widget * @param restart The change of this parameter requires Krusader restart * @param toolTip Tooltip used for this listbox * @param page The subpage of a Konfigurator page (because of setDefaults) * * @return reference to the newly created editbox */ KonfiguratorListBox *createListBox(QString configGroup, QString name, QStringList defaultValue, QWidget *parent = nullptr, bool restart = false, const QString &toolTip = QString(), int page = FIRST_PAGE); /** * Adds a new URL requester item to the page. *
The URL requester widget's name is QString(configGroup + "/" + name).ascii()
* * Sample:

* KonfiguratorURLRequester *myURLRequester = createURLRequester( "class", "name", "default", parentWidget );
* myLayout->addWidget( myURLRequester, 0, 0 ); * * @param configGroup The class name used in KConfig (ex. "Archives") * @param name The itemname used in KConfig (ex. "Do Tar") * @param defaultValue The default value of the URL requester * @param parent Reference to the parent widget * @param restart The change of this parameter requires Krusader restart * @param toolTip Tooltip used for this URL requester * @param page The subpage of a Konfigurator page (because of setDefaults) * @param expansion Whether to perform url expansion * * @return reference to the newly created URL requester */ KonfiguratorURLRequester *createURLRequester(QString configGroup, QString name, QString defaultValue, QWidget *parent, bool restart, const QString &toolTip = QString(), int page = FIRST_PAGE, bool expansion = true); /** * Adds a new font chooser item to the page. *
The font chooser widget's name is QString(configGroup + "/" + name).ascii()
* * Sample:

* KonfiguratorFontChooser *myFontChooser = createFontChooser( "class", "name", QFont(), parentWidget );
* myLayout->addWidget( myFontChooser, 0, 0 ); * * @param configGroup The class name used in KConfig (ex. "Archives") * @param name The item name used in KConfig (ex. "Do Tar") * @param defaultValue The default value of the font chooser * @param parent Reference to the parent widget * @param restart The change of this parameter requires Krusader restart * @param page The subpage of a Konfigurator page (because of setDefaults) * * @return reference to the newly created font chooser */ KonfiguratorFontChooser *createFontChooser(QString configGroup, QString name, const QFont& defaultValue, QWidget *parent = nullptr, bool restart = false, int page = FIRST_PAGE); /** * Adds a new combobox item to the page. *
The combobox widget's name is QString(configGroup + "/" + name).ascii()
* * Sample:

* KONFIGURATOR_NAME_VALUE_PAIR comboInfo[] =
*  {{ i18n( "combo text1" ), "value1" },
*   { i18n( "combo text2" ), "value2" },
*   { i18n( "combo text3" ), "value3" }};

* KonfiguratorComboBox *myComboBox = createComboBox( "class", "name", "value2", comboInfo, 3, parentWidget );
* myLayout->addWidget( myComboBox, 0, 0 ); * * @param configGroup The class name used in KConfig (ex. "Archives") * @param name The item name used in KConfig (ex. "Do Tar") * @param defaultValue 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 label The label that is associated to the combobox * @param parent Reference to the parent widget * @param restart The change of this parameter requires Krusader restart * @param editable Flag indicates that the combo can be edited * @param toolTip Tooltip used for this combobox * @param page The subpage of a Konfigurator page (because of setDefaults) * * @return reference to the newly created combobox */ KonfiguratorComboBox *createComboBox(QString configGroup, QString name, QString defaultValue, KONFIGURATOR_NAME_VALUE_PAIR *params, int paramNum, QLabel *label, QWidget *parent = nullptr, bool restart = false, bool editable = false, const QString &toolTip = QString(), int page = FIRST_PAGE); /** * Creates a frame on the page. * * Sample:

* QGroupBox *myGroup = createFrame( i18n( "MyFrameName" ), parentWidget, "frameName" );
* myLayout->addWidget( myGroup, 0, 0 ); * * @param text The text written out onto the frame * @param parent Reference to the parent widget * * @return reference to the newly created frame */ QGroupBox *createFrame(const QString& text = QString(), QWidget *parent = nullptr); /** * Creates a new QGridLayout element and sets its margins. * * Sample:

* QGroupBox *myGroup = createFrame( i18n( "MyFrameName" ), parentWidget, "frameName" );
* QGridLayout *myLayout = createGridLayout( myGroup ) );
* myLayout->addWidget( myGroup, 0, 0 ); * * @param parent Reference to the parent layout * * @return reference to the newly created QGridLayout */ QGridLayout *createGridLayout(QWidget *parent); /** * Adds a new label to a grid layout. * * Sample:

* QGroupBox *myGroup = createFrame( i18n( "MyFrameName" ), parentWidget, "frameName" );
* QGridLayout *myLayout = createGridLayout( myGroup->layout() );
* addLabel( myLayout, 0, 0, i18n( "Hello world!" ), myGroup, "myLabel" );
* 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 * * @return reference to the newly created label */ QLabel *addLabel(QGridLayout *layout, int x, int y, const QString& label, QWidget *parent = nullptr); /** * Creates a spacer object (for justifying in QHBox). * * Sample:

* QHBox *hbox = new QHBox( myParent, "hbox" );
* createSpinBox( "class", "spin", 5, 1, 10, hbox );
* createSpacer( hbox );
* myLayout->addWidget( hbox, 0, 0 ); * * @param parent Reference to the parent widget * * @return reference to the newly created spacer widget */ QWidget *createSpacer(QWidget *parent = nullptr); /** * Creates a separator line. * * Sample:

* QFrame *myLine = createLine( myParent, "myLine" );
* myLayout->addWidget( myLine, 1, 0 );
* * @param parent Reference to the parent widget * @param vertical Means vertical line * * @return reference to the newly created spacer widget */ QFrame *createLine(QWidget *parent = nullptr, 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.
* * 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:

* KONFIGURATOR_CHECKBOX_PARAM myCBArray[] =
*  {{"CbClass","CbName1", false, i18n( "name1" ), false, "tooltip1"},
*   {"CbClass","CbName2", true, i18n( "name2" ), false, "tooltip2"},
*   {"CbClass","CbName3", true, i18n( "name3" ), false, "tooltip3"}};

* KonfiguratorCheckBoxGroup *myCheckBoxGroup = createCheckBoxGroup( 1, 0, myCBArray, 3, myParent, "myCheckboxGroup" );
* myCheckBoxGroup->find( 0 )->setEnabled( false );

* myLayout->addWidget( myCheckBoxGroup, 0, 0 );
* * @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 page 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, QWidget *parent = nullptr, int page = 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.
* * 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:

* KONFIGURATOR_NAME_VALUE_TIP radioInfo[] =
*  {{ i18n( "radio text1" ), "value1", i18n( "tooltip1" ) },
*   { i18n( "radio text2" ), "value2", i18n( "tooltip2" ) },
*   { i18n( "radio text3" ), "value3", i18n( "tooltip3" ) }};

* KonfiguratorRadioButtons *myRadioGroup = createRadioButtonGroup( "class", "name", "value1", * 1, 0, radioInfo, 3, myParent, "myRadioGroup" );
* myRadioGroup->find( i18n( "radio text1" ) )->setEnabled( false );
* myLayout->addWidget( myRadioGroup, 0, 0 );
* * @param configGroup The class name used in KConfig (ex. "Archives") * @param name The item name used in KConfig (ex. "Do Tar") * @param defaultValue 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 restart The change of this parameter requires Krusader restart * @param page The subpage of a Konfigurator page (because of setDefaults) * * @return reference to the newly created radio button group widget */ KonfiguratorRadioButtons *createRadioButtonGroup(QString configGroup, QString name, QString defaultValue, int sizex, int sizey, KONFIGURATOR_NAME_VALUE_TIP *params, int paramNum, QWidget *parent = nullptr, bool restart = false, int page = 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:

* KonfiguratorEditBox *myEditBox = createEditBox( "class", "name", "default", parentWidget);
* myLayout->addWidget( myEditBox, 0, 0 );
* 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. *
The chooser's widget's name is QString(configGroup + "/" + name).ascii()
* * Sample:

* KonfiguratorColorChooser *myColorChooser = createColorChooser( "class", "name", QColor( 255, 0, 255 ), parentWidget );
* myLayout->addWidget( myColorChooser, 0, 0 ); * * @param configGroup The class name used in KConfig (ex. "Archives") * @param name The item name used in KConfig (ex. "Do Tar") * @param defaultValue The default value of the color chooser * @param parent Reference to the parent widget * @param restart The change of this parameter requires Krusader restart * @param addColPtr The additional color values * @param addColNum Number of additional colors * @param page The subpage of a Konfigurator page (because of setDefaults) * * @return reference to the newly created combobox */ KonfiguratorColorChooser *createColorChooser(QString configGroup, QString name, QColor defaultValue, QWidget *parent = nullptr, bool restart = false, ADDITIONAL_COLOR *addColPtr = nullptr, int addColNum = 0, int page = 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: QList 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 KConfig (ex. "Archives") */ QString configClass; /** * The item name used in KConfig (ex. "Do Tar") */ QString configName; /** * The default value of the checkbox */ bool defaultValue; /** * The text field of the checkbox */ QString text; /** * The change of this parameter requires Krusader restart */ bool restart; /** * The checkbox's tooltip */ QString toolTip; }; #endif /* __KONFIGURATOR_PAGE_H__ */