mirror of
https://github.com/Bismuth-Forge/bismuth.git
synced 2024-09-17 11:37:10 +03:00
refactor: use qmlformat for qmlfiles
This commit is contained in:
parent
aad9860962
commit
8c3adf0130
@ -75,6 +75,7 @@
|
||||
},
|
||||
"prettier": {},
|
||||
"lint-staged": {
|
||||
"**/*": "prettier --write --ignore-unknown"
|
||||
"**/*": "prettier --write --ignore-unknown",
|
||||
"**/*.qml": "qmlformat"
|
||||
}
|
||||
}
|
||||
|
@ -1,62 +1,58 @@
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
// SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import "./components" as BIC
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12 as QQC2
|
||||
import QtQuick.Layouts 1.15
|
||||
|
||||
import org.kde.kcm 1.5 as KCM
|
||||
import org.kde.kirigami 2.7 as Kirigami
|
||||
|
||||
import "./components" as BIC
|
||||
|
||||
Kirigami.FormLayout {
|
||||
id: appearanceTab
|
||||
id: appearanceTab
|
||||
|
||||
Item {
|
||||
Kirigami.FormData.isSection: true
|
||||
Kirigami.FormData.label: i18n("Outer Gaps")
|
||||
}
|
||||
Item {
|
||||
Kirigami.FormData.isSection: true
|
||||
Kirigami.FormData.label: i18n("Outer Gaps")
|
||||
}
|
||||
|
||||
BIC.PixelsConfigSpinBox {
|
||||
Kirigami.FormData.label: i18n("Left:")
|
||||
settingName: "screenGapLeft"
|
||||
}
|
||||
BIC.PixelsConfigSpinBox {
|
||||
Kirigami.FormData.label: i18n("Left:")
|
||||
settingName: "screenGapLeft"
|
||||
}
|
||||
|
||||
BIC.PixelsConfigSpinBox {
|
||||
Kirigami.FormData.label: i18n("Top:")
|
||||
settingName: "screenGapTop"
|
||||
}
|
||||
BIC.PixelsConfigSpinBox {
|
||||
Kirigami.FormData.label: i18n("Top:")
|
||||
settingName: "screenGapTop"
|
||||
}
|
||||
|
||||
BIC.PixelsConfigSpinBox {
|
||||
Kirigami.FormData.label: i18n("Right:")
|
||||
settingName: "screenGapRight"
|
||||
}
|
||||
BIC.PixelsConfigSpinBox {
|
||||
Kirigami.FormData.label: i18n("Right:")
|
||||
settingName: "screenGapRight"
|
||||
}
|
||||
|
||||
BIC.PixelsConfigSpinBox {
|
||||
Kirigami.FormData.label: i18n("Bottom:")
|
||||
settingName: "screenGapBottom"
|
||||
}
|
||||
BIC.PixelsConfigSpinBox {
|
||||
Kirigami.FormData.label: i18n("Bottom:")
|
||||
settingName: "screenGapBottom"
|
||||
}
|
||||
|
||||
Item {
|
||||
Kirigami.FormData.isSection: true
|
||||
Kirigami.FormData.label: "Inner Gaps"
|
||||
}
|
||||
Item {
|
||||
Kirigami.FormData.isSection: true
|
||||
Kirigami.FormData.label: "Inner Gaps"
|
||||
}
|
||||
|
||||
BIC.PixelsConfigSpinBox {
|
||||
Kirigami.FormData.label: i18n("All:")
|
||||
settingName: "tileLayoutGap"
|
||||
}
|
||||
BIC.PixelsConfigSpinBox {
|
||||
Kirigami.FormData.label: i18n("All:")
|
||||
settingName: "tileLayoutGap"
|
||||
}
|
||||
|
||||
Kirigami.Separator {
|
||||
Kirigami.FormData.isSection: true
|
||||
}
|
||||
Kirigami.Separator {
|
||||
Kirigami.FormData.isSection: true
|
||||
}
|
||||
|
||||
BIC.ConfigCheckBox {
|
||||
text: i18n("No borders around tiled windows")
|
||||
settingName: "noTileBorder"
|
||||
}
|
||||
|
||||
BIC.ConfigCheckBox {
|
||||
text: i18n("No borders around tiled windows")
|
||||
settingName: "noTileBorder"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,137 +1,145 @@
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12 as QQC2
|
||||
import QtQuick.Layouts 1.15
|
||||
|
||||
import org.kde.kcm 1.5 as KCM
|
||||
import org.kde.kirigami 2.7 as Kirigami
|
||||
// SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import "./components" as BIC
|
||||
import "./views" as BIView
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12 as QQC2
|
||||
import QtQuick.Layouts 1.15
|
||||
import org.kde.kcm 1.5 as KCM
|
||||
import org.kde.kirigami 2.7 as Kirigami
|
||||
|
||||
Kirigami.FormLayout {
|
||||
id: behaviorTab
|
||||
id: behaviorTab
|
||||
|
||||
Item {
|
||||
Kirigami.FormData.isSection: true
|
||||
Kirigami.FormData.label: i18n("Layouts")
|
||||
}
|
||||
|
||||
BIC.ConfigCheckBox {
|
||||
Kirigami.FormData.label: i18n("Separate layouts for each:")
|
||||
text: i18n("Activity")
|
||||
settingName: "layoutPerActivity"
|
||||
}
|
||||
|
||||
BIC.ConfigCheckBox {
|
||||
text: i18n("Virtual Desktop")
|
||||
settingName: "layoutPerDesktop"
|
||||
}
|
||||
|
||||
QQC2.Button {
|
||||
id: configureLayoutsButton
|
||||
icon.name: "document-edit"
|
||||
text: i18n("Customize Layouts...")
|
||||
onClicked: () => kcm.push("./views/Layouts.qml")
|
||||
}
|
||||
|
||||
Item {
|
||||
Kirigami.FormData.isSection: true
|
||||
Kirigami.FormData.label: i18n("Windows")
|
||||
}
|
||||
|
||||
BIC.ConfigCheckBox {
|
||||
text: i18n("Maximize sole window")
|
||||
settingName: "maximizeSoleTile"
|
||||
}
|
||||
|
||||
BIC.ConfigCheckBox {
|
||||
text: i18n("Floating windows always on top")
|
||||
settingName: "keepFloatAbove"
|
||||
}
|
||||
|
||||
QQC2.ButtonGroup {
|
||||
id: windowSpawnPositionGroup
|
||||
}
|
||||
|
||||
QQC2.RadioButton {
|
||||
Kirigami.FormData.label: i18n("Spawn windows at:")
|
||||
text: i18n("Master area")
|
||||
QQC2.ButtonGroup.group: windowSpawnPositionGroup
|
||||
|
||||
checked: kcm.config.newWindowAsMaster
|
||||
onClicked: kcm.config.newWindowAsMaster = checked
|
||||
|
||||
KCM.SettingStateBinding {
|
||||
configObject: kcm.config
|
||||
settingName: "newWindowAsMaster"
|
||||
Item {
|
||||
Kirigami.FormData.isSection: true
|
||||
Kirigami.FormData.label: i18n("Layouts")
|
||||
}
|
||||
}
|
||||
|
||||
QQC2.RadioButton {
|
||||
text: i18n("The layout's end")
|
||||
QQC2.ButtonGroup.group: windowSpawnPositionGroup
|
||||
|
||||
checked: !kcm.config.newWindowAsMaster
|
||||
onClicked: kcm.config.newWindowAsMaster = !checked
|
||||
|
||||
KCM.SettingStateBinding {
|
||||
configObject: kcm.config
|
||||
settingName: "newWindowAsMaster"
|
||||
BIC.ConfigCheckBox {
|
||||
Kirigami.FormData.label: i18n("Separate layouts for each:")
|
||||
text: i18n("Activity")
|
||||
settingName: "layoutPerActivity"
|
||||
}
|
||||
}
|
||||
|
||||
QQC2.Button {
|
||||
id: windowRules
|
||||
icon.name: "document-edit"
|
||||
text: i18n("Window Rules...")
|
||||
onClicked: () => kcm.push("./views/WindowRules.qml")
|
||||
}
|
||||
|
||||
Item {
|
||||
Kirigami.FormData.isSection: true
|
||||
Kirigami.FormData.label: i18n("Restrictions")
|
||||
}
|
||||
|
||||
BIC.ConfigCheckBox {
|
||||
id: restrictWidth
|
||||
text: i18n("Restrict window width")
|
||||
settingName: "limitTileWidth"
|
||||
}
|
||||
|
||||
BIC.RatioConfigSpinBox {
|
||||
Kirigami.FormData.label: i18n("Window Width/Screen Height ratio:")
|
||||
settingName: "limitTileWidthRatio"
|
||||
|
||||
// For some reason we cannot pass a custom property to
|
||||
// extraEnabledConditions, so we have to define it here.
|
||||
// It is also a reason why RatioConfigSpinBox uses
|
||||
// QQC2.SpinBox instead of ConfigSPinBox component
|
||||
KCM.SettingStateBinding {
|
||||
configObject: kcm.config
|
||||
settingName: "limitTileWidthRatio"
|
||||
extraEnabledConditions: restrictWidth.checked
|
||||
BIC.ConfigCheckBox {
|
||||
text: i18n("Virtual Desktop")
|
||||
settingName: "layoutPerDesktop"
|
||||
}
|
||||
}
|
||||
|
||||
BIC.ConfigCheckBox {
|
||||
text: i18n("Prevent window minimization")
|
||||
settingName: "preventMinimize"
|
||||
}
|
||||
QQC2.Button {
|
||||
id: configureLayoutsButton
|
||||
|
||||
BIC.ConfigCheckBox {
|
||||
text: i18n("Prevent window from protruding from its screen")
|
||||
settingName: "preventProtrusion"
|
||||
}
|
||||
icon.name: "document-edit"
|
||||
text: i18n("Customize Layouts...")
|
||||
onClicked: () => {
|
||||
return kcm.push("./views/Layouts.qml");
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
Kirigami.FormData.isSection: true
|
||||
Kirigami.FormData.label: i18n("Windows")
|
||||
}
|
||||
|
||||
BIC.ConfigCheckBox {
|
||||
text: i18n("Maximize sole window")
|
||||
settingName: "maximizeSoleTile"
|
||||
}
|
||||
|
||||
BIC.ConfigCheckBox {
|
||||
text: i18n("Floating windows always on top")
|
||||
settingName: "keepFloatAbove"
|
||||
}
|
||||
|
||||
QQC2.ButtonGroup {
|
||||
id: windowSpawnPositionGroup
|
||||
}
|
||||
|
||||
QQC2.RadioButton {
|
||||
Kirigami.FormData.label: i18n("Spawn windows at:")
|
||||
text: i18n("Master area")
|
||||
QQC2.ButtonGroup.group: windowSpawnPositionGroup
|
||||
checked: kcm.config.newWindowAsMaster
|
||||
onClicked: kcm.config.newWindowAsMaster = checked
|
||||
|
||||
KCM.SettingStateBinding {
|
||||
configObject: kcm.config
|
||||
settingName: "newWindowAsMaster"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QQC2.RadioButton {
|
||||
text: i18n("The layout's end")
|
||||
QQC2.ButtonGroup.group: windowSpawnPositionGroup
|
||||
checked: !kcm.config.newWindowAsMaster
|
||||
onClicked: kcm.config.newWindowAsMaster = !checked
|
||||
|
||||
KCM.SettingStateBinding {
|
||||
configObject: kcm.config
|
||||
settingName: "newWindowAsMaster"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QQC2.Button {
|
||||
id: windowRules
|
||||
|
||||
icon.name: "document-edit"
|
||||
text: i18n("Window Rules...")
|
||||
onClicked: () => {
|
||||
return kcm.push("./views/WindowRules.qml");
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
Kirigami.FormData.isSection: true
|
||||
Kirigami.FormData.label: i18n("Restrictions")
|
||||
}
|
||||
|
||||
BIC.ConfigCheckBox {
|
||||
id: restrictWidth
|
||||
|
||||
text: i18n("Restrict window width")
|
||||
settingName: "limitTileWidth"
|
||||
}
|
||||
|
||||
BIC.RatioConfigSpinBox {
|
||||
Kirigami.FormData.label: i18n("Window Width/Screen Height ratio:")
|
||||
settingName: "limitTileWidthRatio"
|
||||
|
||||
// For some reason we cannot pass a custom property to
|
||||
// extraEnabledConditions, so we have to define it here.
|
||||
// It is also a reason why RatioConfigSpinBox uses
|
||||
// QQC2.SpinBox instead of ConfigSPinBox component
|
||||
KCM.SettingStateBinding {
|
||||
configObject: kcm.config
|
||||
settingName: "limitTileWidthRatio"
|
||||
extraEnabledConditions: restrictWidth.checked
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BIC.ConfigCheckBox {
|
||||
text: i18n("Prevent window minimization")
|
||||
settingName: "preventMinimize"
|
||||
}
|
||||
|
||||
BIC.ConfigCheckBox {
|
||||
text: i18n("Prevent window from protruding from its screen")
|
||||
settingName: "preventProtrusion"
|
||||
}
|
||||
|
||||
QQC2.Button {
|
||||
id: workspaceRules
|
||||
|
||||
icon.name: "document-edit"
|
||||
text: i18n("Workspace Rules...")
|
||||
onClicked: () => {
|
||||
return kcm.push("./views/WorkspaceRules.qml");
|
||||
}
|
||||
}
|
||||
|
||||
QQC2.Button {
|
||||
id: workspaceRules
|
||||
icon.name: "document-edit"
|
||||
text: i18n("Workspace Rules...")
|
||||
onClicked: () => kcm.push("./views/WorkspaceRules.qml")
|
||||
}
|
||||
}
|
||||
|
@ -1,25 +1,24 @@
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
// SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12 as QQC2
|
||||
|
||||
import org.kde.kcm 1.5 as KCM
|
||||
|
||||
QQC2.CheckBox {
|
||||
id: root
|
||||
/**
|
||||
* Name for the config option to represent
|
||||
*/
|
||||
property string settingName
|
||||
id: root
|
||||
|
||||
checked: kcm.config[settingName]
|
||||
onClicked: kcm.config[settingName] = checked
|
||||
/**
|
||||
* Name for the config option to represent
|
||||
*/
|
||||
property string settingName
|
||||
|
||||
checked: kcm.config[settingName]
|
||||
onClicked: kcm.config[settingName] = checked
|
||||
|
||||
KCM.SettingStateBinding {
|
||||
configObject: kcm.config
|
||||
settingName: root.settingName
|
||||
}
|
||||
|
||||
KCM.SettingStateBinding {
|
||||
configObject: kcm.config
|
||||
settingName: root.settingName
|
||||
}
|
||||
}
|
||||
|
@ -1,31 +1,28 @@
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
// SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12 as QQC2
|
||||
|
||||
import org.kde.kcm 1.5 as KCM
|
||||
import org.kde.kirigami 2.7 as Kirigami
|
||||
|
||||
QQC2.SpinBox {
|
||||
id: root
|
||||
id: root
|
||||
|
||||
/**
|
||||
* Name for the config option to represent
|
||||
*/
|
||||
property string settingName: ""
|
||||
/**
|
||||
* Name for the config option to represent
|
||||
*/
|
||||
property string settingName: ""
|
||||
|
||||
// Implicit dimensions are set to break binding loop
|
||||
implicitWidth: Kirigami.Units.gridUnit * 5
|
||||
implicitHeight: Kirigami.Units.gridUnit * 1.75
|
||||
// Implicit dimensions are set to break binding loop
|
||||
implicitWidth: Kirigami.Units.gridUnit * 5
|
||||
implicitHeight: Kirigami.Units.gridUnit * 1.75
|
||||
value: kcm.config[settingName]
|
||||
onValueModified: kcm.config[settingName] = value
|
||||
|
||||
value: kcm.config[settingName]
|
||||
onValueModified: kcm.config[settingName] = value
|
||||
KCM.SettingStateBinding {
|
||||
configObject: kcm.config
|
||||
settingName: root.settingName
|
||||
}
|
||||
|
||||
KCM.SettingStateBinding {
|
||||
configObject: kcm.config
|
||||
settingName: root.settingName
|
||||
}
|
||||
}
|
||||
|
@ -1,25 +1,24 @@
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
// SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12 as QQC2
|
||||
|
||||
import org.kde.kcm 1.5 as KCM
|
||||
|
||||
QQC2.TextField {
|
||||
id: root
|
||||
/**
|
||||
* Name for the config option to represent
|
||||
*/
|
||||
property string settingName
|
||||
id: root
|
||||
|
||||
text: kcm.config[settingName]
|
||||
onEditingFinished: kcm.config[settingName] = text
|
||||
/**
|
||||
* Name for the config option to represent
|
||||
*/
|
||||
property string settingName
|
||||
|
||||
text: kcm.config[settingName]
|
||||
onEditingFinished: kcm.config[settingName] = text
|
||||
|
||||
KCM.SettingStateBinding {
|
||||
configObject: kcm.config
|
||||
settingName: root.settingName
|
||||
}
|
||||
|
||||
KCM.SettingStateBinding {
|
||||
configObject: kcm.config
|
||||
settingName: root.settingName
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,20 @@
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
// SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12 as QQC2
|
||||
import QtQuick.Layouts 1.15
|
||||
|
||||
import org.kde.kirigami 2.7 as Kirigami
|
||||
|
||||
ConfigSpinBox {
|
||||
textFromValue: (value, _locale) => `${Number(value).toLocaleString(locale, 'f', 0)} px`
|
||||
valueFromText: (text, locale) => Number.fromLocaleString(locale, text.replace(" px", ""))
|
||||
// Pixels are always positive
|
||||
from: 0
|
||||
to: 512
|
||||
editable: true
|
||||
textFromValue: (value, _locale) => {
|
||||
return `${Number(value).toLocaleString(locale, 'f', 0)} px`;
|
||||
}
|
||||
valueFromText: (text, locale) => {
|
||||
return Number.fromLocaleString(locale, text.replace(" px", ""));
|
||||
}
|
||||
// Pixels are always positive
|
||||
from: 0
|
||||
to: 512
|
||||
editable: true
|
||||
}
|
||||
|
@ -1,47 +1,44 @@
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
// SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12 as QQC2
|
||||
|
||||
import org.kde.kirigami 2.7 as Kirigami
|
||||
import org.kde.kcm 1.5 as KCM
|
||||
import org.kde.kirigami 2.7 as Kirigami
|
||||
|
||||
QQC2.SpinBox {
|
||||
id: root
|
||||
id: root
|
||||
|
||||
/**
|
||||
* Name for the config option to represent
|
||||
*/
|
||||
property string settingName: ""
|
||||
property int decimals: 2
|
||||
property real realValue: value / 100
|
||||
/**
|
||||
* Name for the config option to represent
|
||||
*/
|
||||
property string settingName: ""
|
||||
property int decimals: 2
|
||||
property real realValue: value / 100
|
||||
|
||||
// Implicit dimensions are set to break binding loop
|
||||
implicitWidth: Kirigami.Units.gridUnit * 5
|
||||
implicitHeight: Kirigami.Units.gridUnit * 1.75
|
||||
// Implicit dimensions are set to break binding loop
|
||||
implicitWidth: Kirigami.Units.gridUnit * 5
|
||||
implicitHeight: Kirigami.Units.gridUnit * 1.75
|
||||
from: 5
|
||||
to: 300
|
||||
stepSize: 5
|
||||
editable: true
|
||||
// IDK why, but this is needed to make the SpinBox work
|
||||
Component.onCompleted: () => {
|
||||
root.value = kcm.config[settingName] * 100;
|
||||
}
|
||||
value: kcm.config[settingName] * 100
|
||||
onValueModified: kcm.config[settingName] = realValue
|
||||
textFromValue: (value, locale) => {
|
||||
return Number(value / 100).toLocaleString(locale, 'f', root.decimals);
|
||||
}
|
||||
valueFromText: (text, locale) => {
|
||||
return Number.fromLocaleString(locale, text) * 100;
|
||||
}
|
||||
|
||||
from: 5
|
||||
to: 300
|
||||
stepSize: 5
|
||||
editable: true
|
||||
validator: DoubleValidator {
|
||||
bottom: Math.min(root.from, root.to)
|
||||
top: Math.max(root.from, root.to)
|
||||
}
|
||||
|
||||
validator: DoubleValidator {
|
||||
bottom: Math.min(root.from, root.to)
|
||||
top: Math.max(root.from, root.to)
|
||||
}
|
||||
|
||||
// IDK why, but this is needed to make the SpinBox work
|
||||
Component.onCompleted: () => {
|
||||
root.value = kcm.config[settingName] * 100
|
||||
}
|
||||
|
||||
value: kcm.config[settingName] * 100
|
||||
onValueModified: kcm.config[settingName] = realValue
|
||||
|
||||
textFromValue: (value, locale) => Number(value / 100).toLocaleString(locale, 'f', root.decimals)
|
||||
valueFromText: (text, locale) => Number.fromLocaleString(locale, text) * 100
|
||||
}
|
||||
|
||||
|
@ -1,63 +1,68 @@
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
// SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12 as QQC2
|
||||
import QtQuick.Layouts 1.15
|
||||
|
||||
import org.kde.kirigami 2.7 as Kirigami
|
||||
import org.kde.kcm 1.5 as KCM
|
||||
import org.kde.kirigami 2.7 as Kirigami
|
||||
|
||||
KCM.SimpleKCM {
|
||||
id: root
|
||||
KCM.ConfigModule.quickHelp: i18n("This module lets you manage various window tiling options.")
|
||||
id: root
|
||||
|
||||
implicitWidth: Kirigami.Units.gridUnit * 38
|
||||
implicitHeight: Kirigami.Units.gridUnit * 35
|
||||
KCM.ConfigModule.quickHelp: i18n("This module lets you manage various window tiling options.")
|
||||
implicitWidth: Kirigami.Units.gridUnit * 38
|
||||
implicitHeight: Kirigami.Units.gridUnit * 35
|
||||
|
||||
// TODO: replace this TabBar-plus-Frame-in-a-ColumnLayout with whatever shakes
|
||||
// out of https://bugs.kde.org/show_bug.cgi?id=394296
|
||||
ColumnLayout {
|
||||
id: tabLayout
|
||||
spacing: 0
|
||||
// TODO: replace this TabBar-plus-Frame-in-a-ColumnLayout with whatever shakes
|
||||
// out of https://bugs.kde.org/show_bug.cgi?id=394296
|
||||
ColumnLayout {
|
||||
id: tabLayout
|
||||
|
||||
QQC2.TabBar {
|
||||
id: tabBar
|
||||
// Tab styles generally assume that they're touching the inner layout,
|
||||
// not the frame, so we need to move the tab bar down a pixel and make
|
||||
// sure it's drawn on top of the frame
|
||||
z: 1
|
||||
Layout.bottomMargin: -1
|
||||
spacing: 0
|
||||
|
||||
QQC2.TabButton {
|
||||
text: i18n("Appearance")
|
||||
}
|
||||
QQC2.TabBar {
|
||||
id: tabBar
|
||||
|
||||
// Tab styles generally assume that they're touching the inner layout,
|
||||
// not the frame, so we need to move the tab bar down a pixel and make
|
||||
// sure it's drawn on top of the frame
|
||||
z: 1
|
||||
Layout.bottomMargin: -1
|
||||
|
||||
QQC2.TabButton {
|
||||
text: i18n("Appearance")
|
||||
}
|
||||
|
||||
QQC2.TabButton {
|
||||
text: i18n("Behavior")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QQC2.Frame {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
StackLayout {
|
||||
currentIndex: tabBar.currentIndex
|
||||
anchors.fill: parent
|
||||
// This breaks anything inside, that is not FormLayout
|
||||
// but necessary for adequate padding
|
||||
anchors.topMargin: Kirigami.Units.gridUnit * -0.5
|
||||
|
||||
Appearance {
|
||||
}
|
||||
|
||||
// For some reason QML is very British and
|
||||
// refuses to load the Behavior.qml (without "u")
|
||||
Behaviour {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QQC2.TabButton {
|
||||
text: i18n("Behavior")
|
||||
}
|
||||
}
|
||||
|
||||
QQC2.Frame {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
StackLayout {
|
||||
currentIndex: tabBar.currentIndex
|
||||
anchors.fill: parent
|
||||
// This breaks anything inside, that is not FormLayout
|
||||
// but necessary for adequate padding
|
||||
anchors.topMargin: Kirigami.Units.gridUnit * -0.5
|
||||
|
||||
Appearance {}
|
||||
|
||||
// For some reason QML is very British and
|
||||
// refuses to load the Behavior.qml (without "u")
|
||||
Behaviour {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,96 +1,111 @@
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
// SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import "../components" as BIC
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12 as QQC2
|
||||
import QtQuick.Layouts 1.15
|
||||
|
||||
import org.kde.kcm 1.5 as KCM
|
||||
import org.kde.kirigami 2.7 as Kirigami
|
||||
|
||||
import "../components" as BIC
|
||||
|
||||
Kirigami.Page {
|
||||
id: root
|
||||
title: "Window Layouts"
|
||||
id: root
|
||||
|
||||
ListModel {
|
||||
id: layoutsModel
|
||||
ListElement {
|
||||
name: "Tile"
|
||||
settingName: "enableTileLayout"
|
||||
}
|
||||
ListElement {
|
||||
name: "Monocle"
|
||||
settingName: "enableMonocleLayout"
|
||||
editable: true
|
||||
}
|
||||
ListElement {
|
||||
name: "Three Column"
|
||||
settingName: "enableThreeColumnLayout"
|
||||
}
|
||||
ListElement {
|
||||
name: "Spiral"
|
||||
settingName: "enableSpiralLayout"
|
||||
}
|
||||
ListElement {
|
||||
name: "Spread"
|
||||
settingName: "enableSpreadLayout"
|
||||
}
|
||||
ListElement {
|
||||
name: "Stair"
|
||||
settingName: "enableStairLayout"
|
||||
}
|
||||
ListElement {
|
||||
name: "Quarter"
|
||||
settingName: "enableQuarterLayout"
|
||||
}
|
||||
ListElement {
|
||||
name: "Floating"
|
||||
settingName: "enableFloatingLayout"
|
||||
}
|
||||
}
|
||||
title: "Window Layouts"
|
||||
|
||||
KCM.ScrollView {
|
||||
anchors.fill: parent
|
||||
ListModel {
|
||||
id: layoutsModel
|
||||
|
||||
view: ListView {
|
||||
model: layoutsModel
|
||||
|
||||
delegate: Kirigami.SwipeListItem {
|
||||
contentItem: RowLayout {
|
||||
RowLayout {
|
||||
BIC.ConfigCheckBox {
|
||||
id: layoutCheckBox
|
||||
settingName: model.settingName
|
||||
}
|
||||
|
||||
QQC2.Label {
|
||||
text: `${model.name} Layout`
|
||||
}
|
||||
}
|
||||
ListElement {
|
||||
name: "Tile"
|
||||
settingName: "enableTileLayout"
|
||||
}
|
||||
actions: [
|
||||
Kirigami.Action {
|
||||
id: editLayout
|
||||
enabled: model.editable && layoutCheckBox.checked
|
||||
visible: model.editable
|
||||
iconName: "edit-rename"
|
||||
tooltip: i18nc("@info:tooltip", "Edit Layout")
|
||||
onTriggered: () => {
|
||||
monocleSheet.open()
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MonocleOverlay {
|
||||
id: monocleSheet
|
||||
parent: root // Without this, overlay does not work
|
||||
}
|
||||
ListElement {
|
||||
name: "Monocle"
|
||||
settingName: "enableMonocleLayout"
|
||||
editable: true
|
||||
}
|
||||
|
||||
ListElement {
|
||||
name: "Three Column"
|
||||
settingName: "enableThreeColumnLayout"
|
||||
}
|
||||
|
||||
ListElement {
|
||||
name: "Spiral"
|
||||
settingName: "enableSpiralLayout"
|
||||
}
|
||||
|
||||
ListElement {
|
||||
name: "Spread"
|
||||
settingName: "enableSpreadLayout"
|
||||
}
|
||||
|
||||
ListElement {
|
||||
name: "Stair"
|
||||
settingName: "enableStairLayout"
|
||||
}
|
||||
|
||||
ListElement {
|
||||
name: "Quarter"
|
||||
settingName: "enableQuarterLayout"
|
||||
}
|
||||
|
||||
ListElement {
|
||||
name: "Floating"
|
||||
settingName: "enableFloatingLayout"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
KCM.ScrollView {
|
||||
anchors.fill: parent
|
||||
|
||||
view: ListView {
|
||||
model: layoutsModel
|
||||
|
||||
delegate: Kirigami.SwipeListItem {
|
||||
actions: [
|
||||
Kirigami.Action {
|
||||
id: editLayout
|
||||
|
||||
enabled: model.editable && layoutCheckBox.checked
|
||||
visible: model.editable
|
||||
iconName: "edit-rename"
|
||||
tooltip: i18nc("@info:tooltip", "Edit Layout")
|
||||
onTriggered: () => {
|
||||
monocleSheet.open();
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
contentItem: RowLayout {
|
||||
RowLayout {
|
||||
BIC.ConfigCheckBox {
|
||||
id: layoutCheckBox
|
||||
|
||||
settingName: model.settingName
|
||||
}
|
||||
|
||||
QQC2.Label {
|
||||
text: `${model.name} Layout`
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MonocleOverlay {
|
||||
id: monocleSheet
|
||||
|
||||
parent: root // Without this, overlay does not work
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,34 +1,31 @@
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
// SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import "../components" as BIC
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12 as QQC2
|
||||
import QtQuick.Layouts 1.15
|
||||
|
||||
import org.kde.kcm 1.5 as KCM
|
||||
import org.kde.kirigami 2.7 as Kirigami
|
||||
|
||||
import "../components" as BIC
|
||||
|
||||
Kirigami.OverlaySheet {
|
||||
id: monocleOverlay
|
||||
id: monocleOverlay
|
||||
|
||||
header: Kirigami.Heading {
|
||||
text: i18nc("@title:window", "Monocle Layout Settings")
|
||||
}
|
||||
Kirigami.FormLayout {
|
||||
BIC.ConfigCheckBox {
|
||||
text: i18n("Fully maximize windows (no borders, no gaps)")
|
||||
settingName: "monocleMaximize"
|
||||
}
|
||||
|
||||
BIC.ConfigCheckBox {
|
||||
text: i18n("Minimize unfocused windows")
|
||||
settingName: "monocleMinimizeRest"
|
||||
}
|
||||
|
||||
Kirigami.FormLayout {
|
||||
BIC.ConfigCheckBox {
|
||||
text: i18n("Fully maximize windows (no borders, no gaps)")
|
||||
settingName: "monocleMaximize"
|
||||
}
|
||||
|
||||
BIC.ConfigCheckBox {
|
||||
text: i18n("Minimize unfocused windows")
|
||||
settingName: "monocleMinimizeRest"
|
||||
header: Kirigami.Heading {
|
||||
text: i18nc("@title:window", "Monocle Layout Settings")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,69 +1,67 @@
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
// SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import "../components" as BIC
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12 as QQC2
|
||||
import QtQuick.Layouts 1.15
|
||||
|
||||
import org.kde.kcm 1.5 as KCM
|
||||
import org.kde.kirigami 2.7 as Kirigami
|
||||
|
||||
import "../components" as BIC
|
||||
|
||||
Kirigami.Page {
|
||||
id: root
|
||||
title: "Window Rules"
|
||||
id: root
|
||||
|
||||
Kirigami.FormLayout {
|
||||
anchors.fill: parent
|
||||
title: "Window Rules"
|
||||
|
||||
Kirigami.FormLayout {
|
||||
anchors.fill: parent
|
||||
|
||||
Item {
|
||||
Kirigami.FormData.isSection: true
|
||||
Kirigami.FormData.label: i18n("Ignore Windows")
|
||||
}
|
||||
|
||||
BIC.ConfigTextField {
|
||||
Kirigami.FormData.label: "With classes:"
|
||||
placeholderText: "Classes (comma separated)"
|
||||
settingName: "ignoreClass"
|
||||
implicitWidth: Kirigami.Units.gridUnit * 20
|
||||
}
|
||||
|
||||
BIC.ConfigTextField {
|
||||
Kirigami.FormData.label: "With titles:"
|
||||
placeholderText: "Titles (comma separated)"
|
||||
settingName: "ignoreTitle"
|
||||
}
|
||||
|
||||
BIC.ConfigTextField {
|
||||
Kirigami.FormData.label: "With roles:"
|
||||
placeholderText: "Roles (comma separated)"
|
||||
settingName: "ignoreRole"
|
||||
}
|
||||
|
||||
Item {
|
||||
Kirigami.FormData.isSection: true
|
||||
Kirigami.FormData.label: i18n("Float Windows")
|
||||
}
|
||||
|
||||
BIC.ConfigTextField {
|
||||
Kirigami.FormData.label: "With classes:"
|
||||
placeholderText: "Classes (comma separated)"
|
||||
settingName: "floatingClass"
|
||||
}
|
||||
|
||||
BIC.ConfigTextField {
|
||||
Kirigami.FormData.label: "With titles:"
|
||||
placeholderText: "Titles (comma separated)"
|
||||
settingName: "floatingTitle"
|
||||
}
|
||||
|
||||
BIC.ConfigCheckBox {
|
||||
text: "With utility roles"
|
||||
settingName: "floatUtility"
|
||||
}
|
||||
|
||||
Item {
|
||||
Kirigami.FormData.isSection: true
|
||||
Kirigami.FormData.label: i18n("Ignore Windows")
|
||||
}
|
||||
|
||||
BIC.ConfigTextField {
|
||||
Kirigami.FormData.label: "With classes:"
|
||||
placeholderText: "Classes (comma separated)"
|
||||
settingName: "ignoreClass"
|
||||
implicitWidth: Kirigami.Units.gridUnit * 20
|
||||
}
|
||||
|
||||
BIC.ConfigTextField {
|
||||
Kirigami.FormData.label: "With titles:"
|
||||
placeholderText: "Titles (comma separated)"
|
||||
settingName: "ignoreTitle"
|
||||
}
|
||||
|
||||
BIC.ConfigTextField {
|
||||
Kirigami.FormData.label: "With roles:"
|
||||
placeholderText: "Roles (comma separated)"
|
||||
settingName: "ignoreRole"
|
||||
}
|
||||
|
||||
Item {
|
||||
Kirigami.FormData.isSection: true
|
||||
Kirigami.FormData.label: i18n("Float Windows")
|
||||
}
|
||||
|
||||
BIC.ConfigTextField {
|
||||
Kirigami.FormData.label: "With classes:"
|
||||
placeholderText: "Classes (comma separated)"
|
||||
settingName: "floatingClass"
|
||||
}
|
||||
|
||||
BIC.ConfigTextField {
|
||||
Kirigami.FormData.label: "With titles:"
|
||||
placeholderText: "Titles (comma separated)"
|
||||
settingName: "floatingTitle"
|
||||
}
|
||||
|
||||
BIC.ConfigCheckBox {
|
||||
text: "With utility roles"
|
||||
settingName: "floatUtility"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,42 +1,41 @@
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
// SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import "../components" as BIC
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12 as QQC2
|
||||
import QtQuick.Layouts 1.15
|
||||
|
||||
import org.kde.kcm 1.5 as KCM
|
||||
import org.kde.kirigami 2.7 as Kirigami
|
||||
|
||||
import "../components" as BIC
|
||||
|
||||
Kirigami.Page {
|
||||
id: root
|
||||
title: "Workspace Rules"
|
||||
id: root
|
||||
|
||||
Kirigami.FormLayout {
|
||||
anchors.fill: parent
|
||||
title: "Workspace Rules"
|
||||
|
||||
Kirigami.FormLayout {
|
||||
anchors.fill: parent
|
||||
|
||||
Item {
|
||||
Kirigami.FormData.isSection: true
|
||||
Kirigami.FormData.label: i18n("Disable Tiling")
|
||||
}
|
||||
|
||||
BIC.ConfigTextField {
|
||||
Kirigami.FormData.label: "On Activities:"
|
||||
placeholderText: "Activities names (comma separated)"
|
||||
settingName: "ignoreActivity"
|
||||
implicitWidth: Kirigami.Units.gridUnit * 20
|
||||
}
|
||||
|
||||
BIC.ConfigTextField {
|
||||
// implicitWidth: Kirigami.Units.gridUnit * 20
|
||||
|
||||
Kirigami.FormData.label: "On Screens:"
|
||||
placeholderText: "Screen numbers (comma separated)"
|
||||
settingName: "ignoreScreen"
|
||||
}
|
||||
|
||||
Item {
|
||||
Kirigami.FormData.isSection: true
|
||||
Kirigami.FormData.label: i18n("Disable Tiling")
|
||||
}
|
||||
|
||||
BIC.ConfigTextField {
|
||||
Kirigami.FormData.label: "On Activities:"
|
||||
placeholderText: "Activities names (comma separated)"
|
||||
settingName: "ignoreActivity"
|
||||
implicitWidth: Kirigami.Units.gridUnit * 20
|
||||
}
|
||||
|
||||
BIC.ConfigTextField {
|
||||
Kirigami.FormData.label: "On Screens:"
|
||||
placeholderText: "Screen numbers (comma separated)"
|
||||
settingName: "ignoreScreen"
|
||||
// implicitWidth: Kirigami.Units.gridUnit * 20
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,27 +1,32 @@
|
||||
// SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Qt.labs.platform 1.1 as Labs
|
||||
import QtQuick 2.0
|
||||
|
||||
import Qt.labs.platform 1.1 as Labs
|
||||
|
||||
Labs.SystemTrayIcon {
|
||||
id: root
|
||||
visible: true
|
||||
icon.name: "bismuth"
|
||||
tooltip: "Windows' Tiling"
|
||||
id: root
|
||||
|
||||
menu: Labs.Menu {
|
||||
id: menu
|
||||
visible: false // Prevent from showing on Script Loading
|
||||
visible: true
|
||||
icon.name: "bismuth"
|
||||
tooltip: "Windows' Tiling"
|
||||
|
||||
property var onToggleTiling: () => {}
|
||||
menu: Labs.Menu {
|
||||
id: menu
|
||||
|
||||
property var onToggleTiling: () => {
|
||||
}
|
||||
|
||||
visible: false // Prevent from showing on Script Loading
|
||||
|
||||
Labs.MenuItem {
|
||||
text: i18n("Toggle Tiling")
|
||||
icon.name: "window"
|
||||
onTriggered: () => {
|
||||
return menu.onToggleTiling();
|
||||
}
|
||||
}
|
||||
|
||||
Labs.MenuItem {
|
||||
text: i18n("Toggle Tiling")
|
||||
icon.name: "window"
|
||||
onTriggered: () => menu.onToggleTiling()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,20 +1,39 @@
|
||||
// SPDX-FileCopyrightText: 2018-2019 Eon S. Jeon <esjeon@hyunmu.am>
|
||||
// SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick 2.0
|
||||
import org.kde.kwin 2.0;
|
||||
import org.kde.taskmanager 0.1 as TaskManager
|
||||
|
||||
import "../code/index.mjs" as Bismuth
|
||||
import QtQuick 2.0
|
||||
import org.kde.kwin 2.0
|
||||
import org.kde.taskmanager 0.1 as TaskManager
|
||||
|
||||
Item {
|
||||
id: scriptRoot
|
||||
|
||||
property var controller
|
||||
|
||||
Component.onCompleted: {
|
||||
console.log("[Bismuth] Initiating the script");
|
||||
const qmlObjects = {
|
||||
"scriptRoot": scriptRoot,
|
||||
"trayItem": trayItem,
|
||||
"activityInfo": activityInfo,
|
||||
"popupDialog": popupDialog
|
||||
};
|
||||
const kwinScriptingAPI = {
|
||||
"workspace": workspace,
|
||||
"options": options,
|
||||
"KWin": KWin
|
||||
};
|
||||
scriptRoot.controller = Bismuth.init(qmlObjects, kwinScriptingAPI);
|
||||
}
|
||||
Component.onDestruction: {
|
||||
console.log("[Bismuth] Everybody is dead");
|
||||
scriptRoot.controller.drop();
|
||||
}
|
||||
|
||||
TrayItem {
|
||||
id: trayItem
|
||||
id: trayItem
|
||||
}
|
||||
|
||||
TaskManager.ActivityInfo {
|
||||
@ -23,34 +42,12 @@ Item {
|
||||
|
||||
Loader {
|
||||
id: popupDialog
|
||||
source: "popup.qml"
|
||||
|
||||
function show(text) {
|
||||
this.item.show(text);
|
||||
}
|
||||
|
||||
source: "popup.qml"
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
console.log("[Bismuth] Initiating the script");
|
||||
|
||||
const qmlObjects = {
|
||||
scriptRoot: scriptRoot,
|
||||
trayItem: trayItem,
|
||||
activityInfo: activityInfo,
|
||||
popupDialog: popupDialog
|
||||
};
|
||||
|
||||
const kwinScriptingAPI = {
|
||||
workspace: workspace,
|
||||
options: options,
|
||||
KWin: KWin
|
||||
};
|
||||
|
||||
scriptRoot.controller = Bismuth.init(qmlObjects, kwinScriptingAPI);
|
||||
}
|
||||
|
||||
Component.onDestruction: {
|
||||
console.log("[Bismuth] Everybody is dead");
|
||||
scriptRoot.controller.drop();
|
||||
}
|
||||
}
|
||||
|
@ -1,47 +1,55 @@
|
||||
// SPDX-FileCopyrightText: 2018-2019 Eon S. Jeon <esjeon@hyunmu.am>
|
||||
// SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Controls 2.0
|
||||
import QtQuick.Layouts 1.15
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore;
|
||||
import org.kde.kwin 2.0
|
||||
import org.kde.plasma.components 3.0 as PC3
|
||||
import org.kde.kwin 2.0;
|
||||
|
||||
/*
|
||||
* Component Documentation
|
||||
* - PlasmaCore global `theme` object:
|
||||
* https://api.kde.org/frameworks/plasma-framework/html/classPlasma_1_1Theme.html
|
||||
* - PlasmaCore.Dialog:
|
||||
* https://api.kde.org/frameworks/plasma-framework/html/classPlasmaQuick_1_1Dialog.html
|
||||
*/
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
|
||||
PlasmaCore.Dialog {
|
||||
id: popupDialog
|
||||
|
||||
property rect screenGeometry
|
||||
|
||||
function show(text) {
|
||||
// Abort any previous timers
|
||||
hideTimer.stop();
|
||||
// Update current screen information
|
||||
this.screenGeometry = workspace.clientArea(KWin.FullScreenArea, workspace.activeScreen, workspace.currentDesktop);
|
||||
// Set the text for the popup
|
||||
messageLabel.text = text;
|
||||
this.visible = true;
|
||||
// Start popup hide timer
|
||||
hideTimer.interval = 3000;
|
||||
hideTimer.start();
|
||||
}
|
||||
|
||||
type: PlasmaCore.Dialog.OnScreenDisplay
|
||||
flags: Qt.Popup | Qt.WindowStaysOnTopHint
|
||||
location: PlasmaCore.Types.Floating
|
||||
outputOnly: true
|
||||
|
||||
property rect screenGeometry
|
||||
|
||||
// Spawn popup a little bit lower than the center of the screen for consistency
|
||||
x: (screenGeometry.x + screenGeometry.width / 2) - width / 2;
|
||||
y: (screenGeometry.y + screenGeometry.height * 2 / 3) - height / 2;
|
||||
|
||||
x: (screenGeometry.x + screenGeometry.width / 2) - width / 2
|
||||
y: (screenGeometry.y + screenGeometry.height * 2 / 3) - height / 2
|
||||
visible: false
|
||||
Component.onCompleted: {
|
||||
KWin.registerWindow(this);
|
||||
}
|
||||
|
||||
mainItem: RowLayout {
|
||||
id: main
|
||||
|
||||
// Make popup size consistent with the other Plasma OSD (e.g. PulseAudio one)
|
||||
Layout.minimumWidth: Math.max(messageLabel.implicitWidth, PlasmaCore.Units.gridUnit * 15)
|
||||
Layout.minimumHeight: PlasmaCore.Units.gridUnit * 1.35
|
||||
|
||||
PC3.Label {
|
||||
id: messageLabel
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
// This font size matches the one from Pulse Audio OSD for consistency
|
||||
font.pointSize: PlasmaCore.Theme.defaultFont.pointSize * 1.2
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
@ -50,32 +58,13 @@ PlasmaCore.Dialog {
|
||||
// Hides the popup window when triggered
|
||||
Timer {
|
||||
id: hideTimer
|
||||
repeat: false
|
||||
|
||||
repeat: false
|
||||
onTriggered: {
|
||||
popupDialog.visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
KWin.registerWindow(this);
|
||||
}
|
||||
|
||||
function show(text) {
|
||||
// Abort any previous timers
|
||||
hideTimer.stop();
|
||||
|
||||
// Update current screen information
|
||||
this.screenGeometry = workspace.clientArea(KWin.FullScreenArea, workspace.activeScreen, workspace.currentDesktop);
|
||||
|
||||
// Set the text for the popup
|
||||
messageLabel.text = text;
|
||||
|
||||
this.visible = true;
|
||||
|
||||
// Start popup hide timer
|
||||
hideTimer.interval = 3000;
|
||||
hideTimer.start();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user