From 539e037777955d7bc7face4ac1e62a18756d104d Mon Sep 17 00:00:00 2001 From: deva Date: Fri, 20 Mar 2009 13:52:25 +0000 Subject: Fixed crash on doubleclik on the frame. --- client/macrodrawer.cc | 10 ++++++++-- client/macrodrawer.h | 6 ++++++ client/mainwindow.cc | 2 ++ 3 files changed, 16 insertions(+), 2 deletions(-) (limited to 'client') diff --git a/client/macrodrawer.cc b/client/macrodrawer.cc index 72395bb..ec761e9 100644 --- a/client/macrodrawer.cc +++ b/client/macrodrawer.cc @@ -53,7 +53,8 @@ MacroDrawer::MacroDrawer(MacroWindow *p, QString title) } installEventFilter(this); - connect(b, SIGNAL(clicked()), mw, SLOT(toggleMacro())); + // connect(b, SIGNAL(clicked()), mw, SLOT(toggleMacro())); + connect(b, SIGNAL(clicked()), this, SLOT(toggleMe())); } } @@ -61,7 +62,12 @@ bool MacroDrawer::eventFilter(QObject *obj, QEvent *event) { if(event->type() == QEvent::MouseButtonRelease) { QMouseEvent *mouseEvent = static_cast(event); - if(mouseEvent->y() < 16) mw->toggleMacro(); // Only activate when clicking the top. + if(mouseEvent->y() < 16 && isEnabled()) toggle();//mw->toggleMacro(); // Only activate when clicking the top. } return QObject::eventFilter(obj, event); } + +void MacroDrawer::toggleMe() +{ + emit toggle(); +} diff --git a/client/macrodrawer.h b/client/macrodrawer.h index b634198..a6a5d6d 100644 --- a/client/macrodrawer.h +++ b/client/macrodrawer.h @@ -39,6 +39,12 @@ public: protected: bool eventFilter(QObject *obj, QEvent *event); +public slots: + void toggleMe(); + +signals: + void toggle(); + private: MacroWindow *mw; }; diff --git a/client/mainwindow.cc b/client/mainwindow.cc index 6ba72e0..f0601ca 100644 --- a/client/mainwindow.cc +++ b/client/mainwindow.cc @@ -156,6 +156,8 @@ void MainWindow::update() macros[macroname]->isstatic = isstatic; MacroDrawer *g = new MacroDrawer(macros[macroname], xml_elem.attribute("caption", macroname)); + connect(g, SIGNAL(toggle()), macros[macroname], SLOT(toggleMacro())); + ((QBoxLayout*)w->layout())->addWidget(g); QHBoxLayout *l = new QHBoxLayout(); -- cgit v1.2.3