Skip to content

Commit

Permalink
Fixed bugs, added seperate task name
Browse files Browse the repository at this point in the history
  • Loading branch information
riscyseven committed Apr 30, 2023
1 parent 8a0be2a commit 2a0cace
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 43 deletions.
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PyQt6==6.4.2
PyQt6==6.5.0
requests==2.28.2
pynput==1.7.6
cx-Freeze==6.14.2
cx-Freeze==6.14.9
14 changes: 10 additions & 4 deletions src/attr.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,16 @@ class SettingAttr:
class StartMenuAttr:
NAME = 0
ICON = 1
FILE = 2

templateList = [
{
templateList = {
"New Project": {
NAME: "New Project",
ICON: "src/resources/blank.png",
ICON: "src/resources/blank.png"
},
"General Template": {
NAME: "General Template",
ICON: "src/resources/scoreboard.png",
FILE: "src/resources/premade.json"
}
]
}
2 changes: 1 addition & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
if not DEBUG:
import src
sys.path.append(src.CURR_PATH)
from gm_resources import resourcePath
from gm_resources import resourcePath, GMessageBox
from window.mainwindow import MainWindow
else:
from gm_resources import resourcePath, GMessageBox
Expand Down
4 changes: 2 additions & 2 deletions src/progsetting.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ def getProperties(self) -> Property:
return self.properties


def addRecentlyOpened(self, project, start=False):
def addRecentlyOpened(self, project):
if (exists(project.getFileName())):
if (project.getFileName() in self.recentlyOpened):
self.recentlyOpened.pop(project.getFileName())
self.recentlyOpened[project.getFileName()] = project
if len(self.recentlyOpened) > 10:
self.recentlyOpened.popitem(last=False)
self.recentlyOpened.popitem()


def getRecentlyOpened(self) -> dict:
Expand Down
2 changes: 1 addition & 1 deletion src/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(self, name: str="untitled", author: str="TeleScore"):
self.property["Date"] = ""
self.property["FN"] = ""
self.property["Author"] = getlogin()
self.property["Version"] = "1.0.1 Beta"
self.property["Version"] = "1.0.2 Beta"
self._renameLOCallBack = []
self._renameCompCallBack = []

Expand Down
Binary file added src/resources/scoreboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 14 additions & 7 deletions src/window/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self, project: Project=None, parent=None):
self.cmdStack = QtGui.QUndoStack(self) # Command stack used for undo/redo
self.currComp = None
self.currLO = None

self.tabs = []
self._initUI(project)


Expand Down Expand Up @@ -96,7 +96,7 @@ def _initUI(self, project) -> None:

# This is a bit redundant. If there is a simpler way of doing this, please change it.
self.toolBar.addWidget(QPushButton(QtGui.QIcon(resourcePath("src/resources/icon.ico")),
" TeleScore v1.0.1 Beta"))
" TeleScore v1.0.2 Beta"))
self.toolBar.addSeparator()
self.addTabPushButton = QPushButton("Add Tab")
self.toolBar.addWidget(self.addTabPushButton)
Expand Down Expand Up @@ -201,18 +201,27 @@ def _popOutTab(self, clicked):
tab = self.tabWidget.currentWidget()
self.clearCurrComp()

dialog = TabDialog(tab, self._popOutTabClosed, self)
dialog.setWindowTitle(tab.objectName())
dialog.show()
newTab = TabDialog(tab, self._popOutTabClosed, None)
newTab.setWindowTitle(tab.objectName())
newTab.show()

tab.setVisible(True)
self._refreshTabButton()

self.tabs.append(newTab)


def _popOutTabClosed(self, tab):
self.clearCurrComp()
self.tabWidget.addTab(tab.getTab(), tab.getTab().objectName())
self._refreshTabButton()
self.tabs.remove(tab)


def removeTabs(self):
for dialog in self.tabs:
dialog.deleteLater()
self.tabs = []


def _refreshTabButton(self):
Expand Down Expand Up @@ -328,7 +337,6 @@ def keyPressEvent(self, evt: QtGui.QKeyEvent) -> None:
match evt.key():
case Qt.Key.Key_S:
self.saveAction()

evt.accept()


Expand All @@ -338,5 +346,4 @@ def closingDialog(self) -> bool:
self.saveAction()
elif (dialog.getCode() == dialog.CANCEL):
return False

return True
22 changes: 13 additions & 9 deletions src/window/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def _initUI(self):

# Setting up the toolbar
self.toolBar.addWidget(QtWidgets.QPushButton(QIcon(resourcePath("src/resources/icon.ico")),
" TeleScore v1.0.1 Beta"))
" TeleScore v1.0.2 Beta"))
self.toolBar.addSeparator()
self.editModeButton = QtWidgets.QPushButton("Editor Mode")
self.toolBar.addWidget(self.editModeButton)
Expand Down Expand Up @@ -74,8 +74,6 @@ def _initUI(self):

self.toolBar.setVisible(False)

#self.editor = Editor()
#self.setCentralWidget(self.editor)
self.startMenu = StartMenu(self._newTriggered, self._openTriggered)
self.setCentralWidget(self.startMenu)
self._windowChanged()
Expand Down Expand Up @@ -195,13 +193,15 @@ def _editModeClicked(self):


def _createNewDialog(self, tab):
dialog = TabDialog(tab, self._popOutTabClosed, self)
dialog = TabDialog(tab, self._popOutTabClosed, None)
dialog.setWindowTitle(tab.objectName())
dialog.show()
self.dialogs.append(dialog)


def _removeAllDialog(self):
if (self.editor != None):
self.editor.removeTabs()
for dialog in self.dialogs:
dialog.deleteLater()
self.dialogs = []
Expand All @@ -226,11 +226,15 @@ def _popOutTabClosed(self, tab):

def closeEvent(self, evt) -> None:
StartFile().save()
if (self.editor != None):
if (self.editor.closingDialog()):
evt.accept()
else:
evt.ignore()
if (self.editor == None):
self._removeAllDialog()
return

if (self.editor.closingDialog()):
evt.accept()
self._removeAllDialog()
else:
evt.ignore()


def _windowChanged(self):
Expand Down
26 changes: 12 additions & 14 deletions src/window/startmenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def __init__(self, newCallBack, openCallBack, parent=None):
super().__init__(parent) # Call the inherited classes __init__ method
self.newCallBack = newCallBack
self.openCallBack = openCallBack
self.templateMap = {}
self._initUI()


Expand Down Expand Up @@ -43,17 +44,16 @@ def _loadStartFile(self):
:param: none
:return: none
"""
try:
raise Exception
except:
self.templateList = StartMenuAttr.templateList

self.templateList = StartMenuAttr.templateList
self._loadTemplates()
self._loadRecent()


def _newTemplateClicked(self, item: QListWidgetItem):
self.newCallBack()
if (item.text() == "New Project"):
self.newCallBack()
else:
self.openCallBack(None, StartMenuAttr.templateList[item.text()][StartMenuAttr.FILE])


def _openTemplateClicked(self, item: QTreeWidgetItem):
Expand All @@ -68,20 +68,20 @@ def resizeEvent(self, evt):
:param evt: resize event information
:return: none
"""
width = int(self.treeWidget.width()/self.treeWidget.columnCount())
width = int(self.treeWidget.width() / self.treeWidget.columnCount())

for i in range(self.treeWidget.columnCount()):
self.treeWidget.header().resizeSection(i, width)


def _loadTemplates(self) -> None:
def _loadTemplates(self):
"""
Loads the templates into the start menu
:param templates: dictionary of templates
:return: none
"""
for value in self.templateList:
for value in self.templateList.values():
try:
self.listWidget.addItem(QListWidgetItem(QIcon(resourcePath(value[StartMenuAttr.ICON])),
value[StartMenuAttr.NAME]))
Expand All @@ -105,11 +105,9 @@ def _loadRecent(self) -> None:
setting = ProgSetting()
for proj in setting.getRecentlyOpened().values():
item = QTreeWidgetItem()
item.setTextAlignment(0, Qt.AlignmentFlag.AlignCenter)
item.setTextAlignment(1, Qt.AlignmentFlag.AlignCenter)
item.setTextAlignment(2, Qt.AlignmentFlag.AlignCenter)
item.setTextAlignment(3, Qt.AlignmentFlag.AlignCenter)
item.setTextAlignment(4, Qt.AlignmentFlag.AlignCenter)
for i in range(4):
item.setTextAlignment(4, Qt.AlignmentFlag.AlignCenter)

tempProj = proj.getProperty()

item.setText(0, tempProj["Name"])
Expand Down
4 changes: 4 additions & 0 deletions src/window/tabdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from PyQt6.QtWidgets import QDialog
from PyQt6 import uic
from PyQt6.QtGui import QIcon
from PyQt6.QtCore import Qt

from gm_resources import resourcePath
Expand All @@ -16,15 +17,18 @@ def __init__(self, tab, callBack, parent=None):
uic.loadUi(resourcePath("src/window/ui/tabdialog.ui"), self) # Load the .ui file
self.layout().addWidget(tab)
self._tab = tab
self.setWindowIcon(QIcon(resourcePath("src/resources/icon.ico")))
self.setWindowFlag(Qt.WindowType.WindowMaximizeButtonHint, True)
self.setWindowFlag(Qt.WindowType.WindowMinimizeButtonHint, True)
self.setWindowFlag(Qt.WindowType.WindowCloseButtonHint, True)
self._callBack = callBack
self.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose, True)


def getTab(self):
return self._tab


def closeEvent(self, event):
self._callBack(self)
event.accept()
Expand Down
9 changes: 6 additions & 3 deletions src/window/ui/about.ui
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</font>
</property>
<property name="text">
<string>Version: 1.0.1 Beta</string>
<string>Version: 1.0.2 Beta</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
Expand Down Expand Up @@ -67,7 +67,10 @@
</font>
</property>
<property name="text">
<string>JumpShot team is composed of: riscyseven, TheLittleDoc, Fisk31, controldelta, Glenn</string>
<string>JumpShot team is composed of: riscyseven, TheLittleDoc, Fisk31, controldelta, SPCCleveland9035</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
Expand All @@ -79,7 +82,7 @@
</font>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:14pt;&quot;&gt;Discord/Support/Community/Resource: &lt;/span&gt;&lt;a href=&quot;https://discord.gg/q9NwK8XAAK&quot;&gt;&lt;span style=&quot; font-size:14pt; text-decoration: underline; color:#007af4;&quot;&gt;Link&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;&lt;span style=&quot; font-size:14pt;&quot;&gt;Discord/Support/Community/Resource: &lt;/span&gt;&lt;a href=&quot;https://discord.telescore.live/&quot;&gt;&lt;span style=&quot; font-size:14pt; text-decoration: underline; color:#007af4;&quot;&gt;Link&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
Expand Down

0 comments on commit 2a0cace

Please sign in to comment.