Add close button (WIP) to journal

This commit is contained in:
Vinyl Darkscratch 2018-03-12 13:57:52 -07:00
parent 8443907f74
commit bdb307fba9
2 changed files with 10 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 B

View file

@ -49,6 +49,9 @@ class AnimationTimer(QThread):
class Journal(QWidget): class Journal(QWidget):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.app = kwargs['app']
del kwargs['app']
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.mousedown = False self.mousedown = False
@ -57,6 +60,9 @@ class Journal(QWidget):
self.label = QLabel(self) self.label = QLabel(self)
self.change_image('default_en') self.change_image('default_en')
self.close_label = QLabel(self)
self.close_label.setPixmap(QPixmap(os.path.join(base_path, 'images', 'close.png')))
self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint) self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint)
self.setAttribute(Qt.WA_TranslucentBackground) self.setAttribute(Qt.WA_TranslucentBackground)
self.setMouseTracking(True) self.setMouseTracking(True)
@ -70,6 +76,9 @@ class Journal(QWidget):
self.mousedown = True self.mousedown = True
self.mousedownpos = event.pos() self.mousedownpos = event.pos()
if self.mousedownpos.x() <= 24 and self.mousedownpos.y() < 24:
self.app.quit()
def mouseReleaseEvent(self, event): def mouseReleaseEvent(self, event):
self.mousedown = False self.mousedown = False
@ -142,7 +151,7 @@ if __name__ == '__main__':
else: else:
# Author's Journal mode # Author's Journal mode
journal = Journal() journal = Journal(app = app)
save_path = os.path.join(documents_path, 'Oneshot', 'save_progress.oneshot') save_path = os.path.join(documents_path, 'Oneshot', 'save_progress.oneshot')
if os.path.exists(save_path): if os.path.exists(save_path):
with open(save_path, 'rb') as save: with open(save_path, 'rb') as save: