Commit 9a2dd891 authored by WINTZ Julien's avatar WINTZ Julien

Having a the title stuff working ... sowmhow ...

Far from being satisfactory.

- Need to install event filter on children
- The de facto parent/child hierarchy is f***ing complicated when using
  dtk's menu framework
parent 00d2d7e7
...@@ -19,6 +19,59 @@ ...@@ -19,6 +19,59 @@
#include <dtkFonts> #include <dtkFonts>
#include <dtkWidgets> #include <dtkWidgets>
// ///////////////////////////////////////////////////////////////////
//
// ///////////////////////////////////////////////////////////////////
class dtkThemesWidgetsFilter : public QObject
{
Q_OBJECT
public:
dtkThemesWidgetsFilter(QWidget *destination) : m_destination(destination)
{
}
protected:
bool eventFilter(QObject *obj, QEvent *event) override;
private:
QWidget *m_destination = nullptr;
};
bool dtkThemesWidgetsFilter::eventFilter(QObject *obj, QEvent *event)
{
if(event->type() == QEvent::MouseTrackingChange)
{
qDebug() << Q_FUNC_INFO << "Got one ..." << 1;
event->ignore();
return true;
}
if(event->type() == QEvent::MouseButtonPress)
{
qDebug() << Q_FUNC_INFO << "Got one ..." << 2;
event->ignore();
return true;
}
if(event->type() == QEvent::MouseMove)
{
qDebug() << Q_FUNC_INFO << "Got one ..." << 3;
event->ignore();
return true;
}
return QObject::eventFilter(obj, event);
}
// ///////////////////////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////////////////////
// //
// ///////////////////////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////////////////////
...@@ -77,11 +130,15 @@ int main(int argc, char **argv) ...@@ -77,11 +130,15 @@ int main(int argc, char **argv)
void setup(dtkApplication *application) void setup(dtkApplication *application)
{ {
QLabel *bg = new QLabel(application->window()); QLabel *bg = new QLabel(application->window()->central());
bg->setPixmap(QPixmap(":/main_1.jpg")); bg->setPixmap(QPixmap(":/main_1.jpg"));
bg->setMouseTracking(true);
bg->installEventFilter(new dtkThemesWidgetsFilter(application->window()));
QScrollArea *area = new QScrollArea(application->window()); QScrollArea *area = new QScrollArea(application->window());
area->setWidget(bg); area->setWidget(bg);
area->setMouseTracking(true);
area->installEventFilter(new dtkThemesWidgetsFilter(application->window()));
dtkWidgetsMenu *menu_1 = new dtkWidgetsMenu(fa::circlethin, "MainLevel 1"); dtkWidgetsMenu *menu_1 = new dtkWidgetsMenu(fa::circlethin, "MainLevel 1");
dtkWidgetsMenuItem *menuitem_11 = menu_1->addItem(fa::circleo, "Cycle through background"); dtkWidgetsMenuItem *menuitem_11 = menu_1->addItem(fa::circleo, "Cycle through background");
...@@ -128,7 +185,6 @@ void setup(dtkApplication *application) ...@@ -128,7 +185,6 @@ void setup(dtkApplication *application)
// dtkWidgetsParameterMenuBarGenerator menubar_generator_1(":parameters_nature_1.json", ":parameters_definition_1.json"); // dtkWidgetsParameterMenuBarGenerator menubar_generator_1(":parameters_nature_1.json", ":parameters_definition_1.json");
// dtkWidgetsParameterMenuBarGenerator menubar_generator_2(":parameters_nature_2.json", ":parameters_definition_2.json"); // dtkWidgetsParameterMenuBarGenerator menubar_generator_2(":parameters_nature_2.json", ":parameters_definition_2.json");
application->window()->setCentralWidget(area);
application->window()->menubar()->addMenu(menu_1); application->window()->menubar()->addMenu(menu_1);
application->window()->menubar()->addMenu(menu_2); application->window()->menubar()->addMenu(menu_2);
application->window()->menubar()->addMenu(menu_3); application->window()->menubar()->addMenu(menu_3);
...@@ -138,8 +194,21 @@ void setup(dtkApplication *application) ...@@ -138,8 +194,21 @@ void setup(dtkApplication *application)
application->window()->populate(); application->window()->populate();
QVBoxLayout *layout = new QVBoxLayout;
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
layout->addWidget(area);
application->window()->setCentralLayout(layout);
application->window()->menubar()->touch(); application->window()->menubar()->touch();
application->window()->initialize();
} }
// ///////////////////////////////////////////////////////////////////
#include "main.moc"
// //
// main.cpp ends here // main.cpp ends here
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