diff --git a/src/global.h b/src/global.h index 3b6af43e9..e3c4a1cca 100644 --- a/src/global.h +++ b/src/global.h @@ -1,46 +1,51 @@ /* * Copyright 2015 Ashish Bansal * * 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. * * This program 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 this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef GLOBAL_H #define GLOBAL_H #include #include namespace Dolphin { QList validateUris(const QStringList& uriList); /** * Returns the home url which is defined in General Settings */ QUrl homeUrl(); enum class OpenNewWindowFlag { None = 0, Select = 1<<1 }; Q_DECLARE_FLAGS(OpenNewWindowFlags, OpenNewWindowFlag) /** * Opens a new Dolphin window */ void openNewWindow(const QList &urls = {}, QWidget *window = nullptr, const OpenNewWindowFlags &flags = OpenNewWindowFlag::None); + + /** + * TODO: Move this somewhere global to all KDE apps, not just Dolphin + */ + const int VERTICAL_SPACER_HEIGHT = 18; } #endif //GLOBAL_H diff --git a/src/settings/dolphinsettingsdialog.cpp b/src/settings/dolphinsettingsdialog.cpp index a79561b4a..6bddb861f 100644 --- a/src/settings/dolphinsettingsdialog.cpp +++ b/src/settings/dolphinsettingsdialog.cpp @@ -1,158 +1,158 @@ /*************************************************************************** * Copyright (C) 2006 by Peter Penz * * peter.penz@gmx.at * * * * 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. * * * * This program 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 this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "dolphinsettingsdialog.h" #include "dolphin_generalsettings.h" #include "dolphinmainwindow.h" #include "general/generalsettingspage.h" #include "navigation/navigationsettingspage.h" #include "services/servicessettingspage.h" #include "startup/startupsettingspage.h" #include "trash/trashsettingspage.h" #include "viewmodes/viewsettingspage.h" #include #include #include #include DolphinSettingsDialog::DolphinSettingsDialog(const QUrl& url, QWidget* parent) : KPageDialog(parent), m_pages() { const QSize minSize = minimumSize(); - setMinimumSize(QSize(512, minSize.height())); + setMinimumSize(QSize(540, minSize.height())); setFaceType(List); setWindowTitle(i18nc("@title:window", "Dolphin Preferences")); QDialogButtonBox* box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel | QDialogButtonBox::RestoreDefaults); box->button(QDialogButtonBox::Apply)->setEnabled(false); box->button(QDialogButtonBox::Ok)->setDefault(true); setButtonBox(box); connect(box->button(QDialogButtonBox::Ok), &QAbstractButton::clicked, this, &DolphinSettingsDialog::applySettings); connect(box->button(QDialogButtonBox::Apply), &QAbstractButton::clicked, this, &DolphinSettingsDialog::applySettings); connect(box->button(QDialogButtonBox::RestoreDefaults), &QAbstractButton::clicked, this, &DolphinSettingsDialog::restoreDefaults); // General GeneralSettingsPage* generalSettingsPage = new GeneralSettingsPage(url, this); KPageWidgetItem* generalSettingsFrame = addPage(generalSettingsPage, i18nc("@title:group General settings", "General")); generalSettingsFrame->setIcon(QIcon::fromTheme(QStringLiteral("view-preview"))); connect(generalSettingsPage, &GeneralSettingsPage::changed, this, &DolphinSettingsDialog::enableApply); // Startup StartupSettingsPage* startupSettingsPage = new StartupSettingsPage(url, this); KPageWidgetItem* startupSettingsFrame = addPage(startupSettingsPage, i18nc("@title:group", "Startup")); startupSettingsFrame->setIcon(QIcon::fromTheme(QStringLiteral("go-home"))); connect(startupSettingsPage, &StartupSettingsPage::changed, this, &DolphinSettingsDialog::enableApply); // View Modes ViewSettingsPage* viewSettingsPage = new ViewSettingsPage(this); KPageWidgetItem* viewSettingsFrame = addPage(viewSettingsPage, i18nc("@title:group", "View Modes")); viewSettingsFrame->setIcon(QIcon::fromTheme(QStringLiteral("view-choose"))); connect(viewSettingsPage, &ViewSettingsPage::changed, this, &DolphinSettingsDialog::enableApply); // Navigation NavigationSettingsPage* navigationSettingsPage = new NavigationSettingsPage(this); KPageWidgetItem* navigationSettingsFrame = addPage(navigationSettingsPage, i18nc("@title:group", "Navigation")); navigationSettingsFrame->setIcon(QIcon::fromTheme(QStringLiteral("edit-select"))); connect(navigationSettingsPage, &NavigationSettingsPage::changed, this, &DolphinSettingsDialog::enableApply); // Services ServicesSettingsPage* servicesSettingsPage = new ServicesSettingsPage(this); KPageWidgetItem* servicesSettingsFrame = addPage(servicesSettingsPage, i18nc("@title:group", "Services")); servicesSettingsFrame->setIcon(QIcon::fromTheme(QStringLiteral("flag"))); connect(servicesSettingsPage, &ServicesSettingsPage::changed, this, &DolphinSettingsDialog::enableApply); // Trash auto* trashSettingsPage = createTrashSettingsPage(this); if (trashSettingsPage) { KPageWidgetItem* trashSettingsFrame = addPage(trashSettingsPage, i18nc("@title:group", "Trash")); trashSettingsFrame->setIcon(QIcon::fromTheme(QStringLiteral("trash-empty"))); connect(trashSettingsPage, &TrashSettingsPage::changed, this, &DolphinSettingsDialog::enableApply); } m_pages.append(generalSettingsPage); m_pages.append(startupSettingsPage); m_pages.append(viewSettingsPage); m_pages.append(navigationSettingsPage); m_pages.append(servicesSettingsPage); if (trashSettingsPage) { m_pages.append(trashSettingsPage); } const KConfigGroup dialogConfig(KSharedConfig::openConfig(QStringLiteral("dolphinrc")), "SettingsDialog"); KWindowConfig::restoreWindowSize(windowHandle(), dialogConfig); } DolphinSettingsDialog::~DolphinSettingsDialog() { KConfigGroup dialogConfig(KSharedConfig::openConfig(QStringLiteral("dolphinrc")), "SettingsDialog"); KWindowConfig::saveWindowSize(windowHandle(), dialogConfig); } void DolphinSettingsDialog::enableApply() { buttonBox()->button(QDialogButtonBox::Apply)->setEnabled(true); } void DolphinSettingsDialog::applySettings() { foreach (SettingsPageBase* page, m_pages) { page->applySettings(); } emit settingsChanged(); GeneralSettings* settings = GeneralSettings::self(); if (settings->modifiedStartupSettings()) { // Reset the modified startup settings hint. The changed startup settings // have been applied already due to emitting settingsChanged(). settings->setModifiedStartupSettings(false); settings->save(); } buttonBox()->button(QDialogButtonBox::Apply)->setEnabled(false); } void DolphinSettingsDialog::restoreDefaults() { foreach (SettingsPageBase* page, m_pages) { page->restoreDefaults(); } } SettingsPageBase *DolphinSettingsDialog::createTrashSettingsPage(QWidget *parent) { if (!KAuthorized::authorizeControlModule(QStringLiteral("kcmtrash.desktop"))) { return nullptr; } return new TrashSettingsPage(parent); } diff --git a/src/settings/general/behaviorsettingspage.cpp b/src/settings/general/behaviorsettingspage.cpp index ba8d0549c..921ab3f8e 100644 --- a/src/settings/general/behaviorsettingspage.cpp +++ b/src/settings/general/behaviorsettingspage.cpp @@ -1,182 +1,188 @@ /*************************************************************************** * Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at) and * * and Patrice Tremblay * * * * 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. * * * * This program 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 this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "behaviorsettingspage.h" +#include "global.h" #include "views/viewproperties.h" #include +#include #include -#include +#include #include -#include +#include BehaviorSettingsPage::BehaviorSettingsPage(const QUrl& url, QWidget* parent) : SettingsPageBase(parent), m_url(url), m_localViewProps(nullptr), m_globalViewProps(nullptr), m_showToolTips(nullptr), m_showSelectionToggle(nullptr), m_naturalSorting(nullptr), m_caseSensitiveSorting(nullptr), m_caseInsensitiveSorting(nullptr), m_renameInline(nullptr), m_useTabForSplitViewSwitch(nullptr) { - QVBoxLayout* topLayout = new QVBoxLayout(this); + QFormLayout* topLayout = new QFormLayout(this); + // View properties - QGroupBox* viewPropsBox = new QGroupBox(i18nc("@title:group", "View"), this); - viewPropsBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); + m_localViewProps = new QRadioButton(i18nc("@option:radio", "Remember properties for each folder")); + m_globalViewProps = new QRadioButton(i18nc("@option:radio", "Use common properties for all folders")); + + QButtonGroup* viewGroup = new QButtonGroup(this); + viewGroup->addButton(m_localViewProps); + viewGroup->addButton(m_globalViewProps); + topLayout->addRow(i18nc("@title:group", "View: "), m_localViewProps); + topLayout->addRow(QString(), m_globalViewProps); + - m_localViewProps = new QRadioButton(i18nc("@option:radio", "Remember properties for each folder"), viewPropsBox); - m_globalViewProps = new QRadioButton(i18nc("@option:radio", "Use common properties for all folders"), viewPropsBox); + topLayout->addItem(new QSpacerItem(0, Dolphin::VERTICAL_SPACER_HEIGHT, QSizePolicy::Fixed, QSizePolicy::Fixed)); - QVBoxLayout* viewPropsLayout = new QVBoxLayout(viewPropsBox); - viewPropsLayout->addWidget(m_localViewProps); - viewPropsLayout->addWidget(m_globalViewProps); // Sorting properties - QGroupBox* sortingPropsBox = new QGroupBox(i18nc("@title:group", "Sorting Mode"), this); - sortingPropsBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); + m_naturalSorting = new QRadioButton(i18nc("option:radio", "Natural")); + m_caseInsensitiveSorting = new QRadioButton(i18nc("option:radio", "Alphabetical, case insensitive")); + m_caseSensitiveSorting = new QRadioButton(i18nc("option:radio", "Alphabetical, case sensitive")); - m_naturalSorting = new QRadioButton(i18nc("option:radio", "Natural sorting"), sortingPropsBox); - m_caseInsensitiveSorting = new QRadioButton(i18nc("option:radio", "Alphabetical sorting, case insensitive"), sortingPropsBox); - m_caseSensitiveSorting = new QRadioButton(i18nc("option:radio", "Alphabetical sorting, case sensitive"), sortingPropsBox); + QButtonGroup* sortingModeGroup = new QButtonGroup(this); + sortingModeGroup->addButton(m_naturalSorting); + sortingModeGroup->addButton(m_caseInsensitiveSorting); + sortingModeGroup->addButton(m_caseSensitiveSorting); + topLayout->addRow(i18nc("@title:group", "Sorting mode: "), m_naturalSorting); + topLayout->addRow(QString(), m_caseInsensitiveSorting); + topLayout->addRow(QString(), m_caseSensitiveSorting); + + + topLayout->addItem(new QSpacerItem(0, Dolphin::VERTICAL_SPACER_HEIGHT, QSizePolicy::Fixed, QSizePolicy::Fixed)); - QVBoxLayout* sortingPropsLayout = new QVBoxLayout(sortingPropsBox); - sortingPropsLayout->addWidget(m_naturalSorting); - sortingPropsLayout->addWidget(m_caseInsensitiveSorting); - sortingPropsLayout->addWidget(m_caseSensitiveSorting); // 'Show tooltips' - m_showToolTips = new QCheckBox(i18nc("@option:check", "Show tooltips"), this); + m_showToolTips = new QCheckBox(i18nc("@option:check", "Show tooltips")); + topLayout->addRow(i18nc("@title:group", "Miscellaneous: "), m_showToolTips); // 'Show selection marker' - m_showSelectionToggle = new QCheckBox(i18nc("@option:check", "Show selection marker"), this); + m_showSelectionToggle = new QCheckBox(i18nc("@option:check", "Show selection marker")); + topLayout->addRow(QString(), m_showSelectionToggle); // 'Inline renaming of items' - m_renameInline = new QCheckBox(i18nc("option:check", "Rename inline"), this); - - // 'Use tab for switching between right and left split' - m_useTabForSplitViewSwitch = new QCheckBox(i18nc("option:check", "Use tab for switching between right and left split view"), this); - - topLayout->addWidget(viewPropsBox); - topLayout->addWidget(sortingPropsBox); - topLayout->addWidget(m_showToolTips); - topLayout->addWidget(m_showSelectionToggle); - topLayout->addWidget(m_renameInline); - topLayout->addWidget(m_useTabForSplitViewSwitch); - topLayout->addStretch(); + m_renameInline = new QCheckBox(i18nc("option:check", "Rename inline")); + topLayout->addRow(QString(), m_renameInline); + + // 'Switch between split views with tab key' + m_useTabForSplitViewSwitch = new QCheckBox(i18nc("option:check", "Switch between split views with tab key")); + topLayout->addRow(QString(), m_useTabForSplitViewSwitch); loadSettings(); connect(m_localViewProps, &QRadioButton::toggled, this, &BehaviorSettingsPage::changed); connect(m_globalViewProps, &QRadioButton::toggled, this, &BehaviorSettingsPage::changed); connect(m_showToolTips, &QCheckBox::toggled, this, &BehaviorSettingsPage::changed); connect(m_showSelectionToggle, &QCheckBox::toggled, this, &BehaviorSettingsPage::changed); connect(m_naturalSorting, &QRadioButton::toggled, this, &BehaviorSettingsPage::changed); connect(m_caseInsensitiveSorting, &QRadioButton::toggled, this, &BehaviorSettingsPage::changed); connect(m_caseSensitiveSorting, &QRadioButton::toggled, this, &BehaviorSettingsPage::changed); connect(m_renameInline, &QCheckBox::toggled, this, &BehaviorSettingsPage::changed); connect(m_useTabForSplitViewSwitch, &QCheckBox::toggled, this, &BehaviorSettingsPage::changed); } BehaviorSettingsPage::~BehaviorSettingsPage() { } void BehaviorSettingsPage::applySettings() { GeneralSettings* settings = GeneralSettings::self(); ViewProperties props(m_url); // read current view properties const bool useGlobalViewProps = m_globalViewProps->isChecked(); settings->setGlobalViewProps(useGlobalViewProps); settings->setShowToolTips(m_showToolTips->isChecked()); settings->setShowSelectionToggle(m_showSelectionToggle->isChecked()); setSortingChoiceValue(settings); settings->setRenameInline(m_renameInline->isChecked()); settings->setUseTabForSwitchingSplitView(m_useTabForSplitViewSwitch->isChecked()); settings->save(); if (useGlobalViewProps) { // Remember the global view properties by applying the current view properties. // It is important that GeneralSettings::globalViewProps() is set before // the class ViewProperties is used, as ViewProperties uses this setting // to find the destination folder for storing the view properties. ViewProperties globalProps(m_url); globalProps.setDirProperties(props); } } void BehaviorSettingsPage::restoreDefaults() { GeneralSettings* settings = GeneralSettings::self(); settings->useDefaults(true); loadSettings(); settings->useDefaults(false); } void BehaviorSettingsPage::loadSettings() { const bool useGlobalViewProps = GeneralSettings::globalViewProps(); m_localViewProps->setChecked(!useGlobalViewProps); m_globalViewProps->setChecked(useGlobalViewProps); m_showToolTips->setChecked(GeneralSettings::showToolTips()); m_showSelectionToggle->setChecked(GeneralSettings::showSelectionToggle()); m_renameInline->setChecked(GeneralSettings::renameInline()); m_useTabForSplitViewSwitch->setChecked(GeneralSettings::useTabForSwitchingSplitView()); loadSortingChoiceSettings(); } void BehaviorSettingsPage::setSortingChoiceValue(GeneralSettings *settings) { using Choice = GeneralSettings::EnumSortingChoice; if (m_naturalSorting->isChecked()) { settings->setSortingChoice(Choice::NaturalSorting); } else if (m_caseInsensitiveSorting->isChecked()) { settings->setSortingChoice(Choice::CaseInsensitiveSorting); } else if (m_caseSensitiveSorting->isChecked()) { settings->setSortingChoice(Choice::CaseSensitiveSorting); } } void BehaviorSettingsPage::loadSortingChoiceSettings() { using Choice = GeneralSettings::EnumSortingChoice; switch (GeneralSettings::sortingChoice()) { case Choice::NaturalSorting: m_naturalSorting->setChecked(true); break; case Choice::CaseInsensitiveSorting: m_caseInsensitiveSorting->setChecked(true); break; case Choice::CaseSensitiveSorting: m_caseSensitiveSorting->setChecked(true); break; default: Q_UNREACHABLE(); } } diff --git a/src/settings/general/confirmationssettingspage.cpp b/src/settings/general/confirmationssettingspage.cpp index 728d082d2..d96dfe0b2 100644 --- a/src/settings/general/confirmationssettingspage.cpp +++ b/src/settings/general/confirmationssettingspage.cpp @@ -1,133 +1,135 @@ /*************************************************************************** * Copyright (C) 2012 by Peter Penz * * * * 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. * * * * This program 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 this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "confirmationssettingspage.h" #include "dolphin_generalsettings.h" +#include "global.h" #include #include #include #include namespace { const bool ConfirmEmptyTrash = true; const bool ConfirmTrash = false; const bool ConfirmDelete = true; const bool ConfirmScriptExecution = true; } ConfirmationsSettingsPage::ConfirmationsSettingsPage(QWidget* parent) : SettingsPageBase(parent), m_confirmMoveToTrash(nullptr), m_confirmEmptyTrash(nullptr), m_confirmDelete(nullptr), m_confirmClosingMultipleTabs(nullptr) { QVBoxLayout* topLayout = new QVBoxLayout(this); QLabel* confirmLabelKde = new QLabel(i18nc("@title:group", "Ask for confirmation in all KDE applications when:"), this); confirmLabelKde->setWordWrap(true); m_confirmMoveToTrash = new QCheckBox(i18nc("@option:check Ask for confirmation when", "Moving files or folders to trash"), this); m_confirmEmptyTrash = new QCheckBox(i18nc("@option:check Ask for confirmation when", "Emptying trash"), this); m_confirmDelete = new QCheckBox(i18nc("@option:check Ask for confirmation when", "Deleting files or folders"), this); m_confirmScriptExecution = new QCheckBox(i18nc("@option:check Ask for confirmation when", "Executing scripts or desktop files"), this); - QLabel* confirmLabelDolphin = new QLabel(i18nc("@title:group", "Ask for confirmation when:"), this); + QLabel* confirmLabelDolphin = new QLabel(i18nc("@title:group", "Ask for confirmation in Dolphin when:"), this); confirmLabelDolphin->setWordWrap(true); - m_confirmClosingMultipleTabs = new QCheckBox(i18nc("@option:check Ask for confirmation when", - "Closing Dolphin windows with multiple tabs"), this); + m_confirmClosingMultipleTabs = new QCheckBox(i18nc("@option:check Ask for confirmation in Dolphin when", + "Closing windows with multiple tabs"), this); topLayout->addWidget(confirmLabelKde); topLayout->addWidget(m_confirmMoveToTrash); topLayout->addWidget(m_confirmEmptyTrash); topLayout->addWidget(m_confirmDelete); topLayout->addWidget(m_confirmScriptExecution); + topLayout->addSpacing(Dolphin::VERTICAL_SPACER_HEIGHT); topLayout->addWidget(confirmLabelDolphin); topLayout->addWidget(m_confirmClosingMultipleTabs); topLayout->addStretch(); loadSettings(); connect(m_confirmMoveToTrash, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed); connect(m_confirmEmptyTrash, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed); connect(m_confirmDelete, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed); connect(m_confirmScriptExecution, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed); connect(m_confirmClosingMultipleTabs, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed); } ConfirmationsSettingsPage::~ConfirmationsSettingsPage() { } void ConfirmationsSettingsPage::applySettings() { KSharedConfig::Ptr kioConfig = KSharedConfig::openConfig(QStringLiteral("kiorc"), KConfig::NoGlobals); KConfigGroup confirmationGroup(kioConfig, "Confirmations"); confirmationGroup.writeEntry("ConfirmTrash", m_confirmMoveToTrash->isChecked()); confirmationGroup.writeEntry("ConfirmEmptyTrash", m_confirmEmptyTrash->isChecked()); confirmationGroup.writeEntry("ConfirmDelete", m_confirmDelete->isChecked()); confirmationGroup.sync(); if (m_confirmScriptExecution->isChecked()) { KConfigGroup scriptExecutionGroup(kioConfig, "Executable scripts"); scriptExecutionGroup.writeEntry("behaviourOnLaunch", "alwaysAsk"); scriptExecutionGroup.sync(); } GeneralSettings* settings = GeneralSettings::self(); settings->setConfirmClosingMultipleTabs(m_confirmClosingMultipleTabs->isChecked()); settings->save(); } void ConfirmationsSettingsPage::restoreDefaults() { GeneralSettings* settings = GeneralSettings::self(); settings->useDefaults(true); loadSettings(); settings->useDefaults(false); m_confirmMoveToTrash->setChecked(ConfirmTrash); m_confirmEmptyTrash->setChecked(ConfirmEmptyTrash); m_confirmDelete->setChecked(ConfirmDelete); m_confirmScriptExecution->setChecked(ConfirmScriptExecution); } void ConfirmationsSettingsPage::loadSettings() { KSharedConfig::Ptr kioConfig = KSharedConfig::openConfig(QStringLiteral("kiorc"), KConfig::IncludeGlobals); const KConfigGroup confirmationGroup(kioConfig, "Confirmations"); m_confirmMoveToTrash->setChecked(confirmationGroup.readEntry("ConfirmTrash", ConfirmTrash)); m_confirmEmptyTrash->setChecked(confirmationGroup.readEntry("ConfirmEmptyTrash", ConfirmEmptyTrash)); m_confirmDelete->setChecked(confirmationGroup.readEntry("ConfirmDelete", ConfirmDelete)); const KConfigGroup scriptExecutionGroup(KSharedConfig::openConfig(QStringLiteral("kiorc")), "Executable scripts"); const QString value = scriptExecutionGroup.readEntry("behaviourOnLaunch", "alwaysAsk"); m_confirmScriptExecution->setChecked(value == QLatin1String("alwaysAsk")); m_confirmClosingMultipleTabs->setChecked(GeneralSettings::confirmClosingMultipleTabs()); } diff --git a/src/settings/startup/startupsettingspage.cpp b/src/settings/startup/startupsettingspage.cpp index 4071ee04f..f8b7daa79 100644 --- a/src/settings/startup/startupsettingspage.cpp +++ b/src/settings/startup/startupsettingspage.cpp @@ -1,195 +1,186 @@ /*************************************************************************** * Copyright (C) 2008 by Peter Penz * * * * 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. * * * * This program 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 this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "startupsettingspage.h" #include "dolphin_generalsettings.h" #include "dolphinmainwindow.h" #include "dolphinviewcontainer.h" #include "global.h" #include #include #include #include -#include -#include #include #include +#include +#include #include StartupSettingsPage::StartupSettingsPage(const QUrl& url, QWidget* parent) : SettingsPageBase(parent), m_url(url), m_homeUrl(nullptr), m_splitView(nullptr), m_editableUrl(nullptr), m_showFullPath(nullptr), m_filterBar(nullptr), m_showFullPathInTitlebar(nullptr) { - QVBoxLayout* topLayout = new QVBoxLayout(this); - QWidget* vBox = new QWidget(this); - QVBoxLayout *vBoxLayout = new QVBoxLayout(vBox); - vBoxLayout->setMargin(0); - vBoxLayout->setAlignment(Qt::AlignTop); + QFormLayout* topLayout = new QFormLayout(this); - // create 'Home URL' editor - QGroupBox* homeBox = new QGroupBox(i18nc("@title:group", "Home Folder"), vBox); - vBoxLayout->addWidget(homeBox); - QWidget* homeUrlBox = new QWidget(homeBox); - QHBoxLayout *homeUrlBoxLayout = new QHBoxLayout(homeUrlBox); + // create 'Home URL' editor + QHBoxLayout* homeUrlBoxLayout = new QHBoxLayout(); homeUrlBoxLayout->setMargin(0); - QLabel* homeUrlLabel = new QLabel(i18nc("@label:textbox", "Location:"), homeUrlBox); - homeUrlBoxLayout->addWidget(homeUrlLabel); - m_homeUrl = new QLineEdit(homeUrlBox); - homeUrlBoxLayout->addWidget(m_homeUrl); + m_homeUrl = new QLineEdit(); m_homeUrl->setClearButtonEnabled(true); + homeUrlBoxLayout->addWidget(m_homeUrl); - QPushButton* selectHomeUrlButton = new QPushButton(QIcon::fromTheme(QStringLiteral("folder-open")), QString(), homeUrlBox); + QPushButton* selectHomeUrlButton = new QPushButton(QIcon::fromTheme(QStringLiteral("folder-open")), QString()); homeUrlBoxLayout->addWidget(selectHomeUrlButton); #ifndef QT_NO_ACCESSIBILITY selectHomeUrlButton->setAccessibleName(i18nc("@action:button", "Select Home Location")); #endif connect(selectHomeUrlButton, &QPushButton::clicked, this, &StartupSettingsPage::selectHomeUrl); - QWidget* buttonBox = new QWidget(homeBox); - QHBoxLayout *buttonBoxLayout = new QHBoxLayout(buttonBox); + QHBoxLayout* buttonBoxLayout = new QHBoxLayout(); buttonBoxLayout->setMargin(0); - QPushButton* useCurrentButton = new QPushButton(i18nc("@action:button", "Use Current Location"), buttonBox); + QPushButton* useCurrentButton = new QPushButton(i18nc("@action:button", "Use Current Location")); buttonBoxLayout->addWidget(useCurrentButton); connect(useCurrentButton, &QPushButton::clicked, this, &StartupSettingsPage::useCurrentLocation); - QPushButton* useDefaultButton = new QPushButton(i18nc("@action:button", "Use Default Location"), buttonBox); + QPushButton* useDefaultButton = new QPushButton(i18nc("@action:button", "Use Default Location")); buttonBoxLayout->addWidget(useDefaultButton); connect(useDefaultButton, &QPushButton::clicked, this, &StartupSettingsPage::useDefaultLocation); - QVBoxLayout* homeBoxLayout = new QVBoxLayout(homeBox); - homeBoxLayout->addWidget(homeUrlBox); - homeBoxLayout->addWidget(buttonBox); + QVBoxLayout* homeBoxLayout = new QVBoxLayout(); + homeBoxLayout->setMargin(0); + homeBoxLayout->addLayout(homeUrlBoxLayout); + homeBoxLayout->addLayout(buttonBoxLayout); + + topLayout->addRow(i18nc("@label:textbox", "Start in:"), homeBoxLayout); + + + topLayout->addItem(new QSpacerItem(0, Dolphin::VERTICAL_SPACER_HEIGHT, QSizePolicy::Fixed, QSizePolicy::Fixed)); + // create 'Split view', 'Show full path', 'Editable location' and 'Filter bar' checkboxes - m_splitView = new QCheckBox(i18nc("@option:check Startup Settings", "Split view mode"), vBox); - vBoxLayout->addWidget(m_splitView); - m_editableUrl = new QCheckBox(i18nc("@option:check Startup Settings", "Editable location bar"), vBox); - vBoxLayout->addWidget(m_editableUrl); - m_showFullPath = new QCheckBox(i18nc("@option:check Startup Settings", "Show full path inside location bar"), vBox); - vBoxLayout->addWidget(m_showFullPath); - m_filterBar = new QCheckBox(i18nc("@option:check Startup Settings", "Show filter bar"), vBox); - vBoxLayout->addWidget(m_filterBar); - m_showFullPathInTitlebar = new QCheckBox(i18nc("@option:check Startup Settings", "Show full path in title bar"), vBox); - vBoxLayout->addWidget(m_showFullPathInTitlebar); - - // Add a dummy widget with no restriction regarding - // a vertical resizing. This assures that the dialog layout - // is not stretched vertically. - new QWidget(vBox); - - topLayout->addWidget(vBox); + m_splitView = new QCheckBox(i18nc("@option:check Startup Settings", "Split view mode")); + topLayout->addRow(i18nc("@label:checkbox", "Window options:"), m_splitView); + m_editableUrl = new QCheckBox(i18nc("@option:check Startup Settings", "Editable location bar")); + topLayout->addRow(QString(), m_editableUrl); + m_showFullPath = new QCheckBox(i18nc("@option:check Startup Settings", "Show full path inside location bar")); + topLayout->addRow(QString(), m_showFullPath); + m_filterBar = new QCheckBox(i18nc("@option:check Startup Settings", "Show filter bar")); + topLayout->addRow(QString(), m_filterBar); + m_showFullPathInTitlebar = new QCheckBox(i18nc("@option:check Startup Settings", "Show full path in title bar")); + topLayout->addRow(QString(), m_showFullPathInTitlebar); + loadSettings(); connect(m_homeUrl, &QLineEdit::textChanged, this, &StartupSettingsPage::slotSettingsChanged); connect(m_splitView, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); connect(m_editableUrl, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); connect(m_showFullPath, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); connect(m_filterBar, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); connect(m_showFullPathInTitlebar, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); } StartupSettingsPage::~StartupSettingsPage() { } void StartupSettingsPage::applySettings() { GeneralSettings* settings = GeneralSettings::self(); const QUrl url(QUrl::fromUserInput(m_homeUrl->text(), QString(), QUrl::AssumeLocalFile)); KFileItem fileItem(url); if ((url.isValid() && fileItem.isDir()) || (url.scheme() == QLatin1String("timeline"))) { settings->setHomeUrl(url.toDisplayString(QUrl::PreferLocalFile)); } else { KMessageBox::error(this, i18nc("@info", "The location for the home folder is invalid or does not exist, it will not be applied.")); } settings->setSplitView(m_splitView->isChecked()); settings->setEditableUrl(m_editableUrl->isChecked()); settings->setShowFullPath(m_showFullPath->isChecked()); settings->setFilterBar(m_filterBar->isChecked()); settings->setShowFullPathInTitlebar(m_showFullPathInTitlebar->isChecked()); settings->save(); } void StartupSettingsPage::restoreDefaults() { GeneralSettings* settings = GeneralSettings::self(); settings->useDefaults(true); loadSettings(); settings->useDefaults(false); } void StartupSettingsPage::slotSettingsChanged() { // Provide a hint that the startup settings have been changed. This allows the views // to apply the startup settings only if they have been explicitly changed by the user // (see bug #254947). GeneralSettings::setModifiedStartupSettings(true); emit changed(); } void StartupSettingsPage::selectHomeUrl() { const QUrl homeUrl(QUrl::fromUserInput(m_homeUrl->text(), QString(), QUrl::AssumeLocalFile)); QUrl url = QFileDialog::getExistingDirectoryUrl(this, QString(), homeUrl); if (!url.isEmpty()) { m_homeUrl->setText(url.toDisplayString(QUrl::PreferLocalFile)); slotSettingsChanged(); } } void StartupSettingsPage::useCurrentLocation() { m_homeUrl->setText(m_url.toDisplayString(QUrl::PreferLocalFile)); } void StartupSettingsPage::useDefaultLocation() { m_homeUrl->setText(QDir::homePath()); } void StartupSettingsPage::loadSettings() { const QUrl url(Dolphin::homeUrl()); m_homeUrl->setText(url.toDisplayString(QUrl::PreferLocalFile)); m_splitView->setChecked(GeneralSettings::splitView()); m_editableUrl->setChecked(GeneralSettings::editableUrl()); m_showFullPath->setChecked(GeneralSettings::showFullPath()); m_filterBar->setChecked(GeneralSettings::filterBar()); m_showFullPathInTitlebar->setChecked(GeneralSettings::showFullPathInTitlebar()); } diff --git a/src/settings/trash/trashsettingspage.cpp b/src/settings/trash/trashsettingspage.cpp index 4c71aa3ec..a9b8c734c 100644 --- a/src/settings/trash/trashsettingspage.cpp +++ b/src/settings/trash/trashsettingspage.cpp @@ -1,68 +1,57 @@ /*************************************************************************** * Copyright (C) 2009 by Shaun Reich shaun.reich@kdemail.net * * * * 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. * * * * This program 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 this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "trashsettingspage.h" #include -#include +#include TrashSettingsPage::TrashSettingsPage(QWidget* parent) : SettingsPageBase(parent) { - QVBoxLayout* topLayout = new QVBoxLayout(this); - QWidget* vBox = new QWidget(this); - QVBoxLayout *vBoxVBoxLayout = new QVBoxLayout(vBox); - vBoxVBoxLayout->setMargin(0); + QFormLayout* topLayout = new QFormLayout(this); m_proxy = new KCModuleProxy(QStringLiteral("kcmtrash")); - topLayout->addWidget(m_proxy); - - // Add a dummy widget with no restriction regarding - // a vertical resizing. This assures that the dialog layout - // is not stretched vertically. - QWidget *w = new QWidget(vBox); - vBoxVBoxLayout->addWidget(w); - - topLayout->addWidget(vBox); + topLayout->addRow(m_proxy); loadSettings(); connect(m_proxy, static_cast(&KCModuleProxy::changed), this, &TrashSettingsPage::changed); } TrashSettingsPage::~TrashSettingsPage() { } void TrashSettingsPage::applySettings() { m_proxy->save(); } void TrashSettingsPage::restoreDefaults() { m_proxy->defaults(); } void TrashSettingsPage::loadSettings() { m_proxy->load(); } diff --git a/src/settings/viewmodes/viewsettingstab.cpp b/src/settings/viewmodes/viewsettingstab.cpp index 3971c8ed8..925a982d9 100644 --- a/src/settings/viewmodes/viewsettingstab.cpp +++ b/src/settings/viewmodes/viewsettingstab.cpp @@ -1,291 +1,267 @@ /*************************************************************************** * Copyright (C) 2008-2011 by Peter Penz * * * * 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. * * * * This program 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 this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "viewsettingstab.h" #include "dolphin_compactmodesettings.h" #include "dolphin_detailsmodesettings.h" #include "dolphin_iconsmodesettings.h" #include "dolphinfontrequester.h" +#include "global.h" #include "views/zoomlevelinfo.h" #include #include #include #include -#include #include -#include -#include +#include ViewSettingsTab::ViewSettingsTab(Mode mode, QWidget* parent) : QWidget(parent), m_mode(mode), m_defaultSizeSlider(nullptr), m_previewSizeSlider(nullptr), m_fontRequester(nullptr), m_widthBox(nullptr), m_maxLinesBox(nullptr), m_expandableFolders(nullptr) { - QVBoxLayout* topLayout = new QVBoxLayout(this); + QFormLayout* topLayout = new QFormLayout(this); - // Create "Icon Size" group - QGroupBox* iconSizeGroup = new QGroupBox(this); - iconSizeGroup->setTitle(i18nc("@title:group", "Icon Size")); + // Create "Icon Size" section const int minRange = ZoomLevelInfo::minimumLevel(); const int maxRange = ZoomLevelInfo::maximumLevel(); - QLabel* defaultLabel = new QLabel(i18nc("@label:listbox", "Default:"), this); - m_defaultSizeSlider = new QSlider(Qt::Horizontal, this); + m_defaultSizeSlider = new QSlider(Qt::Horizontal); m_defaultSizeSlider->setPageStep(1); m_defaultSizeSlider->setTickPosition(QSlider::TicksBelow); m_defaultSizeSlider->setRange(minRange, maxRange); connect(m_defaultSizeSlider, &QSlider::valueChanged, this, &ViewSettingsTab::slotDefaultSliderMoved); + topLayout->addRow(i18nc("@label:listbox", "Default icon size:"), m_defaultSizeSlider); - QLabel* previewLabel = new QLabel(i18nc("@label:listbox", "Preview:"), this); - m_previewSizeSlider = new QSlider(Qt::Horizontal, this); + m_previewSizeSlider = new QSlider(Qt::Horizontal); m_previewSizeSlider->setPageStep(1); m_previewSizeSlider->setTickPosition(QSlider::TicksBelow); m_previewSizeSlider->setRange(minRange, maxRange); connect(m_previewSizeSlider, &QSlider::valueChanged, this, &ViewSettingsTab::slotPreviewSliderMoved); + topLayout->addRow(i18nc("@label:listbox", "Preview icon size:"), m_previewSizeSlider); - QGridLayout* layout = new QGridLayout(iconSizeGroup); - layout->addWidget(defaultLabel, 0, 0, Qt::AlignRight); - layout->addWidget(m_defaultSizeSlider, 0, 1); - layout->addWidget(previewLabel, 1, 0, Qt::AlignRight); - layout->addWidget(m_previewSizeSlider, 1, 1); - // Create "Text" group - QGroupBox* textGroup = new QGroupBox(i18nc("@title:group", "Text"), this); + topLayout->addItem(new QSpacerItem(0, Dolphin::VERTICAL_SPACER_HEIGHT, QSizePolicy::Fixed, QSizePolicy::Fixed)); - QLabel* fontLabel = new QLabel(i18nc("@label:listbox", "Font:"), textGroup); - m_fontRequester = new DolphinFontRequester(textGroup); - QGridLayout* textGroupLayout = new QGridLayout(textGroup); - textGroupLayout->addWidget(fontLabel, 0, 0, Qt::AlignRight); - textGroupLayout->addWidget(m_fontRequester, 0, 1); + // Create "Label" section + m_fontRequester = new DolphinFontRequester(this); + topLayout->addRow(i18nc("@label:listbox", "Label font:"), m_fontRequester); + switch (m_mode) { case IconsMode: { - QLabel* widthLabel = new QLabel(i18nc("@label:listbox", "Width:"), textGroup); - m_widthBox = new QComboBox(textGroup); - m_widthBox->addItem(i18nc("@item:inlistbox Text width", "Small")); - m_widthBox->addItem(i18nc("@item:inlistbox Text width", "Medium")); - m_widthBox->addItem(i18nc("@item:inlistbox Text width", "Large")); - m_widthBox->addItem(i18nc("@item:inlistbox Text width", "Huge")); - - QLabel* maxLinesLabel = new QLabel(i18nc("@label:listbox", "Maximum lines:"), textGroup); - m_maxLinesBox = new QComboBox(textGroup); + m_widthBox = new QComboBox(); + m_widthBox->addItem(i18nc("@item:inlistbox Label width", "Small")); + m_widthBox->addItem(i18nc("@item:inlistbox Label width", "Medium")); + m_widthBox->addItem(i18nc("@item:inlistbox Label width", "Large")); + m_widthBox->addItem(i18nc("@item:inlistbox Label width", "Huge")); + topLayout->addRow(i18nc("@label:listbox", "Label width:"), m_widthBox); + + m_maxLinesBox = new QComboBox(); m_maxLinesBox->addItem(i18nc("@item:inlistbox Maximum lines", "Unlimited")); m_maxLinesBox->addItem(i18nc("@item:inlistbox Maximum lines", "1")); m_maxLinesBox->addItem(i18nc("@item:inlistbox Maximum lines", "2")); m_maxLinesBox->addItem(i18nc("@item:inlistbox Maximum lines", "3")); m_maxLinesBox->addItem(i18nc("@item:inlistbox Maximum lines", "4")); m_maxLinesBox->addItem(i18nc("@item:inlistbox Maximum lines", "5")); - - textGroupLayout->addWidget(widthLabel, 2, 0, Qt::AlignRight); - textGroupLayout->addWidget(m_widthBox, 2, 1); - textGroupLayout->addWidget(maxLinesLabel, 3, 0, Qt::AlignRight); - textGroupLayout->addWidget(m_maxLinesBox, 3, 1); + topLayout->addRow(i18nc("@label:listbox", "Maximum lines:"), m_maxLinesBox); break; } case CompactMode: { - QLabel* maxWidthLabel = new QLabel(i18nc("@label:listbox", "Maximum width:"), textGroup); - m_widthBox = new QComboBox(textGroup); + m_widthBox = new QComboBox(); m_widthBox->addItem(i18nc("@item:inlistbox Maximum width", "Unlimited")); m_widthBox->addItem(i18nc("@item:inlistbox Maximum width", "Small")); m_widthBox->addItem(i18nc("@item:inlistbox Maximum width", "Medium")); m_widthBox->addItem(i18nc("@item:inlistbox Maximum width", "Large")); - - textGroupLayout->addWidget(maxWidthLabel, 2, 0, Qt::AlignRight); - textGroupLayout->addWidget(m_widthBox, 2, 1); + topLayout->addRow(i18nc("@label:listbox", "Maximum width:"), m_widthBox); break; } case DetailsMode: - m_expandableFolders = new QCheckBox(i18nc("@option:check", "Expandable folders"), this); + m_expandableFolders = new QCheckBox(i18nc("@option:check", "Expandable")); + topLayout->addRow(i18nc("@label:checkbox", "Folders:"), m_expandableFolders); break; default: break; } - topLayout->addWidget(iconSizeGroup); - topLayout->addWidget(textGroup); - if (m_expandableFolders) { - topLayout->addWidget(m_expandableFolders); - } - topLayout->addStretch(1); - loadSettings(); connect(m_defaultSizeSlider, &QSlider::valueChanged, this, &ViewSettingsTab::changed); connect(m_previewSizeSlider, &QSlider::valueChanged, this, &ViewSettingsTab::changed); connect(m_fontRequester, &DolphinFontRequester::changed, this, &ViewSettingsTab::changed); switch (m_mode) { case IconsMode: connect(m_widthBox, static_cast(&QComboBox::currentIndexChanged), this, &ViewSettingsTab::changed); connect(m_maxLinesBox, static_cast(&QComboBox::currentIndexChanged), this, &ViewSettingsTab::changed); break; case CompactMode: connect(m_widthBox, static_cast(&QComboBox::currentIndexChanged), this, &ViewSettingsTab::changed); break; case DetailsMode: connect(m_expandableFolders, &QCheckBox::toggled, this, &ViewSettingsTab::changed); break; default: break; } } ViewSettingsTab::~ViewSettingsTab() { } void ViewSettingsTab::applySettings() { const QFont font = m_fontRequester->currentFont(); const bool useSystemFont = (m_fontRequester->mode() == DolphinFontRequester::SystemFont); switch (m_mode) { case IconsMode: IconsModeSettings::setTextWidthIndex(m_widthBox->currentIndex()); IconsModeSettings::setMaximumTextLines(m_maxLinesBox->currentIndex()); break; case CompactMode: CompactModeSettings::setMaximumTextWidthIndex(m_widthBox->currentIndex()); break; case DetailsMode: DetailsModeSettings::setExpandableFolders(m_expandableFolders->isChecked()); break; default: break; } ViewModeSettings settings(viewMode()); const int iconSize = ZoomLevelInfo::iconSizeForZoomLevel(m_defaultSizeSlider->value()); const int previewSize = ZoomLevelInfo::iconSizeForZoomLevel(m_previewSizeSlider->value()); settings.setIconSize(iconSize); settings.setPreviewSize(previewSize); settings.setUseSystemFont(useSystemFont); settings.setFontFamily(font.family()); settings.setFontSize(font.pointSizeF()); settings.setItalicFont(font.italic()); settings.setFontWeight(font.weight()); settings.save(); } void ViewSettingsTab::restoreDefaultSettings() { KConfigSkeleton* settings = nullptr; switch (m_mode) { case IconsMode: settings = IconsModeSettings::self(); break; case CompactMode: settings = CompactModeSettings::self(); break; case DetailsMode: settings = DetailsModeSettings::self(); break; default: Q_ASSERT(false); break; } settings->useDefaults(true); loadSettings(); settings->useDefaults(false); } void ViewSettingsTab::loadSettings() { switch (m_mode) { case IconsMode: m_widthBox->setCurrentIndex(IconsModeSettings::textWidthIndex()); m_maxLinesBox->setCurrentIndex(IconsModeSettings::maximumTextLines()); break; case CompactMode: m_widthBox->setCurrentIndex(CompactModeSettings::maximumTextWidthIndex()); break; case DetailsMode: m_expandableFolders->setChecked(DetailsModeSettings::expandableFolders()); break; default: break; } const ViewModeSettings settings(viewMode()); const QSize iconSize(settings.iconSize(), settings.iconSize()); m_defaultSizeSlider->setValue(ZoomLevelInfo::zoomLevelForIconSize(iconSize)); const QSize previewSize(settings.previewSize(), settings.previewSize()); m_previewSizeSlider->setValue(ZoomLevelInfo::zoomLevelForIconSize(previewSize)); m_fontRequester->setMode(settings.useSystemFont() ? DolphinFontRequester::SystemFont : DolphinFontRequester::CustomFont); QFont font(settings.fontFamily(), qRound(settings.fontSize())); font.setItalic(settings.italicFont()); font.setWeight(settings.fontWeight()); font.setPointSizeF(settings.fontSize()); m_fontRequester->setCustomFont(font); } ViewModeSettings::ViewMode ViewSettingsTab::viewMode() const { ViewModeSettings::ViewMode mode; switch (m_mode) { case ViewSettingsTab::IconsMode: mode = ViewModeSettings::IconsMode; break; case ViewSettingsTab::CompactMode: mode = ViewModeSettings::CompactMode; break; case ViewSettingsTab::DetailsMode: mode = ViewModeSettings::DetailsMode; break; default: mode = ViewModeSettings::IconsMode; Q_ASSERT(false); break; } return mode; } void ViewSettingsTab::slotDefaultSliderMoved(int value) { showToolTip(m_defaultSizeSlider, value); } void ViewSettingsTab::slotPreviewSliderMoved(int value) { showToolTip(m_previewSizeSlider, value); } void ViewSettingsTab::showToolTip(QSlider* slider, int value) { const int size = ZoomLevelInfo::iconSizeForZoomLevel(value); slider->setToolTip(i18ncp("@info:tooltip", "Size: 1 pixel", "Size: %1 pixels", size)); if (!slider->isVisible()) { return; } QPoint global = slider->rect().topLeft(); global.ry() += slider->height() / 2; QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), slider->mapToGlobal(global)); QApplication::sendEvent(slider, &toolTipEvent); }