diff --git a/src/settings/ConfigurationDialog.h b/src/settings/ConfigurationDialog.h index 37ae10d8..627bb6db 100644 --- a/src/settings/ConfigurationDialog.h +++ b/src/settings/ConfigurationDialog.h @@ -1,289 +1,285 @@ /* Copyright 2019 by Mariusz Glebocki Based on KConfigDialog and KConfigDialogManager from KConfigWidgets Copyright (C) 2003 Benjamin C Meyer (ben+kdelibs at meyerhome dot net) Copyright (C) 2003 Waldo Bastian 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 CONFIGURATIONDIALOG_H #define CONFIGURATIONDIALOG_H // Qt #include #include #include #include #include // KDE #include #include #include // Konsole #include "konsoleprivate_export.h" class KConfig; class KCoreConfigSkeleton; class KConfigDialogManager; namespace Konsole { class ConfigDialogButtonGroupManager; // KConfigDialog-like class, as the original KConfigDialog wraps // all pages in QScrollArea. KConfigDialog, when fixed, should // be source compatible with this class, so simple class replace // should suffice. class KONSOLEPRIVATE_EXPORT ConfigurationDialog: public KPageDialog { Q_OBJECT Q_SIGNALS: void widgetModified(); void settingsChanged(); public: explicit ConfigurationDialog(QWidget *parent, KCoreConfigSkeleton *config); ~ConfigurationDialog() override = default; void addPage(KPageWidgetItem *item, bool manage); protected Q_SLOTS: void updateButtons(); void settingsChangedSlot(); protected: void setApplyButtonEnabled(bool enabled); void setRestoreDefaultsButtonEnabled(bool enabled); void showEvent(QShowEvent *event) override; private: Q_DISABLE_COPY(ConfigurationDialog) KConfigDialogManager *_manager = nullptr; ConfigDialogButtonGroupManager *_groupManager = nullptr; bool _shown = false; }; // KConfigDialogManager-like class for managing QButtonGroups, // which are not supported by KConfigDialogManager yet. When // support will be available in minimum KF5 used by Konsole, // just remove this class and all expressions which refer to it. class ConfigDialogButtonGroupManager: public QObject { Q_OBJECT public: ConfigDialogButtonGroupManager(QObject *parent, KCoreConfigSkeleton *config) : QObject(parent) , _config(config) { Q_ASSERT(config); connect(_config, &KCoreConfigSkeleton::configChanged, this, &ConfigDialogButtonGroupManager::updateWidgets); } void addChildren(const QObject *parentObj) { - for (const QObject *child: parentObj->children()) { - if (!child->objectName().startsWith(ManagedNamePrefix)) { - continue; - } - - const char *className = child->metaObject()->className(); - if (qstrcmp(className, "QButtonGroup") == 0) { - add(qobject_cast(child)); + const auto allButtonGroups = parentObj->findChildren(); + for (const auto *buttonGroup: allButtonGroups) { + if (buttonGroup->objectName().startsWith(ManagedNamePrefix)) { + add(buttonGroup); } } } void add(const QButtonGroup *obj) { Q_ASSERT(obj->exclusive()); connect(obj, QOverload::of(&QButtonGroup::buttonToggled), this, &ConfigDialogButtonGroupManager::setButtonState, Qt::UniqueConnection); _groups.append(obj); } bool hasChanged() const { for(const QButtonGroup *group: qAsConst(_groups)) { int value = buttonToEnumValue(group->checkedButton()); const auto enumItem = groupToConfigItemEnum(group); if(!enumItem->isEqual(value)) { return true; } } return false; } bool isDefault() const { bool useDefaults = _config->useDefaults(true); bool result = !hasChanged(); _config->useDefaults(useDefaults); return result; } Q_SIGNALS: void settingsChanged(); void widgetModified(); public Q_SLOTS: void updateWidgets() { bool prevSignalsBlocked = signalsBlocked(); bool changed = false; blockSignals(true); for(const QButtonGroup *group: qAsConst(_groups)) { auto *enumItem = groupToConfigItemEnum(group); if(enumItem == nullptr) { continue; } int value = enumItem->value(); const QString &valueName = enumItem->choices().at(value).name; QAbstractButton *currentButton = nullptr; for(auto &button: group->buttons()) { if(button->objectName() == valueName) { currentButton = button; break; } } if(currentButton == nullptr) { return; } currentButton->setChecked(true); changed = true; } blockSignals(prevSignalsBlocked); if(changed) { QTimer::singleShot(0, this, &ConfigDialogButtonGroupManager::widgetModified); } } void updateWidgetsDefault() { bool useDefaults = _config->useDefaults(true); updateWidgets(); _config->useDefaults(useDefaults); } void updateSettings() { bool updateConfig = false; for(const QButtonGroup *group: qAsConst(_groups)) { auto *enumItem = groupToConfigItemEnum(group); if(enumItem == nullptr) { continue; } const auto *currentButton = group->checkedButton(); if(currentButton == nullptr) { continue; } const int value = buttonToEnumValue(currentButton); if(value < 0) { continue; } if(!enumItem->isEqual(value)) { enumItem->setValue(value); updateConfig = true; } } if(updateConfig) { _config->save(); emit settingsChanged(); } } protected Q_SLOTS: void setButtonState(QAbstractButton *button, bool checked) { Q_ASSERT(button); Q_ASSERT(button->group()); if(!checked) { // Both deselected and selected buttons trigger this slot, ignore the deselected one return; } auto *enumItem = groupToConfigItemEnum(button->group()); if(enumItem == nullptr) { return; } int value = buttonToEnumValue(button); if(value < 0) { return; } emit settingsChanged(); } private: // Returns configuration item associated with the group KCoreConfigSkeleton::ItemEnum * groupToConfigItemEnum(const QButtonGroup *group) const { Q_ASSERT(group); const QString key = group->objectName().mid(ManagedNamePrefix.length()); auto *item = _config->findItem(key); if(item == nullptr) { return nullptr; } auto *enumItem = dynamic_cast(item); if(enumItem == nullptr) { return nullptr; } return enumItem; } // Returns a value the button represents in its group int buttonToEnumValue(const QAbstractButton *button) const { Q_ASSERT(button); Q_ASSERT(button->group()); if(_buttonValues.contains(button)) { return _buttonValues[button]; } const auto *enumItem = groupToConfigItemEnum(button->group()); if(enumItem == nullptr) { return -1; } const auto &choices = enumItem->choices(); const QString buttonName = button->objectName(); int value = -1; for(int i = 0; i < choices.size(); ++i) { if(buttonName == choices.at(i).name) { value = i; break; } } _buttonValues[button] = value; return value; } static const QString ManagedNamePrefix; mutable QMap _buttonValues; KCoreConfigSkeleton *_config = nullptr; QList _groups; }; } #endif // CONFIGURATIONDIALOG_H diff --git a/src/settings/TabBarSettings.cpp b/src/settings/TabBarSettings.cpp index d319b9f1..bfd1dd17 100644 --- a/src/settings/TabBarSettings.cpp +++ b/src/settings/TabBarSettings.cpp @@ -1,42 +1,47 @@ /* Copyright 2011 Kurt Hindenburg 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) version 3 or any later version accepted by the membership of KDE e.V. (or its successor appro- ved by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of version 3 of the license. 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, see http://www.gnu.org/licenses/. */ // Own #include "TabBarSettings.h" using namespace Konsole; TabBarSettings::TabBarSettings(QWidget* aParent) : QWidget(aParent) { setupUi(this); + // For some reason these layouts have invalid sizes when + // sizeHint() is read before the widget is shown. + appearanceTabLayout->activate(); + behaviorTabLayout->activate(); + // Enable CSS file selector only when tabbar is visible and custom css is active const auto updateStyleSheetFileEnable = [this](bool) { kcfg_TabBarUserStyleSheetFile->setEnabled(kcfg_TabBarUseUserStyleSheet->isChecked() && !AlwaysHideTabBar->isChecked()); }; connect(kcfg_TabBarUseUserStyleSheet, &QAbstractButton::toggled, this, updateStyleSheetFileEnable); connect(AlwaysHideTabBar, &QAbstractButton::toggled, this, updateStyleSheetFileEnable); } TabBarSettings::~TabBarSettings() = default; diff --git a/src/settings/TabBarSettings.ui b/src/settings/TabBarSettings.ui index 30475bbc..8a410d60 100644 --- a/src/settings/TabBarSettings.ui +++ b/src/settings/TabBarSettings.ui @@ -1,568 +1,613 @@ TabBarSettings 0 0 - 384 - 512 + 382 + 418 0 0 0 0 0 - - - 6 + + + 0 - - - - &Never - - - kcfg_TabBarVisibility - - - - - - - Use user-defined stylesheet: - - - - - - - After c&urrent tab - - - kcfg_NewTabBehavior - - - - - - - Close tab on middle-click - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 16 - 20 - - - - - - - - None - - - kcfg_CloseTabButton - - - - - - - Show Close Tab button: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - false - - - text/css - - - (none) - - - - - - - On &the tab bar - - - kcfg_CloseTabButton - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 16 - - - - - - - - On each tab - - - kcfg_CloseTabButton - - - - - - - Miscellaneous: - - - - - - - Put new tabs: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 16 - - - - - - - - Position: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - At the end - - - kcfg_NewTabBehavior - - - - - - - When needed - - - kcfg_TabBarVisibility - - - - - - - A&lways - - - kcfg_TabBarVisibility - - - - - - - Below terminal area - - - kcfg_TabBarPosition - - - - - - - Above terminal area - - - kcfg_TabBarPosition - - - - - - - Expand individual tab widths to full window - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 16 - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 16 - - - - - - - - Show: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - Qt::Vertical - - - - 20 - 0 - - - + + + Appearance + + + + 0 + + + + + 6 + + + + + Show: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + When needed + + + kcfg_TabBarVisibility + + + + + + + Alwa&ys + + + kcfg_TabBarVisibility + + + + + + + &Never + + + kcfg_TabBarVisibility + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 16 + + + + + + + + Position: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Be&low terminal area + + + kcfg_TabBarPosition + + + + + + + Above terminal area + + + kcfg_TabBarPosition + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 16 + + + + + + + + Show Close Tab button: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + &On each tab + + + kcfg_CloseTabButton + + + + + + + On &the tab bar + + + kcfg_CloseTabButton + + + + + + + None + + + kcfg_CloseTabButton + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 16 + + + + + + + + Miscellaneous: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Expand individual tab widths to full window + + + + + + + Use user-defined stylesheet: + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 16 + 20 + + + + + + + + false + + + text/css + + + (none) + + + + + + + + + Qt::Vertical + + + + 0 + 0 + + + + + + + + + Behavior + + + + 0 + + + + + 6 + + + + + Put new tabs: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + At &the end + + + kcfg_NewTabBehavior + + + + + + + After current &tab + + + kcfg_NewTabBehavior + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 16 + + + + + + + + Miscellaneous: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Close tab on middle-click + + + + + + + + + Qt::Vertical + + + + 0 + 0 + + + + + + + KUrlRequester QFrame
kurlrequester.h
1
+ tabs ShowTabBarWhenNeeded AlwaysShowTabBar AlwaysHideTabBar Bottom Top OnEachTab OnTabBar None + kcfg_ExpandTabWidth + kcfg_TabBarUseUserStyleSheet PutNewTabAtTheEnd PutNewTabAfterCurrentTab kcfg_CloseTabOnMiddleMouseButton - kcfg_ExpandTabWidth - kcfg_TabBarUseUserStyleSheet AlwaysHideTabBar toggled(bool) - kcfg_TabBarUseUserStyleSheet - setDisabled(bool) - - - 141 - 72 - - - 141 - 420 - - - - - AlwaysHideTabBar - toggled(bool) - PutNewTabAfterCurrentTab + None setDisabled(bool) - 141 - 72 + 20 + 20 - 141 - 320 + 20 + 20 AlwaysHideTabBar toggled(bool) - kcfg_CloseTabOnMiddleMouseButton + showCloseTabButtonLabel setDisabled(bool) - 141 - 72 + 20 + 20 - 141 - 368 + 20 + 20 AlwaysHideTabBar toggled(bool) - None + OnTabBar setDisabled(bool) - 141 - 72 + 20 + 20 - 141 - 246 + 20 + 20 AlwaysHideTabBar toggled(bool) - showCloseTabButtonLabel + Bottom setDisabled(bool) - 141 - 72 + 20 + 20 - 21 - 194 + 20 + 20 AlwaysHideTabBar toggled(bool) - OnTabBar + OnEachTab setDisabled(bool) - 141 - 72 + 20 + 20 - 141 - 220 + 20 + 20 AlwaysHideTabBar toggled(bool) - Bottom + positionLabel setDisabled(bool) - 141 - 72 + 20 + 20 - 141 - 146 + 20 + 20 AlwaysHideTabBar toggled(bool) - OnEachTab + Top setDisabled(bool) - 141 - 72 + 20 + 20 - 141 - 194 + 20 + 20 AlwaysHideTabBar toggled(bool) - miscellaneousLabel + miscellaneousAppearanceLabel setDisabled(bool) - 141 - 72 + 20 + 20 - 63 - 368 + 20 + 20 AlwaysHideTabBar toggled(bool) - putNewTabsLabel + kcfg_ExpandTabWidth setDisabled(bool) - 141 - 72 + 20 + 20 - 21 - 294 + 20 + 20 AlwaysHideTabBar toggled(bool) - positionLabel + kcfg_TabBarUseUserStyleSheet setDisabled(bool) - 141 - 72 + 20 + 20 - 21 - 120 + 20 + 20 - AlwaysHideTabBar + kcfg_TabBarUseUserStyleSheet toggled(bool) - PutNewTabAtTheEnd - setDisabled(bool) + kcfg_TabBarUserStyleSheetFile + setEnabled(bool) - 141 - 72 + 20 + 20 - 141 - 294 + 20 + 20 AlwaysHideTabBar toggled(bool) - Top + kcfg_CloseTabOnMiddleMouseButton setDisabled(bool) - 141 - 72 + 20 + 20 - 141 - 120 + 20 + 20 AlwaysHideTabBar toggled(bool) - kcfg_ExpandTabWidth + miscellaneousBehaviorLabel setDisabled(bool) - 141 - 72 + 20 + 20 - 141 - 394 + 20 + 20 - - + +