Auto hide/show plugin containers
Commit amended for code style and to add comments by Adam Honse <calcprogrammer1@gmail.com>
This commit is contained in:
parent
84371c3cd8
commit
8ee0b12ef8
5 changed files with 51 additions and 28 deletions
|
|
@ -1213,3 +1213,37 @@ void Ui::OpenRGBDialog2::on_ActionSaveProfileAs_triggered()
|
|||
{
|
||||
SaveProfileAs();
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDialog2::on_MainTabBar_currentChanged(int tab_idx)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Hide all plugins |
|
||||
\*---------------------------------------------------------*/
|
||||
for(unsigned int i = 0; i < (ui->MainTabBar->count()); i++)
|
||||
{
|
||||
QWidget* tab = ui->MainTabBar->widget(i);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Dynamic cast is essential in this check to ensure the |
|
||||
| tab is actually a plugin container |
|
||||
\*-----------------------------------------------------*/
|
||||
if((i != tab_idx) && (dynamic_cast<OpenRGBPluginContainer*>(tab) != nullptr))
|
||||
{
|
||||
((OpenRGBPluginContainer*) tab)->Hide();
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Show plugin if needed |
|
||||
\*---------------------------------------------------------*/
|
||||
QWidget* tab = ui->MainTabBar->widget(tab_idx);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Dynamic cast is essential in this check to ensure the tab |
|
||||
| is actually a plugin container |
|
||||
\*---------------------------------------------------------*/
|
||||
if(dynamic_cast<OpenRGBPluginContainer*>(tab) != nullptr)
|
||||
{
|
||||
((OpenRGBPluginContainer*) tab)->Show();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ private slots:
|
|||
void on_ButtonRescan_clicked();
|
||||
void on_ActionSaveProfile_triggered();
|
||||
void on_ActionSaveProfileAs_triggered();
|
||||
void on_MainTabBar_currentChanged(int);
|
||||
};
|
||||
|
||||
#endif // OPENRGBDIALOG2_H
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ Ui::OpenRGBPluginContainer::OpenRGBPluginContainer(QWidget *plugin, QWidget *par
|
|||
|
||||
ui->PluginContainerLayout->layout()->addWidget(plugin_widget);
|
||||
|
||||
plugin_widget->hide();
|
||||
Hide();
|
||||
}
|
||||
|
||||
Ui::OpenRGBPluginContainer::~OpenRGBPluginContainer()
|
||||
|
|
@ -19,14 +19,14 @@ Ui::OpenRGBPluginContainer::~OpenRGBPluginContainer()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
void Ui::OpenRGBPluginContainer::on_ShowPluginButton_clicked()
|
||||
void Ui::OpenRGBPluginContainer::Hide()
|
||||
{
|
||||
if(plugin_widget->isHidden())
|
||||
{
|
||||
plugin_widget->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin_widget->hide();
|
||||
}
|
||||
plugin_widget->hide();
|
||||
ui->PluginContainerLayout->layout()->invalidate();
|
||||
}
|
||||
|
||||
void Ui::OpenRGBPluginContainer::Show()
|
||||
{
|
||||
plugin_widget->show();
|
||||
ui->PluginContainerLayout->layout()->invalidate();
|
||||
}
|
||||
|
|
@ -17,9 +17,8 @@ class Ui::OpenRGBPluginContainer : public QWidget
|
|||
public:
|
||||
explicit OpenRGBPluginContainer(QWidget *plugin, QWidget *parent = nullptr);
|
||||
~OpenRGBPluginContainer();
|
||||
|
||||
private slots:
|
||||
void on_ShowPluginButton_clicked();
|
||||
void Hide();
|
||||
void Show();
|
||||
|
||||
private:
|
||||
Ui::OpenRGBPluginContainerUi *ui;
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
<width>256</width>
|
||||
<height>120</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
|
|
@ -21,18 +21,7 @@
|
|||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="PluginContainerLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetNoConstraint</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="ShowPluginButton">
|
||||
<property name="text">
|
||||
<string>Show/Hide Plugin</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<layout class="QGridLayout" name="PluginContainerLayout"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue