From f667e4efe5f59a2e765c724e713762fd4089fdeb Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 22 Jan 2015 22:30:03 +0000 Subject: [PATCH] Add menu option to show/hide time panel, closes #161 --- resources/ui/carla_host.ui | 14 ++++++++++---- source/carla_host.py | 34 +++++++++++++++++++++++++--------- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/resources/ui/carla_host.ui b/resources/ui/carla_host.ui index 6bcfacc8b..505411b0d 100644 --- a/resources/ui/carla_host.ui +++ b/resources/ui/carla_host.ui @@ -144,7 +144,7 @@ 0 0 870 - 19 + 20 @@ -217,6 +217,7 @@ &Settings + @@ -730,9 +731,6 @@ true - - true - Show &Toolbar @@ -793,6 +791,14 @@ Show External + + + true + + + Show Time Panel + + diff --git a/source/carla_host.py b/source/carla_host.py index 27063ffc7..517f5f29e 100644 --- a/source/carla_host.py +++ b/source/carla_host.py @@ -220,11 +220,9 @@ class HostWindow(QMainWindow): # ---------------------------------------------------------------------------------------------------- # Set up GUI (panels) - self.fPanelTime = CarlaPanelTime(host, self) - self.fPanelTime.setEnabled(False) - - if not host.isPlugin: - QTimer.singleShot(0, self.fPanelTime.show) + self.ui.panelTime = CarlaPanelTime(host, self) + self.ui.panelTime.setEnabled(False) + self.ui.panelTime.adjustSize() # ---------------------------------------------------------------------------------------------------- # Set up GUI (rack) @@ -345,6 +343,7 @@ class HostWindow(QMainWindow): self.ui.act_canvas_save_image.triggered.connect(self.slot_canvasSaveImage) self.ui.act_canvas_arrange.setEnabled(False) # TODO, later + self.ui.act_settings_show_time_panel.toggled.connect(self.slot_showTimePanel) self.ui.act_settings_show_meters.toggled.connect(self.slot_showCanvasMeters) self.ui.act_settings_show_keyboard.toggled.connect(self.slot_showCanvasKeyboard) self.ui.act_settings_configure.triggered.connect(self.slot_configureCarla) @@ -366,6 +365,7 @@ class HostWindow(QMainWindow): self.ui.miniCanvasPreview.miniCanvasMoved.connect(self.slot_miniCanvasMoved) + self.ui.panelTime.finished.connect(self.slot_timePanelClosed) self.ui.tabWidget.currentChanged.connect(self.slot_tabChanged) self.scene.scaleChanged.connect(self.slot_canvasScaleChanged) @@ -607,7 +607,7 @@ class HostWindow(QMainWindow): self.ui.act_file_save.setEnabled(True) self.ui.act_file_save_as.setEnabled(True) - self.fPanelTime.setEnabled(True) + self.ui.panelTime.setEnabled(True) self.startTimers() @@ -631,7 +631,7 @@ class HostWindow(QMainWindow): self.ui.act_file_save.setEnabled(False) self.ui.act_file_save_as.setEnabled(False) - self.fPanelTime.setEnabled(False) + self.ui.panelTime.setEnabled(False) # -------------------------------------------------------------------------------------------------------- # Plugins @@ -1217,8 +1217,11 @@ class HostWindow(QMainWindow): settings = QSettings() settings.setValue("Geometry", self.saveGeometry()) + settings.setValue("TimePanelGeometry", self.ui.panelTime.saveGeometry()) + #settings.setValue("SplitterState", self.ui.splitter.saveState()) - settings.setValue("ShowToolbar", self.ui.toolBar.isVisible()) + settings.setValue("ShowTimePanel", self.ui.panelTime.isVisible()) + settings.setValue("ShowToolbar", self.ui.toolBar.isVisible()) diskFolders = [] @@ -1237,6 +1240,11 @@ class HostWindow(QMainWindow): if firstTime: self.restoreGeometry(settings.value("Geometry", "")) + self.ui.panelTime.restoreGeometry(settings.value("TimePanelGeometry", "")) + + showTimePanel = settings.value("ShowTimePanel", True, type=bool) + self.ui.act_settings_show_time_panel.setChecked(showTimePanel) + self.ui.panelTime.setVisible(showTimePanel) showToolbar = settings.value("ShowToolbar", True, type=bool) self.ui.act_settings_show_toolbar.setChecked(showToolbar) @@ -1306,6 +1314,10 @@ class HostWindow(QMainWindow): # -------------------------------------------------------------------------------------------------------- # Settings (menu actions) + @pyqtSlot(bool) + def slot_showTimePanel(self, yesNo): + self.ui.panelTime.setVisible(yesNo) + @pyqtSlot(bool) def slot_showCanvasMeters(self, yesNo): self.ui.peak_in.setVisible(yesNo) @@ -1538,6 +1550,10 @@ class HostWindow(QMainWindow): # -------------------------------------------------------------------------------------------------------- # Misc + @pyqtSlot() + def slot_timePanelClosed(self): + self.ui.act_settings_show_time_panel.setChecked(False) + @pyqtSlot(int) def slot_tabChanged(self, index): if index != 1: @@ -1709,7 +1725,7 @@ class HostWindow(QMainWindow): def idleFast(self): self.host.engine_idle() - self.fPanelTime.refreshTransport() + self.ui.panelTime.refreshTransport() if self.fPluginCount == 0 or self.fCurrentlyRemovingAllPlugins: return