mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
Add setting for showing date in status bar
As the title said. Requested in plasma-mobile/plasma-settings#17 I marked it as a draft because there is a small regression which removes vertical alignment of right icons.
This commit is contained in:
parent
5e2ff03e25
commit
8f9db42e8f
5 changed files with 75 additions and 8 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ Item {
|
|||
ClockText {
|
||||
visible: root.showTime
|
||||
Layout.fillHeight: true
|
||||
font.pixelSize: textPixelSize
|
||||
fontPixelSize: textPixelSize
|
||||
source: timeSource
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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};
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue