~feng-kylin/youker-assistant/youker-assistant

« back to all changes in this revision

Viewing changes to component/kylinswitcher.cpp

  • Committer: lixiang
  • Date: 2018-03-06 03:13:06 UTC
  • Revision ID: lixiang@kylinos.cn-20180306031306-fd7qnru3vm4a1xjd
Rewrite with Qt5, and add system monitor

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
{
26
26
    setWindowFlags(Qt::FramelessWindowHint);
27
27
    switchedOn = false;
28
 
    mouse_press = false;
 
28
    m_mousePressed = false;
29
29
    pixmap_on.load("://res/switch-on.png");
30
30
    pixmap_off.load("://res/switch-off.png");
31
31
    this->setFixedSize(pixmap_on.width(), pixmap_on.height());
36
36
{
37
37
    if(event->button() == Qt::LeftButton)
38
38
    {
39
 
        mouse_press = true;
 
39
        m_mousePressed = true;
40
40
    }
41
41
}
42
42
 
43
43
void KylinSwitcher::mouseReleaseEvent(QMouseEvent *event)
44
44
{
45
 
    if (mouse_press && this->rect().contains(event->pos())) {
46
 
        mouse_press = false;
 
45
    if (m_mousePressed && this->rect().contains(event->pos())) {
 
46
        m_mousePressed = false;
47
47
        switchedOn = !switchedOn;
48
48
        emit clicked();
49
49
    }