From 6e27d4f95ea4e184467c97fe7e1d2ad8d4549046 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Tue, 26 Jun 2018 09:59:44 +0100 Subject: [PATCH] Make the list of line checkboxes scrollable. Copied from Perforce Change: 194172 --- mps/tool/monitor | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/mps/tool/monitor b/mps/tool/monitor index 839c8dc54dc..b2a7d159d8e 100755 --- a/mps/tool/monitor +++ b/mps/tool/monitor @@ -374,17 +374,23 @@ class ApplicationWindow(QtWidgets.QMainWindow): shortcut = QtWidgets.QShortcut(QtGui.QKeySequence("Ctrl+W"), self) shortcut.activated.connect(self.close) - layout = QtWidgets.QHBoxLayout(self._main) + main_layout = QtWidgets.QHBoxLayout(self._main) + + self._lines_scroll = QtWidgets.QScrollArea() + self._lines_widget = QtWidgets.QWidget() + self._lines_scroll.setWidget(self._lines_widget) + self._lines_scroll.setWidgetResizable(True) + self._lines_scroll.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self._line_checkbox = {} - left_panel = QtWidgets.QVBoxLayout() - layout.addLayout(left_panel) + lines_layout = QtWidgets.QVBoxLayout(self._lines_widget) self._lines = QtWidgets.QVBoxLayout() - left_panel.addLayout(self._lines) - left_panel.addStretch(1) + lines_layout.addLayout(self._lines) + lines_layout.addStretch(1) + main_layout.addWidget(self._lines_scroll) canvas = FigureCanvas(Figure(figsize=(10, 6))) - layout.addWidget(canvas) + main_layout.addWidget(canvas) self.addToolBar(QtCore.Qt.BottomToolBarArea, NavigationToolbar(canvas, self)) @@ -411,6 +417,8 @@ class ApplicationWindow(QtWidgets.QMainWindow): self._model.needs_redraw() checkbox.stateChanged.connect(state_changed) checkbox.setStyleSheet(f"color:{line.color}") + self._lines_scroll.setMinimumWidth( + self._lines_widget.sizeHint().width()) def main():