mirror of
https://github.com/CopterExpress/clever-show.git
synced 2026-05-26 23:19:33 +00:00
Added save as button for config editor
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
# Form implementation generated from reading ui file 'config_editor.ui'
|
||||
#
|
||||
# Created by: PyQt5 UI code generator 5.13.2
|
||||
# Created by: PyQt5 UI code generator 5.14.0
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
||||
@@ -25,19 +25,22 @@ class Ui_config_dialog(object):
|
||||
self.gridLayout.addWidget(self.config_view, 0, 0, 1, 1)
|
||||
self.gridLayout_2 = QtWidgets.QGridLayout()
|
||||
self.gridLayout_2.setObjectName("gridLayout_2")
|
||||
self.buttonBox = QtWidgets.QDialogButtonBox(config_dialog)
|
||||
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
|
||||
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Save)
|
||||
self.buttonBox.setCenterButtons(False)
|
||||
self.buttonBox.setObjectName("buttonBox")
|
||||
self.gridLayout_2.addWidget(self.buttonBox, 0, 2, 1, 1)
|
||||
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
||||
self.gridLayout_2.addItem(spacerItem, 0, 2, 1, 1)
|
||||
self.do_restart = QtWidgets.QCheckBox(config_dialog)
|
||||
self.do_restart.setObjectName("do_restart")
|
||||
self.gridLayout_2.addWidget(self.do_restart, 0, 1, 1, 1)
|
||||
self.buttonBox = QtWidgets.QDialogButtonBox(config_dialog)
|
||||
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Save)
|
||||
self.buttonBox.setObjectName("buttonBox")
|
||||
self.gridLayout_2.addWidget(self.buttonBox, 0, 4, 1, 1)
|
||||
self.do_coloring = QtWidgets.QCheckBox(config_dialog)
|
||||
self.do_coloring.setChecked(True)
|
||||
self.do_coloring.setObjectName("do_coloring")
|
||||
self.gridLayout_2.addWidget(self.do_coloring, 0, 0, 1, 1)
|
||||
self.save_as_button = QtWidgets.QPushButton(config_dialog)
|
||||
self.save_as_button.setObjectName("save_as_button")
|
||||
self.gridLayout_2.addWidget(self.save_as_button, 0, 3, 1, 1)
|
||||
self.gridLayout.addLayout(self.gridLayout_2, 2, 0, 1, 1)
|
||||
self.line = QtWidgets.QFrame(config_dialog)
|
||||
self.line.setFrameShape(QtWidgets.QFrame.HLine)
|
||||
@@ -56,6 +59,7 @@ class Ui_config_dialog(object):
|
||||
self.do_restart.setText(_translate("config_dialog", "Restart"))
|
||||
self.do_restart.setShortcut(_translate("config_dialog", "R"))
|
||||
self.do_coloring.setText(_translate("config_dialog", "Color Indication"))
|
||||
self.save_as_button.setText(_translate("config_dialog", "Save as"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -33,17 +33,17 @@
|
||||
<item row="2" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="2">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="centerButtons">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="do_restart">
|
||||
@@ -55,6 +55,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="do_coloring">
|
||||
<property name="text">
|
||||
@@ -65,6 +72,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QPushButton" name="save_as_button">
|
||||
<property name="text">
|
||||
<string>Save as</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
|
||||
@@ -715,6 +715,7 @@ class ConfigDialog(QtWidgets.QDialog):
|
||||
self.ui.config_view.expandAll()
|
||||
|
||||
self.ui.do_coloring.stateChanged.connect(self.model.enable_color)
|
||||
self.ui.save_as_button.clicked.connect(self.save_as)
|
||||
|
||||
# self.ui.delete_button.pressed.connect(self.remove_selected)
|
||||
|
||||
@@ -728,6 +729,17 @@ class ConfigDialog(QtWidgets.QDialog):
|
||||
)
|
||||
return reply == QMessageBox.Yes
|
||||
|
||||
def save_as(self):
|
||||
cfg = config.ConfigManager()
|
||||
cfg.load_from_dict(self.model.to_config_dict())
|
||||
save_path = QFileDialog.getSaveFileName(self, "Save as configuration file",
|
||||
filter="Config files (*.ini)")[0]
|
||||
if not save_path:
|
||||
return
|
||||
|
||||
cfg.config.filename = save_path
|
||||
cfg.write()
|
||||
|
||||
@pyqtSlot()
|
||||
def run(self):
|
||||
self.show()
|
||||
@@ -807,6 +819,7 @@ class ConfigDialog(QtWidgets.QDialog):
|
||||
|
||||
cfg.config.filename = save_path
|
||||
cfg.write()
|
||||
return True
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user