Skip to content

Commit

Permalink
adições de qualidade de vida
Browse files Browse the repository at this point in the history
  • Loading branch information
Davipcrs committed Jan 13, 2023
1 parent bfedea1 commit 320c777
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
5 changes: 2 additions & 3 deletions gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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'
##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''
1 change: 1 addition & 0 deletions gui/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion gui/saveAs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ class SaveAsDialog(QDialog):
def __init__(self):
super(SaveAsDialog, self).__init__()
self.ui = Ui_SaveAsDialog()
self.ui.setupUi(self)
self.ui.setupUi(self)
self.ui.CancelpushButton.setText("Cancelar")
self.ui.ConfirmpushButton.setText("Confirmar")
19 changes: 13 additions & 6 deletions gui/textEditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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()
Expand All @@ -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:
Expand Down

0 comments on commit 320c777

Please sign in to comment.