Compare commits
6 commits
32b4c7a0f3
...
3fe735e596
Author | SHA1 | Date | |
---|---|---|---|
3fe735e596 | |||
f51e5ed878 | |||
371ff3fa9f | |||
ba3a575ba2 | |||
cb139c6fbf | |||
2b9e2292fa |
5 changed files with 224 additions and 17 deletions
52
ui_clear_dialog.py
Normal file
52
ui_clear_dialog.py
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Form implementation generated from reading ui file 'ui_clear_dialog.ui'
|
||||||
|
#
|
||||||
|
# Created by: PyQt5 UI code generator 5.15.0
|
||||||
|
#
|
||||||
|
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
|
||||||
|
# run again. Do not edit this file unless you know what you are doing.
|
||||||
|
|
||||||
|
|
||||||
|
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||||
|
|
||||||
|
|
||||||
|
class Ui_ClearDialog(object):
|
||||||
|
def setupUi(self, ClearDialog):
|
||||||
|
ClearDialog.setObjectName("ClearDialog")
|
||||||
|
ClearDialog.setWindowModality(QtCore.Qt.ApplicationModal)
|
||||||
|
ClearDialog.resize(265, 75)
|
||||||
|
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Minimum)
|
||||||
|
sizePolicy.setHorizontalStretch(0)
|
||||||
|
sizePolicy.setVerticalStretch(0)
|
||||||
|
sizePolicy.setHeightForWidth(ClearDialog.sizePolicy().hasHeightForWidth())
|
||||||
|
ClearDialog.setSizePolicy(sizePolicy)
|
||||||
|
self.verticalLayout = QtWidgets.QVBoxLayout(ClearDialog)
|
||||||
|
self.verticalLayout.setObjectName("verticalLayout")
|
||||||
|
self.t_clear = QtWidgets.QLabel(ClearDialog)
|
||||||
|
self.t_clear.setObjectName("t_clear")
|
||||||
|
self.verticalLayout.addWidget(self.t_clear)
|
||||||
|
self.l_buttons = QtWidgets.QHBoxLayout()
|
||||||
|
self.l_buttons.setObjectName("l_buttons")
|
||||||
|
self.b_yes = QtWidgets.QPushButton(ClearDialog)
|
||||||
|
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)
|
||||||
|
sizePolicy.setHorizontalStretch(0)
|
||||||
|
sizePolicy.setVerticalStretch(0)
|
||||||
|
sizePolicy.setHeightForWidth(self.b_yes.sizePolicy().hasHeightForWidth())
|
||||||
|
self.b_yes.setSizePolicy(sizePolicy)
|
||||||
|
self.b_yes.setObjectName("b_yes")
|
||||||
|
self.l_buttons.addWidget(self.b_yes)
|
||||||
|
self.b_no = QtWidgets.QPushButton(ClearDialog)
|
||||||
|
self.b_no.setObjectName("b_no")
|
||||||
|
self.l_buttons.addWidget(self.b_no)
|
||||||
|
self.verticalLayout.addLayout(self.l_buttons)
|
||||||
|
|
||||||
|
self.retranslateUi(ClearDialog)
|
||||||
|
QtCore.QMetaObject.connectSlotsByName(ClearDialog)
|
||||||
|
|
||||||
|
def retranslateUi(self, ClearDialog):
|
||||||
|
_translate = QtCore.QCoreApplication.translate
|
||||||
|
ClearDialog.setWindowTitle(_translate("ClearDialog", "Eingabefelder leeren"))
|
||||||
|
self.t_clear.setText(_translate("ClearDialog", "Sollen die Eingabefelder geleert werden?"))
|
||||||
|
self.b_yes.setText(_translate("ClearDialog", "Ja"))
|
||||||
|
self.b_no.setText(_translate("ClearDialog", "Nein"))
|
61
ui_clear_dialog.ui
Normal file
61
ui_clear_dialog.ui
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>ClearDialog</class>
|
||||||
|
<widget class="QDialog" name="ClearDialog">
|
||||||
|
<property name="windowModality">
|
||||||
|
<enum>Qt::ApplicationModal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>265</width>
|
||||||
|
<height>75</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Maximum" vsizetype="Minimum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Eingabefelder leeren</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="t_clear">
|
||||||
|
<property name="text">
|
||||||
|
<string>Sollen die Eingabefelder geleert werden?</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="l_buttons">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="b_yes">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Ja</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="b_no">
|
||||||
|
<property name="text">
|
||||||
|
<string>Nein</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
|
@ -2,9 +2,10 @@
|
||||||
|
|
||||||
# Form implementation generated from reading ui file 'ui_mainwindow.ui'
|
# Form implementation generated from reading ui file 'ui_mainwindow.ui'
|
||||||
#
|
#
|
||||||
# Created by: PyQt5 UI code generator 5.14.2
|
# Created by: PyQt5 UI code generator 5.15.0
|
||||||
#
|
#
|
||||||
# WARNING! All changes made in this file will be lost!
|
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
|
||||||
|
# run again. Do not edit this file unless you know what you are doing.
|
||||||
|
|
||||||
|
|
||||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||||
|
@ -49,10 +50,6 @@ class Ui_MainWindow(object):
|
||||||
self.e_servings.setText("")
|
self.e_servings.setText("")
|
||||||
self.e_servings.setObjectName("e_servings")
|
self.e_servings.setObjectName("e_servings")
|
||||||
self.y_basics.addWidget(self.e_servings, 1, 1, 1, 1)
|
self.y_basics.addWidget(self.e_servings, 1, 1, 1, 1)
|
||||||
self.e_url = QtWidgets.QLineEdit(self.t_basics)
|
|
||||||
self.e_url.setText("")
|
|
||||||
self.e_url.setObjectName("e_url")
|
|
||||||
self.y_basics.addWidget(self.e_url, 2, 3, 1, 1)
|
|
||||||
self.l_recipe_name = QtWidgets.QLabel(self.t_basics)
|
self.l_recipe_name = QtWidgets.QLabel(self.t_basics)
|
||||||
self.l_recipe_name.setObjectName("l_recipe_name")
|
self.l_recipe_name.setObjectName("l_recipe_name")
|
||||||
self.y_basics.addWidget(self.l_recipe_name, 0, 0, 1, 1)
|
self.y_basics.addWidget(self.l_recipe_name, 0, 0, 1, 1)
|
||||||
|
@ -75,6 +72,10 @@ class Ui_MainWindow(object):
|
||||||
self.e_rating_overall.setProperty("value", 3)
|
self.e_rating_overall.setProperty("value", 3)
|
||||||
self.e_rating_overall.setObjectName("e_rating_overall")
|
self.e_rating_overall.setObjectName("e_rating_overall")
|
||||||
self.y_basics.addWidget(self.e_rating_overall, 2, 1, 1, 1)
|
self.y_basics.addWidget(self.e_rating_overall, 2, 1, 1, 1)
|
||||||
|
self.e_url = QtWidgets.QLineEdit(self.t_basics)
|
||||||
|
self.e_url.setText("")
|
||||||
|
self.e_url.setObjectName("e_url")
|
||||||
|
self.y_basics.addWidget(self.e_url, 2, 3, 1, 1)
|
||||||
self.verticalLayout_9.addLayout(self.y_basics)
|
self.verticalLayout_9.addLayout(self.y_basics)
|
||||||
self.horizontalLayout_16 = QtWidgets.QHBoxLayout()
|
self.horizontalLayout_16 = QtWidgets.QHBoxLayout()
|
||||||
self.horizontalLayout_16.setObjectName("horizontalLayout_16")
|
self.horizontalLayout_16.setObjectName("horizontalLayout_16")
|
||||||
|
@ -361,15 +362,19 @@ class Ui_MainWindow(object):
|
||||||
self.gridLayout.addWidget(self.tabWidget, 0, 0, 1, 1)
|
self.gridLayout.addWidget(self.tabWidget, 0, 0, 1, 1)
|
||||||
MainWindow.setCentralWidget(self.centralwidget)
|
MainWindow.setCentralWidget(self.centralwidget)
|
||||||
self.menuBar = QtWidgets.QMenuBar(MainWindow)
|
self.menuBar = QtWidgets.QMenuBar(MainWindow)
|
||||||
self.menuBar.setGeometry(QtCore.QRect(0, 0, 800, 30))
|
self.menuBar.setGeometry(QtCore.QRect(0, 0, 800, 28))
|
||||||
self.menuBar.setObjectName("menuBar")
|
self.menuBar.setObjectName("menuBar")
|
||||||
self.menuMen = QtWidgets.QMenu(self.menuBar)
|
self.menuMen = QtWidgets.QMenu(self.menuBar)
|
||||||
self.menuMen.setObjectName("menuMen")
|
self.menuMen.setObjectName("menuMen")
|
||||||
MainWindow.setMenuBar(self.menuBar)
|
MainWindow.setMenuBar(self.menuBar)
|
||||||
|
self.ma_clear_fields = QtWidgets.QAction(MainWindow)
|
||||||
|
self.ma_clear_fields.setObjectName("ma_clear_fields")
|
||||||
self.ma_close = QtWidgets.QAction(MainWindow)
|
self.ma_close = QtWidgets.QAction(MainWindow)
|
||||||
self.ma_close.setObjectName("ma_close")
|
self.ma_close.setObjectName("ma_close")
|
||||||
self.ma_information = QtWidgets.QAction(MainWindow)
|
self.ma_information = QtWidgets.QAction(MainWindow)
|
||||||
self.ma_information.setObjectName("ma_information")
|
self.ma_information.setObjectName("ma_information")
|
||||||
|
self.menuMen.addAction(self.ma_clear_fields)
|
||||||
|
self.menuMen.addSeparator()
|
||||||
self.menuMen.addAction(self.ma_information)
|
self.menuMen.addAction(self.ma_information)
|
||||||
self.menuMen.addSeparator()
|
self.menuMen.addSeparator()
|
||||||
self.menuMen.addAction(self.ma_close)
|
self.menuMen.addAction(self.ma_close)
|
||||||
|
@ -454,5 +459,6 @@ class Ui_MainWindow(object):
|
||||||
self.b_rating_remove.setText(_translate("MainWindow", "Entfernen"))
|
self.b_rating_remove.setText(_translate("MainWindow", "Entfernen"))
|
||||||
self.tabWidget.setTabText(self.tabWidget.indexOf(self.t_rating), _translate("MainWindow", "Bewertung"))
|
self.tabWidget.setTabText(self.tabWidget.indexOf(self.t_rating), _translate("MainWindow", "Bewertung"))
|
||||||
self.menuMen.setTitle(_translate("MainWindow", "Me&nü"))
|
self.menuMen.setTitle(_translate("MainWindow", "Me&nü"))
|
||||||
|
self.ma_clear_fields.setText(_translate("MainWindow", "Eingaben löschen"))
|
||||||
self.ma_close.setText(_translate("MainWindow", "&Schließen"))
|
self.ma_close.setText(_translate("MainWindow", "&Schließen"))
|
||||||
self.ma_information.setText(_translate("MainWindow", "Informationen"))
|
self.ma_information.setText(_translate("MainWindow", "Informationen"))
|
||||||
|
|
|
@ -98,13 +98,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="3">
|
|
||||||
<widget class="QLineEdit" name="e_url">
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="l_recipe_name">
|
<widget class="QLabel" name="l_recipe_name">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -150,6 +143,13 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="3">
|
||||||
|
<widget class="QLineEdit" name="e_url">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
@ -792,19 +792,26 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>800</width>
|
<width>800</width>
|
||||||
<height>30</height>
|
<height>28</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuMen">
|
<widget class="QMenu" name="menuMen">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Me&nü</string>
|
<string>Me&nü</string>
|
||||||
</property>
|
</property>
|
||||||
|
<addaction name="ma_clear_fields"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
<addaction name="ma_information"/>
|
<addaction name="ma_information"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="ma_close"/>
|
<addaction name="ma_close"/>
|
||||||
</widget>
|
</widget>
|
||||||
<addaction name="menuMen"/>
|
<addaction name="menuMen"/>
|
||||||
</widget>
|
</widget>
|
||||||
|
<action name="ma_clear_fields">
|
||||||
|
<property name="text">
|
||||||
|
<string>Eingaben löschen</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
<action name="ma_close">
|
<action name="ma_close">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Schließen</string>
|
<string>&Schließen</string>
|
||||||
|
|
|
@ -28,6 +28,7 @@ from PyQt5.QtWidgets import QApplication, QMainWindow, QMessageBox, QTableWidget
|
||||||
from ui_mainwindow import Ui_MainWindow
|
from ui_mainwindow import Ui_MainWindow
|
||||||
from ui_code_dialog import Ui_WikiCode
|
from ui_code_dialog import Ui_WikiCode
|
||||||
from ui_about_dialog import Ui_About
|
from ui_about_dialog import Ui_About
|
||||||
|
from ui_clear_dialog import Ui_ClearDialog
|
||||||
|
|
||||||
class AboutDialog(QDialog, Ui_About):
|
class AboutDialog(QDialog, Ui_About):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
@ -38,14 +39,25 @@ class AboutDialog(QDialog, Ui_About):
|
||||||
|
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
|
class ClearDialog(QDialog, Ui_ClearDialog):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(ClearDialog, self).__init__(*args, **kwargs)
|
||||||
|
self.setupUi(self)
|
||||||
|
|
||||||
|
self.b_yes.clicked.connect(self.accept)
|
||||||
|
self.b_no.clicked.connect(self.reject)
|
||||||
|
|
||||||
|
self.show()
|
||||||
|
|
||||||
class WikiCodeDialog(QDialog, Ui_WikiCode):
|
class WikiCodeDialog(QDialog, Ui_WikiCode):
|
||||||
def __init__(self, code, *args, **kwargs):
|
def __init__(self, code, *args, **kwargs):
|
||||||
super(WikiCodeDialog, self).__init__(*args, **kwargs)
|
super(WikiCodeDialog, self).__init__(*args, **kwargs)
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
|
self.copied = False
|
||||||
|
|
||||||
self.e_code.setPlainText(code)
|
self.e_code.setPlainText(code)
|
||||||
|
|
||||||
self.b_close.clicked.connect(self.close)
|
self.b_close.clicked.connect(self.clear_fields)
|
||||||
self.b_copy.clicked.connect(self.copy)
|
self.b_copy.clicked.connect(self.copy)
|
||||||
|
|
||||||
self.show()
|
self.show()
|
||||||
|
@ -53,6 +65,20 @@ class WikiCodeDialog(QDialog, Ui_WikiCode):
|
||||||
def copy(self):
|
def copy(self):
|
||||||
self.e_code.selectAll()
|
self.e_code.selectAll()
|
||||||
self.e_code.copy()
|
self.e_code.copy()
|
||||||
|
self.copied = True
|
||||||
|
|
||||||
|
def clear_fields(self):
|
||||||
|
"""
|
||||||
|
Show the clear fields dialog if the code was at least copied once.
|
||||||
|
"""
|
||||||
|
if self.copied:
|
||||||
|
dialog = ClearDialog()
|
||||||
|
dialog.rejected.connect(self.reject)
|
||||||
|
dialog.accepted.connect(self.accept)
|
||||||
|
dialog.exec_()
|
||||||
|
else:
|
||||||
|
self.close()
|
||||||
|
|
||||||
|
|
||||||
class MainWindow(QMainWindow, Ui_MainWindow):
|
class MainWindow(QMainWindow, Ui_MainWindow):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
@ -63,8 +89,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||||
self.b_cancel.clicked.connect(self.close)
|
self.b_cancel.clicked.connect(self.close)
|
||||||
self.ma_close.triggered.connect(self.close)
|
self.ma_close.triggered.connect(self.close)
|
||||||
|
|
||||||
# Connect about action
|
# Connect other menu actions
|
||||||
self.ma_information.triggered.connect(self.about)
|
self.ma_information.triggered.connect(self.about)
|
||||||
|
self.ma_clear_fields.triggered.connect(self.clear_fields)
|
||||||
|
|
||||||
# Conncect recipe name typing
|
# Conncect recipe name typing
|
||||||
self.e_recipe_name.textChanged.connect(self.updateTitle)
|
self.e_recipe_name.textChanged.connect(self.updateTitle)
|
||||||
|
@ -277,6 +304,59 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||||
code = current_recipe.wikicode(writer)
|
code = current_recipe.wikicode(writer)
|
||||||
|
|
||||||
dialog = WikiCodeDialog(code)
|
dialog = WikiCodeDialog(code)
|
||||||
|
dialog.accepted.connect(self.clear)
|
||||||
|
dialog.exec_()
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
"""
|
||||||
|
Clear all fields
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Tab: Basics
|
||||||
|
self.e_recipe_name.setText("")
|
||||||
|
self.e_servings.setText("")
|
||||||
|
self.e_time.setText("")
|
||||||
|
self.e_rating_overall.setValue(3)
|
||||||
|
self.e_url.setText("")
|
||||||
|
self.e_category.setText("")
|
||||||
|
self.v_categories.clear()
|
||||||
|
|
||||||
|
# Tab: Ingredients
|
||||||
|
self.e_ingredient.setText("")
|
||||||
|
self.e_amount.setText("")
|
||||||
|
self.c_heading.setChecked(False)
|
||||||
|
self.v_ingredients.clear()
|
||||||
|
|
||||||
|
# Tab: Utensils
|
||||||
|
self.e_utensil.setText("")
|
||||||
|
self.v_utensils.clear()
|
||||||
|
|
||||||
|
# Tab: Steps
|
||||||
|
self.e_step.setText("")
|
||||||
|
self.v_steps.clear()
|
||||||
|
|
||||||
|
# Tab: Notes
|
||||||
|
self.e_note.setText("")
|
||||||
|
self.v_notes.clear()
|
||||||
|
|
||||||
|
# Tab: Tips
|
||||||
|
self.e_tip.setText("")
|
||||||
|
self.v_tips.clear()
|
||||||
|
|
||||||
|
# Tab: Variations
|
||||||
|
self.e_variation.setText("")
|
||||||
|
self.v_variations.clear()
|
||||||
|
|
||||||
|
# Tab: Ratings
|
||||||
|
self.e_rating.setText("")
|
||||||
|
self.v_ratings.clear()
|
||||||
|
|
||||||
|
def clear_fields(self):
|
||||||
|
"""
|
||||||
|
Show the clear fields dialog.
|
||||||
|
"""
|
||||||
|
dialog = ClearDialog()
|
||||||
|
dialog.accepted.connect(self.clear)
|
||||||
dialog.exec_()
|
dialog.exec_()
|
||||||
|
|
||||||
def about(self):
|
def about(self):
|
||||||
|
@ -296,6 +376,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||||
if reply == QMessageBox.Yes:
|
if reply == QMessageBox.Yes:
|
||||||
super.close()
|
super.close()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app = QApplication([])
|
app = QApplication([])
|
||||||
app.setApplicationName("WikiCookBook")
|
app.setApplicationName("WikiCookBook")
|
||||||
|
|
Reference in a new issue