2 * SPDX-FileCopyrightText: 2023 Dimosthenis Krallis <dimosthenis.krallis@outlook.com>
4 * SPDX-License-Identifier: GPL-2.0-or-later
7 #include "statusandlocationbarssettingspage.h"
8 #include "dolphinmainwindow.h"
9 #include "dolphinviewcontainer.h"
10 #include "settings/interface/folderstabssettingspage.h"
12 #include <KLocalizedString>
15 #include <QFormLayout>
17 #include <QRadioButton>
18 #include <QSpacerItem>
20 StatusAndLocationBarsSettingsPage::StatusAndLocationBarsSettingsPage(QWidget
*parent
, FoldersTabsSettingsPage
*foldersPage
)
21 : SettingsPageBase(parent
)
22 , m_editableUrl(nullptr)
23 , m_showFullPath(nullptr)
24 , m_showStatusBar(nullptr)
25 , m_showZoomSlider(nullptr)
26 , m_showSpaceInfo(nullptr)
28 // We need to update some urls at the Folders & Tabs tab. We get that from foldersPage and set it on a private attribute
29 // foldersTabsPage. That way, we can modify the necessary stuff from here. Specifically, any changes on locationUpdateInitialViewOptions()
30 // which is a copy of updateInitialViewOptions() on Folders & Tabs.
31 foldersTabsPage
= foldersPage
;
33 QFormLayout
*topLayout
= new QFormLayout(this);
36 m_showStatusBar
= new QCheckBox(i18nc("@option:check", "Show status bar"), this);
37 m_showZoomSlider
= new QCheckBox(i18nc("@option:check", "Show zoom slider"), this);
38 m_showSpaceInfo
= new QCheckBox(i18nc("@option:check", "Show space information"), this);
40 topLayout
->addRow(i18nc("@title:group", "Status Bar: "), m_showStatusBar
);
41 topLayout
->addRow(QString(), m_showZoomSlider
);
42 topLayout
->addRow(QString(), m_showSpaceInfo
);
44 topLayout
->addItem(new QSpacerItem(0, Dolphin::VERTICAL_SPACER_HEIGHT
, QSizePolicy::Fixed
, QSizePolicy::Fixed
));
47 m_editableUrl
= new QCheckBox(i18nc("@option:check Startup Settings", "Make location bar editable"));
48 topLayout
->addRow(i18n("Location bar:"), m_editableUrl
);
50 m_showFullPath
= new QCheckBox(i18nc("@option:check Startup Settings", "Show full path inside location bar"));
51 topLayout
->addRow(QString(), m_showFullPath
);
55 locationUpdateInitialViewOptions();
57 connect(m_editableUrl
, &QCheckBox::toggled
, this, &StatusAndLocationBarsSettingsPage::locationSlotSettingsChanged
);
58 connect(m_showFullPath
, &QCheckBox::toggled
, this, &StatusAndLocationBarsSettingsPage::locationSlotSettingsChanged
);
60 connect(m_showStatusBar
, &QCheckBox::toggled
, this, &StatusAndLocationBarsSettingsPage::changed
);
61 connect(m_showStatusBar
, &QCheckBox::toggled
, this, &StatusAndLocationBarsSettingsPage::onShowStatusBarToggled
);
62 connect(m_showZoomSlider
, &QCheckBox::toggled
, this, &StatusAndLocationBarsSettingsPage::changed
);
63 connect(m_showSpaceInfo
, &QCheckBox::toggled
, this, &StatusAndLocationBarsSettingsPage::changed
);
66 StatusAndLocationBarsSettingsPage::~StatusAndLocationBarsSettingsPage()
70 void StatusAndLocationBarsSettingsPage::applySettings()
72 GeneralSettings
*settings
= GeneralSettings::self();
74 settings
->setEditableUrl(m_editableUrl
->isChecked());
75 settings
->setShowFullPath(m_showFullPath
->isChecked());
77 settings
->setShowStatusBar(m_showStatusBar
->isChecked());
78 settings
->setShowZoomSlider(m_showZoomSlider
->isChecked());
79 settings
->setShowSpaceInfo(m_showSpaceInfo
->isChecked());
84 void StatusAndLocationBarsSettingsPage::onShowStatusBarToggled()
86 const bool checked
= m_showStatusBar
->isChecked();
87 m_showZoomSlider
->setEnabled(checked
);
88 m_showSpaceInfo
->setEnabled(checked
);
91 void StatusAndLocationBarsSettingsPage::restoreDefaults()
93 GeneralSettings
*settings
= GeneralSettings::self();
94 settings
->useDefaults(true);
96 settings
->useDefaults(false);
99 void StatusAndLocationBarsSettingsPage::locationSlotSettingsChanged()
101 // Provide a hint that the startup settings have been changed. This allows the views
102 // to apply the startup settings only if they have been explicitly changed by the user
103 // (see bug #254947).
104 GeneralSettings::setModifiedStartupSettings(true);
106 // Enable and disable home URL controls appropriately
107 locationUpdateInitialViewOptions();
111 void StatusAndLocationBarsSettingsPage::locationUpdateInitialViewOptions()
113 foldersTabsPage
->m_homeUrlBoxLayoutContainer
->setEnabled(foldersTabsPage
->m_homeUrlRadioButton
->isChecked());
114 foldersTabsPage
->m_buttonBoxLayoutContainer
->setEnabled(foldersTabsPage
->m_homeUrlRadioButton
->isChecked());
117 void StatusAndLocationBarsSettingsPage::loadSettings()
119 m_editableUrl
->setChecked(GeneralSettings::editableUrl());
120 m_showFullPath
->setChecked(GeneralSettings::showFullPath());
121 m_showStatusBar
->setChecked(GeneralSettings::showStatusBar());
122 m_showZoomSlider
->setChecked(GeneralSettings::showZoomSlider());
123 m_showSpaceInfo
->setChecked(GeneralSettings::showSpaceInfo());
125 onShowStatusBarToggled();
128 #include "moc_statusandlocationbarssettingspage.cpp"