-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwidget.cpp
54 lines (50 loc) · 1.3 KB
/
widget.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "widget.h"
#include "ui_widget.h"
#include <QTimer>
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
qApp->setQuitOnLastWindowClosed(false);
setAttribute(Qt::WA_DeleteOnClose, false);
#ifdef Q_WS_MAC
macIntegration = new MacIntegration(this);
connect(macIntegration, SIGNAL(dockClicked()), SLOT(show()));
QTimer * timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), macIntegration, SLOT(requestAttention()));
timer->start(5000);
#endif
}
Widget::~Widget()
{
delete ui;
}
void Widget::on_badgeEdit_textChanged(const QString &text)
{
#ifdef Q_WS_MAC
macIntegration->setDockBadge(text);
#endif
}
void Widget::on_overlayButton_clicked()
{
#ifdef Q_WS_MAC
static bool overlaySet = false;
if (!overlaySet)
{
QLabel * overlay = new QLabel(this);
overlay->setPixmap(QPixmap(":/habr_logo.png"));
overlay->setScaledContents(true);
overlay->setAttribute(Qt::WA_TranslucentBackground, true);
overlay->setGeometry(0, 0, 16, 16);
macIntegration->setDockOverlay(overlay);
ui->overlayButton->setText("Remove");
}
else
{
macIntegration->setDockOverlay(NULL);
ui->overlayButton->setText("Add");
}
overlaySet = !overlaySet;
#endif
}