forked from Shinonome/dots-hyprland
settings: make right-clicking config file button copy path (#2112)
This commit is contained in:
@@ -7,6 +7,7 @@ Rectangle {
|
|||||||
id: root
|
id: root
|
||||||
property alias materialIcon: icon.text
|
property alias materialIcon: icon.text
|
||||||
property alias text: noticeText.text
|
property alias text: noticeText.text
|
||||||
|
default property alias data: buttonRow.data
|
||||||
|
|
||||||
radius: Appearance.rounding.normal
|
radius: Appearance.rounding.normal
|
||||||
color: Appearance.colors.colPrimaryContainer
|
color: Appearance.colors.colPrimaryContainer
|
||||||
@@ -28,13 +29,23 @@ Rectangle {
|
|||||||
color: Appearance.colors.colOnPrimaryContainer
|
color: Appearance.colors.colOnPrimaryContainer
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
ColumnLayout {
|
||||||
id: noticeText
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.alignment: Qt.AlignVCenter
|
spacing: 4
|
||||||
text: "Notice message"
|
|
||||||
color: Appearance.colors.colOnPrimaryContainer
|
StyledText {
|
||||||
wrapMode: Text.WordWrap
|
id: noticeText
|
||||||
|
Layout.fillWidth: true
|
||||||
|
text: "Notice message"
|
||||||
|
color: Appearance.colors.colOnPrimaryContainer
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
id: buttonRow
|
||||||
|
visible: children.length > 0
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -332,5 +332,33 @@ ContentPage {
|
|||||||
NoticeBox {
|
NoticeBox {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
text: Translation.tr('Not all options are available in this app. You should also check the config file by hitting the "Config file" button on the topleft corner or opening %1 manually.').arg(Directories.shellConfigPath)
|
text: Translation.tr('Not all options are available in this app. You should also check the config file by hitting the "Config file" button on the topleft corner or opening %1 manually.').arg(Directories.shellConfigPath)
|
||||||
|
|
||||||
|
Item {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
RippleButtonWithIcon {
|
||||||
|
id: copyPathButton
|
||||||
|
property bool justCopied: false
|
||||||
|
Layout.fillWidth: false
|
||||||
|
buttonRadius: Appearance.rounding.small
|
||||||
|
materialIcon: justCopied ? "check" : "content_copy"
|
||||||
|
mainText: justCopied ? Translation.tr("Path copied") : Translation.tr("Copy path")
|
||||||
|
onClicked: {
|
||||||
|
copyPathButton.justCopied = true
|
||||||
|
Quickshell.clipboardText = FileUtils.trimFileProtocol(`${Directories.config}/illogical-impulse/config.json`);
|
||||||
|
revertTextTimer.restart();
|
||||||
|
}
|
||||||
|
colBackground: ColorUtils.transparentize(Appearance.colors.colPrimaryContainer)
|
||||||
|
colBackgroundHover: Appearance.colors.colPrimaryContainerHover
|
||||||
|
colRipple: Appearance.colors.colPrimaryContainerActive
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: revertTextTimer
|
||||||
|
interval: 1500
|
||||||
|
onTriggered: {
|
||||||
|
copyPathButton.justCopied = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import QtQuick
|
|||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import QtQuick.Window
|
import QtQuick.Window
|
||||||
|
import Quickshell
|
||||||
import qs.services
|
import qs.services
|
||||||
import qs.modules.common
|
import qs.modules.common
|
||||||
import qs.modules.common.widgets
|
import qs.modules.common.widgets
|
||||||
@@ -169,15 +170,29 @@ ApplicationWindow {
|
|||||||
|
|
||||||
FloatingActionButton {
|
FloatingActionButton {
|
||||||
id: fab
|
id: fab
|
||||||
iconText: "edit"
|
property bool justCopied: false
|
||||||
buttonText: Translation.tr("Config file")
|
iconText: justCopied ? "check" : "edit"
|
||||||
|
buttonText: justCopied ? Translation.tr("Path copied") : Translation.tr("Config file")
|
||||||
expanded: navRail.expanded
|
expanded: navRail.expanded
|
||||||
downAction: () => {
|
downAction: () => {
|
||||||
Qt.openUrlExternally(`${Directories.config}/illogical-impulse/config.json`);
|
Qt.openUrlExternally(`${Directories.config}/illogical-impulse/config.json`);
|
||||||
}
|
}
|
||||||
|
altAction: () => {
|
||||||
|
Quickshell.clipboardText = CF.FileUtils.trimFileProtocol(`${Directories.config}/illogical-impulse/config.json`);
|
||||||
|
fab.justCopied = true;
|
||||||
|
revertTextTimer.restart()
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: revertTextTimer
|
||||||
|
interval: 1500
|
||||||
|
onTriggered: {
|
||||||
|
fab.justCopied = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
StyledToolTip {
|
StyledToolTip {
|
||||||
text: Translation.tr("Open the shell config file.\nIf the button doesn't work or doesn't open in your favorite editor,\nyou can manually open ~/.config/illogical-impulse/config.json")
|
text: Translation.tr("Open the shell config file\nAlternatively right-click to copy path")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user