gui: add --dry|-d
This commit is contained in:
@@ -698,13 +698,16 @@ class KeyBindings(ConfigWidget):
|
|||||||
|
|
||||||
|
|
||||||
class Config(QtWidgets.QWidget):
|
class Config(QtWidgets.QWidget):
|
||||||
def __init__(self, config):
|
def __init__(self, config, dry=False):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.layout = QtWidgets.QVBoxLayout()
|
|
||||||
self.config = config
|
self.config = config
|
||||||
|
self.dry = dry
|
||||||
|
|
||||||
|
self.layout = QtWidgets.QVBoxLayout()
|
||||||
|
self.setLayout(self.layout)
|
||||||
|
|
||||||
self.add_tabs()
|
self.add_tabs()
|
||||||
self.add_buttons()
|
self.add_buttons()
|
||||||
self.setLayout(self.layout)
|
|
||||||
|
|
||||||
def add_tabs(self):
|
def add_tabs(self):
|
||||||
self.tabs = QtWidgets.QTabWidget()
|
self.tabs = QtWidgets.QTabWidget()
|
||||||
@@ -746,19 +749,27 @@ class Config(QtWidgets.QWidget):
|
|||||||
return state
|
return state
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
state = self.gather_state()
|
state = yaml.dump(self.gather_state())
|
||||||
with open(ALACRITTY_CONFIG, 'w+') as f:
|
if self.dry:
|
||||||
f.write(yaml.dump(state))
|
print(state)
|
||||||
|
else:
|
||||||
|
with open(ALACRITTY_CONFIG, 'w+') as f:
|
||||||
|
f.write(state)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
dry = False
|
||||||
|
if len(sys.argv) == 2 and sys.argv[1] in ['--dry', '-d']:
|
||||||
|
dry = True
|
||||||
|
|
||||||
app = QtWidgets.QApplication([NAME])
|
app = QtWidgets.QApplication([NAME])
|
||||||
app.setApplicationName(NAME)
|
app.setApplicationName(NAME)
|
||||||
|
|
||||||
|
window = QtWidgets.QMainWindow()
|
||||||
with open(ALACRITTY_CONFIG) as f:
|
with open(ALACRITTY_CONFIG) as f:
|
||||||
config = yaml.safe_load(f.read())
|
config = yaml.safe_load(f.read())
|
||||||
window = QtWidgets.QMainWindow()
|
window.setCentralWidget(Config(config, dry=dry))
|
||||||
window.setCentralWidget(Config(config))
|
|
||||||
window.setGeometry(
|
window.setGeometry(
|
||||||
QtWidgets.QStyle.alignedRect(
|
QtWidgets.QStyle.alignedRect(
|
||||||
QtCore.Qt.LeftToRight,
|
QtCore.Qt.LeftToRight,
|
||||||
@@ -771,6 +782,7 @@ def main():
|
|||||||
window.setWindowTitle(NAME)
|
window.setWindowTitle(NAME)
|
||||||
window.setUnifiedTitleAndToolBarOnMac(True)
|
window.setUnifiedTitleAndToolBarOnMac(True)
|
||||||
window.show()
|
window.show()
|
||||||
|
|
||||||
app.exec_()
|
app.exec_()
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user