@@ -30,7 +30,8 @@ Popup {
3030
3131 let lastLang = AppInfoController .lastTranslationLanguage
3232
33- targetLanguageComboBox .selectItemByValue (lastLang .toUpperCase (), " code" )
33+ targetLanguageComboBox .selectItemByValue (lastLang .toUpperCase (),
34+ " code" , true )
3435 internal .sendTranslationRequest ()
3536 }
3637
@@ -178,32 +179,29 @@ Popup {
178179 loadingAnimation .visible = false
179180 }
180181
181- function onTranslationRequestTooLong () {
182- loadingAnimation .visible = false
182+ function onTranslationErrorOccured () {
183+ loadingAnimation .visible = true
184+ errorItem .visible = true
185+ errorText .text = qsTr (
186+ ' Opps! Something went wrong. Please try again.' )
183187 }
184188
185189 function onTranslationLimitReached () {
186190 loadingAnimation .visible = false
191+ errorItem .visible = true
192+ // : Make sure that the words make a valid sentence
193+ errorText .text = qsTr (' You have reached your daily limit.' ) + ' '
194+ + ' <a href="update" style="color: ' + Style .colorBasePurple
195+ + ' ; text-decoration: none;">' + qsTr (
196+ ' Upgrade' ) + ' </a> ' + qsTr (' to continue.' )
187197 }
188198
189- function onTranslationErrorOccured () {
199+ function onTranslationRequestTooLong () {
190200 loadingAnimation .visible = false
201+ errorItem .visible = true
202+ errorText .text = qsTr (
203+ ' Oops! The text is too long. Please shorten your selection.' )
191204 }
192-
193- // function onExplanationLimitReached() {
194- // errorItem.visible = true
195- // //: Make sure that the words make a valid sentence
196- // errorText.text = qsTr('You have reached your daily limit.') + ' '
197- // + ' <a href="update" style="color: ' + Style.colorBasePurple
198- // + '; text-decoration: none;">' + qsTr(
199- // 'Upgrade') + '</a> ' + qsTr('to continue.')
200- // }
201-
202- // function onExplanationRequestTooLong() {
203- // errorItem.visible = true
204- // errorText.text = qsTr(
205- // 'Oops! The text is too long. Please shorten your selection.')
206- // }
207205 }
208206
209207 ColumnLayout {
@@ -249,7 +247,10 @@ Popup {
249247 allowUnselectingItems: false
250248
251249 model: langModel
252- onItemChanged: sourceLanguageComboBox .closePopup ()
250+ onItemChanged: {
251+ translateButton .active = true
252+ sourceLanguageComboBox .closePopup ()
253+ }
253254 }
254255
255256 Item {
@@ -282,7 +283,10 @@ Popup {
282283 allowUnselectingItems: false
283284
284285 model: langModel
285- onItemChanged: targetLanguageComboBox .closePopup ()
286+ onItemChanged: {
287+ translateButton .active = true
288+ targetLanguageComboBox .closePopup ()
289+ }
286290 }
287291 }
288292
@@ -419,9 +423,9 @@ Popup {
419423 Image {
420424 id: errorIllustration
421425 Layout .alignment : Qt .AlignHCenter
422- Layout .topMargin : - 30
426+ Layout .topMargin : - 16
423427 source: Icons .attentionPurple
424- sourceSize .width : 270
428+ sourceSize .width : 160
425429 fillMode: Image .PreserveAspectFit
426430 }
427431
@@ -432,7 +436,7 @@ Popup {
432436 text: " "
433437 color: Style .colorTitle
434438 font .weight : Font .Medium
435- font .pointSize : Fonts .size14
439+ font .pointSize : Fonts .size13
436440 onLinkActivated: Qt .openUrlExternally (
437441 AppInfoController .website + " /pricing" )
438442
@@ -485,29 +489,31 @@ Popup {
485489 }
486490
487491 MButton {
488- id: applyButton
492+ id: translateButton
489493 Layout .preferredWidth : 124
490494 Layout .preferredHeight : 38
491495 Layout .topMargin : 8
492496 Layout .alignment : Qt .AlignLeft
493- borderWidth: 0
494- backgroundColor: Style .colorBasePurple
497+ borderWidth: active ? 0 : 1
498+ backgroundColor: active ? Style .colorBasePurple : " transparent "
495499 text: qsTr (" Translate" )
496- textColor: Style .colorFocusedButtonText
500+ textColor: active ? Style .colorFocusedButtonText : Style . colorUnfocusedButtonText
497501 fontWeight: Font .Medium
498502 fontSize: Fonts .size12
499503
500- onClicked: internal .sendTranslationRequest ()
504+ onClicked: if (active)
505+ internal .sendTranslationRequest ()
501506 }
502507 }
503508
504509 QtObject {
505510 id: internal
506511 property int maxTextHeight: baseRoot .height / 4
507- property int minTextHeight: 120
512+ property int minTextHeight: 140
508513
509514 function sendTranslationRequest () {
510515 root .translation = " "
516+ errorItem .visible = false
511517 loadingAnimation .visible = true
512518
513519 AppInfoController .lastTranslationLanguage
@@ -518,6 +524,8 @@ Popup {
518524 " code" )
519525
520526 AiToolsController .getTranslation (root .input , sourceLang, targetLang)
527+
528+ translateButton .active = false
521529 }
522530 }
523531}
0 commit comments