diff options
| author | Akseli Lahtinen <[email protected]> | 2025-02-24 18:39:22 +0000 |
|---|---|---|
| committer | Akseli Lahtinen <[email protected]> | 2025-02-24 18:39:22 +0000 |
| commit | a27443d904bc220615f2c4e8df74187b0c806d8a (patch) | |
| tree | 420ff120b30bb2492a363abf9ddf80a8697d3ad9 /src/settings | |
| parent | 69c4792928edef91b5aea06772d02eb0f7c873b4 (diff) | |
Add smaller statusbar and set it as default
- Statusbar has three modes: Small, FullWidth and Disabled
- FullWidth is the original statusbar
- Small is the new default statusbar
- This statusbar overlays on top of the items instead of taking space
- It changes size according to content
- Disabled turns statusbar completely off
- Zoom slider and space information is only shown in full-width statusbar
- Space information is now always on
- If user navigates with keyboard, or scrolls to selection, the scrolling will take the statusbar into account
- This makes sure the statusbar does not cover any items
Related discussion: https://invent.kde.org/system/dolphin/-/issues/50
Diffstat (limited to 'src/settings')
5 files changed, 84 insertions, 26 deletions
diff --git a/src/settings/dolphin_25.04_update_statusandlocationbarssettings.cpp b/src/settings/dolphin_25.04_update_statusandlocationbarssettings.cpp new file mode 100644 index 000000000..2188fcb82 --- /dev/null +++ b/src/settings/dolphin_25.04_update_statusandlocationbarssettings.cpp @@ -0,0 +1,28 @@ +/* + SPDX-FileCopyrightText: 2025 Akseli Lahtinen <[email protected]> + + SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include <KConfigGroup> +#include <KSharedConfig> + +int main() +{ + const auto showStatusBar = QStringLiteral("ShowStatusBar"); + auto config = KSharedConfig::openConfig(QStringLiteral("dolphinrc")); + + KConfigGroup general = config->group(QStringLiteral("General")); + if (!general.hasKey(showStatusBar)) { + return EXIT_SUCCESS; + } + + const auto value = general.readEntry(showStatusBar); + if (value == QStringLiteral("true")) { + general.writeEntry(showStatusBar, QStringLiteral("Small")); + } else if (value == QStringLiteral("false")) { + general.writeEntry(showStatusBar, QStringLiteral("Disabled")); + } + + return general.sync() ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/src/settings/dolphin_generalsettings.kcfg b/src/settings/dolphin_generalsettings.kcfg index c800eadb8..e950099ec 100644 --- a/src/settings/dolphin_generalsettings.kcfg +++ b/src/settings/dolphin_generalsettings.kcfg @@ -117,18 +117,19 @@ <label>Use auto-expanding folders for all view types</label> <default>false</default> </entry> - <entry name="ShowStatusBar" type="Bool"> - <label>Show the statusbar</label> - <default>true</default> + <entry name="ShowStatusBar" type="Enum"> + <choices> + <choice name="Small" /> + <choice name="FullWidth" /> + <choice name="Disabled" /> + </choices> + <label>Statusbar</label> + <default>0</default> <emit signal="showStatusBarChanged" /> </entry> <entry name="ShowZoomSlider" type="Bool"> <label>Show zoom slider in the statusbar</label> - <default>true</default> - </entry> - <entry name="ShowSpaceInfo" type="Bool"> - <label>Show the space information in the statusbar</label> - <default>true</default> + <default>false</default> </entry> <entry name="LockPanels" type="Bool"> <label>Lock the layout of the panels</label> diff --git a/src/settings/dolphin_statusandlocationbarssettings.upd b/src/settings/dolphin_statusandlocationbarssettings.upd new file mode 100644 index 000000000..d7dd095f2 --- /dev/null +++ b/src/settings/dolphin_statusandlocationbarssettings.upd @@ -0,0 +1,9 @@ +#SPDX-FileCopyrightText: 2025 Akseli Lahtinen <[email protected]> +#SPDX-License-Identifier: GPL-2.0-or-later + +#Configuration update for Dolphin +Version=6 + +#Convert bool ShowStatusBar to enum ShowStatusBar +Id=25.04-convert-bool-showstatusbar-to-enum-showstatusbar +Script=dolphin_25.04_update_statusandlocationbarssettings diff --git a/src/settings/interface/statusandlocationbarssettingspage.cpp b/src/settings/interface/statusandlocationbarssettingspage.cpp index 5e0536a6e..14b5c8188 100644 --- a/src/settings/interface/statusandlocationbarssettingspage.cpp +++ b/src/settings/interface/statusandlocationbarssettingspage.cpp @@ -14,16 +14,21 @@ #include <QCheckBox> #include <QFormLayout> +#include <QButtonGroup> #include <QRadioButton> #include <QSpacerItem> +#include <QStyle> +#include <QStyleOption> StatusAndLocationBarsSettingsPage::StatusAndLocationBarsSettingsPage(QWidget *parent, FoldersTabsSettingsPage *foldersPage) : SettingsPageBase(parent) , m_editableUrl(nullptr) , m_showFullPath(nullptr) - , m_showStatusBar(nullptr) + , m_statusBarButtonGroup(nullptr) + , m_showStatusBarSmall(nullptr) + , m_showStatusBarFullWidth(nullptr) , m_showZoomSlider(nullptr) - , m_showSpaceInfo(nullptr) + , m_disableStatusBar(nullptr) { // We need to update some urls at the Folders & Tabs tab. We get that from foldersPage and set it on a private attribute // foldersTabsPage. That way, we can modify the necessary stuff from here. Specifically, any changes on locationUpdateInitialViewOptions() @@ -33,14 +38,30 @@ StatusAndLocationBarsSettingsPage::StatusAndLocationBarsSettingsPage(QWidget *pa QFormLayout *topLayout = new QFormLayout(this); // Status bar - m_showStatusBar = new QCheckBox(i18nc("@option:check", "Show status bar"), this); + m_statusBarButtonGroup = new QButtonGroup(this); + m_showStatusBarSmall = new QRadioButton(i18nc("@option:radio", "Small"), this); + m_showStatusBarFullWidth = new QRadioButton(i18nc("@option:radio", "Full width"), this); m_showZoomSlider = new QCheckBox(i18nc("@option:check", "Show zoom slider"), this); - m_showSpaceInfo = new QCheckBox(i18nc("@option:check", "Show space information"), this); + m_disableStatusBar = new QRadioButton(i18nc("@option:check", "Disabled"), this); - topLayout->addRow(i18nc("@title:group", "Status Bar: "), m_showStatusBar); - topLayout->addRow(QString(), m_showZoomSlider); - topLayout->addRow(QString(), m_showSpaceInfo); + m_statusBarButtonGroup->addButton(m_showStatusBarSmall, GeneralSettings::EnumShowStatusBar::Small); + m_statusBarButtonGroup->addButton(m_showStatusBarFullWidth, GeneralSettings::EnumShowStatusBar::FullWidth); + m_statusBarButtonGroup->addButton(m_disableStatusBar, GeneralSettings::EnumShowStatusBar::Disabled); + topLayout->addRow(i18nc("@title:group", "Status Bar:"), m_showStatusBarSmall); + topLayout->addRow(QString(), m_showStatusBarFullWidth); + + // Indent the m_showZoomSlider checkbox under m_showStatusBarFullWidth. + QHBoxLayout *zoomSliderLayout = new QHBoxLayout; + QStyleOption opt; + opt.initFrom(this); + zoomSliderLayout->addItem( + new QSpacerItem(style()->pixelMetric(QStyle::PM_IndicatorWidth, &opt, this), Dolphin::VERTICAL_SPACER_HEIGHT, QSizePolicy::Fixed, QSizePolicy::Fixed)); + zoomSliderLayout->addWidget(m_showZoomSlider); + + topLayout->addRow(QString(), zoomSliderLayout); + + topLayout->addRow(QString(), m_disableStatusBar); topLayout->addItem(new QSpacerItem(0, Dolphin::VERTICAL_SPACER_HEIGHT, QSizePolicy::Fixed, QSizePolicy::Fixed)); // Location bar @@ -57,10 +78,9 @@ StatusAndLocationBarsSettingsPage::StatusAndLocationBarsSettingsPage(QWidget *pa connect(m_editableUrl, &QCheckBox::toggled, this, &StatusAndLocationBarsSettingsPage::locationSlotSettingsChanged); connect(m_showFullPath, &QCheckBox::toggled, this, &StatusAndLocationBarsSettingsPage::locationSlotSettingsChanged); - connect(m_showStatusBar, &QCheckBox::toggled, this, &StatusAndLocationBarsSettingsPage::changed); - connect(m_showStatusBar, &QCheckBox::toggled, this, &StatusAndLocationBarsSettingsPage::onShowStatusBarToggled); + connect(m_statusBarButtonGroup, &QButtonGroup::idClicked, this, &StatusAndLocationBarsSettingsPage::changed); + connect(m_statusBarButtonGroup, &QButtonGroup::idClicked, this, &StatusAndLocationBarsSettingsPage::onShowStatusBarToggled); connect(m_showZoomSlider, &QCheckBox::toggled, this, &StatusAndLocationBarsSettingsPage::changed); - connect(m_showSpaceInfo, &QCheckBox::toggled, this, &StatusAndLocationBarsSettingsPage::changed); } StatusAndLocationBarsSettingsPage::~StatusAndLocationBarsSettingsPage() @@ -74,18 +94,16 @@ void StatusAndLocationBarsSettingsPage::applySettings() settings->setEditableUrl(m_editableUrl->isChecked()); settings->setShowFullPath(m_showFullPath->isChecked()); - settings->setShowStatusBar(m_showStatusBar->isChecked()); + settings->setShowStatusBar(m_statusBarButtonGroup->checkedId()); settings->setShowZoomSlider(m_showZoomSlider->isChecked()); - settings->setShowSpaceInfo(m_showSpaceInfo->isChecked()); settings->save(); } void StatusAndLocationBarsSettingsPage::onShowStatusBarToggled() { - const bool checked = m_showStatusBar->isChecked(); + const bool checked = (m_statusBarButtonGroup->checkedId() == GeneralSettings::EnumShowStatusBar::FullWidth); m_showZoomSlider->setEnabled(checked); - m_showSpaceInfo->setEnabled(checked); } void StatusAndLocationBarsSettingsPage::restoreDefaults() @@ -118,9 +136,8 @@ void StatusAndLocationBarsSettingsPage::loadSettings() { m_editableUrl->setChecked(GeneralSettings::editableUrl()); m_showFullPath->setChecked(GeneralSettings::showFullPath()); - m_showStatusBar->setChecked(GeneralSettings::showStatusBar()); + m_statusBarButtonGroup->button(GeneralSettings::showStatusBar())->setChecked(true); m_showZoomSlider->setChecked(GeneralSettings::showZoomSlider()); - m_showSpaceInfo->setChecked(GeneralSettings::showSpaceInfo()); onShowStatusBarToggled(); } diff --git a/src/settings/interface/statusandlocationbarssettingspage.h b/src/settings/interface/statusandlocationbarssettingspage.h index c22ff2041..3b8049782 100644 --- a/src/settings/interface/statusandlocationbarssettingspage.h +++ b/src/settings/interface/statusandlocationbarssettingspage.h @@ -16,6 +16,7 @@ class QCheckBox; class QLineEdit; class QLabel; class QRadioButton; +class QButtonGroup; /** * @brief Tab page for the 'Behavior' settings of the Dolphin settings dialog. @@ -47,9 +48,11 @@ private: QCheckBox *m_editableUrl; QCheckBox *m_showFullPath; - QCheckBox *m_showStatusBar; + QButtonGroup *m_statusBarButtonGroup; + QRadioButton *m_showStatusBarSmall; + QRadioButton *m_showStatusBarFullWidth; QCheckBox *m_showZoomSlider; - QCheckBox *m_showSpaceInfo; + QRadioButton *m_disableStatusBar; }; #endif |
