2
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
5
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
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.
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.
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/>.
20
#include "middlewidget.h"
21
#include "../component/kylintoolbutton.h"
22
#include "mainwindow.h"
25
MiddleWidget::MiddleWidget(QWidget *parent, QString arch, QString os)
26
: QWidget(parent), cur_arch(arch), osname(os)
28
this->setFixedSize(900, 47);
29
this->setAutoFillBackground(true);
31
palette.setColor(QPalette::Background, QColor(233,238,241));//#e9eef1
32
this->setPalette(palette);
34
QStringList icon_list;
35
QStringList text_list;
36
// if(this->cur_arch == "aarch64" || this->osname == "Kylin" || this->osname == "YHKylin")
38
// icon_list<<":/tool/res/menu/home"<<":/tool/res/menu/cleanup"<<":/tool/res/menu/sysinfo"<<":/tool/res/menu/toolkits";
39
// text_list<< tr("KylinHome") << tr("Cleanup") << tr("Sysinfo") << tr("Toolkits");
42
icon_list<<":/tool/res/menu/home"<<":/tool/res/menu/cleanup"<<":/tool/res/menu/sysinfo"<<":/tool/res/menu/feature"<<":/tool/res/menu/toolkits";
43
text_list<< tr("Home") << tr("Cleanup") << tr("Sysinfo") << tr("Feature") << tr("Toolkits");
46
QHBoxLayout *button_layout = new QHBoxLayout();
48
QSignalMapper *signal_mapper = new QSignalMapper(this);
49
for(int i=0; i<icon_list.size(); i++)
51
KylinToolButton *tool_button = new KylinToolButton(icon_list.at(i), text_list.at(i));
52
tool_button->setFixedSize(180, 47);
53
button_list.append(tool_button);
54
connect(tool_button, SIGNAL(clicked()), signal_mapper, SLOT(map()));
55
signal_mapper->setMapping(tool_button, QString::number(i, 10));
56
button_layout->addWidget(tool_button, 0, Qt::AlignBottom);
58
this->switchSelectedPageIndex("0");
59
connect(signal_mapper, SIGNAL(mapped(QString)), this, SLOT(switchSelectedPageIndex(QString)));
61
button_layout->addStretch();
62
button_layout->setSpacing(8);
63
button_layout->setMargin(0);
64
button_layout->setContentsMargins(15, 0, 15, 0);
66
setLayout(button_layout);
70
MiddleWidget::~MiddleWidget()
72
for(int i=0; i<button_list.count(); i++)
74
KylinToolButton *btn = button_list.at(i);
81
void MiddleWidget::switchSelectedPageIndex(QString index)
84
int current_index = index.toInt(&ok, 10);
86
for(int i=0; i<button_list.count(); i++)
88
KylinToolButton *tool_button = button_list.at(i);
89
if(current_index == i)
91
tool_button->setMousePress(true);
95
tool_button->setMousePress(false);
98
emit turnCurrentPage(current_index);
101
void MiddleWidget::showBoxTool()
103
// if(this->cur_arch == "aarch64" || this->osname == "Kylin" || this->osname == "YHKylin") {
104
// this->switchSelectedPageIndex("3");
107
this->switchSelectedPageIndex("4");