1 #include "mycheckbox.h"
\r
3 int MyCheckBox::instances = 0;
\r
5 MyCheckBox::MyCheckBox(QWidget *parent) :
\r
9 qDebug() << "MyCheckBox instances:" << instances;
\r
10 uncheckedColor = palette();
\r
11 checkedColor.setColor(QPalette::WindowText, Qt::gray);
\r
13 setContextMenuPolicy(Qt::CustomContextMenu);
\r
14 connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotContextMenuActivated(QPoint)));
\r
15 connect(this, SIGNAL(toggled(bool)), this, SLOT(slotTriggered(bool)));
\r
18 MyCheckBox::MyCheckBox(const QString & text, QWidget *parent) :
\r
19 QCheckBox(text, parent)
\r
22 qDebug() << "MyCheckBox instances:" << instances;
\r
24 uncheckedColor = palette();
\r
25 checkedColor.setColor(QPalette::WindowText, Qt::gray);
\r
27 setContextMenuPolicy(Qt::CustomContextMenu);
\r
28 connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotContextMenuActivated(QPoint)));
\r
29 connect(this, SIGNAL(toggled(bool)), this, SLOT(slotTriggered(bool)));
\r
32 MyCheckBox::~MyCheckBox()
\r
35 qDebug() << "MyCheckBox instances left:" << instances;
\r
38 void MyCheckBox::slotDeleteClicked()
\r
40 qDebug() << "Delete clicked";
\r
41 emit signalDeleteClicked(this);
\r
44 void MyCheckBox::slotContextMenuActivated(QPoint point)
\r
46 qDebug() << "Context menu activated";
\r
48 menu.addAction(tr("Delete"), this, SLOT(slotDeleteClicked()));
\r
49 menu.exec(this->mapToGlobal(point));
\r
52 void MyCheckBox::slotTriggered(bool checked)
\r
56 setPalette(checkedColor);
\r
60 setPalette(uncheckedColor);
\r
63 f.setStrikeOut(checked);
\r