Skip to content

Commit

Permalink
properly remember size and position of dialogs fix #784
Browse files Browse the repository at this point in the history
  • Loading branch information
jopohl committed Jun 26, 2020
1 parent 849f7f5 commit 7cdea46
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 50 deletions.
3 changes: 3 additions & 0 deletions src/urh/controller/MainController.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ def __init__(self, *args):
self.ui.actionSave_project.setVisible(False)
self.ui.actionClose_project.setVisible(False)

self.restoreGeometry(settings.read("{}/geometry".format(self.__class__.__name__), type=bytes))

def __set_non_project_warning_visibility(self):
show = settings.read("show_non_project_warning", True, bool) and not self.project_manager.project_loaded
self.ui.labelNonProjectMode.setVisible(show)
Expand Down Expand Up @@ -415,6 +417,7 @@ def set_frame_numbers(self):

def closeEvent(self, event: QCloseEvent):
self.save_project()
settings.write("{}/geometry".format(self.__class__.__name__), self.saveGeometry())
super().closeEvent(event)

def close_all_files(self):
Expand Down
6 changes: 1 addition & 5 deletions src/urh/controller/dialogs/DecoderDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,7 @@ def __init__(self, decodings, signals, project_manager: ProjectManager,

# Connects
self.create_connects()

try:
self.restoreGeometry(settings.read("{}/geometry".format(self.__class__.__name__)))
except TypeError:
pass
self.restoreGeometry(settings.read("{}/geometry".format(self.__class__.__name__), type=bytes))

def create_connects(self):
self.ui.inpt.textChanged.connect(self.decoder_update)
Expand Down
6 changes: 1 addition & 5 deletions src/urh/controller/dialogs/FuzzingDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ def __init__(self, protocol: ProtocolAnalyzerContainer, label_index: int, msg_in
self.ui.tblFuzzingValues.resize_me()

self.create_connects()

try:
self.restoreGeometry(settings.read("{}/geometry".format(self.__class__.__name__)))
except TypeError:
pass
self.restoreGeometry(settings.read("{}/geometry".format(self.__class__.__name__), type=bytes))

@property
def message(self):
Expand Down
6 changes: 1 addition & 5 deletions src/urh/controller/dialogs/MessageTypeDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ def __init__(self, message_type: MessageType, parent=None):
self.ui.cbRulesetMode.setCurrentIndex(self.message_type.ruleset.mode.value)

self.create_connects()

try:
self.restoreGeometry(settings.read("{}/geometry".format(self.__class__.__name__)))
except TypeError:
pass
self.restoreGeometry(settings.read("{}/geometry".format(self.__class__.__name__), type=bytes))

def create_connects(self):
self.ui.btnAddRule.clicked.connect(self.on_btn_add_rule_clicked)
Expand Down
6 changes: 1 addition & 5 deletions src/urh/controller/dialogs/ModulatorDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ def __init__(self, modulators, tree_model=None, parent=None):
QLineEdit.TrailingPosition)

self.create_connects()

try:
self.restoreGeometry(settings.read("{}/geometry".format(self.__class__.__name__)))
except TypeError:
pass
self.restoreGeometry(settings.read("{}/geometry".format(self.__class__.__name__), type=bytes))

self.set_bits_per_symbol_enabled_status()
self.set_modulation_profile_status()
Expand Down
6 changes: 1 addition & 5 deletions src/urh/controller/dialogs/OptionsDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,7 @@ def __init__(self, installed_plugins, highlighted_plugins=None, parent=None):
self.ui.labelRebuildNativeStatus.setText("")

self.show_available_colormaps()

try:
self.restoreGeometry(settings.read("{}/geometry".format(self.__class__.__name__)))
except TypeError:
pass
self.restoreGeometry(settings.read("{}/geometry".format(self.__class__.__name__), type=bytes))

def create_connects(self):
self.ui.doubleSpinBoxFuzzingPause.valueChanged.connect(self.on_spinbox_fuzzing_pause_value_changed)
Expand Down
6 changes: 1 addition & 5 deletions src/urh/controller/dialogs/ProjectDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,7 @@ def __init__(self, new_project=True, project_manager: ProjectManager = None, par
self.ui.lineEdit_Path.setText(os.path.realpath(os.path.join(os.curdir, "new")))

self.on_line_edit_path_text_edited()

try:
self.restoreGeometry(settings.read("{}/geometry".format(self.__class__.__name__)))
except TypeError:
pass
self.restoreGeometry(settings.read("{}/geometry".format(self.__class__.__name__), type=bytes))

@property
def participants(self):
Expand Down
5 changes: 1 addition & 4 deletions src/urh/controller/dialogs/ProtocolLabelDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,7 @@ def __init__(self, message: Message, viewtype: int, selected_index=None, parent=
self.setAttribute(Qt.WA_DeleteOnClose)
self.setWindowFlags(Qt.Window)

try:
self.restoreGeometry(settings.read("{}/geometry".format(self.__class__.__name__)))
except TypeError:
pass
self.restoreGeometry(settings.read("{}/geometry".format(self.__class__.__name__), type=bytes))

for i in range(self.model.rowCount()):
self.open_editors(i)
Expand Down
6 changes: 1 addition & 5 deletions src/urh/controller/dialogs/SendRecvDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ def __init__(self, project_manager: ProjectManager, is_tx: bool, continuous_send
self.device_settings_widget.ui.cbDevice.setCurrentText(NetworkSDRInterfacePlugin.NETWORK_SDR_NAME)

self.timer = QTimer(self)

try:
self.restoreGeometry(settings.read("{}/geometry".format(self.__class__.__name__)))
except TypeError:
pass
self.restoreGeometry(settings.read("{}/geometry".format(self.__class__.__name__), type=bytes))

self.ui.splitter.setSizes([int(0.4 * self.width()), int(0.6 * self.width())])

Expand Down
6 changes: 1 addition & 5 deletions src/urh/controller/dialogs/SignalDetailsDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ def __init__(self, signal, parent=None):
self.set_duration()

self.ui.dsb_sample_rate.valueChanged.connect(self.on_dsb_sample_rate_value_changed)

try:
self.restoreGeometry(settings.read("{}/geometry".format(self.__class__.__name__)))
except TypeError:
pass
self.restoreGeometry(settings.read("{}/geometry".format(self.__class__.__name__), type=bytes))

def closeEvent(self, event: QCloseEvent):
settings.write("{}/geometry".format(self.__class__.__name__), self.saveGeometry())
Expand Down
5 changes: 1 addition & 4 deletions src/urh/controller/widgets/PluginFrame.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ def __init__(self, plugins, highlighted_plugins=None, parent=None):
self.ui.groupBoxSettings.setLayout(self.settings_layout)
self.create_connects()

try:
self.restoreGeometry(settings.read("{}/geometry".format(self.__class__.__name__)))
except TypeError:
pass
self.restoreGeometry(settings.read("{}/geometry".format(self.__class__.__name__), type=bytes))


def create_connects(self):
Expand Down
6 changes: 4 additions & 2 deletions src/urh/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,10 @@ def main():
import ctypes
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID("jopohl.urh")

main_window.showMaximized()
# main_window.setFixedSize(1920, 1080 - 30) # Youtube
if settings.read("MainController/geometry", type=bytes):
main_window.show()
else:
main_window.showMaximized()

if "autoclose" in sys.argv[1:]:
# Autoclose after 1 second, this is useful for automated testing
Expand Down

0 comments on commit 7cdea46

Please sign in to comment.