forked from Shinonome/dots-hyprland
sidebar: translator: change layout to reduce eye movement
This commit is contained in:
@@ -100,62 +100,17 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Flickable {
|
ColumnLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
Flickable {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.fillHeight: true
|
||||||
contentHeight: contentColumn.implicitHeight
|
contentHeight: contentColumn.implicitHeight
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: contentColumn
|
id: contentColumn
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
LanguageSelectorButton { // Source language button
|
|
||||||
id: sourceLanguageButton
|
|
||||||
displayText: root.sourceLanguage
|
|
||||||
onClicked: {
|
|
||||||
root.showLanguageSelectorDialog(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TextCanvas { // Content input
|
|
||||||
id: inputCanvas
|
|
||||||
isInput: true
|
|
||||||
placeholderText: qsTr("Enter text to translate...")
|
|
||||||
onInputTextChanged: {
|
|
||||||
translateTimer.restart();
|
|
||||||
}
|
|
||||||
GroupButton {
|
|
||||||
id: pasteButton
|
|
||||||
baseWidth: height
|
|
||||||
buttonRadius: Appearance.rounding.small
|
|
||||||
contentItem: MaterialSymbol {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
iconSize: Appearance.font.pixelSize.larger
|
|
||||||
text: "content_paste"
|
|
||||||
color: deleteButton.enabled ? Appearance.colors.colOnLayer1 : Appearance.colors.colSubtext
|
|
||||||
}
|
|
||||||
onClicked: {
|
|
||||||
root.inputField.text = Quickshell.clipboardText
|
|
||||||
}
|
|
||||||
}
|
|
||||||
GroupButton {
|
|
||||||
id: deleteButton
|
|
||||||
baseWidth: height
|
|
||||||
buttonRadius: Appearance.rounding.small
|
|
||||||
enabled: inputCanvas.inputTextArea.text.length > 0
|
|
||||||
contentItem: MaterialSymbol {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
iconSize: Appearance.font.pixelSize.larger
|
|
||||||
text: "close"
|
|
||||||
color: deleteButton.enabled ? Appearance.colors.colOnLayer1 : Appearance.colors.colSubtext
|
|
||||||
}
|
|
||||||
onClicked: {
|
|
||||||
root.inputField.text = ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LanguageSelectorButton { // Target language button
|
LanguageSelectorButton { // Target language button
|
||||||
id: targetLanguageButton
|
id: targetLanguageButton
|
||||||
displayText: root.targetLanguage
|
displayText: root.targetLanguage
|
||||||
@@ -211,6 +166,55 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LanguageSelectorButton { // Source language button
|
||||||
|
id: sourceLanguageButton
|
||||||
|
displayText: root.sourceLanguage
|
||||||
|
onClicked: {
|
||||||
|
root.showLanguageSelectorDialog(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TextCanvas { // Content input
|
||||||
|
id: inputCanvas
|
||||||
|
isInput: true
|
||||||
|
placeholderText: qsTr("Enter text to translate...")
|
||||||
|
onInputTextChanged: {
|
||||||
|
translateTimer.restart();
|
||||||
|
}
|
||||||
|
GroupButton {
|
||||||
|
id: pasteButton
|
||||||
|
baseWidth: height
|
||||||
|
buttonRadius: Appearance.rounding.small
|
||||||
|
contentItem: MaterialSymbol {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
iconSize: Appearance.font.pixelSize.larger
|
||||||
|
text: "content_paste"
|
||||||
|
color: deleteButton.enabled ? Appearance.colors.colOnLayer1 : Appearance.colors.colSubtext
|
||||||
|
}
|
||||||
|
onClicked: {
|
||||||
|
root.inputField.text = Quickshell.clipboardText
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GroupButton {
|
||||||
|
id: deleteButton
|
||||||
|
baseWidth: height
|
||||||
|
buttonRadius: Appearance.rounding.small
|
||||||
|
enabled: inputCanvas.inputTextArea.text.length > 0
|
||||||
|
contentItem: MaterialSymbol {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
iconSize: Appearance.font.pixelSize.larger
|
||||||
|
text: "close"
|
||||||
|
color: deleteButton.enabled ? Appearance.colors.colOnLayer1 : Appearance.colors.colSubtext
|
||||||
|
}
|
||||||
|
onClicked: {
|
||||||
|
root.inputField.text = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
active: root.showLanguageSelector
|
active: root.showLanguageSelector
|
||||||
@@ -234,6 +238,8 @@ Item {
|
|||||||
root.sourceLanguage = result;
|
root.sourceLanguage = result;
|
||||||
ConfigOptions.language.translator.sourceLanguage = result; // Save to config
|
ConfigOptions.language.translator.sourceLanguage = result; // Save to config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
translateTimer.restart(); // Restart translation after language change
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user