diff options
Diffstat (limited to 'client/macrodrawer.cc')
-rw-r--r-- | client/macrodrawer.cc | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/client/macrodrawer.cc b/client/macrodrawer.cc new file mode 100644 index 0000000..97868f8 --- /dev/null +++ b/client/macrodrawer.cc @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * macrodrawer.cc + * + * Tue Jan 6 15:49:48 CET 2009 + * Copyright 2009 Bent Bisballe Nyeng + * deva@aasimon.org + ****************************************************************************/ + +/* + * This file is part of Pracro. + * + * Pracro is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Pracro is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Pracro; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#include "macrodrawer.h" + +#include <QPushButton> + +MacroDrawer::MacroDrawer(MacroWindow *p, QString title) +{ + installEventFilter(this); + mw = p; + + if(!mw->isstatic) setTitle(" " + title); + setFlat(true); + + { + QFont f = font(); + f.setItalic(true); + setFont(f); + } + + if(!mw->isstatic) { + QPushButton *b = new QPushButton("±", this); + b->setFixedSize(16,16); + b->move(0,0); + { + QFont f = b->font(); + f.setBold(false); + f.setItalic(false); + b->setFont(f); + } + + connect(b, SIGNAL(clicked()), mw, SLOT(toggleMacro())); + } +} + +bool MacroDrawer::eventFilter(QObject *obj, QEvent *event) +{ + if(event->type() == QEvent::MouseButtonRelease) { + QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); + if(mouseEvent->y() < 16) mw->toggleMacro(); // Only activate when clicking the top. + } + return QObject::eventFilter(obj, event); +} |