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