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

« back to all changes in this revision

Viewing changes to mainui/titlewidget.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:
1
 
/*
2
 
 * Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
3
 
 *
4
 
 * Authors:
5
 
 *  Kobe Lee    xiangli@ubuntukylin.com/kobe24_lixiang@126.com
6
 
 *
7
 
 * This program is free software; you can redistribute it and/or modify
8
 
 * it under the terms of the GNU General Public License as published by
9
 
 * the Free Software Foundation; version 3.
10
 
 *
11
 
 * This program is distributed in the hope that it will be useful,
12
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 * GNU General Public License for more details.
15
 
 *
16
 
 * You should have received a copy of the GNU General Public License
17
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 
 */
19
 
 
20
 
#include "titlewidget.h"
21
 
#include "mainwindow.h"
22
 
 
23
 
TitleWidget::TitleWidget(QWidget *parent, QString arch, QString os)
24
 
        : QWidget(parent)
25
 
{
26
 
    this->setFixedSize(900, 36);
27
 
    min_button = new SystemButton();
28
 
    close_button = new SystemButton();
29
 
    skin_button = new SystemButton();
30
 
    main_menu_button = new SystemButton();
31
 
    min_button->loadPixmap(":/sys/res/sysBtn/min_button.png");
32
 
    close_button->loadPixmap(":/sys/res/sysBtn/close_button.png");
33
 
    skin_button->loadPixmap(":/sys/res/sysBtn/skin_button.png");
34
 
    main_menu_button->loadPixmap(":/sys/res/sysBtn/main_menu.png");
35
 
    min_button->setFocusPolicy(Qt::NoFocus);
36
 
    close_button->setFocusPolicy(Qt::NoFocus);
37
 
    skin_button->setFocusPolicy(Qt::NoFocus);
38
 
    main_menu_button->setFocusPolicy(Qt::NoFocus);
39
 
 
40
 
    QHBoxLayout *title_layout = new QHBoxLayout();
41
 
    if(arch == "aarch64" || os == "Kylin" || os == "YHKylin")
42
 
    {
43
 
        title_layout->addWidget(main_menu_button, 0, Qt::AlignTop);
44
 
        title_layout->addWidget(skin_button, 0, Qt::AlignTop);
45
 
        title_layout->addWidget(min_button, 0, Qt::AlignTop);
46
 
        title_layout->addWidget(close_button, 0, Qt::AlignTop);
47
 
    }
48
 
    else
49
 
    {
50
 
        title_layout->addWidget(close_button, 0, Qt::AlignTop);
51
 
        title_layout->addWidget(min_button, 0, Qt::AlignTop);
52
 
        title_layout->addWidget(skin_button, 0, Qt::AlignTop);
53
 
        title_layout->addWidget(main_menu_button, 0, Qt::AlignTop);
54
 
    }
55
 
 
56
 
    title_layout->addStretch();
57
 
    title_layout->setSpacing(0);
58
 
    title_layout->setContentsMargins(0, 0, 5, 0);
59
 
 
60
 
    QVBoxLayout *main_layout = new QVBoxLayout();
61
 
    main_layout->addLayout(title_layout);
62
 
    main_layout->setSpacing(0);
63
 
    main_layout->setContentsMargins(0, 0, 0, 0);
64
 
 
65
 
    setLayout(main_layout);
66
 
 
67
 
    is_move = false;
68
 
}
69
 
 
70
 
TitleWidget::~TitleWidget()
71
 
{
72
 
    if(min_button != NULL)
73
 
    {
74
 
        delete min_button;
75
 
        min_button = NULL;
76
 
    }
77
 
    if(close_button != NULL)
78
 
    {
79
 
        delete close_button;
80
 
        close_button = NULL;
81
 
    }
82
 
    if(skin_button != NULL)
83
 
    {
84
 
        delete skin_button;
85
 
        skin_button = NULL;
86
 
    }
87
 
    if(main_menu_button != NULL)
88
 
    {
89
 
        delete main_menu_button;
90
 
        main_menu_button = NULL;
91
 
    }
92
 
}
93
 
 
94
 
void TitleWidget::initConnect() {
95
 
    connect(min_button, SIGNAL(clicked()), p_mainwindow, SLOT(showMinimized()));
96
 
    connect(close_button, SIGNAL(clicked()), this, SIGNAL(closeApp()));
97
 
    connect(skin_button, SIGNAL(clicked()), p_mainwindow, SLOT(openSkinCenter()));
98
 
    connect(main_menu_button, SIGNAL(clicked()), p_mainwindow, SLOT(showMainMenu()));
99
 
}