Skip to content

Commit

Permalink
UI optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
royshil committed Jun 16, 2024
1 parent a01ecd0 commit bae689a
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 40 deletions.
40 changes: 36 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
QLocale,
QObject,
QCoreApplication,
QEvent,
)
from dotenv import load_dotenv
from os import path
Expand Down Expand Up @@ -104,8 +105,8 @@ def __init__(self, translator: QTranslator, parent: QObject):
)
)

menubar = self.menuBar()
file_menu = menubar.addMenu("File")
self.menubar = self.menuBar()
file_menu = self.menubar.addMenu("File")

# check for updates
check_for_updates(False)
Expand Down Expand Up @@ -133,6 +134,12 @@ def __init__(self, translator: QTranslator, parent: QObject):
self.addLanguageOption(languageMenu, "Russian", "ru_RU")
self.addLanguageOption(languageMenu, "Chinese (Simplified)", "zh_CN")

# Hide the menu bar by default
self.menubar.setVisible(False)

# Show the menu bar when the Alt key is pressed
self.installEventFilter(self)

self.ui.pushButton_connectObs.clicked.connect(self.openOBSConnectModal)
self.ui.statusbar.showMessage("OBS: Not Connected")

Expand Down Expand Up @@ -311,6 +318,25 @@ def __init__(self, translator: QTranslator, parent: QObject):
self.get_sources.connect(self.getSources)
self.get_sources.emit()

def eventFilter(self, obj, event):
if event.type() == QEvent.KeyPress and event.key() == Qt.Key_Alt:
self.menubar.setVisible(True)
elif event.type() == QEvent.FocusOut and self.menubar.isVisible():
self.menubar.setVisible(False)
elif event.type() == QEvent.WindowDeactivate and self.menubar.isVisible():
self.menubar.setVisible(False)
return super().eventFilter(obj, event)

def focusOutEvent(self, event):
if self.menubar.isVisible():
self.menubar.setVisible(False)
super().focusOutEvent(event)

def changeEvent(self, event):
if event.type() == QEvent.WindowDeactivate and self.menubar.isVisible():
self.menubar.setVisible(False)
super().changeEvent(event)

def changeLanguage(self, locale):
locale_file = path.abspath(
path.join(path.dirname(__file__), "translations", f"scoresight_{locale}.qm")
Expand Down Expand Up @@ -441,11 +467,17 @@ def toggleStabilize(self):
# self.ui.pushButton_starthttpserver.setText("🛑 Stop the server")

def toggleStopUpdates(self, value):
self.ui.statusbar.showMessage("Stopped updates" if value else "Resumed updates")
self.ui.statusbar.showMessage(
self.translator.translate("main", "Stopped updates")
if value
else self.translator.translate("main", "Resumed updates")
)
self.updateOCRResults = not value
# change the text on the button
self.ui.pushButton_stopUpdates.setText(
"▶️ Resume updates" if value else "🛑 Stop updates"
self.translator.translate("main", "Resume updates")
if value
else self.translator.translate("main", "Stop updates")
)

def selectOutputFolder(self):
Expand Down
32 changes: 17 additions & 15 deletions mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>961</width>
<height>858</height>
<height>720</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -37,7 +37,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>12</number>
<number>3</number>
</property>
<item>
<widget class="QWidget" name="groupBox_sb_info" native="true">
Expand Down Expand Up @@ -160,7 +160,6 @@
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
Expand All @@ -180,7 +179,6 @@
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
Expand Down Expand Up @@ -238,18 +236,15 @@
</item>
<item>
<widget class="QGroupBox" name="groupBox_target_settings">
<property name="title">
<string>Target Information Settings</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="spacing">
<number>2</number>
</property>
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>3</number>
Expand All @@ -267,7 +262,7 @@
</property>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<property name="spacing">
<number>0</number>
<number>3</number>
</property>
<property name="leftMargin">
<number>0</number>
Expand All @@ -281,6 +276,13 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Target:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_selectedInfo">
<property name="text">
Expand Down Expand Up @@ -945,7 +947,7 @@
</attribute>
<layout class="QFormLayout" name="formLayout_2">
<property name="verticalSpacing">
<number>2</number>
<number>3</number>
</property>
<property name="bottomMargin">
<number>0</number>
Expand Down Expand Up @@ -1119,7 +1121,7 @@
<item alignment="Qt::AlignTop">
<widget class="QLabel" name="label_8">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;HTML Scoreboard: &lt;a href=&quot;http://localhost:18099/scoresight&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;http://localhost:18099/scoresight&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;JSON: &lt;a href=&quot;http://localhost:18099/json&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;http://localhost:18099/json&lt;/span&gt;&lt;/a&gt; (optional: ?pivot)&lt;/p&gt;&lt;p&gt;XML: &lt;a href=&quot;http://localhost:18099/xml&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;http://localhost:18099/xml&lt;/span&gt;&lt;/a&gt; (optional: ?pivot)&lt;/p&gt;&lt;p&gt;CSV: &lt;a href=&quot;http://localhost:18099/csv&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;http://localhost:18099/csv&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;HTML Scoreboard: &lt;a href=&quot;http://localhost:18099/scoresight&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;http://localhost:18099/scoresight&lt;br/&gt;&lt;/span&gt;&lt;/a&gt;JSON: &lt;a href=&quot;http://localhost:18099/json&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;http://localhost:18099/json&lt;/span&gt;&lt;/a&gt; (optional: ?pivot)&lt;br/&gt;XML: &lt;a href=&quot;http://localhost:18099/xml&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;http://localhost:18099/xml&lt;/span&gt;&lt;/a&gt; (optional: ?pivot)&lt;br/&gt;CSV: &lt;a href=&quot;http://localhost:18099/csv&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;http://localhost:18099/csv&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
Expand Down Expand Up @@ -1781,7 +1783,7 @@
<x>0</x>
<y>0</y>
<width>961</width>
<height>21</height>
<height>20</height>
</rect>
</property>
</widget>
Expand Down
10 changes: 5 additions & 5 deletions translations/scoresight_nl_NL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@
<message>
<location filename="../mainwindow.ui" line="425"/>
<source>Select Preset</source>
<translation>Preset selecteren</translation>
<translation>Selecteren voorkeuze</translation>
</message>
<message>
<location filename="../mainwindow.ui" line="454"/>
Expand Down Expand Up @@ -268,7 +268,7 @@
<message>
<location filename="../mainwindow.ui" line="514"/>
<source>Ordinal (1st, 2nd, ..)</source>
<translation>Ordinaal (1e, 2e, ..)</translation>
<translation>Volgorde (1e, 2e, ..)</translation>
</message>
<message>
<location filename="../mainwindow.ui" line="545"/>
Expand All @@ -293,7 +293,7 @@
<message>
<location filename="../mainwindow.ui" line="603"/>
<source>Remove leading 0s</source>
<translation>Leidende nullen verwijderen</translation>
<translation>Eerste nul verwijderen</translation>
</message>
<message>
<location filename="../mainwindow.ui" line="628"/>
Expand Down Expand Up @@ -338,7 +338,7 @@
<message>
<location filename="../mainwindow.ui" line="692"/>
<source>Adaptive</source>
<translation>Adaptief</translation>
<translation>Aanpasbaar</translation>
</message>
<message>
<location filename="../mainwindow.ui" line="727"/>
Expand All @@ -353,7 +353,7 @@
<message>
<location filename="../mainwindow.ui" line="794"/>
<source>Dilate</source>
<translation>Dilateren</translation>
<translation>Verbreden</translation>
</message>
<message>
<location filename="../mainwindow.ui" line="814"/>
Expand Down
2 changes: 1 addition & 1 deletion ui_about.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
################################################################################
## Form generated from reading UI file 'about.ui'
##
## Created by: Qt User Interface Compiler version 6.7.0
## Created by: Qt User Interface Compiler version 6.7.1
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
Expand Down
2 changes: 1 addition & 1 deletion ui_connect_obs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
################################################################################
## Form generated from reading UI file 'connect_obs.ui'
##
## Created by: Qt User Interface Compiler version 6.7.0
## Created by: Qt User Interface Compiler version 6.7.1
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
Expand Down
2 changes: 1 addition & 1 deletion ui_log_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
################################################################################
## Form generated from reading UI file 'log_view.ui'
##
## Created by: Qt User Interface Compiler version 6.7.0
## Created by: Qt User Interface Compiler version 6.7.1
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
Expand Down
25 changes: 15 additions & 10 deletions ui_mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
################################################################################
## Form generated from reading UI file 'mainwindow.ui'
##
## Created by: Qt User Interface Compiler version 6.7.0
## Created by: Qt User Interface Compiler version 6.7.1
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
Expand All @@ -27,7 +27,7 @@ class Ui_MainWindow(object):
def setupUi(self, MainWindow):
if not MainWindow.objectName():
MainWindow.setObjectName(u"MainWindow")
MainWindow.resize(961, 858)
MainWindow.resize(961, 720)
self.centralwidget = QWidget(MainWindow)
self.centralwidget.setObjectName(u"centralwidget")
self.horizontalLayout = QHBoxLayout(self.centralwidget)
Expand All @@ -44,7 +44,7 @@ def setupUi(self, MainWindow):
self.frame.setFrameShadow(QFrame.Plain)
self.frame.setLineWidth(0)
self.verticalLayout = QVBoxLayout(self.frame)
self.verticalLayout.setSpacing(12)
self.verticalLayout.setSpacing(3)
self.verticalLayout.setObjectName(u"verticalLayout")
self.groupBox_sb_info = QWidget(self.frame)
self.groupBox_sb_info.setObjectName(u"groupBox_sb_info")
Expand Down Expand Up @@ -137,10 +137,10 @@ def setupUi(self, MainWindow):

self.groupBox_target_settings = QGroupBox(self.groupBox_sb_info)
self.groupBox_target_settings.setObjectName(u"groupBox_target_settings")
self.groupBox_target_settings.setCheckable(False)
self.verticalLayout_5 = QVBoxLayout(self.groupBox_target_settings)
self.verticalLayout_5.setSpacing(2)
self.verticalLayout_5.setObjectName(u"verticalLayout_5")
self.verticalLayout_5.setContentsMargins(3, 3, 3, 3)
self.verticalLayout_5.setContentsMargins(3, 0, 3, 3)
self.widget_10 = QWidget(self.groupBox_target_settings)
self.widget_10.setObjectName(u"widget_10")
sizePolicy2 = QSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Preferred)
Expand All @@ -149,9 +149,14 @@ def setupUi(self, MainWindow):
sizePolicy2.setHeightForWidth(self.widget_10.sizePolicy().hasHeightForWidth())
self.widget_10.setSizePolicy(sizePolicy2)
self.horizontalLayout_12 = QHBoxLayout(self.widget_10)
self.horizontalLayout_12.setSpacing(0)
self.horizontalLayout_12.setSpacing(3)
self.horizontalLayout_12.setObjectName(u"horizontalLayout_12")
self.horizontalLayout_12.setContentsMargins(0, 0, 0, 0)
self.label_6 = QLabel(self.widget_10)
self.label_6.setObjectName(u"label_6")

self.horizontalLayout_12.addWidget(self.label_6)

self.label_selectedInfo = QLabel(self.widget_10)
self.label_selectedInfo.setObjectName(u"label_selectedInfo")

Expand Down Expand Up @@ -491,7 +496,7 @@ def setupUi(self, MainWindow):
self.tab_textFiles.setSizePolicy(sizePolicy3)
self.formLayout_2 = QFormLayout(self.tab_textFiles)
self.formLayout_2.setObjectName(u"formLayout_2")
self.formLayout_2.setVerticalSpacing(2)
self.formLayout_2.setVerticalSpacing(0)
self.formLayout_2.setContentsMargins(-1, -1, -1, 0)
self.label_7 = QLabel(self.tab_textFiles)
self.label_7.setObjectName(u"label_7")
Expand Down Expand Up @@ -917,7 +922,7 @@ def setupUi(self, MainWindow):
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QMenuBar(MainWindow)
self.menubar.setObjectName(u"menubar")
self.menubar.setGeometry(QRect(0, 0, 961, 21))
self.menubar.setGeometry(QRect(0, 0, 961, 20))
MainWindow.setMenuBar(self.menubar)
self.statusbar = QStatusBar(MainWindow)
self.statusbar.setObjectName(u"statusbar")
Expand All @@ -942,7 +947,7 @@ def retranslateUi(self, MainWindow):
self.toolButton_removeBox.setText(QCoreApplication.translate("MainWindow", u"-", None))
self.pushButton_makeBox.setText(QCoreApplication.translate("MainWindow", u"Add to Scene ->", None))
self.pushButton_removeBox.setText(QCoreApplication.translate("MainWindow", u"Remove Selected", None))
self.groupBox_target_settings.setTitle(QCoreApplication.translate("MainWindow", u"Target Information Settings", None))
self.label_6.setText(QCoreApplication.translate("MainWindow", u"Target:", None))
self.label_selectedInfo.setText(QCoreApplication.translate("MainWindow", u"Select an item above", None))
self.pushButton_restoreDefaults.setText(QCoreApplication.translate("MainWindow", u"Defaults", None))
self.label_2.setText(QCoreApplication.translate("MainWindow", u"Format", None))
Expand Down Expand Up @@ -1008,7 +1013,7 @@ def retranslateUi(self, MainWindow):
#endif // QT_CONFIG(tooltip)
self.label_savePerSec.setText(QCoreApplication.translate("MainWindow", u"Save / s", None))
self.tabWidget_outputs.setTabText(self.tabWidget_outputs.indexOf(self.tab_textFiles), QCoreApplication.translate("MainWindow", u"Text Files", None))
self.label_8.setText(QCoreApplication.translate("MainWindow", u"<html><head/><body><p>HTML Scoreboard: <a href=\"http://localhost:18099/scoresight\"><span style=\" text-decoration: underline; color:#0000ff;\">http://localhost:18099/scoresight</span></a></p><p>JSON: <a href=\"http://localhost:18099/json\"><span style=\" text-decoration: underline; color:#0000ff;\">http://localhost:18099/json</span></a> (optional: ?pivot)</p><p>XML: <a href=\"http://localhost:18099/xml\"><span style=\" text-decoration: underline; color:#0000ff;\">http://localhost:18099/xml</span></a> (optional: ?pivot)</p><p>CSV: <a href=\"http://localhost:18099/csv\"><span style=\" text-decoration: underline; color:#0000ff;\">http://localhost:18099/csv</span></a></p></body></html>", None))
self.label_8.setText(QCoreApplication.translate("MainWindow", u"<html><head/><body><p>HTML Scoreboard: <a href=\"http://localhost:18099/scoresight\"><span style=\" text-decoration: underline; color:#0000ff;\">http://localhost:18099/scoresight<br/></span></a>JSON: <a href=\"http://localhost:18099/json\"><span style=\" text-decoration: underline; color:#0000ff;\">http://localhost:18099/json</span></a> (optional: ?pivot)<br/>XML: <a href=\"http://localhost:18099/xml\"><span style=\" text-decoration: underline; color:#0000ff;\">http://localhost:18099/xml</span></a> (optional: ?pivot)<br/>CSV: <a href=\"http://localhost:18099/csv\"><span style=\" text-decoration: underline; color:#0000ff;\">http://localhost:18099/csv</span></a></p></body></html>", None))
self.tabWidget_outputs.setTabText(self.tabWidget_outputs.indexOf(self.tab_browser), QCoreApplication.translate("MainWindow", u"Browser", None))
self.pushButton_connectObs.setText(QCoreApplication.translate("MainWindow", u"Connect OBS", None))
self.lineEdit_sceneName.setText(QCoreApplication.translate("MainWindow", u"ScoreSight Scene", None))
Expand Down
2 changes: 1 addition & 1 deletion ui_screen_capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
################################################################################
## Form generated from reading UI file 'screen_capture.ui'
##
## Created by: Qt User Interface Compiler version 6.7.0
## Created by: Qt User Interface Compiler version 6.7.1
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
Expand Down
2 changes: 1 addition & 1 deletion ui_update_available.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
################################################################################
## Form generated from reading UI file 'update_available.ui'
##
## Created by: Qt User Interface Compiler version 6.7.0
## Created by: Qt User Interface Compiler version 6.7.1
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
Expand Down
2 changes: 1 addition & 1 deletion ui_url_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
################################################################################
## Form generated from reading UI file 'url_source.ui'
##
## Created by: Qt User Interface Compiler version 6.7.0
## Created by: Qt User Interface Compiler version 6.7.1
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
Expand Down

0 comments on commit bae689a

Please sign in to comment.