Skip to content

Commit

Permalink
#29: override Title Source for maximized windows
Browse files Browse the repository at this point in the history
  • Loading branch information
antroids committed Apr 22, 2024
1 parent 8a83ac6 commit 632ed37
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 112 deletions.
10 changes: 10 additions & 0 deletions package/contents/config/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,22 @@
<entry name="widgetElements" type="StringList">
<default>windowCloseButton,windowMaximizeButton,windowMinimizeButton,windowIcon,windowTitle</default>
</entry>

<entry name="overrideElementsMaximized" type="Bool">
<default>false</default>
</entry>
<entry name="widgetElementsMaximized" type="StringList">
<default>windowCloseButton,windowMaximizeButton,windowMinimizeButton,windowIcon,windowTitle</default>
</entry>
<entry name="windowTitleSourceMaximized" type="Enum">
<choices>
<choice name="AppName" />
<choice name="Decoration" />
<choice name="GenericAppName" />
<choice name="AlwaysUndefined" />
</choices>
<default>2</default>
</entry>

<entry name="windowTitleMinimumWidth" type="Int">
<default>0</default>
Expand Down
227 changes: 118 additions & 109 deletions package/contents/ui/config/ConfigAppearance.qml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ KCM.SimpleKCM {
property alias cfg_widgetElements: widgetElements.elements
property alias cfg_overrideElementsMaximized: overrideElementsMaximized.checked
property alias cfg_widgetElementsMaximized: widgetElementsMaximized.elements
property alias cfg_windowTitleSourceMaximized: windowTitleSourceMaximized.currentIndex

Kirigami.FormLayout {
anchors.left: parent.left
Expand All @@ -62,98 +63,6 @@ KCM.SimpleKCM {
visible: kWinConfig.lastError !== ""
}

Kirigami.Separator {
Kirigami.FormData.isSection: true
Kirigami.FormData.label: i18n("Window Control Buttons")
}

ComboBox {
id: widgetButtonsIconsTheme

Kirigami.FormData.label: i18n("Button icons source:")
Layout.minimumWidth: Kirigami.Units.gridUnit * 15
model: [i18n("Plasma: Global icon theme"), i18n("Breeze: Implicit Breeze icons"), i18n("Aurorae: Window decorations theme")]
}

RowLayout {
Kirigami.FormData.label: i18n("Aurorae theme:")

ComboBox {
id: widgetButtonsAuroraeTheme

function updateCurrentIndex() {
currentIndex = indexOfValue(cfg_widgetButtonsAuroraeTheme);
}

Layout.minimumWidth: Kirigami.Units.gridUnit * 15
enabled: widgetButtonsIconsTheme.currentIndex == 2 && model.count > 0
Component.onCompleted: updateCurrentIndex()
onActivated: cfg_widgetButtonsAuroraeTheme = currentValue
displayText: !!currentText ? currentText : (model.count > 0) ? i18n("<Select Aurorae theme>") : i18n("<Aurorae themes not found>")
textRole: "name"
valueRole: "folder"
model: kWinConfig.auroraeThemes
}

KCM.ContextualHelpButton {
visible: widgetButtonsAuroraeTheme.model.count == 0
toolTipText: i18n("Some window decorations themes, e.g. Breeze or Plastik, could be installed in your system as binary libraries and thus be visible and usable in System settings, but they are not detectable and cannot be used by this widget. There are no plans to support such binary themes due to technical complications.
-
Regular Aurorae themes for window decorations are supported by this widget and you can install them in System settings through \"Window decorations\" page or use \"Breeze\" or \"Plasma\" options in \"Button icons source\" field above instead")
}

KCM.ContextualHelpButton {
visible: widgetButtonsAuroraeTheme.model.count > 0
toolTipText: i18n("Some window decorations themes, e.g. Breeze or Plastik, could be installed in your system as binary libraries and thus be visible and usable in System settings, but they are not detectable and cannot be used by this widget. There are no plans to support such binary themes due to technical complications.
-
You can install more of regular Aurorae themes for window decorations in System settings through \"Window decorations\" page or use \"Breeze\" or \"Plasma\" options in \"Button icons source\" field above instead")
}
}
Label {
text: i18n("<p>Missing your theme? <a href=\"https://github.com/antroids/application-title-bar/issues/25\">Report here.</a></p>")
onLinkActivated: function (link) {
Qt.openUrlExternally(link);
}
}

SpinBox {
id: widgetButtonsMargins

Kirigami.FormData.label: i18n("Buttons margins:")
from: 0
to: 32
}

RowLayout {
Kirigami.FormData.label: i18n("Buttons width/height ratio:")

SpinBox {
id: widgetButtonsAspectRatio

from: 0
to: 200
}

KCM.ContextualHelpButton {
toolTipText: i18n("The ratio of button width in percent to 100% of its height. If you need wider buttons, the value should be >100, otherwise less.")
}
}

RowLayout {
Kirigami.FormData.label: i18n("Animation speed in ms:")

SpinBox {
id: widgetButtonsAnimation

from: 0
to: 10000
}

KCM.ContextualHelpButton {
toolTipText: i18n("Animation speed of buttons transitions in milliseconds.")
}
}

Kirigami.Separator {
Kirigami.FormData.isSection: true
Kirigami.FormData.label: i18n("Widget Layout")
Expand Down Expand Up @@ -278,32 +187,93 @@ You can install more of regular Aurorae themes for window decorations in System

Kirigami.Separator {
Kirigami.FormData.isSection: true
Kirigami.FormData.label: i18n("Override widget elements for maximized windows")
Kirigami.FormData.label: i18n("Window Control Buttons")
}

CheckBox {
id: overrideElementsMaximized
ComboBox {
id: widgetButtonsIconsTheme

text: i18n("override")
Kirigami.FormData.label: i18n("Button icons source:")
Layout.minimumWidth: Kirigami.Units.gridUnit * 15
model: [i18n("Plasma: Global icon theme"), i18n("Breeze: Implicit Breeze icons"), i18n("Aurorae: Window decorations theme")]
}

WidgetElements {
id: widgetElementsMaximized
RowLayout {
Kirigami.FormData.label: i18n("Aurorae theme:")

Kirigami.FormData.label: i18n("Elements:")
enabled: overrideElementsMaximized.checked
ComboBox {
id: widgetButtonsAuroraeTheme

function updateCurrentIndex() {
currentIndex = indexOfValue(cfg_widgetButtonsAuroraeTheme);
}

Layout.minimumWidth: Kirigami.Units.gridUnit * 15
enabled: widgetButtonsIconsTheme.currentIndex == 2 && model.count > 0
Component.onCompleted: updateCurrentIndex()
onActivated: cfg_widgetButtonsAuroraeTheme = currentValue
displayText: !!currentText ? currentText : (model.count > 0) ? i18n("<Select Aurorae theme>") : i18n("<Aurorae themes not found>")
textRole: "name"
valueRole: "folder"
model: kWinConfig.auroraeThemes
}

KCM.ContextualHelpButton {
visible: widgetButtonsAuroraeTheme.model.count == 0
toolTipText: i18n("Some window decorations themes, e.g. Breeze or Plastik, could be installed in your system as binary libraries and thus be visible and usable in System settings, but they are not detectable and cannot be used by this widget. There are no plans to support such binary themes due to technical complications.
-
Regular Aurorae themes for window decorations are supported by this widget and you can install them in System settings through \"Window decorations\" page or use \"Breeze\" or \"Plasma\" options in \"Button icons source\" field above instead")
}

KCM.ContextualHelpButton {
visible: widgetButtonsAuroraeTheme.model.count > 0
toolTipText: i18n("Some window decorations themes, e.g. Breeze or Plastik, could be installed in your system as binary libraries and thus be visible and usable in System settings, but they are not detectable and cannot be used by this widget. There are no plans to support such binary themes due to technical complications.
-
You can install more of regular Aurorae themes for window decorations in System settings through \"Window decorations\" page or use \"Breeze\" or \"Plasma\" options in \"Button icons source\" field above instead")
}
}
Label {
text: i18n("<p>Missing your theme? <a href=\"https://github.com/antroids/application-title-bar/issues/25\">Report here.</a></p>")
onLinkActivated: function (link) {
Qt.openUrlExternally(link);
}
}

AddWidgetElement {
enabled: overrideElementsMaximized.checked
SpinBox {
id: widgetButtonsMargins

onCurrentValueChanged: function () {
if (currentValue) {
widgetElementsMaximized.model.append({
"value": currentValue
});
currentIndex = 0;
}
Kirigami.FormData.label: i18n("Buttons margins:")
from: 0
to: 32
}

RowLayout {
Kirigami.FormData.label: i18n("Buttons width/height ratio:")

SpinBox {
id: widgetButtonsAspectRatio

from: 0
to: 200
}

KCM.ContextualHelpButton {
toolTipText: i18n("The ratio of button width in percent to 100% of its height. If you need wider buttons, the value should be >100, otherwise less.")
}
}

RowLayout {
Kirigami.FormData.label: i18n("Animation speed in ms:")

SpinBox {
id: widgetButtonsAnimation

from: 0
to: 10000
}

KCM.ContextualHelpButton {
toolTipText: i18n("Animation speed of buttons transitions in milliseconds.")
}
}

Expand Down Expand Up @@ -415,5 +385,44 @@ You can install more of regular Aurorae themes for window decorations in System
to: 64
}
}

Kirigami.Separator {
Kirigami.FormData.isSection: true
Kirigami.FormData.label: i18n("Override for maximized windows")
}

CheckBox {
id: overrideElementsMaximized

text: i18n("override")
}

WidgetElements {
id: widgetElementsMaximized

Kirigami.FormData.label: i18n("Elements:")
enabled: overrideElementsMaximized.checked
}

AddWidgetElement {
enabled: overrideElementsMaximized.checked

onCurrentValueChanged: function () {
if (currentValue) {
widgetElementsMaximized.model.append({
"value": currentValue
});
currentIndex = 0;
}
}
}

ComboBox {
id: windowTitleSourceMaximized

enabled: overrideElementsMaximized.checked
Kirigami.FormData.label: i18n("Window title source:")
model: [i18n("Application name"), i18n("Decoration"), i18n("Generic Application name"), i18n("Always undefined")]
}
}
}
5 changes: 3 additions & 2 deletions package/contents/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,9 @@ PlasmoidItem {
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

function titleText(activeWindow, windowTitleSource) {
function titleText(windowTitleSource) {
switch (windowTitleSource) {
case 0:
return tasksModel.activeWindow.appName;
Expand All @@ -256,7 +257,7 @@ PlasmoidItem {
Layout.maximumWidth: !hideEmpty ? plasmoid.configuration.windowTitleMaximumWidth : 0
Layout.alignment: root.widgetAlignment
Layout.fillWidth: plasmoid.configuration.widgetFillWidth
text: titleText(tasksModel.activeWindow, plasmoid.configuration.windowTitleSource) || plasmoid.configuration.windowTitleUndefined
text: titleText(windowTitleSource) || plasmoid.configuration.windowTitleUndefined
font.pointSize: plasmoid.configuration.windowTitleFontSize
font.bold: plasmoid.configuration.windowTitleFontBold
fontSizeMode: plasmoid.configuration.windowTitleFontSizeMode
Expand Down
2 changes: 1 addition & 1 deletion package/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"Id": "com.github.antroids.application-title-bar",
"Name": "Application Title Bar",
"License": "GPL-3.0+",
"Version": "0.5.0",
"Version": "0.5.1",
"Website": "https://github.com/antroids/application-title-bar",
"FormFactors": [
"desktop"
Expand Down

0 comments on commit 632ed37

Please sign in to comment.