Browse Source

Make parameter groups collapsable

tags/v2.1-rc1
falkTX 5 years ago
parent
commit
cbe6bb84c7
2 changed files with 62 additions and 2 deletions
  1. +3
    -2
      source/frontend/carla_widgets.py
  2. +59
    -0
      source/frontend/widgets/collapsablewidget.py

+ 3
- 2
source/frontend/carla_widgets.py View File

@@ -33,6 +33,7 @@ import ui_carla_parameter

from carla_shared import *
from carla_utils import *
from widgets.collapsablewidget import CollapsibleBox
from widgets.paramspinbox import CustomInputDialog
from widgets.pixmapkeyboard import PixmapKeyboardHArea

@@ -1493,8 +1494,8 @@ class PluginEdit(QDialog):
groupSymbol, groupName = groupName.split(":",1)
groupLayout, groupWidget = groupWidgets.get(groupSymbol, (None, None))
if groupLayout is None:
groupWidget = QGroupBox(groupName, scrollAreaWidget)
groupLayout = QVBoxLayout(groupWidget)
groupWidget = CollapsibleBox(groupName, scrollAreaWidget)
groupLayout = groupWidget.getContentLayout()
groupWidget.setPalette(palette2)
scrollAreaLayout.addWidget(groupWidget)
groupWidgets[groupSymbol] = (groupLayout, groupWidget)


+ 59
- 0
source/frontend/widgets/collapsablewidget.py View File

@@ -0,0 +1,59 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Collapsible Box, a custom Qt widget
# Copyright (C) 2019 Filipe Coelho <falktx@falktx.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# For a full copy of the GNU General Public License see the doc/GPL.txt file.

# ------------------------------------------------------------------------------------------------------------
# Imports (Global)

from PyQt5.QtCore import pyqtSlot, Qt
from PyQt5.QtWidgets import QGroupBox, QSizePolicy, QToolButton, QVBoxLayout, QWidget

# ------------------------------------------------------------------------------------------------------------
# Widget Class

class CollapsibleBox(QGroupBox):
def __init__(self, title, parent):
QGroupBox.__init__(self, parent)

self.toggle_button = QToolButton(self)
self.toggle_button.setText(title)
self.toggle_button.setCheckable(True)
self.toggle_button.setChecked(True)
self.toggle_button.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
self.toggle_button.setStyleSheet("border: none;")
self.toggle_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
self.toggle_button.setArrowType(Qt.RightArrow)
self.toggle_button.toggled.connect(self.toolButtonPressed)

self.content_area = QWidget(self)
self.content_layout = QVBoxLayout(self.content_area)
self.content_layout.setContentsMargins(0, 0, 0, 0)
self.content_layout.setSpacing(0)

lay = QVBoxLayout(self)
lay.setContentsMargins(0, 0, 0, 0)
lay.setSpacing(0)
lay.addWidget(self.toggle_button)
lay.addWidget(self.content_area)

@pyqtSlot(bool)
def toolButtonPressed(self, toggled):
self.content_area.setVisible(toggled)
self.toggle_button.setArrowType(Qt.RightArrow if toggled else Qt.DownArrow)

def getContentLayout(self):
return self.content_layout

Loading…
Cancel
Save