Skip to content

Commit

Permalink
Fix window size
Browse files Browse the repository at this point in the history
  • Loading branch information
Dummerle committed Nov 22, 2021
1 parent f4a5946 commit ef4f383
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
13 changes: 13 additions & 0 deletions rare/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,19 @@ def tray(self, reason):
logger.info("Show App")

def exit_app(self, exit_code=0):
# FIXME: Fix this with the downlaod tab redesign
if self.mainwindow is not None:
if self.mainwindow.tab_widget.downloadTab.active_game is not None:
question = QMessageBox.question(
self.mainwindow,
self.tr("Close"),
self.tr("There is a download active. Do you really want to exit app?"),
QMessageBox.Yes, QMessageBox.No)
if question == QMessageBox.No:
return
else:
self.mainwindow.tab_widget.downloadTab.stop_download()
# FIXME: End of FIXME
self.mainwindow.hide()
threadpool = QThreadPool.globalInstance()
threadpool.waitForDone()
Expand Down
14 changes: 4 additions & 10 deletions rare/components/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from PyQt5.QtCore import Qt, QSettings, QTimer, QSize
from PyQt5.QtGui import QCloseEvent, QCursor
from PyQt5.QtWidgets import QMainWindow, QMessageBox, QApplication
from PyQt5.QtWidgets import QMainWindow, QApplication

from rare import data_dir, shared
from rare.components.tabs import TabWidget
Expand Down Expand Up @@ -82,19 +82,13 @@ def timer_finished(self):
self.timer.start(1000)

def closeEvent(self, e: QCloseEvent):
if self.settings.value("save_size", False, bool):
size = self.size().width(), self.size().height()
self.settings.setValue("window_size", size)
if self.settings.value("sys_tray", True, bool):
self.hide()
e.ignore()
return
elif self.offline:
pass
elif self.tab_widget.downloadTab.active_game is not None:
if not QMessageBox.question(self, "Close",
self.tr("There is a download active. Do you really want to exit app?"),
QMessageBox.Yes, QMessageBox.No) == QMessageBox.Yes:
e.ignore()
return
if self.settings.value("save_size", False, bool):
size = self.size().width(), self.size().height()
self.settings.setValue("window_size", size)
e.accept()

0 comments on commit ef4f383

Please sign in to comment.