forked from Shinonome/dots-hyprland
sidebar: translator: change layout to reduce eye movement
This commit is contained in:
@@ -99,116 +99,120 @@ Item {
|
|||||||
getLanguagesProc.bufferList = []; // Clear the buffer
|
getLanguagesProc.bufferList = []; // Clear the buffer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Flickable {
|
ColumnLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
contentHeight: contentColumn.implicitHeight
|
Flickable {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.fillHeight: true
|
||||||
|
contentHeight: contentColumn.implicitHeight
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: contentColumn
|
id: contentColumn
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
LanguageSelectorButton { // Source language button
|
LanguageSelectorButton { // Target language button
|
||||||
id: sourceLanguageButton
|
id: targetLanguageButton
|
||||||
displayText: root.sourceLanguage
|
displayText: root.targetLanguage
|
||||||
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: {
|
onClicked: {
|
||||||
root.inputField.text = Quickshell.clipboardText
|
root.showLanguageSelectorDialog(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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
|
TextCanvas { // Content translation
|
||||||
id: targetLanguageButton
|
id: outputCanvas
|
||||||
displayText: root.targetLanguage
|
isInput: false
|
||||||
onClicked: {
|
placeholderText: qsTr("Translation goes here...")
|
||||||
root.showLanguageSelectorDialog(true);
|
property bool hasTranslation: (root.translatedText.trim().length > 0)
|
||||||
}
|
text: hasTranslation ? root.translatedText : ""
|
||||||
}
|
GroupButton {
|
||||||
|
id: copyButton
|
||||||
TextCanvas { // Content translation
|
baseWidth: height
|
||||||
id: outputCanvas
|
buttonRadius: Appearance.rounding.small
|
||||||
isInput: false
|
enabled: outputCanvas.displayedText.trim().length > 0
|
||||||
placeholderText: qsTr("Translation goes here...")
|
contentItem: MaterialSymbol {
|
||||||
property bool hasTranslation: (root.translatedText.trim().length > 0)
|
anchors.centerIn: parent
|
||||||
text: hasTranslation ? root.translatedText : ""
|
horizontalAlignment: Text.AlignHCenter
|
||||||
GroupButton {
|
iconSize: Appearance.font.pixelSize.larger
|
||||||
id: copyButton
|
text: "content_copy"
|
||||||
baseWidth: height
|
color: copyButton.enabled ? Appearance.colors.colOnLayer1 : Appearance.colors.colSubtext
|
||||||
buttonRadius: Appearance.rounding.small
|
}
|
||||||
enabled: outputCanvas.displayedText.trim().length > 0
|
onClicked: {
|
||||||
contentItem: MaterialSymbol {
|
Quickshell.clipboardText = outputCanvas.displayedText
|
||||||
anchors.centerIn: parent
|
}
|
||||||
horizontalAlignment: Text.AlignHCenter
|
}
|
||||||
iconSize: Appearance.font.pixelSize.larger
|
GroupButton {
|
||||||
text: "content_copy"
|
id: searchButton
|
||||||
color: copyButton.enabled ? Appearance.colors.colOnLayer1 : Appearance.colors.colSubtext
|
baseWidth: height
|
||||||
}
|
buttonRadius: Appearance.rounding.small
|
||||||
onClicked: {
|
enabled: outputCanvas.displayedText.trim().length > 0
|
||||||
Quickshell.clipboardText = outputCanvas.displayedText
|
contentItem: MaterialSymbol {
|
||||||
}
|
anchors.centerIn: parent
|
||||||
}
|
horizontalAlignment: Text.AlignHCenter
|
||||||
GroupButton {
|
iconSize: Appearance.font.pixelSize.larger
|
||||||
id: searchButton
|
text: "travel_explore"
|
||||||
baseWidth: height
|
color: searchButton.enabled ? Appearance.colors.colOnLayer1 : Appearance.colors.colSubtext
|
||||||
buttonRadius: Appearance.rounding.small
|
}
|
||||||
enabled: outputCanvas.displayedText.trim().length > 0
|
onClicked: {
|
||||||
contentItem: MaterialSymbol {
|
let url = ConfigOptions.search.engineBaseUrl + outputCanvas.displayedText;
|
||||||
anchors.centerIn: parent
|
for (let site of ConfigOptions.search.excludedSites) {
|
||||||
horizontalAlignment: Text.AlignHCenter
|
url += ` -site:${site}`;
|
||||||
iconSize: Appearance.font.pixelSize.larger
|
}
|
||||||
text: "travel_explore"
|
Qt.openUrlExternally(url);
|
||||||
color: searchButton.enabled ? Appearance.colors.colOnLayer1 : Appearance.colors.colSubtext
|
|
||||||
}
|
|
||||||
onClicked: {
|
|
||||||
let url = ConfigOptions.search.engineBaseUrl + outputCanvas.displayedText;
|
|
||||||
for (let site of ConfigOptions.search.excludedSites) {
|
|
||||||
url += ` -site:${site}`;
|
|
||||||
}
|
}
|
||||||
Qt.openUrlExternally(url);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 {
|
||||||
@@ -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