Commit 772a44d6 authored by LE BRETON Come's avatar LE BRETON Come
Browse files

Provides the GUI part.

parent 24d0866e
Pipeline #138914 passed with stage
in 0 seconds
......@@ -22,6 +22,7 @@
#include <dtkThemes/dtkThemesEngine>
#include <dtkFonts/dtkFontAwesome>
#include <dtkCore/dtkCoreParameter>
// ///////////////////////////////////////////////////////////////////
// dtkWidgetsMainWindowPrivate
......@@ -29,15 +30,88 @@
class dtkWidgetsMainWindowPrivate
{
public:
dtkWidgetsMenu *populateAdvancedMenu(void);
dtkWidgetsMenu *populateThemesMenu(dtkWidgetsMenu *);
dtkWidgetsMenu *populateAboutMenu(dtkWidgetsMenu *);
QObject *populateAdvancedParametersSwitch(dtkWidgetsMenu *);
public:
dtkWidgetsMenuBar *menubar = nullptr;
public:
dtkWidgetsMenu *menu_files = nullptr;
dtkWidgetsMenu *menu_themes = nullptr;
dtkWidgetsMenu *menu_about = nullptr;
dtkWidgetsMenu *menu_advanced = nullptr;
};
dtkWidgetsMenu *dtkWidgetsMainWindowPrivate::populateAdvancedMenu(void)
{
if(!this->menu_advanced) {
this->menu_advanced = this->menubar->addMenu(fa::question, "Advanced");
this->populateThemesMenu(this->menu_advanced);
this->populateAdvancedParametersSwitch(this->menu_advanced);
this->populateAboutMenu(this->menu_advanced);
}
return this->menu_advanced;
}
dtkWidgetsMenu *dtkWidgetsMainWindowPrivate::populateThemesMenu(dtkWidgetsMenu *menu)
{
dtkWidgetsMenu *menu_themes = menu->menu("Themes");
if(!menu_themes) {
menu_themes = menu->addMenu(fa::paintbrush, "Themes");
auto *inner_menu_theme = menu_themes->addMenu(fa::paintbrush, "Choose Theme");
for (const QString theme : dtkThemesEngine::instance()->themes()) {
dtkWidgetsMenuItem * item = inner_menu_theme->addItem(new dtkWidgetsMenuItemTheme(theme));
QObject::connect(item, &dtkWidgetsMenuItem::clicked, [=] () {
dtkThemesEngine::instance()->apply(theme);
});
}
}
return menu_themes;
}
dtkWidgetsMenu *dtkWidgetsMainWindowPrivate::populateAboutMenu(dtkWidgetsMenu *menu)
{
dtkWidgetsMenu *menu_about = menu->menu("About");
if(!menu_about) {
menu_about = menu->addMenu(fa::question, "About");
menu_about->addMenu(fa::question, "dtk")->addItem(0, "prout");
menu_about->addMenu(fa::question, "dtk environment (conda)")->addItem(0, "Pour Come");
}
return menu_about;
}
QObject *dtkWidgetsMainWindowPrivate::populateAdvancedParametersSwitch(dtkWidgetsMenu *menu)
{
QObject *switch_widget = menu->object("Switch");
if(!switch_widget) {
dtk::d_bool *switch_parameter = new dtk::d_bool("Advanced Parameters", false, false, true, "Shows / Hide the advanced parameters in the menu");
switch_parameter->connect([=](QVariant v) {
if(!menubar) {
return;
}
menubar->displayAdvancedParameters(v.value<dtk::d_bool>());
});
switch_widget = menu->addParameter("Switch", switch_parameter, "dtkWidgetsParameterBoolCheckBox", true);
QObject::connect(switch_widget, &QWidget::destroyed, [=] () {
delete switch_parameter;
});
}
return switch_widget;
}
// ///////////////////////////////////////////////////////////////////
// dtkWidgetsMainWindow
// ///////////////////////////////////////////////////////////////////
......@@ -64,57 +138,10 @@ dtkWidgetsMenuBar *dtkWidgetsMainWindow::menubar(void)
}
void dtkWidgetsMainWindow::populate(void)
{
// Q_UNUSED(this->populateFileMenu());
Q_UNUSED(this->populateThemesMenu());
// Q_UNUSED(this->populateAboutMenu());
}
dtkWidgetsMenu *dtkWidgetsMainWindow::populateFileMenu(void)
{
Q_UNUSED(this->menubar());
if(!d->menu_files) {
d->menu_files = d->menubar->insertMenu(0, fa::file, "Files");
d->menu_files->addItem(0, "Open");
d->menu_files->addItem(0, "Open Recent");
d->menu_files->addItem(0, "Save");
d->menu_files->addItem(0, "Save As");
}
return d->menu_files;
}
dtkWidgetsMenu *dtkWidgetsMainWindow::populateThemesMenu(void)
{
Q_UNUSED(this->menubar());
if(!d->menu_themes) {
d->menu_themes = d->menubar->addMenu(fa::paintbrush, "Themes");
auto *inner_menu_theme = d->menu_themes->addMenu(fa::paintbrush, "Choose Theme");
for (const QString theme : dtkThemesEngine::instance()->themes()) {
dtkWidgetsMenuItem * item = inner_menu_theme->addItem(new dtkWidgetsMenuItemTheme(theme));
connect(item, &dtkWidgetsMenuItem::clicked, [=] () {
dtkThemesEngine::instance()->apply(theme);
});
}
}
return d->menu_themes;
}
dtkWidgetsMenu *dtkWidgetsMainWindow::populateAboutMenu(void)
{
Q_UNUSED(this->menubar());
if(!d->menu_about) {
d->menu_about = d->menubar->addMenu(fa::question, "About");
d->menu_about->addMenu(fa::question, "dtk")->addItem(0, "prout");
d->menu_about->addMenu(fa::question, "dtk environment (conda)")->addItem(0, "Pour Come");
}
return d->menu_about;
Q_UNUSED(d->populateAdvancedMenu());
}
void dtkWidgetsMainWindow::resizeEvent(QResizeEvent *event)
......
......@@ -35,9 +35,6 @@ public:
public:
void populate(void);
dtkWidgetsMenu *populateFileMenu(void);
dtkWidgetsMenu *populateThemesMenu(void);
dtkWidgetsMenu *populateAboutMenu(void);
protected:
void resizeEvent(QResizeEvent *event);
......
......@@ -1142,6 +1142,11 @@ QWidget *dtkWidgetsMenuBar::container(void)
return d->c;
}
void dtkWidgetsMenuBar::displayAdvancedParameters(bool display)
{
}
// /////////////////////////////////////////////////////////////////////////////
#include "dtkWidgetsMenuBar.moc"
......
......@@ -59,6 +59,10 @@ public:
public:
QWidget *container(void);
#pragma mark - Handling of advanced parameters
void displayAdvancedParameters(bool);
// /////////////////////////////////////////////////////////////////////////////
#pragma mark - Convenience builders
// /////////////////////////////////////////////////////////////////////////////
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment