Skip to content

Commit

Permalink
Remove grey area after error box in triggers (Mudlet#3075)
Browse files Browse the repository at this point in the history
* WIP - removed splitter, but grey area still spawns

* Fixed the grey area!

With correct stretching rules in place, thanks to Thorbjørn Lindeijer of Tiled.

* Clean up code
  • Loading branch information
vadi2 authored Sep 29, 2019
1 parent 4f6304b commit 8f0aef9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 25 deletions.
42 changes: 17 additions & 25 deletions src/dlgTriggerEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,41 +172,47 @@ dlgTriggerEditor::dlgTriggerEditor(Host* pH)
setStatusBar(statusBar);
statusBar->show();

mpNonCodeWidgets = new QWidget(this);
auto *layoutColumn = new QVBoxLayout(mpNonCodeWidgets);
splitter_right->addWidget(mpNonCodeWidgets);

// system message area
mpSystemMessageArea = new dlgSystemMessageArea(this);
mpSystemMessageArea->setObjectName(QStringLiteral("mpSystemMessageArea"));
mpSystemMessageArea->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum);
splitter_right->addWidget(mpSystemMessageArea);
// set the stretch factor of the message area to 0 and everything else to 1,
// so our errors box doesn't stretch to produce a grey area
layoutColumn->addWidget(mpSystemMessageArea, 0);
connect(mpSystemMessageArea->messageAreaCloseButton, &QAbstractButton::clicked, mpSystemMessageArea, &QWidget::hide);

// main areas
mpTriggersMainArea = new dlgTriggersMainArea(this);
splitter_right->addWidget(mpTriggersMainArea);
layoutColumn->addWidget(mpTriggersMainArea, 1);
connect(mpTriggersMainArea->pushButtonFgColor, &QAbstractButton::clicked, this, &dlgTriggerEditor::slot_colorizeTriggerSetFgColor);
connect(mpTriggersMainArea->pushButtonBgColor, &QAbstractButton::clicked, this, &dlgTriggerEditor::slot_colorizeTriggerSetBgColor);
connect(mpTriggersMainArea->pushButtonSound, &QAbstractButton::clicked, this, &dlgTriggerEditor::slot_soundTrigger);
connect(mpTriggersMainArea->groupBox_triggerColorizer, &QGroupBox::clicked, this, &dlgTriggerEditor::slot_toggleGroupBoxColorizeTrigger);
connect(mpTriggersMainArea->toolButton_clearSoundFile, &QAbstractButton::clicked, this, &dlgTriggerEditor::slot_clearSoundFile);

mpTimersMainArea = new dlgTimersMainArea(this);
splitter_right->addWidget(mpTimersMainArea);
layoutColumn->addWidget(mpTimersMainArea, 1);

mpAliasMainArea = new dlgAliasMainArea(this);
splitter_right->addWidget(mpAliasMainArea);
layoutColumn->addWidget(mpAliasMainArea, 1);

mpActionsMainArea = new dlgActionMainArea(this);
splitter_right->addWidget(mpActionsMainArea);
layoutColumn->addWidget(mpActionsMainArea, 1);
connect(mpActionsMainArea->checkBox_action_button_isPushDown, &QCheckBox::stateChanged, this, &dlgTriggerEditor::slot_toggle_isPushDownButton);

mpKeysMainArea = new dlgKeysMainArea(this);
splitter_right->addWidget(mpKeysMainArea);
layoutColumn->addWidget(mpKeysMainArea, 1);
connect(mpKeysMainArea->pushButton_key_grabKey, &QAbstractButton::clicked, this, &dlgTriggerEditor::slot_key_grab);

mpVarsMainArea = new dlgVarsMainArea(this);
splitter_right->addWidget(mpVarsMainArea);
layoutColumn->addWidget(mpVarsMainArea, 1);

mpScriptsMainArea = new dlgScriptsMainArea(this);
splitter_right->addWidget(mpScriptsMainArea);
layoutColumn->addWidget(mpScriptsMainArea, 1);

mIsScriptsMainAreaEditHandler = false;
mpScriptsMainAreaEditHandlerItem = nullptr;
Expand Down Expand Up @@ -276,26 +282,12 @@ dlgTriggerEditor::dlgTriggerEditor(Host* pH)
mpErrorConsole->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum);
splitter_right->addWidget(mpErrorConsole);

splitter_right->setStretchFactor(0, 0); // mpSystemMessageArea
splitter_right->setStretchFactor(0, 1); // mpNonCodeWidgets
splitter_right->setCollapsible(0, false);
splitter_right->setStretchFactor(1, 1); // mpTriggersMainArea
splitter_right->setStretchFactor(1, 1); // mpSourceEditorArea
splitter_right->setCollapsible(1, false);
splitter_right->setStretchFactor(2, 1); // mpTimersMainArea
splitter_right->setStretchFactor(2, 1); // mpErrorConsole
splitter_right->setCollapsible(2, false);
splitter_right->setStretchFactor(3, 1); // mpAliasMainArea
splitter_right->setCollapsible(3, false);
splitter_right->setStretchFactor(4, 1); // mpActionsMainArea
splitter_right->setCollapsible(4, false);
splitter_right->setStretchFactor(5, 1); // mpKeysMainArea
splitter_right->setCollapsible(5, false);
splitter_right->setStretchFactor(6, 1); // mpVarsMainArea
splitter_right->setCollapsible(6, false);
splitter_right->setStretchFactor(7, 1); // mpScriptsMainArea
splitter_right->setCollapsible(7, false);
splitter_right->setStretchFactor(8, 3); // mpSourceEditorArea
splitter_right->setCollapsible(8, false);
splitter_right->setStretchFactor(9, 1); // mpErrorConsole
splitter_right->setCollapsible(9, false);

mpErrorConsole->hide();

Expand Down
3 changes: 3 additions & 0 deletions src/dlgTriggerEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,9 @@ private slots:

QScrollArea* mpScrollArea;
QWidget* HpatternList;
// this widget holds the errors, trigger patterns, and all other widgets that aren't edbee
// in it, as a workaround for an extra splitter getting created by Qt below the error msg otherwise
QWidget *mpNonCodeWidgets;
dlgTriggersMainArea* mpTriggersMainArea;
dlgTimersMainArea* mpTimersMainArea;
dlgSystemMessageArea* mpSystemMessageArea;
Expand Down
6 changes: 6 additions & 0 deletions src/ui/triggers_main_area.ui
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
<height>270</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QGridLayout" name="gridLayout_triggers_main_area" rowstretch="0,1" columnstretch="1,0">
<property name="leftMargin">
<number>0</number>
Expand Down

0 comments on commit 8f0aef9

Please sign in to comment.