diff --git a/gui/main.py b/gui/main.py index b211ca9..e215c39 100644 --- a/gui/main.py +++ b/gui/main.py @@ -21,10 +21,9 @@ def main(): app.setStyleSheet(_style) except: - with open("data\darktheme.qss") as f: + with open("theme\darktheme.qss") as f: _style = f.read() app.setStyleSheet(_style) - app.exec() @@ -34,4 +33,4 @@ def main(): main() -##pyinstaller --windowed .\gui\main.py --paths C:\Users\davip\Documents\Projetos\2DpsNotes --add-data 'C:\Users\davip\Documents\Projetos\2DpsNotes\style\dark\darktheme.qss;data' \ No newline at end of file +##pyinstaller --windowed .\gui\main.py --paths C:\Users\davip\Documents\Projetos\2DpsNotes --add-data 'C:\Users\davip\Documents\Projetos\2DpsNotes\style\dark\darktheme.qss;theme --add-data 'C:\Users\davip\Documents\Projetos\2DpsNotes\LICENSE;license'' \ No newline at end of file diff --git a/gui/mainwindow.py b/gui/mainwindow.py index 61cdbcc..f35d713 100644 --- a/gui/mainwindow.py +++ b/gui/mainwindow.py @@ -25,6 +25,7 @@ def __init__(self): self.txt.wClosed.connect(self.txt.ui.mainEditor.clear) self.txt.wClosed.connect(self.show) self.ui.label.setText("Quantidade de arquivos: " + str(self.model.rowCount())) + self.ui.label_2.setText("") def changeWindow(self): self.txt.passFileName(None) diff --git a/gui/saveAs.py b/gui/saveAs.py index bf6cf9b..5db89f6 100644 --- a/gui/saveAs.py +++ b/gui/saveAs.py @@ -5,4 +5,6 @@ class SaveAsDialog(QDialog): def __init__(self): super(SaveAsDialog, self).__init__() self.ui = Ui_SaveAsDialog() - self.ui.setupUi(self) \ No newline at end of file + self.ui.setupUi(self) + self.ui.CancelpushButton.setText("Cancelar") + self.ui.ConfirmpushButton.setText("Confirmar") \ No newline at end of file diff --git a/gui/textEditor.py b/gui/textEditor.py index 6938b69..eb4b408 100644 --- a/gui/textEditor.py +++ b/gui/textEditor.py @@ -18,7 +18,6 @@ def __init__(self): self.arqname = None self.prevName = None self.str = None - self.ui.mainEditor.setPlainText(self.str) self.ui.actionSave.triggered.connect(self.f_getTextFromEditor) self.ui.actionSaveAs.triggered.connect(self.f_ActionSaveAs) @@ -31,7 +30,8 @@ def f_getTextFromEditor(self): def f_ActionSaveAs(self): self.saveAsDialog.show() - self.saveAsDialog.ui.ConfirmpushButton.clicked.connect(self.f_getFileName) + self.saveAsDialog.ui.ConfirmpushButton.clicked.connect(self.f_getFileName) + self.saveAsDialog.ui.CancelpushButton.clicked.connect(self.saveAsDialog.close) def f_getFileName(self): self.arqname = self.saveAsDialog.ui.lineEdit.text() @@ -40,20 +40,27 @@ def f_getFileName(self): self.prevName = self.arqname Saving(self.arqname, self.str) - def passFileName(self, prevname): - self.prevName = prevname + def passFileName(self, name): + print(name) + self.prevName = name if self.prevName != None: self.str = loadFile(self.prevName) + self.ui.mainEditor.setPlainText(self.str) else: pass def closeEvent(self, event): - reply = QMessageBox.question(self, 'Fechar Janela', 'Tem certeza que vai fechar a janela? Progresso pode ser perdido', QMessageBox.Yes | QMessageBox.No, QMessageBox.No) + + if self.prevName == None or self.ui.mainEditor.toPlainText() != loadFile(self.prevName): + reply = QMessageBox.question(self, 'Fechar Janela', 'Tem certeza que vai fechar a janela? Existem modificações não salvas.', QMessageBox.Yes | QMessageBox.No, QMessageBox.No) - if reply == QMessageBox.Yes: + else: event.accept() self.wClosed.emit(event.isAccepted) + if reply == QMessageBox.Yes: + event.accept() + self.wClosed.emit(event.isAccepted) #https://doc.qt.io/qtforpython/tutorials/basictutorial/signals_and_slots.html else: