Skip to content

Commit

Permalink
Feat: Add a toast message when text has been copied to clipboard (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
RikudouSage committed Jul 17, 2023
1 parent c1912ef commit 0d51fd9
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 4 deletions.
1 change: 1 addition & 0 deletions harbour-chatgpt.pro
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ SOURCES += src/harbour-chatgpt.cpp \
src/settings.cpp

DISTFILES += qml/harbour-chatgpt.qml \
qml/components/Toaster.qml \
qml/cover/CoverPage.qml \
qml/pages/ApiKeyHelpPage.qml \
qml/pages/ChangeChatTitleDialog.qml \
Expand Down
51 changes: 51 additions & 0 deletions qml/components/Toaster.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import QtQuick 2.0
import Sailfish.Silica 1.0

Item {
function show(text, timeout) {
if (!timeout) {
timeout = 5000;
}

textLabel.text = text;
notificationHideTimer.interval = timeout;
notificationHideTimer.start();
opacity = 1;
}

id: toaster
opacity: 0
z: 100

Behavior on opacity {
NumberAnimation {
duration: 300
}
}

Timer {
id: notificationHideTimer
running: false
repeat: false

onTriggered: {
opacity = 0;
}
}

Rectangle {
color: "black"
width: textLabel.width + Theme.horizontalPageMargin * 2
x: Screen.width / 2 - width / 2
y: Screen.height - Theme.itemSizeMedium
height: textLabel.height + Theme.paddingSmall * 2
radius: 20
opacity: 0.9

Label {
anchors.centerIn: parent
id: textLabel
color: Theme.lightPrimaryColor
}
}
}
7 changes: 7 additions & 0 deletions qml/pages/ChatDetailPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import QtQuick.Layouts 1.1

import cz.chrastecky.chatgpt 1.0

import "../components" as Components

Page {
id: page
allowedOrientations: Orientation.All
Expand All @@ -12,6 +14,10 @@ Page {
property string messageInProgress: ''
property bool chatIndicatorVisible: false

Components.Toaster {
id: toaster
}

ChatStorage {
id: chatStorage
}
Expand Down Expand Up @@ -88,6 +94,7 @@ Page {

onClicked: {
Clipboard.text = message.text;
toaster.show(qsTr("The message has been copied to clipboard."))

This comment has been minimized.

Copy link
@henning-schild

henning-schild Jul 17, 2023

to the clipboard

}

Rectangle {
Expand Down
2 changes: 1 addition & 1 deletion rpm/harbour-chatgpt.spec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Name: harbour-chatgpt
%define _binary_payload w2.xzdio

Summary: ChatGPT
Version: 0.9.11
Version: 0.9.12
Release: 1
License: MIT
URL: https://openrepos.net/content/rikudousennin/chatgpt
Expand Down
4 changes: 4 additions & 0 deletions translations/harbour-chatgpt-cs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
<source>Type your message</source>
<translation>Napište svou zprávu</translation>
</message>
<message>
<source>The message has been copied to clipboard.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatListPage</name>
Expand Down
12 changes: 9 additions & 3 deletions translations/harbour-chatgpt-pl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?xml version="1.0" ?><!DOCTYPE TS><TS version="2.1" language="pl">
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="pl">
<context>
<name>ApiKeyHelpPage</name>
<message>
Expand Down Expand Up @@ -53,6 +55,10 @@
<source>Type your message</source>
<translation>Napisz wiadomość</translation>
</message>
<message>
<source>The message has been copied to clipboard.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatListPage</name>
Expand Down Expand Up @@ -297,7 +303,7 @@ Read the description at https://platform.openai.com/docs/api-reference/chat/crea
</message>
<message>
<source>Note: The system message counts towards your &apos;%1&apos; limit.</source>
<extracomment>The %1 gets replaced by the translation for 'Conversation length'</extracomment>
<extracomment>The %1 gets replaced by the translation for &apos;Conversation length&apos;</extracomment>
<translation>Uwaga: wiadomość systemowa wlicza się do limitu &quot;%1&quot; wiadomości.</translation>
</message>
<message>
Expand Down Expand Up @@ -366,4 +372,4 @@ Read the description at https://platform.openai.com/docs/api-reference/chat/crea
<translation>Model AI</translation>
</message>
</context>
</TS>
</TS>
4 changes: 4 additions & 0 deletions translations/harbour-chatgpt-sv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
<source>Type your message</source>
<translation>Skriv ditt meddelande</translation>
</message>
<message>
<source>The message has been copied to clipboard.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatListPage</name>
Expand Down
4 changes: 4 additions & 0 deletions translations/harbour-chatgpt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
<source>Type your message</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The message has been copied to clipboard.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatListPage</name>
Expand Down

0 comments on commit 0d51fd9

Please sign in to comment.