Skip to content

Commit

Permalink
Added dimensions save function
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitnitsky committed May 17, 2019
1 parent 9979fa3 commit 3b69b97
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 6 deletions.
File renamed without changes.
13 changes: 11 additions & 2 deletions Ui_main_ui_eng.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@

class Ui_MainWindow(object):
def setupUi(self, MainWindow):
width, height = loadDimensions()
MainWindow.setObjectName("MainWindow")
MainWindow.resize(1696, 601)
MainWindow.resize(width, height)
MainWindow.setLayoutDirection(QtCore.Qt.RightToLeft)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
Expand Down Expand Up @@ -804,4 +805,12 @@ def retranslateUi(self, MainWindow):
self.actionUpdate_Courses_DB.setText(_translate("MainWindow", "Update Courses"))
self.actionInfo.setText(_translate("MainWindow", "Info"))


def loadDimensions():
try:
filename = open("dimensions.cfg", "r")
width = filename.readline()
height = filename.readline()
filename.close()
return int(width.split("=")[1]), int(height.split("=")[1])
except (FileNotFoundError, ValueError):
return 1320,565
14 changes: 12 additions & 2 deletions Ui_main_ui_heb.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@

class Ui_MainWindow(object):
def setupUi(self, MainWindow):
width, height = loadDimensions()
MainWindow.setObjectName("MainWindow")
MainWindow.resize(1696, 601)
MainWindow.resize(width, height)
MainWindow.setLayoutDirection(QtCore.Qt.RightToLeft)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
Expand Down Expand Up @@ -822,4 +823,13 @@ def createRemoveLineButton(line):
"Form",
"<html><head/><body><p><span style=\" font-size:12pt; font-weight:600;\">איפוס שורה</span></p></body></html>"
))
return semester_table_remove_line
return semester_table_remove_line

def loadDimensions():
try:
file = open("dimensions.cfg", "r")
width = file.readline()
height = file.readline()
return int(width.split("=")[1]), int(height.split("=")[1])
except FileNotFoundError:
return 1320,565
2 changes: 2 additions & 0 deletions dimensions.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
width=1542
height=697
2 changes: 1 addition & 1 deletion lng.cfg
Original file line number Diff line number Diff line change
@@ -1 +1 @@
language=heb
language=eng
11 changes: 10 additions & 1 deletion logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def __init__(self):
self.addSemester()
self.saved = True
except FileNotFoundError:
if self.ui.courses_tab_widget.count() == 0:
self.addSemester()
self.update_allowed = True
self.saved = True
pass
Expand Down Expand Up @@ -82,8 +84,15 @@ def closeEvent(self, event):
return
if self.searchWindow:
self.searchWindow.close()
self.saveWindowDimensions()
return super().closeEvent(event)

def saveWindowDimensions(self):
filename = open("dimensions.cfg", "w+")
filename.write("width="+str(self.width())+"\n")
filename.write("height="+str(self.height())+"\n")


def loadLanguage(self):
try:
filename = open("lng.cfg", "r")
Expand Down Expand Up @@ -791,7 +800,7 @@ def removeSemester(self, i, force=False):
if not self.checkIfRowIsEmpty(table, row):
emptySemester = False
break
if force or emptySemester or (self.english_ui and self.my_close("semester", "Remove non-empty semester?")) or self.my_close("semester", "למחוק סמסטר בעל תוכן?"):
if force or emptySemester or (self.english_ui and self.my_close("semester", "Remove non-empty semester?")) or (not self.english_ui and self.my_close("semester", "למחוק סמסטר בעל תוכן?")):
self.ui.courses_tab_widget.removeTab(i)
if self.ui.courses_tab_widget.count() == 0:
self.addSemester()
Expand Down

0 comments on commit 3b69b97

Please sign in to comment.