Commit cd68df16 authored by Momo Cao's avatar Momo Cao Committed by Nate Graham
Browse files

Add a setting to show date and time in one line

BUG: 393957
FIXED-IN: 5.22
parent a056b5d0
......@@ -77,5 +77,13 @@
<label>Whether the popup should remain open when another window is activated</label>
<default>false</default>
</entry>
<entry name="dateDisplayFormat" type="Enum">
<label>Whether the date should be shown below or beside the time</label>
<choices name="Settings::dateDisplayFormat">
<choice name="Adaptive" />
<choice name="BesideTime" />
</choices>
<default>Adaptive</default>
</entry>
</group>
</kcfg>
......@@ -55,8 +55,10 @@ Item {
// This is the index in the list of user selected timezones
property int tzIndex: 0
// if showing the date and the time in one line or
// if the date/timezone cannot be fit with the smallest font to its designated space
readonly property bool oneLineMode: plasmoid.formFactor === PlasmaCore.Types.Horizontal &&
property bool oneLineMode: plasmoid.configuration.dateDisplayFormat === 1 ||
plasmoid.formFactor === PlasmaCore.Types.Horizontal &&
main.height <= 2 * theme.smallestFont.pixelSize &&
(main.showDate || timezoneLabel.visible)
......@@ -182,8 +184,9 @@ Item {
},
State {
name: "horizontalPanelSmall"
when: plasmoid.formFactor === PlasmaCore.Types.Horizontal && main.oneLineMode
name: "oneLineDate"
// the one-line mode has no effect on a vertical panel because it would never fit
when: plasmoid.formFactor !== PlasmaCore.Types.Vertical && main.oneLineMode
PropertyChanges {
target: main
......@@ -211,7 +214,7 @@ Item {
target: dateLabel
height: timeLabel.height
width: dateLabel.paintedWidth
width: dateLabel.paintedWidth + PlasmaCore.Units.smallSpacing
font.pixelSize: 1024
verticalAlignment: Text.AlignVCenter
......@@ -480,15 +483,6 @@ Item {
flow: Grid.TopToBottom
columnSpacing: PlasmaCore.Units.smallSpacing
Rectangle {
height: 0.8 * sizehelper.height
width: 1
visible: main.showDate && main.oneLineMode
color: theme.textColor
opacity: 0.4
}
Components.Label {
id: timeLabel
......
......@@ -23,6 +23,7 @@
import QtQuick 2.0
import QtQuick.Controls 2.3 as QtControls
import QtQuick.Layouts 1.0 as QtLayouts
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.calendar 2.0 as PlasmaCalendar
import org.kde.kquickcontrolsaddons 2.0 // For KCMShell
import org.kde.kirigami 2.5 as Kirigami
......@@ -45,6 +46,7 @@ QtLayouts.ColumnLayout {
property string cfg_dateFormat: "shortDate"
property alias cfg_customDateFormat: customDateFormat.text
property alias cfg_use24hFormat: use24hFormat.currentIndex
property alias cfg_dateDisplayFormat: dateDisplayFormat.currentIndex
onCfg_fontFamilyChanged: {
// HACK by the time we populate our model and/or the ComboBox is finished the value is still undefined
......@@ -75,11 +77,25 @@ QtLayouts.ColumnLayout {
Kirigami.FormLayout {
QtLayouts.Layout.fillWidth: true
QtControls.CheckBox {
id: showDate
QtLayouts.RowLayout {
Kirigami.FormData.label: i18n("Information:")
text: i18n("Show date")
QtControls.CheckBox {
id: showDate
text: i18n("Show date")
}
QtControls.ComboBox {
id: dateDisplayFormat
enabled: showDate.checked
visible: plasmoid.formFactor !== PlasmaCore.Types.Vertical
model: [
i18n("Adaptive location"),
i18n("Always beside time"),
]
onActivated: cfg_dateDisplayFormat = currentIndex
}
}
QtControls.CheckBox {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment