Skip to content

Commit

Permalink
big update
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Polishchuk committed Feb 22, 2023
1 parent 5bab7ae commit 830f524
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 77 deletions.
47 changes: 38 additions & 9 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import math
from turtle import width
from imports import *
import os

appIconPath = 'images/logo.png'

db = sqlite3.connect("arcibinder.db", check_same_thread = False)
if not os.path.exists(os.path.join(os.getenv('APPDATA'), 'arcibinder')):
os.makedirs(os.path.join(os.getenv('APPDATA'), 'arcibinder'))

db = sqlite3.connect(os.path.join(os.getenv('APPDATA'), 'arcibinder', 'arcibinder.db'), check_same_thread = False)
dbcursor = db.cursor()

basedir = os.path.dirname(__file__)
Expand Down Expand Up @@ -62,6 +65,9 @@ def updateProfiles():
pass

for profile in profilesList:
if not profile[2]:
return

keyboard.add_hotkey(profile[2], playProfile, args=(str(profile[1]),))


Expand All @@ -88,6 +94,10 @@ def _show(self):

def editProfileButtonCallback(self):
global editWindow

if not self.ui.listWidget.currentItem():
return

editWindow.showWithUuid(nameToUuid(self.ui.listWidget.currentItem().text()))

def updateListItems(self):
Expand Down Expand Up @@ -129,12 +139,19 @@ def showWithUuid(self, uuid: str):
dbcursor.execute(f"SELECT * FROM 'profile_{uuid}'")
profilestrings = dbcursor.fetchall()

self.ui.shortcut.hide()
self.ui.shortcutlabel.hide()
dbcursor.execute(f"SELECT hotkey FROM profilesData WHERE uuid='{uuid}'")
hotkey = dbcursor.fetchone()[0]


#self.ui.shortcut.hide()
#self.ui.shortcutlabel.hide()
self.ui.profileName.hide()
self.ui.profiileNameLabel.hide()
self.ui.createProfileButton.setText('Изменить')

try:
self.ui.shortcut.setKeySequence(hotkey)

if profilestrings[0] != "":
editWindow.ui.string1.setText(profilestrings[0][0])
editWindow.ui.cooldown1.setText(str(profilestrings[0][1]))
Expand Down Expand Up @@ -177,17 +194,28 @@ def createProfileButtonCallback(self):
_uuid = self.saveduuid if self.saveduuid != -1 else str(uuid.uuid4().hex)
_name = uuidToName(self.saveduuid) if self.saveduuid != -1 else self.ui.profileName.text()

if not _name:
msgbox = QMessageBox()
msgbox.setWindowTitle(f"ArciBinder")
msgbox.setText(f"Вы забыли ввести название профиля!")
msgbox.setIcon(QMessageBox.Icon.Critical)
msgbox.setStandardButtons(QMessageBox.StandardButton.Ok)
msgbox.exec()
return

dbcursor.execute(f"SELECT hotkey FROM profilesData WHERE uuid='{self.saveduuid}'")

_hotkey = str(dbcursor.fetchone()[0]) if self.saveduuid != -1 else self.ui.shortcut.keySequence().toString().split(',')[0]
_hotkey = self.ui.shortcut.keySequence().toString().split(',')[0]

dbcursor.execute(f"SELECT * FROM profilesData WHERE hotkey='{self.ui.shortcut.keySequence().toString()}'")
dbcursor.execute(f"SELECT * FROM profilesData WHERE hotkey='{_hotkey}'")
profileWithCurrentHotkey = dbcursor.fetchall()

if len(profileWithCurrentHotkey) > 0:
print(self.saveduuid == -1)

if len(profileWithCurrentHotkey) > 0 and self.saveduuid == -1:
msgbox = QMessageBox()
msgbox.setWindowTitle(f"ArciBinder")
msgbox.setText(f"Данная клавиша уже занята!\nУдалите бинд {profileWithCurrentHotkey[0][0]} или измените клавишу.")
msgbox.setText(f"Данная клавиша уже занята!\nУдалите профиль {profileWithCurrentHotkey[0][0]} или измените клавишу.")
msgbox.setIcon(QMessageBox.Icon.Critical)
msgbox.setStandardButtons(QMessageBox.StandardButton.Ok)
msgbox.exec()
Expand All @@ -213,6 +241,7 @@ def createProfileButtonCallback(self):
if self.ui.string7.text() != "" and self.ui.cooldown7.text() != "" and self.ui.cooldown1.text().isnumeric(): dbcursor.execute(f'''INSERT INTO 'profile_{_uuid}' VALUES('{str(self.ui.string7.text())}', '{int(self.ui.cooldown7.text())}')''')
if self.ui.string8.text() != "" and self.ui.cooldown8.text() != "" and self.ui.cooldown1.text().isnumeric(): dbcursor.execute(f'''INSERT INTO 'profile_{_uuid}' VALUES('{str(self.ui.string8.text())}', '{int(self.ui.cooldown8.text())}')''')
if self.ui.string9.text() != "" and self.ui.cooldown9.text() != "" and self.ui.cooldown1.text().isnumeric(): dbcursor.execute(f'''INSERT INTO 'profile_{_uuid}' VALUES('{str(self.ui.string9.text())}', '{int(self.ui.cooldown9.text())}')''')
#if self.ui.shortcut.keySequence().toString().split(',')[0] != "": dbcursor.execute(f'''INSERT INTO 'profilesData' VALUES('', '', '')''')

db.commit()
updateProfiles()
Expand Down Expand Up @@ -242,7 +271,7 @@ def _show(self):

def deleteButtonCallback(self):
msgbox = QMessageBox()
msgbox.setText(f"Вы действительно хотите удалить {self.ui.listWidget.currentItem().text()}?")
msgbox.setText(f"Вы действительно хотите удалить профиль {self.ui.listWidget.currentItem().text()}?")
msgbox.setWindowTitle(f"ArciBinder")
msgbox.setIcon(QMessageBox.Icon.Question)
msgbox.setStandardButtons(QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No)
Expand Down
2 changes: 1 addition & 1 deletion mainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def setupUi(self, MainWindow):
self.title.setFont(font)
self.title.setLayoutDirection(QtCore.Qt.LayoutDirection.LeftToRight)
self.title.setStyleSheet("QLabel {\n"
" color: #fefefe;\n"
" color: rgb(220, 220, 220)\n"
"}")
self.title.setObjectName("title")
self.editProfileButton = QtWidgets.QPushButton(self.centralwidget)
Expand Down
2 changes: 1 addition & 1 deletion profileDeleteWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def setupUi(self, ProfileDeleteWindow):
self.centralwidget = QtWidgets.QWidget(ProfileDeleteWindow)
self.centralwidget.setObjectName("centralwidget")
self.listWidget = QtWidgets.QListWidget(self.centralwidget)
self.listWidget.setGeometry(QtCore.QRect(10, 40, 361, 321))
self.listWidget.setGeometry(QtCore.QRect(10, 40, 361, 311))
self.listWidget.setObjectName("listWidget")
self.deleteProfileButton = QtWidgets.QPushButton(self.centralwidget)
self.deleteProfileButton.setGeometry(QtCore.QRect(130, 360, 121, 31))
Expand Down
52 changes: 34 additions & 18 deletions profileEditWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class Ui_ProfileEditWindow(object):
def setupUi(self, ProfileEditWindow):
ProfileEditWindow.setObjectName("ProfileEditWindow")
ProfileEditWindow.resize(941, 411)
ProfileEditWindow.resize(946, 417)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/resources/logo.ico"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
ProfileEditWindow.setWindowIcon(icon)
Expand Down Expand Up @@ -49,7 +49,7 @@ def setupUi(self, ProfileEditWindow):
self.centralwidget = QtWidgets.QWidget(ProfileEditWindow)
self.centralwidget.setObjectName("centralwidget")
self.label_8 = QtWidgets.QLabel(self.centralwidget)
self.label_8.setGeometry(QtCore.QRect(30, 210, 21, 31))
self.label_8.setGeometry(QtCore.QRect(30, 200, 21, 31))
font = QtGui.QFont()
font.setFamily("Rubik")
font.setPointSize(11)
Expand Down Expand Up @@ -189,7 +189,7 @@ def setupUi(self, ProfileEditWindow):
self.group8.setStretch(0, 4)
self.group8.setStretch(1, 1)
self.label_6 = QtWidgets.QLabel(self.centralwidget)
self.label_6.setGeometry(QtCore.QRect(30, 150, 21, 31))
self.label_6.setGeometry(QtCore.QRect(30, 140, 21, 31))
font = QtGui.QFont()
font.setFamily("Rubik")
font.setPointSize(11)
Expand All @@ -198,16 +198,20 @@ def setupUi(self, ProfileEditWindow):
self.label_6.setFont(font)
self.label_6.setObjectName("label_6")
self.label_2 = QtWidgets.QLabel(self.centralwidget)
self.label_2.setGeometry(QtCore.QRect(710, 40, 201, 16))
self.label_2.setGeometry(QtCore.QRect(720, 40, 191, 20))
font = QtGui.QFont()
font.setFamily("Rubik")
font.setPointSize(10)
font.setBold(False)
font.setWeight(50)
self.label_2.setFont(font)
self.label_2.setStyleSheet("QLabel {\n"
" color: rgb(220, 220, 220)\n"
"}")
self.label_2.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
self.label_2.setObjectName("label_2")
self.label_4 = QtWidgets.QLabel(self.centralwidget)
self.label_4.setGeometry(QtCore.QRect(30, 90, 21, 31))
self.label_4.setGeometry(QtCore.QRect(30, 80, 21, 31))
font = QtGui.QFont()
font.setFamily("Rubik")
font.setPointSize(11)
Expand All @@ -216,7 +220,7 @@ def setupUi(self, ProfileEditWindow):
self.label_4.setFont(font)
self.label_4.setObjectName("label_4")
self.label_3 = QtWidgets.QLabel(self.centralwidget)
self.label_3.setGeometry(QtCore.QRect(30, 60, 21, 31))
self.label_3.setGeometry(QtCore.QRect(30, 50, 21, 31))
font = QtGui.QFont()
font.setFamily("Rubik")
font.setPointSize(11)
Expand Down Expand Up @@ -285,7 +289,7 @@ def setupUi(self, ProfileEditWindow):
self.group7.setStretch(0, 4)
self.group7.setStretch(1, 1)
self.label_9 = QtWidgets.QLabel(self.centralwidget)
self.label_9.setGeometry(QtCore.QRect(30, 240, 21, 31))
self.label_9.setGeometry(QtCore.QRect(30, 230, 21, 31))
font = QtGui.QFont()
font.setFamily("Rubik")
font.setPointSize(11)
Expand All @@ -294,7 +298,7 @@ def setupUi(self, ProfileEditWindow):
self.label_9.setFont(font)
self.label_9.setObjectName("label_9")
self.label_11 = QtWidgets.QLabel(self.centralwidget)
self.label_11.setGeometry(QtCore.QRect(30, 300, 21, 31))
self.label_11.setGeometry(QtCore.QRect(30, 290, 21, 31))
font = QtGui.QFont()
font.setFamily("Rubik")
font.setPointSize(11)
Expand All @@ -303,16 +307,20 @@ def setupUi(self, ProfileEditWindow):
self.label_11.setFont(font)
self.label_11.setObjectName("label_11")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(330, 40, 51, 16))
self.label.setGeometry(QtCore.QRect(320, 40, 61, 16))
font = QtGui.QFont()
font.setFamily("Rubik")
font.setPointSize(12)
font.setBold(False)
font.setWeight(50)
self.label.setFont(font)
self.label.setStyleSheet("QLabel {\n"
" color: rgb(220, 220, 220)\n"
"}")
self.label.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
self.label.setObjectName("label")
self.label_10 = QtWidgets.QLabel(self.centralwidget)
self.label_10.setGeometry(QtCore.QRect(30, 270, 21, 31))
self.label_10.setGeometry(QtCore.QRect(30, 260, 21, 31))
font = QtGui.QFont()
font.setFamily("Rubik")
font.setPointSize(11)
Expand All @@ -321,7 +329,7 @@ def setupUi(self, ProfileEditWindow):
self.label_10.setFont(font)
self.label_10.setObjectName("label_10")
self.label_5 = QtWidgets.QLabel(self.centralwidget)
self.label_5.setGeometry(QtCore.QRect(30, 120, 21, 31))
self.label_5.setGeometry(QtCore.QRect(30, 110, 21, 31))
font = QtGui.QFont()
font.setFamily("Rubik")
font.setPointSize(11)
Expand All @@ -330,7 +338,7 @@ def setupUi(self, ProfileEditWindow):
self.label_5.setFont(font)
self.label_5.setObjectName("label_5")
self.label_7 = QtWidgets.QLabel(self.centralwidget)
self.label_7.setGeometry(QtCore.QRect(30, 180, 21, 31))
self.label_7.setGeometry(QtCore.QRect(30, 170, 21, 31))
font = QtGui.QFont()
font.setFamily("Rubik")
font.setPointSize(11)
Expand Down Expand Up @@ -429,30 +437,38 @@ def setupUi(self, ProfileEditWindow):
self.group3.setStretch(0, 4)
self.group3.setStretch(1, 1)
self.shortcutlabel = QtWidgets.QLabel(self.centralwidget)
self.shortcutlabel.setGeometry(QtCore.QRect(70, 350, 161, 16))
self.shortcutlabel.setGeometry(QtCore.QRect(70, 340, 161, 21))
font = QtGui.QFont()
font.setFamily("Rubik")
font.setPointSize(14)
self.shortcutlabel.setFont(font)
self.shortcutlabel.setStyleSheet("QLabel {\n"
" color: rgb(220, 220, 220)\n"
"}")
self.shortcutlabel.setObjectName("shortcutlabel")
self.shortcut = QtWidgets.QKeySequenceEdit(self.centralwidget)
self.shortcut.setGeometry(QtCore.QRect(110, 370, 71, 21))
self.shortcut.setGeometry(QtCore.QRect(70, 370, 151, 21))
font = QtGui.QFont()
font.setFamily("Rubik")
font.setPointSize(10)
self.shortcut.setFont(font)
self.shortcut.setToolTip("")
self.shortcut.setLocale(QtCore.QLocale(QtCore.QLocale.Language.Russian, QtCore.QLocale.Country.Russia))
self.shortcut.setKeySequence("")
self.shortcut.setObjectName("shortcut")
self.profileName = QtWidgets.QLineEdit(self.centralwidget)
self.profileName.setGeometry(QtCore.QRect(430, 370, 181, 21))
self.profileName.setGeometry(QtCore.QRect(400, 370, 161, 21))
self.profileName.setText("")
self.profileName.setObjectName("profileName")
self.profiileNameLabel = QtWidgets.QLabel(self.centralwidget)
self.profiileNameLabel.setGeometry(QtCore.QRect(470, 350, 101, 16))
self.profiileNameLabel.setGeometry(QtCore.QRect(390, 341, 191, 20))
font = QtGui.QFont()
font.setFamily("Rubik")
font.setPointSize(14)
self.profiileNameLabel.setFont(font)
self.profiileNameLabel.setStyleSheet("QLabel {\n"
" color: rgb(220, 220, 220)\n"
"}")
self.profiileNameLabel.setObjectName("profiileNameLabel")
self.closeButton = QtWidgets.QPushButton(self.centralwidget)
self.closeButton.setGeometry(QtCore.QRect(900, 10, 31, 21))
Expand Down Expand Up @@ -480,7 +496,7 @@ def setupUi(self, ProfileEditWindow):
self.title.setFont(font)
self.title.setLayoutDirection(QtCore.Qt.LayoutDirection.LeftToRight)
self.title.setStyleSheet("QLabel {\n"
" color: #fefefe;\n"
" color: rgb(220, 220, 220)\n"
"}")
self.title.setObjectName("title")
ProfileEditWindow.setCentralWidget(self.centralwidget)
Expand Down Expand Up @@ -520,7 +536,7 @@ def retranslateUi(self, ProfileEditWindow):
self.cooldown2.setText(_translate("ProfileEditWindow", "0"))
self.cooldown3.setText(_translate("ProfileEditWindow", "0"))
self.shortcutlabel.setText(_translate("ProfileEditWindow", "Горячая клавиша"))
self.profiileNameLabel.setText(_translate("ProfileEditWindow", " Название"))
self.profiileNameLabel.setText(_translate("ProfileEditWindow", " Название профиля"))
self.closeButton.setText(_translate("ProfileEditWindow", "X"))
self.minimizeButton.setText(_translate("ProfileEditWindow", "_"))
self.title.setText(_translate("ProfileEditWindow", "<html><head/><body><p>Редактор профиля</p></body></html>"))
Expand Down
8 changes: 4 additions & 4 deletions profileListWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class Ui_ProfileListWindow(object):
def setupUi(self, ProfileListWindow):
ProfileListWindow.setObjectName("ProfileListWindow")
ProfileListWindow.resize(378, 411)
ProfileListWindow.resize(378, 415)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/resources/logo.ico"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
ProfileListWindow.setWindowIcon(icon)
Expand Down Expand Up @@ -49,10 +49,10 @@ def setupUi(self, ProfileListWindow):
self.centralwidget = QtWidgets.QWidget(ProfileListWindow)
self.centralwidget.setObjectName("centralwidget")
self.listWidget = QtWidgets.QListWidget(self.centralwidget)
self.listWidget.setGeometry(QtCore.QRect(10, 40, 361, 321))
self.listWidget.setGeometry(QtCore.QRect(10, 40, 361, 311))
self.listWidget.setObjectName("listWidget")
self.editProfileButton = QtWidgets.QPushButton(self.centralwidget)
self.editProfileButton.setGeometry(QtCore.QRect(110, 360, 181, 31))
self.editProfileButton.setGeometry(QtCore.QRect(120, 360, 161, 31))
font = QtGui.QFont()
font.setFamily("Rubik")
font.setPointSize(14)
Expand Down Expand Up @@ -85,7 +85,7 @@ def setupUi(self, ProfileListWindow):
self.title.setFont(font)
self.title.setLayoutDirection(QtCore.Qt.LayoutDirection.LeftToRight)
self.title.setStyleSheet("QLabel {\n"
" color: #fefefe;\n"
" color: rgb(220, 220, 220)\n"
"}")
self.title.setObjectName("title")
ProfileListWindow.setCentralWidget(self.centralwidget)
Expand Down
2 changes: 1 addition & 1 deletion ui/mainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ QListWidget {
</property>
<property name="styleSheet">
<string notr="true">QLabel {
color: #fefefe;
color: rgb(220, 220, 220)
}</string>
</property>
<property name="text">
Expand Down
4 changes: 2 additions & 2 deletions ui/profileDeleteWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<string>Удаление профиля</string>
</property>
<property name="windowIcon">
<iconset resource="resources.qrc">
<iconset>
<normaloff>:/resources/logo.ico</normaloff>:/resources/logo.ico</iconset>
</property>
<property name="styleSheet">
Expand Down Expand Up @@ -56,7 +56,7 @@ QListWidget {
<x>10</x>
<y>40</y>
<width>361</width>
<height>321</height>
<height>311</height>
</rect>
</property>
</widget>
Expand Down
Loading

0 comments on commit 830f524

Please sign in to comment.