Skip to content

Commit

Permalink
Add vertical scrollbar to General tab of Simulation dialog
Browse files Browse the repository at this point in the history
Without scrollbar, the hight of the dialog may exceed the size of a
laptop screen. The OK/Cancel buttons become unaccessible under Gnome.
  • Loading branch information
rfranke committed Oct 24, 2016
1 parent 05d565c commit 885d497
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
29 changes: 28 additions & 1 deletion OMEdit/OMEditGUI/Simulation/SimulationDialog.cpp
Expand Up @@ -110,6 +110,28 @@ void SimulationDialog::directSimulate(LibraryTreeItem *pLibraryTreeItem, bool la
simulate();
}

/*!
A scroll area with vertical bar and adjustment of width
See: https://forum.qt.io/topic/13374/solved-qscrollarea-vertical-scroll-only
*/
class VerticalScrollArea : public QScrollArea
{
public:
VerticalScrollArea()
{
setWidgetResizable(true);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
}

virtual bool eventFilter(QObject *o, QEvent *e)
{
if (o && o == widget() && e->type() == QEvent::Resize)
setMinimumWidth(widget()->minimumSizeHint().width() + verticalScrollBar()->width());
return QScrollArea::eventFilter(o, e);
}
};

/*!
Creates all the controls and set their layout.
*/
Expand All @@ -124,6 +146,11 @@ void SimulationDialog::setUpForm()
mpSimulationTabWidget = new QTabWidget;
// General Tab
mpGeneralTab = new QWidget;
// General Tab scroll area
mpGeneralTabScrollArea = new VerticalScrollArea;
mpGeneralTabScrollArea->setFrameShape(QFrame::NoFrame);
mpGeneralTabScrollArea->setBackgroundRole(QPalette::Base);
mpGeneralTabScrollArea->setWidget(mpGeneralTab);
// Simulation Interval
mpSimulationIntervalGroupBox = new QGroupBox(tr("Simulation Interval"));
mpStartTimeLabel = new Label(tr("Start Time:"));
Expand Down Expand Up @@ -270,7 +297,7 @@ void SimulationDialog::setUpForm()
pGeneralTabLayout->addWidget(mpLaunchAnimationCheckBox, 7, 0, 1, 3);
mpGeneralTab->setLayout(pGeneralTabLayout);
// add General Tab to Simulation TabWidget
mpSimulationTabWidget->addTab(mpGeneralTab, Helper::general);
mpSimulationTabWidget->addTab(mpGeneralTabScrollArea, Helper::general);
// Output Tab
mpOutputTab = new QWidget;
// Output Format
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/Simulation/SimulationDialog.h
Expand Up @@ -83,6 +83,7 @@ class SimulationDialog : public QDialog
QTabWidget *mpSimulationTabWidget;
// General Tab
QWidget *mpGeneralTab;
QScrollArea *mpGeneralTabScrollArea;
QGroupBox *mpSimulationIntervalGroupBox;
Label *mpStartTimeLabel;
QLineEdit *mpStartTimeTextBox;
Expand Down

0 comments on commit 885d497

Please sign in to comment.