diff --git a/components/mobileshell/qml/statusbar/ClockText.qml b/components/mobileshell/qml/statusbar/ClockText.qml index 60d16b8f..2250f55f 100644 --- a/components/mobileshell/qml/statusbar/ClockText.qml +++ b/components/mobileshell/qml/statusbar/ClockText.qml @@ -11,17 +11,34 @@ import QtQuick.Layouts 1.15 import org.kde.plasma.plasma5support 2.0 as P5Support import org.kde.plasma.components 3.0 as PlasmaComponents import org.kde.plasma.private.mobileshell as MobileShell +import org.kde.plasma.private.mobileshell.shellsettingsplugin as ShellSettings import org.kde.kirigami as Kirigami -PlasmaComponents.Label { - id: clock - +RowLayout { + id: clockText + + required property int fontPixelSize required property P5Support.DataSource source + + PlasmaComponents.Label { + id: clock - property bool is24HourTime: MobileShell.ShellUtil.isSystem24HourFormat + property bool is24HourTime: MobileShell.ShellUtil.isSystem24HourFormat - text: Qt.formatTime(source.data.Local.DateTime, is24HourTime ? "h:mm" : "h:mm ap") - color: Kirigami.Theme.textColor - verticalAlignment: Qt.AlignVCenter + text: Qt.formatTime(source.data.Local.DateTime, is24HourTime ? "h:mm" : "h:mm ap") + color: Kirigami.Theme.textColor + verticalAlignment: Qt.AlignVCenter + font.pixelSize: fontPixelSize + } + + PlasmaComponents.Label { + id: date + visible: ShellSettings.Settings.dateInStatusBar && !root.showSecondRow + + text: Qt.formatDate(source.data.Local.DateTime, "ddd. MMMM d") + color: Kirigami.Theme.textColor + verticalAlignment: Qt.AlignVCenter + font.pixelSize: fontPixelSize + } } diff --git a/components/mobileshell/qml/statusbar/StatusBar.qml b/components/mobileshell/qml/statusbar/StatusBar.qml index 8cabab6f..ea17c0e8 100644 --- a/components/mobileshell/qml/statusbar/StatusBar.qml +++ b/components/mobileshell/qml/statusbar/StatusBar.qml @@ -113,7 +113,7 @@ Item { ClockText { visible: root.showTime Layout.fillHeight: true - font.pixelSize: textPixelSize + fontPixelSize: textPixelSize source: timeSource } diff --git a/components/shellsettingsplugin/mobileshellsettings.cpp b/components/shellsettingsplugin/mobileshellsettings.cpp index b47e0a56..508426f4 100644 --- a/components/shellsettingsplugin/mobileshellsettings.cpp +++ b/components/shellsettingsplugin/mobileshellsettings.cpp @@ -29,6 +29,7 @@ MobileShellSettings::MobileShellSettings(QObject *parent) Q_EMIT vibrationsEnabledChanged(); Q_EMIT vibrationDurationChanged(); Q_EMIT animationsEnabledChanged(); + Q_EMIT dateInStatusBarChanged(); Q_EMIT navigationPanelEnabledChanged(); Q_EMIT alwaysShowKeyboardToggleOnNavigationPanelChanged(); Q_EMIT keyboardButtonEnabledChanged(); @@ -79,6 +80,19 @@ void MobileShellSettings::setAnimationsEnabled(bool animationsEnabled) m_config->sync(); } +bool MobileShellSettings::dateInStatusBar() const +{ + auto group = KConfigGroup{m_config, GENERAL_CONFIG_GROUP}; + return group.readEntry("dateInStatusBar", false); +} + +void MobileShellSettings::setDateInStatusBar(bool dateInStatusBar) +{ + auto group = KConfigGroup{m_config, GENERAL_CONFIG_GROUP}; + group.writeEntry("dateInStatusBar", dateInStatusBar, KConfigGroup::Notify); + m_config->sync(); +} + bool MobileShellSettings::navigationPanelEnabled() const { auto group = KConfigGroup{m_config, GENERAL_CONFIG_GROUP}; diff --git a/components/shellsettingsplugin/mobileshellsettings.h b/components/shellsettingsplugin/mobileshellsettings.h index 4382df01..1c6b4cd7 100644 --- a/components/shellsettingsplugin/mobileshellsettings.h +++ b/components/shellsettingsplugin/mobileshellsettings.h @@ -29,6 +29,9 @@ class MobileShellSettings : public QObject Q_PROPERTY(int vibrationDuration READ vibrationDuration WRITE setVibrationDuration NOTIFY vibrationDurationChanged) Q_PROPERTY(bool animationsEnabled READ animationsEnabled WRITE setAnimationsEnabled NOTIFY animationsEnabledChanged) + // status bar + Q_PROPERTY(bool dateInStatusBar READ dateInStatusBar WRITE setDateInStatusBar NOTIFY dateInStatusBarChanged) + // navigation panel Q_PROPERTY(bool navigationPanelEnabled READ navigationPanelEnabled WRITE setNavigationPanelEnabled NOTIFY navigationPanelEnabledChanged) Q_PROPERTY(bool alwaysShowKeyboardToggleOnNavigationPanel READ alwaysShowKeyboardToggleOnNavigationPanel WRITE setAlwaysShowKeyboardToggleOnNavigationPanel @@ -91,6 +94,20 @@ public: */ void setAnimationsEnabled(bool animationsEnabled); + /** + * Whether date is shown in the status bar. + * + * If true, date will be shown in the status bar next to the clock. + */ + bool dateInStatusBar() const; + + /** + * Set whether date is shown in the status bar. + * + * @param dateInStatusBar Whether date is shown in the status bar. + */ + void setDateInStatusBar(bool dateInStatusBar); + /** * Whether the navigation panel is enabled. * @@ -165,6 +182,7 @@ Q_SIGNALS: void alwaysShowKeyboardToggleOnNavigationPanelChanged(); void keyboardButtonEnabledChanged(); void animationsEnabledChanged(); + void dateInStatusBarChanged(); void taskSwitcherPreviewsEnabledChanged(); void actionDrawerTopLeftModeChanged(); void actionDrawerTopRightModeChanged(); diff --git a/kcms/mobileshell/ui/main.qml b/kcms/mobileshell/ui/main.qml index a24844a3..f0d3f7e6 100644 --- a/kcms/mobileshell/ui/main.qml +++ b/kcms/mobileshell/ui/main.qml @@ -49,6 +49,24 @@ KCM.SimpleKCM { } } + FormCard.FormHeader { + title: i18n("Status bar") + } + + FormCard.FormCard { + FormCard.FormSwitchDelegate { + id: dateInStatusBar + text: i18n("Date in status bar") + description: i18n("If on, date will be shown next to the clock in the status bar.") + checked: ShellSettings.Settings.dateInStatusBar + onCheckedChanged: { + if (checked != ShellSettings.Settings.dateInStatusBar) { + ShellSettings.Settings.dateInStatusBar = checked; + } + } + } + } + FormCard.FormHeader { title: i18n("Navigation Panel") }