Skip to content

Commit

Permalink
gui: added scroll area to CollapsableMenuControlButton
Browse files Browse the repository at this point in the history
- this fixes overlapping channels if there are too many

Signed-off-by: Andrei Popa <[email protected]>
  • Loading branch information
andrei47w committed Sep 12, 2024
1 parent 3346fc8 commit 781c2c4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
1 change: 0 additions & 1 deletion gui/include/gui/widgets/menucontrolbutton.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <utils.h>
#include <compositewidget.h>


class QScrollArea;
namespace scopy {

Expand Down
4 changes: 4 additions & 0 deletions gui/include/gui/widgets/verticalchannelmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <scopy-gui_export.h>
#include <compositewidget.h>

class QScrollArea;
namespace scopy {
class SCOPY_GUI_EXPORT VerticalChannelManager : public QWidget, public CompositeWidget
{
Expand All @@ -21,6 +22,9 @@ class SCOPY_GUI_EXPORT VerticalChannelManager : public QWidget, public Composite
private:
QSpacerItem *spacer;
QVBoxLayout *lay;
QVBoxLayout *m_contLayout;
QScrollArea *m_scrollArea;
QWidget *m_container;
};
} // namespace scopy

Expand Down
32 changes: 24 additions & 8 deletions gui/src/widgets/verticalchannelmanager.cpp
Original file line number Diff line number Diff line change
@@ -1,33 +1,49 @@
#include <widgets/verticalchannelmanager.h>
#include <QScrollArea>

using namespace scopy;
VerticalChannelManager::VerticalChannelManager(QWidget *parent)
: QWidget(parent)
{
lay = new QVBoxLayout(this);
setLayout(lay);
lay->setMargin(0);
lay->setSpacing(6);
spacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding);
lay->addSpacerItem(spacer);
lay->setSpacing(0);

setLayout(lay);
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding);

spacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding);

QWidget *m_container = new QWidget(this);
m_contLayout = new QVBoxLayout(m_container);
m_contLayout->addSpacerItem(spacer);
m_contLayout->setMargin(0);
m_contLayout->setSpacing(6);
m_container->setLayout(m_contLayout);

m_scrollArea = new QScrollArea(this);
m_scrollArea->setWidget(m_container);
m_scrollArea->setWidgetResizable(true);
m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
m_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
lay->addWidget(m_scrollArea);
}

VerticalChannelManager::~VerticalChannelManager() {}

void VerticalChannelManager::add(QWidget *ch)
{
int position = lay->indexOf(spacer);
lay->insertWidget(position, ch);
int position = m_contLayout->indexOf(spacer);
m_contLayout->insertWidget(position, ch);
ch->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
}

void VerticalChannelManager::addEnd(QWidget *ch)
{
lay->addWidget(ch);
m_contLayout->addWidget(ch);
ch->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
}

void VerticalChannelManager::remove(QWidget *ch) { lay->removeWidget(ch); }
void VerticalChannelManager::remove(QWidget *ch) { m_contLayout->removeWidget(ch); }

#include "moc_verticalchannelmanager.cpp"

0 comments on commit 781c2c4

Please sign in to comment.