Commit f09596d4 authored by WINTZ Julien's avatar WINTZ Julien

Towards filtering event the right way.

parent 2558f8a3
......@@ -19,59 +19,6 @@
#include <dtkFonts>
#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);
}
// /////////////////////////////////////////////////////////////////////////////
//
// /////////////////////////////////////////////////////////////////////////////
......@@ -130,25 +77,11 @@ int main(int argc, char **argv)
void setup(dtkApplication *application)
{
QLabel *bg = new QLabel(application->window()->central());
QLabel *bg = new QLabel;
bg->setPixmap(QPixmap(":/main_1.jpg"));
bg->setMouseTracking(true);
// ///////////////////////////////////////////////////////////////////
// TODO: This is theoretically ok ... but ergonomically unacceptable
// ///////////////////////////////////////////////////////////////////
bg->installEventFilter(new dtkThemesWidgetsFilter(application->window()));
// ///////////////////////////////////////////////////////////////////
QScrollArea *area = new QScrollArea(application->window());
area->setWidget(bg);
area->setMouseTracking(true);
// ///////////////////////////////////////////////////////////////////
// TODO: This is theoretically ok ... but ergonomically unacceptable
// ///////////////////////////////////////////////////////////////////
// area->installEventFilter(new dtkThemesWidgetsFilter(application->window()));
// ///////////////////////////////////////////////////////////////////
// Besides, only deepest widgets need to have a filter
// ///////////////////////////////////////////////////////////////////
dtkWidgetsMenu *menu_1 = new dtkWidgetsMenu(fa::circlethin, "MainLevel 1");
dtkWidgetsMenuItem *menuitem_11 = menu_1->addItem(fa::circleo, "Cycle through background");
......@@ -204,21 +137,10 @@ void setup(dtkApplication *application)
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()->setCentralWidget(area);
application->window()->menubar()->touch();
application->window()->initialize();
}
// ///////////////////////////////////////////////////////////////////
#include "main.moc"
//
// 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