Skip to content

Commit

Permalink
#55: fill height with title, vertical alignment option for title, use…
Browse files Browse the repository at this point in the history
… padding instead of margins
  • Loading branch information
antroids committed Sep 24, 2024
1 parent 9976f27 commit a99e7aa
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
8 changes: 8 additions & 0 deletions package/contents/config/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@
</choices>
<default>0</default>
</entry>
<entry name="windowTitleVerticalAlignment" type="Enum">
<choices>
<choice name="Top" />
<choice name="Bottom" />
<choice name="Center" />
</choices>
<default>2</default>
</entry>
<entry name="windowTitleHideEmpty" type="Bool">
<default>false</default>
</entry>
Expand Down
8 changes: 8 additions & 0 deletions package/contents/ui/config/ConfigAppearance.qml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ KCM.SimpleKCM {
property alias cfg_windowTitleFontSizeMode: windowTitleFontSizeMode.currentIndex
property alias cfg_windowTitleSource: windowTitleSource.currentIndex
property alias cfg_windowTitleHorizontalAlignment: windowTitleHorizontalAlignment.currentIndex
property alias cfg_windowTitleVerticalAlignment: windowTitleVerticalAlignment.currentIndex
property alias cfg_windowTitleHideEmpty: windowTitleHideEmpty.checked
property alias cfg_windowTitleUndefined: windowTitleUndefined.text
property alias cfg_windowTitleMarginsLeft: windowTitleMarginsLeft.value
Expand Down Expand Up @@ -346,6 +347,13 @@ You can install more of regular Aurorae themes for window decorations in System
model: [i18n("Left"), i18n("Right"), i18n("Center"), i18n("Justify")]
}

ComboBox {
id: windowTitleVerticalAlignment

Kirigami.FormData.label: i18n("Vertical alignment:")
model: [i18n("Top"), i18n("Bottom"), i18n("Center")]
}

RowLayout {
Kirigami.FormData.label: i18n("Window title margins:")

Expand Down
12 changes: 8 additions & 4 deletions package/contents/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -184,21 +184,19 @@ PlasmoidItem {
id: windowTitleLabel

readonly property var horizontalAlignmentValues: [Text.AlignLeft, Text.AlignRight, Text.AlignHCenter, Text.AlignJustify]
readonly property var verticalAlignmentValues: [Text.AlignTop, Text.AlignBottom, Text.AlignVCenter]

property var modelData
property bool empty: text === undefined || text === ""
property bool hideEmpty: empty && plasmoid.configuration.windowTitleHideEmpty
property int windowTitleSource: plasmoid.configuration.overrideElementsMaximized && tasksModel.activeWindow.maximized ? plasmoid.configuration.windowTitleSourceMaximized : plasmoid.configuration.windowTitleSource
property var titleTextReplacements: []

Layout.leftMargin: !hideEmpty ? plasmoid.configuration.windowTitleMarginsLeft : 0
Layout.topMargin: !hideEmpty ? plasmoid.configuration.windowTitleMarginsTotitleReplacementsTypesp : 0
Layout.bottomMargin: !hideEmpty ? plasmoid.configuration.windowTitleMarginsBottom : 0
Layout.rightMargin: !hideEmpty ? plasmoid.configuration.windowTitleMarginsRight : 0
Layout.minimumWidth: plasmoid.configuration.windowTitleMinimumWidth
Layout.maximumWidth: !hideEmpty ? plasmoid.configuration.windowTitleMaximumWidth : 0
Layout.alignment: root.widgetAlignment
Layout.fillWidth: plasmoid.configuration.widgetFillWidth
Layout.fillHeight: true
Layout.preferredWidth: textMetrics.advanceWidth + leftPadding + rightPadding + 1 // Magic number
text: titleText(windowTitleSource) || plasmoid.configuration.windowTitleUndefined
font.pointSize: plasmoid.configuration.windowTitleFontSize
Expand All @@ -209,6 +207,12 @@ PlasmoidItem {
wrapMode: Text.WrapAnywhere
enabled: tasksModel.hasActiveWindow
horizontalAlignment: horizontalAlignmentValues[plasmoid.configuration.windowTitleHorizontalAlignment]
verticalAlignment: verticalAlignmentValues[plasmoid.configuration.windowTitleVerticalAlignment]

bottomPadding: !hideEmpty ? plasmoid.configuration.windowTitleMarginsBottom : 0
leftPadding: !hideEmpty ? plasmoid.configuration.windowTitleMarginsLeft : 0
rightPadding: !hideEmpty ? plasmoid.configuration.windowTitleMarginsRight : 0
topPadding: !hideEmpty ? plasmoid.configuration.windowTitleMarginsTop : 0

Accessible.role: Accessible.TitleBar
Accessible.name: text
Expand Down

0 comments on commit a99e7aa

Please sign in to comment.