Skip to content

Commit 264786e

Browse files
committed
Last refactoring before bump version
1 parent 6b49e66 commit 264786e

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

pyqt_openai/main.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import os
22
import sys
3-
import webbrowser
43

54
import requests
65

@@ -35,12 +34,12 @@
3534
from pyqt_openai.chat_widget.openAiChatBotWidget import OpenAIChatBotWidget
3635
from pyqt_openai.replicate_widget.replicateWidget import ReplicateWidget
3736
from pyqt_openai.settingsDialog import SettingsDialog
38-
from pyqt_openai.util.script import get_font, restart_app, show_message_box
37+
from pyqt_openai.util.script import get_font, restart_app, show_message_box, goPayPal, goBuyMeCoffee
3938
from pyqt_openai.doNotAskAgainDialog import DoNotAskAgainDialog
4039
from pyqt_openai.sqlite import get_db_filename
4140

4241
from pyqt_openai.pyqt_openai_data import OPENAI_STRUCT, LLAMAINDEX_WRAPPER
43-
from pyqt_openai import PAYPAL_URL, BUYMEACOFFEE_URL, INI_FILE_NAME, SHORTCUT_FULL_SCREEN, \
42+
from pyqt_openai import INI_FILE_NAME, SHORTCUT_FULL_SCREEN, \
4443
APP_INITIAL_WINDOW_SIZE, APP_NAME, APP_ICON, ICON_STACKONTOP, ICON_CUSTOMIZE, ICON_FULLSCREEN, ICON_CLOSE
4544

4645
# HighDPI support
@@ -109,10 +108,10 @@ def __setActions(self):
109108
self.__aboutAction.triggered.connect(self.__showAboutDialog)
110109

111110
self.__paypalAction = QAction('Paypal', self)
112-
self.__paypalAction.triggered.connect(self.__paypal)
111+
self.__paypalAction.triggered.connect(goPayPal)
113112

114113
self.__buyMeCoffeeAction = QAction('Buy me a coffee!', self)
115-
self.__buyMeCoffeeAction.triggered.connect(self.__buyMeCoffee)
114+
self.__buyMeCoffeeAction.triggered.connect(goBuyMeCoffee)
116115

117116
# toolbar action
118117
self.__chooseAiAction = QWidgetAction(self)
@@ -328,12 +327,6 @@ def __showAboutDialog(self):
328327
aboutDialog = AboutDialog()
329328
aboutDialog.exec()
330329

331-
def __paypal(self):
332-
webbrowser.open(PAYPAL_URL)
333-
334-
def __buyMeCoffee(self):
335-
webbrowser.open(BUYMEACOFFEE_URL)
336-
337330
def __stackToggle(self, f):
338331
if f:
339332
self.setWindowFlags(self.windowFlags() | Qt.WindowType.WindowStaysOnTopHint)

pyqt_openai/util/script.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import re
66
import string
77
import sys
8+
import webbrowser
89
import zipfile
910
from datetime import datetime
1011
from pathlib import Path
@@ -15,7 +16,7 @@
1516
from qtpy.QtWidgets import QMessageBox
1617

1718
from pyqt_openai import INI_FILE_NAME, DEFAULT_FONT_SIZE, DEFAULT_FONT_FAMILY, MAIN_INDEX, \
18-
PROMPT_NAME_REGEX
19+
PROMPT_NAME_REGEX, PAYPAL_URL, BUYMEACOFFEE_URL
1920
from pyqt_openai.models import ImagePromptContainer
2021
from pyqt_openai.pyqt_openai_data import DB
2122

@@ -297,4 +298,10 @@ def get_prompt_data(prompt_type='form'):
297298
'content': entry.content
298299
})
299300
data.append(group_obj)
300-
return data
301+
return data
302+
303+
def goPayPal():
304+
webbrowser.open(PAYPAL_URL)
305+
306+
def goBuyMeCoffee():
307+
webbrowser.open(BUYMEACOFFEE_URL)

pyqt_openai/widgets/linkLabel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ def setUrl(self, url):
1616
self.__url = url
1717

1818
def mouseReleaseEvent(self, QMouseEvent):
19-
v = 1 if os.environ['QT_API'] == 'pyqt5' else Qt.MouseButtons.LeftButton
19+
v = 1 if os.environ['QT_API'] == 'pyqt5' else Qt.MouseButton.LeftButton
2020
if QMouseEvent.button() == v:
2121
QDesktopServices.openUrl(QUrl(self.__url))

0 commit comments

Comments
 (0)