forked from openkylin/quarkai
rewrite mainwindow
This commit is contained in:
parent
971af2debd
commit
97fe174155
|
@ -25,7 +25,7 @@ AgentListItem::AgentListItem(QWidget *parent) :
|
|||
QWidget(parent)
|
||||
{
|
||||
this->setWindowFlags(Qt::FramelessWindowHint);
|
||||
mouse_press = false;
|
||||
m_mousePressed = false;
|
||||
label = new QLabel();
|
||||
delede_button = new QPushButton();
|
||||
delede_button->setFocusPolicy(Qt::NoFocus);
|
||||
|
@ -81,15 +81,15 @@ void AgentListItem::mousePressEvent(QMouseEvent *event)
|
|||
{
|
||||
if(event->button() == Qt::LeftButton)
|
||||
{
|
||||
mouse_press = true;
|
||||
m_mousePressed = true;
|
||||
}
|
||||
}
|
||||
|
||||
void AgentListItem::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if(mouse_press)
|
||||
if(m_mousePressed)
|
||||
{
|
||||
emit showItemName(label->text());
|
||||
mouse_press = false;
|
||||
m_mousePressed = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public slots:
|
|||
void onDeleteButtonClicked();
|
||||
|
||||
private:
|
||||
bool mouse_press;
|
||||
bool m_mousePressed;
|
||||
QLabel *label;
|
||||
QPushButton *delede_button;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ KylinButton::KylinButton(QWidget *parent)
|
|||
:QPushButton(parent)
|
||||
{
|
||||
status = NORMAL;
|
||||
mouse_press = false;
|
||||
m_mousePressed = false;
|
||||
}
|
||||
|
||||
KylinButton::~KylinButton()
|
||||
|
@ -47,7 +47,7 @@ void KylinButton::mousePressEvent(QMouseEvent *event)
|
|||
{
|
||||
if(event->button() == Qt::LeftButton)
|
||||
{
|
||||
mouse_press = true;
|
||||
m_mousePressed = true;
|
||||
status = PRESS;
|
||||
update();
|
||||
}
|
||||
|
@ -55,9 +55,9 @@ void KylinButton::mousePressEvent(QMouseEvent *event)
|
|||
|
||||
void KylinButton::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if(mouse_press && this->rect().contains(event->pos()))
|
||||
if(m_mousePressed && this->rect().contains(event->pos()))
|
||||
{
|
||||
mouse_press = false;
|
||||
m_mousePressed = false;
|
||||
status = ENTER;
|
||||
update();
|
||||
emit clicked();
|
||||
|
|
|
@ -48,7 +48,7 @@ private:
|
|||
|
||||
int btn_width; //按钮宽度
|
||||
int btn_height; //按钮高度
|
||||
bool mouse_press; //按钮左键是否按下
|
||||
bool m_mousePressed; //按钮左键是否按下
|
||||
};
|
||||
|
||||
#endif //KYLINBUTTON_H
|
||||
|
|
|
@ -25,7 +25,7 @@ KylinSwitcher::KylinSwitcher(QWidget *parent) :
|
|||
{
|
||||
setWindowFlags(Qt::FramelessWindowHint);
|
||||
switchedOn = false;
|
||||
mouse_press = false;
|
||||
m_mousePressed = false;
|
||||
pixmap_on.load("://res/switch-on.png");
|
||||
pixmap_off.load("://res/switch-off.png");
|
||||
this->setFixedSize(pixmap_on.width(), pixmap_on.height());
|
||||
|
@ -36,14 +36,14 @@ void KylinSwitcher::mousePressEvent(QMouseEvent *event)
|
|||
{
|
||||
if(event->button() == Qt::LeftButton)
|
||||
{
|
||||
mouse_press = true;
|
||||
m_mousePressed = true;
|
||||
}
|
||||
}
|
||||
|
||||
void KylinSwitcher::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (mouse_press && this->rect().contains(event->pos())) {
|
||||
mouse_press = false;
|
||||
if (m_mousePressed && this->rect().contains(event->pos())) {
|
||||
m_mousePressed = false;
|
||||
switchedOn = !switchedOn;
|
||||
emit clicked();
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public slots:
|
|||
private:
|
||||
QPixmap pixmap_on;
|
||||
QPixmap pixmap_off;
|
||||
bool mouse_press;
|
||||
bool m_mousePressed;
|
||||
};
|
||||
|
||||
#endif // KYLINSWITCHER_H
|
||||
|
|
|
@ -50,7 +50,7 @@ KylinToolButton::KylinToolButton(const QString &pic_name, const QString &text, Q
|
|||
setAutoRaise(true);
|
||||
this->setObjectName("transparentToolButton");
|
||||
mouse_over = false;
|
||||
mouse_press = false;
|
||||
m_mousePressed = false;
|
||||
pressed = false;
|
||||
}
|
||||
|
||||
|
@ -103,9 +103,9 @@ void KylinToolButton::setMouseHover()
|
|||
|
||||
void KylinToolButton::setMousePress(bool is_press)
|
||||
{
|
||||
this->mouse_press = is_press;
|
||||
this->m_mousePressed = is_press;
|
||||
|
||||
if(this->mouse_press)
|
||||
if(this->m_mousePressed)
|
||||
{
|
||||
this->setIcon(QIcon(press_icon));
|
||||
pressed = true;
|
||||
|
@ -122,7 +122,7 @@ void KylinToolButton::setMousePress(bool is_press)
|
|||
// }
|
||||
// else
|
||||
// {
|
||||
// if(this->mouse_press)
|
||||
// if(this->m_mousePressed)
|
||||
// {
|
||||
// this->setIcon(QIcon(press_icon));
|
||||
// }
|
||||
|
|
|
@ -41,7 +41,7 @@ protected:
|
|||
|
||||
public:
|
||||
bool mouse_over; //鼠标是否移过
|
||||
bool mouse_press; //鼠标是否按下
|
||||
bool m_mousePressed; //鼠标是否按下
|
||||
QIcon normal_icon;
|
||||
QIcon hover_icon;
|
||||
QIcon press_icon;
|
||||
|
|
|
@ -24,7 +24,7 @@ SystemButton::SystemButton(QWidget *parent) :
|
|||
QPushButton(parent)
|
||||
{
|
||||
status = NORMAL;
|
||||
mouse_press = false;
|
||||
m_mousePressed = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -46,7 +46,7 @@ void SystemButton::mousePressEvent(QMouseEvent *event)
|
|||
{
|
||||
if(event->button() == Qt::LeftButton)
|
||||
{
|
||||
mouse_press = true;
|
||||
m_mousePressed = true;
|
||||
status = PRESS;
|
||||
update();
|
||||
}
|
||||
|
@ -54,9 +54,9 @@ void SystemButton::mousePressEvent(QMouseEvent *event)
|
|||
|
||||
void SystemButton::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if(mouse_press && this->rect().contains(event->pos()))
|
||||
if(m_mousePressed && this->rect().contains(event->pos()))
|
||||
{
|
||||
mouse_press = false;
|
||||
m_mousePressed = false;
|
||||
status = ENTER;
|
||||
update();
|
||||
emit clicked();
|
||||
|
|
|
@ -48,7 +48,7 @@ private:
|
|||
QPixmap pixmap;
|
||||
enum ButtonStatus{NORMAL, ENTER, PRESS};
|
||||
ButtonStatus status;
|
||||
bool mouse_press; //按钮左键是否按下
|
||||
bool m_mousePressed; //按钮左键是否按下
|
||||
int btn_width;
|
||||
int btn_height;
|
||||
};
|
||||
|
|
|
@ -27,12 +27,19 @@
|
|||
#define ITEMVSPACE 5
|
||||
#define PAGESPACE 20
|
||||
#define ITEMWIDTH 650
|
||||
#define SHADOW_LEFT_TOP_PADDING 1
|
||||
#define SHADOW_RIGHT_BOTTOM_PADDING 2
|
||||
#define MAIN_WINDOW_WIDTH 900
|
||||
#define MAIN_WINDOW_HEIGHT 600
|
||||
//const int windowShadowPadding = 10;
|
||||
|
||||
//#define VERSION "2.4.1"
|
||||
|
||||
const QString KYLIN_COMPANY_SETTING = "kylin/kylin-assistant";
|
||||
const QString KYLIN_SETTING_FILE_NAME_SETTING = "kylin-assistant";
|
||||
|
||||
|
||||
|
||||
typedef enum{
|
||||
YOUKER_EN,
|
||||
YOUKER_ZH_CN,
|
||||
|
|
|
@ -27,11 +27,8 @@ SessionDispatcher::SessionDispatcher(QObject *parent)
|
|||
"/com/kylin/assistant/sessiondaemon",
|
||||
"com.kylin.assistant.sessiondaemon",
|
||||
QDBusConnection::sessionBus());
|
||||
|
||||
// QObject::connect(sessioniface, SIGNAL(autostartmanage_data_signal(QVariantMap)), this, SLOT(handlerAutoManageData(QVariantMap)));
|
||||
|
||||
|
||||
|
||||
QObject::connect(sessioniface, SIGNAL(autostartmanage_data_signal(QStringList)), this, SLOT(handlerAutoManageData(QStringList)));
|
||||
QObject::connect(sessioniface, SIGNAL(autostartmanage_status_signal(QString)), this, SLOT(handlerAutoManageStatus(QString)));
|
||||
QObject::connect(sessioniface, SIGNAL(autostartmanage_error_signal(QString)), this, SLOT(handlerAutoManageError(QString)));
|
||||
|
|
|
@ -18,5 +18,6 @@ kylin-assistant (1.0.0-0ubuntu1) bionic; urgency=low
|
|||
* Add monitor for file system.
|
||||
* Add QDbus module(system dbus and session dbus).
|
||||
* Make all dbus modules quit when the app quit.
|
||||
* Rewrite mainwindow.
|
||||
|
||||
-- lixiang <lixiang@kylinos.cn> Mon, 29 Jan 2018 17:54:44 +0800
|
||||
|
|
|
@ -293,7 +293,7 @@ void MonitorTitleWidget::initToolbarLeftContent()
|
|||
w->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
m_toolLeftLayout = new QHBoxLayout(w);
|
||||
m_toolLeftLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_toolLeftLayout->setSpacing(0);
|
||||
m_toolLeftLayout->setSpacing(10);
|
||||
|
||||
MyUnderLineButton *processButton = new MyUnderLineButton();
|
||||
processButton->setName(tr("Processes"));
|
||||
|
@ -336,8 +336,6 @@ void MonitorTitleWidget::initToolbarLeftContent()
|
|||
emit canelSearchEditFocus();
|
||||
});
|
||||
|
||||
m_toolLeftLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_toolLeftLayout->setSpacing(10);
|
||||
m_toolLeftLayout->addStretch();
|
||||
m_toolLeftLayout->addWidget(processButton);
|
||||
m_toolLeftLayout->addWidget(resourcesButton);
|
||||
|
|
|
@ -236,23 +236,23 @@ void AboutDialog::mousePressEvent(QMouseEvent *event)
|
|||
{
|
||||
if(event->button() == Qt::LeftButton)
|
||||
{
|
||||
mouse_press = true;
|
||||
drag_pos = event->globalPos() - this->frameGeometry().topLeft();
|
||||
m_mousePressed = true;
|
||||
m_dragPosition = event->globalPos() - this->frameGeometry().topLeft();
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void AboutDialog::mouseReleaseEvent(QMouseEvent *)
|
||||
{
|
||||
mouse_press = false;
|
||||
m_mousePressed = false;
|
||||
}
|
||||
|
||||
void AboutDialog::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if(mouse_press)
|
||||
if(m_mousePressed)
|
||||
{
|
||||
QPoint move_pos = event->globalPos();
|
||||
move(move_pos - drag_pos);
|
||||
move(move_pos - m_dragPosition);
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,8 +52,8 @@ protected:
|
|||
|
||||
private:
|
||||
// KylinTitleBar *title_bar;
|
||||
QPoint drag_pos; //移动的距离
|
||||
bool mouse_press; //按下鼠标左键
|
||||
QPoint m_dragPosition; //移动的距离
|
||||
bool m_mousePressed; //按下鼠标左键
|
||||
QWidget *baseWidget;
|
||||
SystemButton *close_btn;
|
||||
QPushButton *aboutBtn;
|
||||
|
|
|
@ -28,7 +28,7 @@ CleanerActionWidget::CleanerActionWidget(QWidget *parent)
|
|||
this->setFixedSize(900, 150);
|
||||
|
||||
this->setAutoFillBackground(true);
|
||||
this->setObjectName("transparentWidget");
|
||||
// this->setObjectName("transparentWidget");
|
||||
// cache_page = new CacheActionWidget(this);
|
||||
// statked_widget = new QStackedWidget(this);
|
||||
//// QPalette palette;
|
||||
|
|
|
@ -140,6 +140,20 @@ bool DataWorker::copyAppointedFile(QString filename)
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
//---------------scan on homepage
|
||||
void DataWorker::onStartOneKeyScan(const QStringList &categorys)
|
||||
{
|
||||
m_sessionInterface->onekey_scan_function_qt(categorys);
|
||||
}
|
||||
|
||||
//---------------clean on homepage
|
||||
void DataWorker::onStartOneKeyClean()
|
||||
{
|
||||
m_systemInterface->set_user_homedir_qt();
|
||||
m_systemInterface->clean_by_main_one_key_qt();
|
||||
}
|
||||
|
||||
//---------------scan
|
||||
void DataWorker::onStartScanSystem(QMap<QString, QVariant> itemsMap)
|
||||
{
|
||||
|
|
|
@ -51,6 +51,11 @@ public slots:
|
|||
void doWork();
|
||||
void updateSensorValue();
|
||||
|
||||
//scan on homepage
|
||||
void onStartOneKeyScan(const QStringList &categorys);
|
||||
//clean on homepage
|
||||
void onStartOneKeyClean();
|
||||
|
||||
//scan
|
||||
void onStartScanSystem(QMap<QString, QVariant> itemsMap);
|
||||
//clean
|
||||
|
|
|
@ -319,15 +319,15 @@ void HomePage::switchPageIndex(QString index)
|
|||
|
||||
if(index == "0")
|
||||
emit this->sendSubIndex(0);
|
||||
else if(index == "-1")
|
||||
if(this->osarch == "aarch64" || this->osname == "Kylin" || this->osname == "YHKylin")
|
||||
sessionProxy->runApp("cheese");
|
||||
else
|
||||
emit this->sendSubIndex(1);
|
||||
else if(index == "1") {
|
||||
// p_mainwindow->showBoxWidget();
|
||||
emit this->moreSignal();
|
||||
}
|
||||
// else if(index == "-1")
|
||||
// if(this->osarch == "aarch64" || this->osname == "Kylin" || this->osname == "YHKylin")
|
||||
// sessionProxy->runApp("cheese");
|
||||
// else
|
||||
// emit this->sendSubIndex(1);
|
||||
// else if(index == "1") {
|
||||
//// p_mainwindow->showBoxWidget();
|
||||
// emit this->moreSignal();
|
||||
// }
|
||||
|
||||
// if(index == "0")
|
||||
// {
|
||||
|
|
|
@ -68,7 +68,7 @@ InfoWidget::~InfoWidget()
|
|||
}
|
||||
}
|
||||
|
||||
void InfoWidget::initUI(bool has_battery, bool has_sensor)
|
||||
void InfoWidget::initInfoUI(bool has_battery, bool has_sensor)
|
||||
{
|
||||
type_list.clear();
|
||||
icon_list.clear();
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
explicit InfoWidget(QString machine = "", QWidget *parent = 0);
|
||||
~InfoWidget();
|
||||
|
||||
void initUI(bool has_battery, bool has_sensor);
|
||||
void initInfoUI(bool has_battery, bool has_sensor);
|
||||
|
||||
public slots:
|
||||
void changeInfoPage(QListWidgetItem* item);
|
||||
|
|
|
@ -135,6 +135,9 @@ bool registerSingleInstance(const QString &path)
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
//find . | xargs -x touch
|
||||
//linguist: sudo apt-get install qt4-dev-tools
|
||||
|
||||
// QApplication app(argc, argv);
|
||||
Kpplication app("kylin-assistant", argc, argv);
|
||||
app.setQuitOnLastWindowClosed(false);
|
||||
|
@ -242,6 +245,7 @@ int main(int argc, char *argv[])
|
|||
#endif*/
|
||||
|
||||
w.setTranslator(&translator);
|
||||
// w.show();
|
||||
|
||||
// if (sCount > 1) {
|
||||
// w.setGeometry(desktop->screenGeometry(1));
|
||||
|
|
|
@ -0,0 +1,410 @@
|
|||
/*
|
||||
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
|
||||
*
|
||||
* Authors:
|
||||
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "mainbottomwidget.h"
|
||||
#include <QSignalMapper>
|
||||
#include <QDebug>
|
||||
#include "mainwindow.h"
|
||||
#include "../component/toolbutton.h"
|
||||
#include "../component/utils.h"
|
||||
|
||||
MainBottomWidget::MainBottomWidget(QWidget *parent, QString arch, QString os/*, const QString &version*/) :
|
||||
QWidget(parent), osarch(arch), osname(os)
|
||||
{
|
||||
this->setFixedSize(900, 326);
|
||||
|
||||
//set white background color
|
||||
this->setAutoFillBackground(true);
|
||||
QPalette palette;
|
||||
palette.setBrush(QPalette::Window, QBrush(Qt::white));
|
||||
this->setPalette(palette);
|
||||
|
||||
//// QPixmap label_pixmap("");
|
||||
//// movie_label->setPixmap(label_pixmap);
|
||||
//// movie_label->setFixedSize(label_pixmap.size());
|
||||
|
||||
// scan_button->setFocusPolicy(Qt::NoFocus);
|
||||
// QPixmap pixmap("://res/scan.png");
|
||||
// scan_button->setIcon(pixmap);
|
||||
// scan_button->setIconSize(pixmap.size());
|
||||
current_version = qApp->applicationVersion();
|
||||
version_logo = new QLabel();
|
||||
version_title = new QLabel();
|
||||
version_tip = new QLabel();
|
||||
check_btn = new QPushButton();
|
||||
check_btn->hide();
|
||||
// version_label = new QLabel();
|
||||
box_logo = new QLabel();
|
||||
box_title = new QPushButton();
|
||||
box_title->setFixedWidth(240);
|
||||
box_title->setCursor(Qt::PointingHandCursor);
|
||||
box_title->setFocusPolicy(Qt::NoFocus);
|
||||
box_title->setStyleSheet("QPushButton{background:#ffffff;border:none;text-align:left;font-family: 方正黑体_GBK;font-size:24px;color:#000000;}QPushButton:hover{color:#3f96e4;}");//background:transparent;
|
||||
// box_title->installEventFilter(this);
|
||||
box_tip = new QLabel();
|
||||
// more_text_btn = new QPushButton();
|
||||
// more_btn = new QPushButton();
|
||||
|
||||
// auto_start = NULL;
|
||||
// camera_manager = NULL;
|
||||
|
||||
// more_text_btn->setObjectName("checkButton");
|
||||
// more_text_btn->setCursor(Qt::PointingHandCursor);
|
||||
// more_text_btn->setCursor(Qt::OpenHandCursor);
|
||||
// more_text_btn->setFocusPolicy(Qt::NoFocus);
|
||||
// QFont font = more_text_btn->font();
|
||||
// font.setUnderline(true);
|
||||
// more_text_btn->setFont(font);
|
||||
|
||||
check_btn->setObjectName("checkButton");
|
||||
check_btn->setCursor(Qt::PointingHandCursor);
|
||||
check_btn->setFocusPolicy(Qt::NoFocus);
|
||||
// version_label->setObjectName("smallgrayLabel");
|
||||
version_title->setObjectName("bigblackLabel");
|
||||
// box_title->setObjectName("bigblackLabel");
|
||||
version_tip->setAlignment(Qt::AlignLeft);
|
||||
version_tip->setObjectName("smallgrayLabel");
|
||||
version_tip->setFixedWidth(380);
|
||||
box_tip->setAlignment(Qt::AlignLeft);
|
||||
box_tip->setObjectName("smallgrayLabel");
|
||||
version_tip->setWordWrap(true);//QLabel自动换行
|
||||
box_tip->setWordWrap(true);//QLabel自动换行
|
||||
box_tip->setFixedWidth(380);
|
||||
// more_btn->setObjectName("transparentButton");
|
||||
// more_btn->setCursor(Qt::PointingHandCursor);
|
||||
|
||||
version_logo->setFixedSize(65, 65);
|
||||
version_logo->setPixmap(QPixmap("://res/version.png"));
|
||||
box_logo->setFixedSize(65, 65);
|
||||
box_logo->setPixmap(QPixmap("://res/box.png"));
|
||||
|
||||
this->initUI();
|
||||
|
||||
this->setLanguage();
|
||||
|
||||
}
|
||||
|
||||
MainBottomWidget::~MainBottomWidget()
|
||||
{
|
||||
if(version_logo != NULL) {
|
||||
delete version_logo;
|
||||
version_logo = NULL;
|
||||
}
|
||||
if(version_title != NULL) {
|
||||
delete version_title;
|
||||
version_title = NULL;
|
||||
}
|
||||
if(version_tip != NULL) {
|
||||
delete version_tip;
|
||||
version_tip = NULL;
|
||||
}
|
||||
if(check_btn != NULL) {
|
||||
delete check_btn;
|
||||
check_btn = NULL;
|
||||
}
|
||||
if(box_logo != NULL) {
|
||||
delete box_logo;
|
||||
box_logo = NULL;
|
||||
}
|
||||
if(box_title != NULL) {
|
||||
delete box_title;
|
||||
box_title = NULL;
|
||||
}
|
||||
if(box_tip != NULL) {
|
||||
delete box_tip;
|
||||
box_tip = NULL;
|
||||
}
|
||||
// for(int i=0; i<item_list.count(); i++)
|
||||
// {
|
||||
// ToolButton *btn = item_list.at(i);
|
||||
// delete btn;
|
||||
// btn = NULL;
|
||||
// }
|
||||
// item_list.clear();
|
||||
}
|
||||
|
||||
void MainBottomWidget::initUI()
|
||||
{
|
||||
QHBoxLayout *layout1 = new QHBoxLayout();
|
||||
layout1->addWidget(version_title);
|
||||
layout1->addWidget(check_btn);
|
||||
// layout1->addWidget(version_label);
|
||||
layout1->addStretch();
|
||||
layout1->setMargin(0);
|
||||
layout1->setSpacing(5);
|
||||
layout1->setContentsMargins(0,0,0,0);
|
||||
QVBoxLayout *layout2 = new QVBoxLayout();
|
||||
layout2->addStretch();
|
||||
layout2->addLayout(layout1);
|
||||
layout2->addWidget(version_tip);
|
||||
layout2->addStretch();
|
||||
layout2->setMargin(0);
|
||||
layout2->setSpacing(5);
|
||||
layout2->setContentsMargins(0,0,0,0);
|
||||
QHBoxLayout *layout3 = new QHBoxLayout();
|
||||
layout3->addWidget(version_logo/* ,0, Qt::AlignVCenter*/);
|
||||
layout3->addLayout(layout2);
|
||||
layout3->addStretch();
|
||||
layout3->setMargin(0);
|
||||
layout3->setSpacing(5);
|
||||
layout3->setContentsMargins(0,0,0,0);
|
||||
|
||||
QVBoxLayout *layout4 = new QVBoxLayout();
|
||||
layout4->addStretch();
|
||||
layout4->addWidget(box_title);
|
||||
layout4->addWidget(box_tip);
|
||||
layout4->addStretch();
|
||||
layout4->setMargin(0);
|
||||
layout4->setSpacing(5);
|
||||
layout4->setContentsMargins(0,0,0,0);
|
||||
|
||||
|
||||
|
||||
|
||||
/*QStringList icon_list;
|
||||
// icon_list<<"://res/ubuntukylin-software-center"<<"://res/boot"<<"://res/camera";
|
||||
icon_list<<"://res/boot" << "://res/more.png";
|
||||
QStringList text_list;
|
||||
// text_list<< tr("Youker Softeware Center") << tr("Boot Manager") << tr("Camera");
|
||||
text_list << tr("Boot Manager") << tr("More");
|
||||
QHBoxLayout *button_layout = new QHBoxLayout();
|
||||
QSignalMapper *signal_mapper = new QSignalMapper(this);
|
||||
for(int i=0; i<icon_list.size(); i++)
|
||||
{
|
||||
ToolButton *tool_button = new ToolButton;
|
||||
tool_button->setFocusPolicy(Qt::NoFocus);
|
||||
tool_button->setIcon(icon_list.at(i));
|
||||
tool_button->setText(text_list.at(i));
|
||||
connect(tool_button, SIGNAL(clicked()), signal_mapper, SLOT(map()));
|
||||
signal_mapper->setMapping(tool_button, QString::number(i, 10));
|
||||
button_layout->addWidget(tool_button);
|
||||
item_list.append(tool_button);
|
||||
}
|
||||
connect(signal_mapper, SIGNAL(mapped(QString)), this, SLOT(switchPageIndex(QString)));
|
||||
*/
|
||||
|
||||
// more_btn->setFocusPolicy(Qt::NoFocus);
|
||||
// QPixmap pixmap("://res/more.png");
|
||||
// more_btn->setIcon(pixmap);
|
||||
// more_btn->setIconSize(pixmap.size());
|
||||
|
||||
// QVBoxLayout *more_layout = new QVBoxLayout();
|
||||
//// more_layout->addStretch();
|
||||
// more_layout->addWidget(more_btn);
|
||||
// more_layout->addWidget(more_text_btn);
|
||||
//// more_layout->addStretch();
|
||||
// more_layout->setSpacing(0);
|
||||
// more_layout->setMargin(0);
|
||||
// more_layout->setContentsMargins(0, 8, 0, 0);
|
||||
|
||||
// button_layout->addStretch();
|
||||
// button_layout->addLayout(more_layout);
|
||||
//// button_layout->addWidget(more_btn, 0, Qt::AlignTop);
|
||||
// button_layout->setSpacing(20);
|
||||
// button_layout->setMargin(0);
|
||||
// button_layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
QHBoxLayout *layout5 = new QHBoxLayout();
|
||||
layout5->addWidget(box_logo);
|
||||
layout5->addLayout(layout4);
|
||||
layout5->addStretch();
|
||||
// layout5->addLayout(button_layout);
|
||||
layout5->setMargin(0);
|
||||
layout5->setSpacing(5);
|
||||
layout5->setContentsMargins(0,0,0,0);
|
||||
|
||||
|
||||
|
||||
QVBoxLayout *main_layout = new QVBoxLayout();
|
||||
main_layout->addLayout(layout3);
|
||||
main_layout->addLayout(layout5);
|
||||
main_layout->setMargin(0);
|
||||
main_layout->setSpacing(50);
|
||||
main_layout->setContentsMargins(60,50,60,80);
|
||||
|
||||
this->setLayout(main_layout);
|
||||
}
|
||||
|
||||
void MainBottomWidget::initConnect()
|
||||
{
|
||||
connect(this, SIGNAL(moreSignal()), p_mainwindow, SIGNAL(chanegBoxToolStatus()));
|
||||
// connect(more_btn, SIGNAL(clicked()), p_mainwindow, SLOT(showBoxWidget()));
|
||||
// connect(more_btn, SIGNAL(clicked()), p_mainwindow, SIGNAL(chanegBoxToolStatus()));
|
||||
// connect(more_text_btn, SIGNAL(clicked()), p_mainwindow, SLOT(showBoxWidget()));
|
||||
// connect(more_text_btn, SIGNAL(clicked()), p_mainwindow, SIGNAL(chanegBoxToolStatus()));
|
||||
// connect(check_btn, SIGNAL(clicked()), this, SLOT(checkLastestVersion()));
|
||||
connect(check_btn, SIGNAL(clicked()), this, SLOT(onCheckBtnClicked()));
|
||||
connect(this, SIGNAL(sendSignal()), p_mainwindow, SIGNAL(chanegBoxToolStatus()));
|
||||
connect(box_title, SIGNAL(clicked()), this, SIGNAL(sendSignal()));
|
||||
}
|
||||
|
||||
void MainBottomWidget::setLanguage()
|
||||
{
|
||||
version_title->setText(tr("Current Version Number") + " " + current_version);
|
||||
version_tip->setText(tr("Update to the lastest version, make it work better"));
|
||||
check_btn->setText(tr("updating on the backend"));
|
||||
box_title->setText(tr("Common toolbox"));
|
||||
box_tip->setText(tr("Fast and practical, making the system more personalized"));
|
||||
// more_text_btn->setText(tr("More"));
|
||||
// more_btn->setToolTip(tr("More"));
|
||||
}
|
||||
|
||||
void MainBottomWidget::initBoxTool()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MainBottomWidget::onCheckBtnClicked()
|
||||
{
|
||||
emit this->sendOpenUpgrade();
|
||||
check_btn->hide();
|
||||
}
|
||||
|
||||
void MainBottomWidget::displayBackedBtn(bool flag)
|
||||
{
|
||||
if(flag)
|
||||
check_btn->setText(tr("Upgrade is complete"));
|
||||
else
|
||||
check_btn->setText(tr("Updating on the backend"));
|
||||
check_btn->show();
|
||||
}
|
||||
|
||||
void MainBottomWidget::hideBackedBtn()
|
||||
{
|
||||
check_btn->hide();
|
||||
}
|
||||
|
||||
//void HomePage::checkLastestVersion()
|
||||
//{
|
||||
// QStringList version_list = sessionProxy->checkNewVersion();
|
||||
// if(version_list.length() == 1) {
|
||||
// version_label->setText(version_list.at(0));
|
||||
// }
|
||||
// if(version_list.length() == 4) {
|
||||
// version_label->setText(version_list.at(2));
|
||||
// if(version_list.at(3) == "1") {
|
||||
// qDebug() << "Neet to UPdate......";
|
||||
// p_mainwindow->openUpgradePage(version_list);
|
||||
//// systemProxy->update_myself();
|
||||
// }
|
||||
// else {
|
||||
// qDebug() << "Unneccesary to UPdate......";
|
||||
// p_mainwindow->openUpgradePage(version_list);
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// version_label->setText("");
|
||||
// }
|
||||
//}
|
||||
|
||||
void MainBottomWidget::switchPageIndex(QString index)
|
||||
{
|
||||
// bool ok;
|
||||
// int current_index = index.toInt(&ok, 10);
|
||||
|
||||
// if(index == "0")
|
||||
// emit this->sendSubIndex(0);
|
||||
// else if(index == "-1")
|
||||
// if(this->osarch == "aarch64" || this->osname == "Kylin" || this->osname == "YHKylin")
|
||||
// sessionProxy->runApp("cheese");
|
||||
// else
|
||||
// emit this->sendSubIndex(1);
|
||||
// else if(index == "1") {
|
||||
//// p_mainwindow->showBoxWidget();
|
||||
// emit this->moreSignal();
|
||||
// }
|
||||
|
||||
// if(index == "0")
|
||||
// {
|
||||
// if(auto_start == NULL) {
|
||||
// auto_start = new AutoStartWidget(0, sessionProxy);
|
||||
// connect(sessionProxy, SIGNAL(tellAutoModel(QStringList)), auto_start, SLOT(readyReciveData(QStringList)));
|
||||
// connect(sessionProxy, SIGNAL(showAutoModel()), auto_start, SLOT(readyShowUI()));
|
||||
// auto_start->initData();
|
||||
// int w_x = p_mainwindow->frameGeometry().topLeft().x() + (900 / 2) - (560 / 2);
|
||||
// int w_y = p_mainwindow->frameGeometry().topLeft().y() + (600 /2) - (398 / 2);
|
||||
// auto_start->move(w_x, w_y);
|
||||
// auto_start->show();
|
||||
// auto_start->raise();
|
||||
// }
|
||||
// else {
|
||||
// int w_x = p_mainwindow->frameGeometry().topLeft().x() + (900 / 2) - (560 / 2);
|
||||
// int w_y = p_mainwindow->frameGeometry().topLeft().y() + (600 /2) - (398 / 2);
|
||||
// auto_start->move(w_x, w_y);
|
||||
// auto_start->show();
|
||||
// auto_start->raise();
|
||||
// }
|
||||
// }
|
||||
|
||||
// else if(index == "1")
|
||||
// {
|
||||
// if(camera_manager == NULL) {
|
||||
// camera_manager = new CameraManager(0, sessionProxy);
|
||||
// if(sessionProxy->judge_camera_qt())
|
||||
// {
|
||||
// camera_manager->setOKButtonEnable(true);
|
||||
// }
|
||||
// else{
|
||||
// camera_manager->setOKButtonEnable(false);
|
||||
// }
|
||||
// int w_x = p_mainwindow->frameGeometry().topLeft().x() + (900 / 2) - (524 / 2);
|
||||
// int w_y = p_mainwindow->frameGeometry().topLeft().y() + (600 /2) - (277 / 2);
|
||||
// camera_manager->move(w_x, w_y);
|
||||
// camera_manager->exec();
|
||||
//// camera_manager->show();
|
||||
//// camera_manager->raise();
|
||||
// }
|
||||
// else {
|
||||
// int w_x = p_mainwindow->frameGeometry().topLeft().x() + (900 / 2) - (524 / 2);
|
||||
// int w_y = p_mainwindow->frameGeometry().topLeft().y() + (600 /2) - (277 / 2);
|
||||
// camera_manager->move(w_x, w_y);
|
||||
// camera_manager->show();
|
||||
// camera_manager->raise();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
//bool HomePage::eventFilter(QObject *obj, QEvent *event)
|
||||
//{
|
||||
// if(obj == box_title){
|
||||
// if(event->type() == QEvent::MouseButtonRelease){
|
||||
// emit this->sendSignal();
|
||||
//// p_mainwindow->showBoxWidget();
|
||||
// }
|
||||
//// if(event->type() == QEvent::Enter){
|
||||
//// ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeBtn_hover.png"));
|
||||
//// }else if(event->type() == QEvent::Leave){
|
||||
//// ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeBtn.png"));
|
||||
//// }else if(event->type() == QEvent::MouseButtonPress){
|
||||
//// ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeBtn_hover.png"));
|
||||
//// }else if(event->type() == QEvent::MouseButtonRelease){
|
||||
//// QMouseEvent *me = (QMouseEvent *)event;
|
||||
//// QLabel *lb = (QLabel *)obj;
|
||||
//// if(me->x() > 0 && me->x() < lb->width() && me->y() > 0 && me->y() < lb->height()){
|
||||
//// this->close();
|
||||
//// this->destroy();
|
||||
//// }else{
|
||||
//// ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeBtn.png"));
|
||||
//// }
|
||||
//// } else {
|
||||
//// return QObject::eventFilter(obj, event);
|
||||
//// }
|
||||
// }
|
||||
// return QObject::eventFilter(obj, event);
|
||||
//}
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
|
||||
*
|
||||
* Authors:
|
||||
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef MAINBOTTOMWIDGET_H
|
||||
#define MAINBOTTOMWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
#include <QLabel>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
class MainWindow;
|
||||
class ToolButton;
|
||||
|
||||
class MainBottomWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MainBottomWidget(QWidget *parent = 0, QString arch = "", QString os = ""/*, const QString &version = ""*/);
|
||||
~MainBottomWidget();
|
||||
void setLanguage();
|
||||
void initBoxTool();
|
||||
void initConnect();
|
||||
void setParentWindow(MainWindow* window) { p_mainwindow = window;}
|
||||
void initUI();
|
||||
|
||||
//protected:
|
||||
// bool eventFilter(QObject *obj, QEvent *event);
|
||||
|
||||
public slots:
|
||||
void switchPageIndex(QString index);
|
||||
// void checkLastestVersion();
|
||||
void displayBackedBtn(bool flag);
|
||||
void onCheckBtnClicked();
|
||||
void hideBackedBtn();
|
||||
|
||||
signals:
|
||||
void sendSubIndex(int index);
|
||||
void sendSignal();
|
||||
void moreSignal();
|
||||
void sendOpenUpgrade();
|
||||
|
||||
private:
|
||||
QLabel *version_logo;
|
||||
QLabel *version_title;
|
||||
QLabel *version_tip;
|
||||
QPushButton *check_btn;
|
||||
// QLabel *version_label;
|
||||
QLabel *box_logo;
|
||||
QPushButton *box_title;
|
||||
QLabel *box_tip;
|
||||
MainWindow *p_mainwindow;
|
||||
// AutoStartWidget *auto_start;
|
||||
// CameraManager *camera_manager;
|
||||
QString current_version;
|
||||
QString osname;
|
||||
QString osarch;
|
||||
// QList<ToolButton *> item_list;
|
||||
};
|
||||
|
||||
#endif // MAINBOTTOMWIDGET_H
|
|
@ -0,0 +1,883 @@
|
|||
/*
|
||||
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
|
||||
*
|
||||
* Authors:
|
||||
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "maintopwidget.h"
|
||||
#include "mainwindow.h"
|
||||
#include <QDebug>
|
||||
#include <QDateTime>
|
||||
|
||||
|
||||
#include "../plugins/widgets/mytristatebutton.h"
|
||||
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QPainter>
|
||||
#include <QResizeEvent>
|
||||
#include <QStyleFactory>
|
||||
|
||||
|
||||
MainTopWidget::MainTopWidget(bool isMain, QSettings *mSettings, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, pSettings(mSettings)
|
||||
, m_isMain(isMain)
|
||||
{
|
||||
if (m_isMain)
|
||||
this->setFixedSize(900, 227);
|
||||
else
|
||||
this->setFixedSize(900, 150);
|
||||
|
||||
this->setAutoFillBackground(true);
|
||||
// this->setObjectName("transparentWidget");
|
||||
scanFinishTime = "";
|
||||
|
||||
this->initWidgets();
|
||||
|
||||
|
||||
this->initConnect();
|
||||
this->setLanguage();
|
||||
|
||||
|
||||
if (m_isMain) {
|
||||
workFlag = this->getOneKeyFlag();
|
||||
if(workFlag.length() > 0)
|
||||
{
|
||||
if(workFlag == "1")
|
||||
{
|
||||
//clean
|
||||
dateStr = this->getFixCleanDate();
|
||||
result_label->setText(tr("The lastest cleanup time is ") + dateStr);
|
||||
}
|
||||
else if(workFlag == "0")
|
||||
{
|
||||
//scan
|
||||
dateStr = this->getSafeScanDate();
|
||||
result_label->setText(tr("The lastest scan time is ") + dateStr);
|
||||
}
|
||||
}
|
||||
else {
|
||||
result_label->setText(tr("You have not implemented the one key scan and clean-up operation."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MainTopWidget::~MainTopWidget()
|
||||
{
|
||||
if(loading_label) {
|
||||
delete loading_label;
|
||||
loading_label = nullptr;
|
||||
}
|
||||
if(suggest_label) {
|
||||
delete suggest_label;
|
||||
suggest_label = nullptr;
|
||||
}
|
||||
if(scan_result_label) {
|
||||
delete scan_result_label;
|
||||
scan_result_label = nullptr;
|
||||
}
|
||||
if(result_label) {
|
||||
delete result_label;
|
||||
result_label = nullptr;
|
||||
}
|
||||
if(doing_label) {
|
||||
delete doing_label;
|
||||
doing_label = nullptr;
|
||||
}
|
||||
|
||||
delete scan_button;
|
||||
delete clean_button;
|
||||
delete back_button;
|
||||
|
||||
//Segmentation fault
|
||||
QLayoutItem *child;
|
||||
while ((child = m_titleLeftLayout->takeAt(0)) != 0) {
|
||||
if (child->widget())
|
||||
child->widget()->deleteLater();
|
||||
delete child;
|
||||
}
|
||||
while ((child = m_titleRightLayout->takeAt(0)) != 0) {
|
||||
if (child->widget())
|
||||
child->widget()->deleteLater();
|
||||
delete child;
|
||||
}
|
||||
while ((child = m_toolLeftLayout->takeAt(0)) != 0) {
|
||||
if (child->widget())
|
||||
child->widget()->deleteLater();
|
||||
delete child;
|
||||
}
|
||||
while ((child = m_toolRightLayout->takeAt(0)) != 0) {
|
||||
if (child->widget())
|
||||
child->widget()->deleteLater();
|
||||
delete child;
|
||||
}
|
||||
while ((child = m_topLayout->takeAt(0)) != 0) {
|
||||
if (child->widget())
|
||||
child->widget()->deleteLater();
|
||||
delete child;
|
||||
}
|
||||
while ((child = m_bottomLayout->takeAt(0)) != 0) {
|
||||
if (child->widget())
|
||||
child->widget()->deleteLater();
|
||||
delete child;
|
||||
}
|
||||
delete m_layout;
|
||||
}
|
||||
|
||||
void MainTopWidget::initTitlebarLeftContent()
|
||||
{
|
||||
QWidget *w = new QWidget;
|
||||
m_titleLeftLayout = new QHBoxLayout(w);
|
||||
m_titleLeftLayout->setContentsMargins(6, 0, 0, 0);
|
||||
m_titleLeftLayout->setSpacing(0);
|
||||
|
||||
QLabel *appLabel = new QLabel;
|
||||
appLabel->setStyleSheet("QLabel{background-color:transparent;color:#ffffff; font-size:12px;}");
|
||||
appLabel->setText(tr("Kylin Assistant"));
|
||||
m_titleLeftLayout->addWidget(appLabel);
|
||||
|
||||
m_topLayout->addWidget(w, 1, Qt::AlignLeft);
|
||||
}
|
||||
|
||||
void MainTopWidget::initTitlebarRightContent()
|
||||
{
|
||||
QWidget *w = new QWidget;
|
||||
m_titleRightLayout = new QHBoxLayout(w);
|
||||
m_titleRightLayout->setContentsMargins(0, 0, 1, 0);
|
||||
m_titleRightLayout->setSpacing(0);
|
||||
|
||||
m_topLayout->addWidget(w, 1, Qt::AlignRight);
|
||||
|
||||
SystemButton *min_button = new SystemButton();
|
||||
SystemButton *close_button = new SystemButton();
|
||||
// SystemButton *skin_button = new SystemButton();
|
||||
SystemButton *main_menu_button = new SystemButton();
|
||||
min_button->loadPixmap(":/sys/res/sysBtn/min_button.png");
|
||||
close_button->loadPixmap(":/sys/res/sysBtn/close_button.png");
|
||||
// skin_button->loadPixmap(":/sys/res/sysBtn/skin_button.png");
|
||||
main_menu_button->loadPixmap(":/sys/res/sysBtn/main_menu.png");
|
||||
min_button->setFocusPolicy(Qt::NoFocus);
|
||||
close_button->setFocusPolicy(Qt::NoFocus);
|
||||
// skin_button->setFocusPolicy(Qt::NoFocus);
|
||||
main_menu_button->setFocusPolicy(Qt::NoFocus);
|
||||
|
||||
m_titleRightLayout->addWidget(main_menu_button);
|
||||
// m_titleRightLayout->addWidget(skin_button);
|
||||
m_titleRightLayout->addWidget(min_button);
|
||||
m_titleRightLayout->addWidget(close_button);
|
||||
|
||||
connect(main_menu_button, &SystemButton::clicked, this, [=] {
|
||||
emit this->showMenu();
|
||||
/*if (parentWidget()) {
|
||||
parentWidget()->showMainMenu();
|
||||
}*/
|
||||
});
|
||||
// connect(skin_button, &SystemButton::clicked, this, [=] {
|
||||
// if (parentWidget() && parentWidget()->parentWidget()) {
|
||||
// //openSkinCenter()
|
||||
// }
|
||||
// });
|
||||
connect(min_button, &SystemButton::clicked, this, [=] {
|
||||
emit this->showMin();
|
||||
// if (parentWidget()) {
|
||||
// parentWidget()->showMinimized();
|
||||
// }
|
||||
});
|
||||
connect(close_button, &SystemButton::clicked, this, [=] {
|
||||
emit this->closeApp();
|
||||
// window()->close();
|
||||
});
|
||||
|
||||
|
||||
// connect(min_button, SIGNAL(clicked()), p_mainwindow, SLOT(showMinimized()));
|
||||
// connect(close_button, SIGNAL(clicked()), this, SIGNAL(closeApp()));
|
||||
// connect(skin_button, SIGNAL(clicked()), p_mainwindow, SLOT(openSkinCenter()));
|
||||
// connect(main_menu_button, SIGNAL(clicked()), p_mainwindow, SLOT(showMainMenu()));
|
||||
}
|
||||
|
||||
void MainTopWidget::initContentLeftContent()
|
||||
{
|
||||
QWidget *w = new QWidget;
|
||||
w->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
m_toolLeftLayout = new QHBoxLayout(w);
|
||||
m_toolLeftLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_toolLeftLayout->setSpacing(10);
|
||||
|
||||
suggest_label = new QLabel();
|
||||
doing_label = new QLabel();
|
||||
if (m_isMain) {
|
||||
scan_result_label = new QLabel();
|
||||
result_label = new QLabel();
|
||||
loading_label = new LoadingLabel(this, "firstkey");
|
||||
scan_result_label->setObjectName("whiteLabel");
|
||||
scan_result_label->setWordWrap(true);//QLabel自动换行
|
||||
scan_result_label->setFixedWidth(460);
|
||||
scan_result_label->hide();
|
||||
result_label->setWordWrap(true);//QLabel自动换行
|
||||
result_label->setObjectName("smallWhiteLabel");
|
||||
result_label->setFixedWidth(460);
|
||||
suggest_label->setFixedWidth(460);
|
||||
doing_label->setFixedWidth(460);
|
||||
}
|
||||
else {
|
||||
loading_label = new LoadingLabel(this, "clean");
|
||||
suggest_label->setFixedWidth(550);
|
||||
doing_label->setFixedWidth(550);
|
||||
}
|
||||
loading_label->show();
|
||||
|
||||
suggest_label->setObjectName("whiteLabel");
|
||||
suggest_label->setWordWrap(true);//QLabel自动换行
|
||||
doing_label->setWordWrap(true);//QLabel自动换行
|
||||
doing_label->setObjectName("whiteLabel");
|
||||
doing_label->hide();
|
||||
|
||||
QVBoxLayout *layout1 = new QVBoxLayout();
|
||||
layout1->addStretch();
|
||||
layout1->addWidget(suggest_label);
|
||||
if (scan_result_label)
|
||||
layout1->addWidget(scan_result_label);
|
||||
layout1->addWidget(doing_label);
|
||||
if (result_label)
|
||||
layout1->addWidget(result_label);
|
||||
layout1->addStretch();
|
||||
layout1->setSpacing(15);
|
||||
layout1->setContentsMargins(0, 20, 0, 0);
|
||||
|
||||
m_toolLeftLayout->addStretch();
|
||||
m_toolLeftLayout->addWidget(loading_label, 0, Qt::AlignHCenter);
|
||||
m_toolLeftLayout->addLayout(layout1);
|
||||
m_toolLeftLayout->addStretch();
|
||||
|
||||
// m_bottomLayout->addWidget(w);
|
||||
m_bottomLayout->addWidget(w, 1, Qt::AlignLeft);
|
||||
}
|
||||
|
||||
void MainTopWidget::initActionRightContent()
|
||||
{
|
||||
QWidget *w = new QWidget;
|
||||
m_toolRightLayout = new QHBoxLayout(w);
|
||||
m_toolRightLayout->setContentsMargins(0, 3, 6, 10);
|
||||
m_toolRightLayout->setSpacing(5);
|
||||
|
||||
scan_button = new QPushButton(this);
|
||||
clean_button = new QPushButton(this);
|
||||
back_button = new QPushButton(this);
|
||||
|
||||
scan_button->setObjectName("greenButton");
|
||||
scan_button->setFocusPolicy(Qt::NoFocus);
|
||||
if (m_isMain) {
|
||||
scan_button->setFixedSize(204, 65);
|
||||
clean_button->setFixedSize(204, 65);
|
||||
QPixmap pixmap("://res/scan.png");
|
||||
scan_button->setIcon(pixmap);
|
||||
scan_button->setIconSize(pixmap.size());
|
||||
}
|
||||
else {
|
||||
scan_button->setFixedSize(182, 58);
|
||||
clean_button->setFixedSize(182, 58);
|
||||
}
|
||||
scan_button->show();
|
||||
clean_button->setFocusPolicy(Qt::NoFocus);
|
||||
clean_button->setObjectName("greenButton");
|
||||
clean_button->hide();
|
||||
|
||||
back_button->setFocusPolicy(Qt::NoFocus);
|
||||
back_button->setFixedSize(50, 30);
|
||||
// back_button->setObjectName("backButton");
|
||||
back_button->setObjectName("underlineButton");
|
||||
back_button->hide();//setVisible(false)
|
||||
|
||||
m_toolRightLayout->addWidget(scan_button);
|
||||
m_toolRightLayout->addWidget(clean_button);
|
||||
m_toolRightLayout->addWidget(back_button);
|
||||
m_bottomLayout->addWidget(w, 1, Qt::AlignRight);
|
||||
}
|
||||
|
||||
void MainTopWidget::initWidgets()
|
||||
{
|
||||
m_layout = new QVBoxLayout(this);
|
||||
m_layout->setContentsMargins(0, 0, 0, 0);
|
||||
m_layout->setSpacing(0);
|
||||
|
||||
QWidget *topWidget = new QWidget;
|
||||
m_topLayout = new QHBoxLayout(topWidget);
|
||||
m_topLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_topLayout->setSpacing(0);
|
||||
m_layout->addWidget(topWidget, 0, Qt::AlignTop);
|
||||
|
||||
QWidget *bottomWidget = new QWidget;
|
||||
m_bottomLayout = new QHBoxLayout(bottomWidget);
|
||||
m_bottomLayout->setContentsMargins(13, 0, 0, 20);
|
||||
m_bottomLayout->setSpacing(0);
|
||||
m_layout->addWidget(bottomWidget, 0, Qt::AlignBottom);
|
||||
|
||||
this->setLayout(m_layout);
|
||||
|
||||
initTitlebarLeftContent();
|
||||
initTitlebarRightContent();
|
||||
initContentLeftContent();
|
||||
initActionRightContent();
|
||||
}
|
||||
|
||||
void MainTopWidget::initConnect()
|
||||
{
|
||||
connect(scan_button, SIGNAL(clicked()), this, SLOT(onStartButtonClicked()));
|
||||
connect(clean_button, SIGNAL(clicked()), this, SLOT(onCleanButtonClicked()));
|
||||
connect(back_button, SIGNAL(clicked()), this, SLOT(onEndButtonClicked()));
|
||||
}
|
||||
|
||||
void MainTopWidget::setLanguage()
|
||||
{
|
||||
scan_button->setText(tr("Start Scan"));//开始扫描
|
||||
clean_button->setText(tr("Start Cleanup"));//开始清理
|
||||
back_button->setText(tr("Back"));
|
||||
doing_label->setText(tr("Scanning......"));//正在扫描......
|
||||
|
||||
if (m_isMain) {
|
||||
suggest_label->setText(tr("Quick clean up system trash, saving disk space and improving the system efficiency!"));//一键清理系统垃圾,帮您节省磁盘空间,让系统运行更加有效率!
|
||||
scan_result_label->setText(tr("Scan Over"));
|
||||
}
|
||||
else {
|
||||
suggest_label->setText(tr("Regular cleaning, let your computer remains the relaxed state"));//经常清理,让电脑保持最轻松的状态
|
||||
}
|
||||
}
|
||||
|
||||
//void MainTopWidget::enableSanButton()
|
||||
//{
|
||||
// scan_button->setEnabled(true);
|
||||
//}
|
||||
|
||||
void MainTopWidget::showCleanOverStatus()
|
||||
{
|
||||
loading_label->stopLoading();
|
||||
scan_button->show();
|
||||
scan_button->setEnabled(true);
|
||||
clean_button->hide();
|
||||
clean_button->setEnabled(true);
|
||||
back_button->hide();
|
||||
doing_label->setText(tr("Clean OK"));
|
||||
}
|
||||
|
||||
void MainTopWidget::showCleanerData(const QStringList &data)
|
||||
{
|
||||
if(data.length() == 2)
|
||||
{
|
||||
doing_label->setText(tr("Cleaning: ") + data.at(0).split(":").at(1));
|
||||
}
|
||||
else if(data.length() == 3)
|
||||
{
|
||||
doing_label->setText(data.at(0).split(":").at(1) + tr(", Percent is: ") + data.at(1).split(":").at(1) + tr("%, Status is: ") + data.at(2).split(":").at(1));
|
||||
}
|
||||
}
|
||||
|
||||
void MainTopWidget::showCleanerStatus(const QString &status, const QString &domain)
|
||||
{
|
||||
if(status == "Complete:History.firefox" && domain == "history")
|
||||
{
|
||||
doing_label->setText(tr("Clean Firefox history......"));
|
||||
}
|
||||
else if(status == "Complete:History.chromium" && domain == "history")
|
||||
{
|
||||
doing_label->setText(tr("Clean Chromium history......"));
|
||||
}
|
||||
else if(status == "Complete:History.system" && domain == "history")
|
||||
{
|
||||
doing_label->setText(tr("Clean system history......"));
|
||||
}
|
||||
|
||||
else if(status == "Complete:" && domain == "apt")
|
||||
{
|
||||
doing_label->setText(tr("Clean apt......"));
|
||||
}
|
||||
else if(status == "Start:" && domain == "apt")
|
||||
{
|
||||
doing_label->setText(tr("Start clean apt......"));
|
||||
}
|
||||
|
||||
else if(status == "Complete:Cookies.firefox")
|
||||
{
|
||||
doing_label->setText(tr("Clean Firefox Cookie:") + domain);
|
||||
}
|
||||
else if(status == "Complete:Cookies.chromium")
|
||||
{
|
||||
doing_label->setText(tr("Clean Chromium Cookie:") + domain);
|
||||
}
|
||||
}
|
||||
|
||||
void MainTopWidget::showCleanerError(const QString &status)
|
||||
{
|
||||
if(status.contains("Non-existent:"))
|
||||
{
|
||||
if(status.split(":").at(1).length() > 0)
|
||||
doing_label->setText(status.split(":").at(1) + tr(" does not exist"));
|
||||
}
|
||||
else if(status.contains("Working:Chromium"))
|
||||
{
|
||||
doing_label->setText(tr("Chromium Browser is running......"));
|
||||
}
|
||||
}
|
||||
|
||||
void MainTopWidget::showCleanReciveStatus(const QString &status)
|
||||
{
|
||||
if(status == "Complete:Cache")
|
||||
{
|
||||
doing_label->setText(tr("Cache Scan OK"));
|
||||
}
|
||||
else if(status == "Complete:Cookies")
|
||||
{
|
||||
doing_label->setText(tr("Cookies Scan OK"));
|
||||
}
|
||||
else if(status == "Complete:")
|
||||
{
|
||||
doing_label->setText(tr("History Scan OK"));
|
||||
}
|
||||
else if(status == "Complete:Packages")
|
||||
{
|
||||
doing_label->setText(tr("Packages Scan OK"));
|
||||
}
|
||||
else if(status == "Complete:All")
|
||||
{
|
||||
// doing_label->setText(tr("Scaning......"));
|
||||
// doing_label->hide();
|
||||
// loading_label->stopLoading();
|
||||
// scan_button->hide();
|
||||
// scan_button->setEnabled(true);
|
||||
// clean_button->show();
|
||||
// clean_button->setEnabled(true);
|
||||
// suggest_label->show();
|
||||
// back_button->show();
|
||||
}
|
||||
}
|
||||
|
||||
void MainTopWidget::accordScanOverStatusToChange(bool status)
|
||||
{
|
||||
if (status) {
|
||||
doing_label->setText(tr("Scaning......"));
|
||||
doing_label->hide();
|
||||
loading_label->stopLoading();
|
||||
scan_button->hide();
|
||||
scan_button->setEnabled(true);
|
||||
clean_button->show();
|
||||
clean_button->setEnabled(true);
|
||||
suggest_label->show();
|
||||
back_button->show();
|
||||
}
|
||||
else {
|
||||
doing_label->setText(tr("Scaning......"));
|
||||
doing_label->hide();
|
||||
loading_label->stopLoading();
|
||||
scan_button->hide();
|
||||
scan_button->setEnabled(true);
|
||||
clean_button->hide();
|
||||
clean_button->setEnabled(true);
|
||||
suggest_label->show();
|
||||
back_button->show();
|
||||
}
|
||||
}
|
||||
|
||||
void MainTopWidget::showCleanReciveError(const QString &status)
|
||||
{
|
||||
doing_label->setText(tr("Error: ") + status);
|
||||
if(status == "Uninstalled:Firefox")
|
||||
{
|
||||
doing_label->setText(tr("Firefox Browser does not be installed"));
|
||||
}
|
||||
else if(status == "Uninstalled:Chromium")
|
||||
{
|
||||
doing_label->setText(tr("Chromium Browser does not be installed"));
|
||||
}
|
||||
else if(status == "Working:Chromium")
|
||||
{
|
||||
doing_label->setText(tr("Chromium Browser is running"));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(status.contains("Non-existent:"))
|
||||
doing_label->setText(status.split(":").at(1) + tr(" does not exist"));
|
||||
}
|
||||
}
|
||||
|
||||
void MainTopWidget::displayAnimation()
|
||||
{
|
||||
scan_button->setEnabled(false);
|
||||
loading_label->startLoading();
|
||||
suggest_label->hide();
|
||||
doing_label->show();
|
||||
emit this->showDetailData();
|
||||
}
|
||||
|
||||
void MainTopWidget::getScanResult(QString msg)
|
||||
{
|
||||
doing_label->setText(tr("Scanning:") + msg);//正在扫描:
|
||||
}
|
||||
|
||||
void MainTopWidget::finishScanResult(QString msg)
|
||||
{
|
||||
if(msg == "onekey") {
|
||||
// doing_label->setText(tr("Scan Over"));//扫描完成
|
||||
doing_label->hide();
|
||||
scan_result_label->show();
|
||||
result_label->show();
|
||||
QString msg;
|
||||
if (trace.toInt() > 0)
|
||||
{
|
||||
if (cookies.toInt() > 0) {
|
||||
if (garbage == "0.00 B")
|
||||
{
|
||||
msg = trace + tr(" history trace; ") + cookies + tr(" browser cookies.") ;
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = trace + tr(" history trace; ") + cookies + tr(" browser cookies; ") + garbage + tr(" garbage.") ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (garbage == "0.00 B")
|
||||
{
|
||||
msg = trace + tr(" history trace.") ;
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = trace + tr(" history trace; ") + garbage + tr(" garbage.") ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cookies.toInt() > 0)
|
||||
{
|
||||
if (garbage == "0.00 B")
|
||||
{
|
||||
msg = cookies + tr(" browser cookies.") ;
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = cookies + tr(" browser cookies; ") + garbage + tr(" garbage.") ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (garbage == "0.00 B")
|
||||
{
|
||||
msg = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = garbage + tr(" garbage.") ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (msg.isEmpty()) {
|
||||
result_label->setText(tr("No garbage."));
|
||||
scan_button->setEnabled(true);
|
||||
clean_button->hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
result_label->setText(msg);
|
||||
clean_button->show();
|
||||
clean_button->setEnabled(true);
|
||||
}
|
||||
scanFinishTime = this->getCurrentDateTime();
|
||||
// result_label->setText(tr("The lastest scan time is ") + this->getCurrentDateTime());
|
||||
this->writeSafeScanDate();
|
||||
scan_button->hide();
|
||||
back_button->show();
|
||||
loading_label->stopLoading();
|
||||
}
|
||||
}
|
||||
|
||||
void MainTopWidget::getScanAllResult(QString flag, QString msg){
|
||||
if(flag == "h") {
|
||||
trace = msg;
|
||||
}
|
||||
else if(flag == "k") {
|
||||
cookies = msg;
|
||||
}
|
||||
else if(flag == "c") {
|
||||
garbage = msg;
|
||||
}
|
||||
}
|
||||
|
||||
void MainTopWidget::getCleanResult(QString msg/*, QString flag*/)
|
||||
{
|
||||
// if(flag == "onekey") {
|
||||
if (msg == "yes") {//在弹出输入密码验证时,点击了取消按钮
|
||||
loading_label->stopLoading();
|
||||
clean_button->show();
|
||||
clean_button->setEnabled(true);
|
||||
back_button->show();
|
||||
}
|
||||
else if (msg == "no") {//在弹出输入密码验证时,输入密码,验证通过,此时让动态图片开始显示
|
||||
//show dynamic image
|
||||
clean_button->show();
|
||||
clean_button->setEnabled(false);
|
||||
back_button->hide();
|
||||
doing_label->setText(tr("Cleaning......"));//正在清理......
|
||||
loading_label->startLoading();
|
||||
}
|
||||
else if (msg == "c") {
|
||||
doing_label->setText(tr("Garbage Cleanup OK......"));
|
||||
}
|
||||
else if (msg == "h") {
|
||||
doing_label->setText(tr("History Cleanup OK......"));
|
||||
}
|
||||
else if (msg == "k") {
|
||||
doing_label->setText(tr("Cookies Cleanup OK......"));
|
||||
}
|
||||
else if (msg == "o") {
|
||||
this->writeFixCleanDate();
|
||||
//清理完毕后显示清理总数
|
||||
result_label->setText(tr("The lastest cleanup time is ") + this->getCurrentDateTime());
|
||||
doing_label->setText(tr("Cleanup Cookies:") +cookies + tr("; Garbage:") + garbage + tr("; Historical records:") +trace );
|
||||
trace.clear();
|
||||
cookies.clear();
|
||||
garbage.clear();
|
||||
loading_label->stopLoading();
|
||||
scan_button->show();
|
||||
scan_button->setEnabled(true);
|
||||
clean_button->hide();
|
||||
clean_button->setEnabled(true);
|
||||
back_button->hide();
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
void MainTopWidget::finishCleanError(QString msg)
|
||||
{
|
||||
if (msg == "ce") {
|
||||
qDebug() << "GarbageException---------";
|
||||
}
|
||||
else if (msg == "he") {
|
||||
qDebug() << "HistoryException---------";
|
||||
}
|
||||
else if (msg == "ke") {
|
||||
qDebug() << "CookiesException---------";
|
||||
}
|
||||
}
|
||||
|
||||
void MainTopWidget::getCleaningMessage(QString type, QString status)
|
||||
{
|
||||
if(type == "firefoxhistory") {
|
||||
if(status == "start") {
|
||||
doing_label->setText(tr("Cleaning up history trace of Firefox..."));//正在清理Firefox的历史痕迹...
|
||||
}
|
||||
else if(status == "end") {
|
||||
doing_label->setText(tr("Firefox history trace had been cleared!"));//Firefox的历史痕迹已清理完毕!
|
||||
}
|
||||
}
|
||||
else if(type == "chromiumhistory") {
|
||||
if(status == "start") {
|
||||
doing_label->setText(tr("Cleaning up history trace of Chromium..."));//正在清理Chromium的历史痕迹...
|
||||
}
|
||||
else if(status == "end") {
|
||||
doing_label->setText(tr("Chromium history trace had been cleared!"));//Chromium的历史痕迹已清理完毕!
|
||||
}
|
||||
}
|
||||
else if(type == "firefoxcookies") {
|
||||
if(status == "start") {
|
||||
doing_label->setText(tr("Cleaning up Cookies of Firefox..."));//正在清理Firefox的Cookies...
|
||||
}
|
||||
else if(status == "end") {
|
||||
doing_label->setText(tr("Firefox Cookies had been cleared!"));//Firefox的Cookies已清理完毕!
|
||||
}
|
||||
}
|
||||
else if(type == "chromiumcookies") {
|
||||
if(status == "start") {
|
||||
doing_label->setText(tr("Cleaning up Cookies of Chromium..."));//正在清理Chromium的Cookies...
|
||||
}
|
||||
else if(status == "end") {
|
||||
doing_label->setText(tr("Chromium Cookies had been cleared!"));//Chromium的Cookies已清理完毕!
|
||||
}
|
||||
}
|
||||
else if(type == "apt") {
|
||||
if(status == "end") {
|
||||
doing_label->setText(tr("Apt cache had been cleared!"));//Apt缓存已清理完毕!
|
||||
}
|
||||
else {
|
||||
doing_label->setText(tr("Cleaning up Apt cache: ") + status);//正在清理Apt缓存:
|
||||
}
|
||||
}
|
||||
else if(type == "software_center") {
|
||||
if(status == "end") {
|
||||
doing_label->setText(tr("Software Center cache had been cleared!"));//软件中心缓存已清理完毕!
|
||||
}
|
||||
else {
|
||||
doing_label->setText(tr("Cleaning up Software Center cache: ") + status);//正在清理软件中心缓存:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainTopWidget::displayOrgPage()
|
||||
{
|
||||
doing_label->hide();
|
||||
back_button->hide();
|
||||
// loading_label->stopLoading();
|
||||
scan_button->show();
|
||||
scan_button->setEnabled(true);
|
||||
clean_button->hide();
|
||||
suggest_label->show();
|
||||
}
|
||||
|
||||
void MainTopWidget::onStartButtonClicked()
|
||||
{
|
||||
doing_label->setText(tr("Scanning......"));//正在扫描......
|
||||
if (m_isMain) {
|
||||
scan_button->setEnabled(false);
|
||||
loading_label->startLoading();
|
||||
suggest_label->hide();
|
||||
scan_result_label->hide();
|
||||
result_label->hide();
|
||||
doing_label->show();
|
||||
QStringList args;
|
||||
args << "cache" << "history" << "cookies";
|
||||
|
||||
emit this->startOneKeyScan(args);
|
||||
}
|
||||
else {
|
||||
emit this->sendScanSignal();
|
||||
}
|
||||
}
|
||||
|
||||
void MainTopWidget::onCleanButtonClicked()
|
||||
{
|
||||
if (m_isMain) {
|
||||
clean_button->hide();
|
||||
back_button->hide();
|
||||
loading_label->startLoading();
|
||||
suggest_label->hide();
|
||||
scan_result_label->hide();
|
||||
result_label->hide();
|
||||
doing_label->setText(tr("Ready to Cleanup......"));//准备清理......
|
||||
doing_label->show();
|
||||
|
||||
emit this->startOneKeyClean();
|
||||
}
|
||||
else {
|
||||
clean_button->hide();
|
||||
back_button->hide();
|
||||
emit this->sendCleanSignal();
|
||||
}
|
||||
}
|
||||
|
||||
void MainTopWidget::onEndButtonClicked()
|
||||
{
|
||||
if (m_isMain) {
|
||||
result_label->setText(tr("The lastest scan time is ") + scanFinishTime);
|
||||
loading_label->stopLoading();
|
||||
scan_button->show();
|
||||
scan_button->setEnabled(true);
|
||||
clean_button->hide();
|
||||
back_button->hide();
|
||||
suggest_label->show();
|
||||
scan_result_label->hide();
|
||||
result_label->show();
|
||||
doing_label->hide();
|
||||
}
|
||||
else {
|
||||
doing_label->hide();
|
||||
back_button->hide();
|
||||
loading_label->stopLoading();
|
||||
scan_button->show();
|
||||
scan_button->setEnabled(true);
|
||||
clean_button->hide();
|
||||
// back_button->hide();
|
||||
suggest_label->show();
|
||||
// result_label->show();
|
||||
emit this->showMainData();
|
||||
}
|
||||
}
|
||||
|
||||
void MainTopWidget::receivePolicyKitSignal(bool status)
|
||||
{
|
||||
/*display Clean Animation
|
||||
status = true:ok
|
||||
status = false:cacel
|
||||
*/
|
||||
if(status)//ok
|
||||
{
|
||||
clean_button->show();
|
||||
clean_button->setEnabled(false);
|
||||
back_button->hide();//0713
|
||||
scan_button->hide();
|
||||
loading_label->startLoading();
|
||||
suggest_label->hide();
|
||||
doing_label->setText(tr("Ready to Cleanup......"));//准备清理......
|
||||
doing_label->show();
|
||||
}
|
||||
else {
|
||||
clean_button->show();
|
||||
back_button->show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainTopWidget::writeFixCleanDate() {
|
||||
QDateTime time = QDateTime::currentDateTime();//获取系统现在的时间
|
||||
QString str = time.toString("yyyy-MM-dd hh:mm:ss dddd"); //设置显示格式
|
||||
pSettings->beginGroup("OneKeyClean");
|
||||
pSettings->setValue("CleanDate", str);
|
||||
pSettings->setValue("Flag", "1");
|
||||
pSettings->endGroup();
|
||||
pSettings->sync();
|
||||
}
|
||||
|
||||
QString MainTopWidget::getFixCleanDate() {
|
||||
pSettings->beginGroup("OneKeyClean");
|
||||
QString value = pSettings->value("CleanDate").toString();
|
||||
pSettings->endGroup();
|
||||
pSettings->sync();
|
||||
return value;
|
||||
}
|
||||
|
||||
QString MainTopWidget::getCurrentDateTime() {
|
||||
QDateTime time = QDateTime::currentDateTime();//获取系统现在的时间
|
||||
QString str = time.toString("yyyy-MM-dd hh:mm:ss dddd"); //设置显示格式
|
||||
return str;
|
||||
}
|
||||
|
||||
void MainTopWidget::writeSafeScanDate() {
|
||||
QDateTime time = QDateTime::currentDateTime();//获取系统现在的时间
|
||||
QString str = time.toString("yyyy-MM-dd hh:mm:ss dddd"); //设置显示格式
|
||||
pSettings->beginGroup("OneKeyClean");
|
||||
pSettings->setValue("ScanDate", str);
|
||||
pSettings->setValue("Flag", "0");
|
||||
pSettings->endGroup();
|
||||
pSettings->sync();
|
||||
}
|
||||
|
||||
QString MainTopWidget::getSafeScanDate() {
|
||||
pSettings->beginGroup("OneKeyClean");
|
||||
QString value = pSettings->value("ScanDate").toString();
|
||||
pSettings->endGroup();
|
||||
pSettings->sync();
|
||||
return value;
|
||||
}
|
||||
|
||||
QString MainTopWidget::getOneKeyFlag() {
|
||||
pSettings->beginGroup("OneKeyClean");
|
||||
QString value = pSettings->value("Flag").toString();
|
||||
pSettings->endGroup();
|
||||
pSettings->sync();
|
||||
return value;
|
||||
}
|
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
|
||||
*
|
||||
* Authors:
|
||||
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef MAINTOPWIDGET_H
|
||||
#define MAINTOPWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QMouseEvent>
|
||||
#include <QHBoxLayout>
|
||||
#include <QSignalMapper>
|
||||
#include <QVBoxLayout>
|
||||
#include <QSettings>
|
||||
#include "../component/kylinbutton.h"
|
||||
#include "../component/systembutton.h"
|
||||
#include "../component/loadinglabel.h"
|
||||
|
||||
class MainWindow;
|
||||
//class SessionDispatcher;
|
||||
//class SystemDispatcher;
|
||||
|
||||
class MainTopWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MainTopWidget(bool isMain = false, QSettings *mSettings = 0, QWidget *parent = 0);
|
||||
~MainTopWidget();
|
||||
void setParentWindow(MainWindow* window) { p_mainwindow = window;}
|
||||
// void setSessionDbusProxy(SessionDispatcher* dispatcher) { sessionProxy = dispatcher;}
|
||||
// void setSystemDbusProxy(SystemDispatcher* dispatcher) { systemProxy = dispatcher;}
|
||||
void initConnect();
|
||||
void setLanguage();
|
||||
void writeFixCleanDate();
|
||||
QString getFixCleanDate();
|
||||
QString getCurrentDateTime();
|
||||
void writeSafeScanDate();
|
||||
QString getSafeScanDate();
|
||||
QString getOneKeyFlag();
|
||||
|
||||
// void enableSanButton();
|
||||
|
||||
|
||||
void initTitlebarLeftContent();
|
||||
void initTitlebarRightContent();
|
||||
void initContentLeftContent();
|
||||
void initActionRightContent();
|
||||
void initWidgets();
|
||||
|
||||
public slots:
|
||||
void onStartButtonClicked();
|
||||
void onCleanButtonClicked();
|
||||
void onEndButtonClicked();
|
||||
void getScanResult(QString msg);
|
||||
void finishScanResult(QString msg);
|
||||
void getScanAllResult(QString flag, QString msg);
|
||||
void getCleanResult(QString msg/*, QString flag*/);
|
||||
void finishCleanError(QString msg);
|
||||
void getCleaningMessage(QString type, QString status);
|
||||
|
||||
|
||||
//clean page
|
||||
void showCleanReciveStatus(const QString &status);
|
||||
void showCleanReciveError(const QString &status);
|
||||
void showCleanOverStatus();
|
||||
void showCleanerData(const QStringList &data);
|
||||
void showCleanerStatus(const QString &status, const QString &domain);
|
||||
void showCleanerError(const QString &status);
|
||||
void displayOrgPage();
|
||||
void displayAnimation();
|
||||
void receivePolicyKitSignal(bool status);
|
||||
void accordScanOverStatusToChange(bool status);
|
||||
|
||||
signals:
|
||||
void startOneKeyScan(const QStringList &categorys);
|
||||
void startOneKeyClean();
|
||||
|
||||
//clean page
|
||||
void showDetailData();
|
||||
void showMainData();
|
||||
void sendCleanSignal();
|
||||
void sendScanSignal();
|
||||
|
||||
void showMenu();
|
||||
void showSkinCenter();
|
||||
void showMin();
|
||||
void closeApp();
|
||||
|
||||
private:
|
||||
LoadingLabel *loading_label = nullptr;
|
||||
QLabel *suggest_label = nullptr;
|
||||
QLabel *scan_result_label = nullptr;
|
||||
QLabel *result_label = nullptr;
|
||||
QLabel *doing_label = nullptr;
|
||||
QPushButton *scan_button = nullptr;
|
||||
QPushButton *clean_button = nullptr;
|
||||
QPushButton *back_button = nullptr;
|
||||
|
||||
MainWindow *p_mainwindow;
|
||||
// SystemDispatcher *systemProxy;
|
||||
// SessionDispatcher *sessionProxy;
|
||||
QString trace;
|
||||
QString cookies;
|
||||
QString garbage;
|
||||
QSettings *pSettings;
|
||||
QString dateStr;
|
||||
QString workFlag;
|
||||
QString scanFinishTime;
|
||||
|
||||
|
||||
QVBoxLayout *m_layout = nullptr;
|
||||
QHBoxLayout *m_topLayout = nullptr;
|
||||
QHBoxLayout *m_titleRightLayout = nullptr;
|
||||
QHBoxLayout *m_bottomLayout = nullptr;
|
||||
QHBoxLayout *m_titleLeftLayout = nullptr;
|
||||
QHBoxLayout *m_toolLeftLayout = nullptr;
|
||||
QHBoxLayout *m_toolRightLayout = nullptr;
|
||||
|
||||
bool m_isMain;
|
||||
};
|
||||
|
||||
#endif // MAINTOPWIDGET_H
|
File diff suppressed because it is too large
Load Diff
|
@ -31,27 +31,27 @@
|
|||
#include "toolwidget.h"
|
||||
//#include "loginwidget.h"
|
||||
#include "bottomcontentwidget.h"
|
||||
#include "homepage.h"
|
||||
//#include "homepage.h"
|
||||
#include "infowidget.h"
|
||||
#include "settingwidget.h"
|
||||
#include "cleanerwidget.h"
|
||||
#include "boxwidget.h"
|
||||
#include "skincenter.h"
|
||||
//#include "skincenter.h"
|
||||
#include "../component/kylinmenu.h"
|
||||
#include "../component/utils.h"
|
||||
#include "../component/toolkits.h"
|
||||
#include "homeactionwidget.h"
|
||||
#include "infoactionwidget.h"
|
||||
#include "cleaneractionwidget.h"
|
||||
#include "settingactionwidget.h"
|
||||
#include "boxactionwidget.h"
|
||||
//#include "homeactionwidget.h"
|
||||
//#include "infoactionwidget.h"
|
||||
//#include "cleaneractionwidget.h"
|
||||
//#include "settingactionwidget.h"
|
||||
//#include "boxactionwidget.h"
|
||||
#include "aboutdialog.h"
|
||||
#include "upgradedialog.h"
|
||||
|
||||
//#include "upgradedialog.h"
|
||||
//#include "shadowwidget.h"
|
||||
class QParallelAnimationGroup;
|
||||
class SessionDispatcher;
|
||||
class SystemDispatcher;
|
||||
class ShadowWidget;
|
||||
//class ShadowWidget;
|
||||
#include "autostartwidget.h"
|
||||
//#include "cameramanager.h"
|
||||
|
||||
|
@ -59,6 +59,11 @@ class DataWorker;
|
|||
class SystemDbusProxy;
|
||||
class SessionDbusProxy;
|
||||
|
||||
class MainTopWidget;
|
||||
class MiddleWidget;
|
||||
class MainBottomWidget;
|
||||
class TopBaseWidget;
|
||||
|
||||
//class MainWindow : public QDialog
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
|
@ -66,7 +71,7 @@ class MainWindow : public QMainWindow
|
|||
|
||||
public:
|
||||
// explicit MainWindow(QString cur_arch = "", int d_count = 0, QWidget *parent = 0);
|
||||
explicit MainWindow(QString cur_arch = "", int d_count = 0, QWidget* parent = 0, Qt::WindowFlags flags = 0);
|
||||
explicit MainWindow(QString cur_arch = "", int d_count = 0, QWidget* parent = 0/*, Qt::WindowFlags flags = 0*/);
|
||||
~MainWindow();
|
||||
void setTranslator(QTranslator* translator);
|
||||
void initConnect();
|
||||
|
@ -84,20 +89,22 @@ public:
|
|||
bool deleteFile(QString filename);
|
||||
bool CopyFile(QString filename);
|
||||
QString accessOSName();
|
||||
|
||||
void createAboutDialog();
|
||||
|
||||
void initWidgets();
|
||||
void moveCenter();
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseReleaseEvent(QMouseEvent *event);
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
void closeEvent(QCloseEvent *);
|
||||
// virtual void paintEvent(QPaintEvent *event);
|
||||
virtual void paintEvent(QPaintEvent *event);
|
||||
|
||||
public slots:
|
||||
void openSkinCenter();
|
||||
void openUpgradePage(/*QStringList version_list*/);
|
||||
void openUpgradePageAgain();
|
||||
// void openUpgradePageAgain();
|
||||
void showMainMenu();
|
||||
void closeYoukerAssistant();
|
||||
void setCurrentPageIndex(int index);
|
||||
|
@ -110,7 +117,7 @@ public slots:
|
|||
void upAnimFinished();
|
||||
void closeAnimFinished();
|
||||
|
||||
void displayMainWindow(/*int display*/);
|
||||
// void displayMainWindow(/*int display*/);
|
||||
|
||||
|
||||
void onInitDataFinished();
|
||||
|
@ -119,32 +126,42 @@ signals:
|
|||
void chanegBoxToolStatus();
|
||||
|
||||
private:
|
||||
QStackedWidget *topStack;
|
||||
QStackedWidget *bottomStack;
|
||||
QStackedWidget *m_topStack = nullptr;
|
||||
QStackedWidget *m_bottomStack = nullptr;
|
||||
|
||||
MainTopWidget *m_mainTopWidget = nullptr;
|
||||
MiddleWidget *m_middleWidget = nullptr;
|
||||
MainBottomWidget *m_mainBottomWidget = nullptr;
|
||||
MainTopWidget *cleaner_action_widget;
|
||||
TopBaseWidget *info_action_widget = nullptr;
|
||||
TopBaseWidget *setting_action_widget = nullptr;
|
||||
TopBaseWidget *box_action_widget = nullptr;
|
||||
|
||||
|
||||
// QGridLayout *top_grid_layout;
|
||||
// QGridLayout *bottom_grid_layout;
|
||||
TitleWidget *title_widget;
|
||||
ActionWidget *default_action_widget;
|
||||
ActionWidget *other_action_widget;
|
||||
ToolWidget *tool_widget;
|
||||
// TitleWidget *title_widget = nullptr;
|
||||
// ActionWidget *default_action_widget;
|
||||
// ActionWidget *other_action_widget;
|
||||
// ToolWidget *tool_widget = nullptr;
|
||||
// LoginWidget *login_widget;
|
||||
BottomContentWidget *default_content_widget;
|
||||
BottomContentWidget *other_content_widget;
|
||||
HomePage *home_page;
|
||||
// BottomContentWidget *default_content_widget = nullptr;
|
||||
// BottomContentWidget *other_content_widget = nullptr;
|
||||
// HomePage *home_page;
|
||||
InfoWidget *info_widget;
|
||||
CleanerWidget *cleaner_widget;
|
||||
SettingWidget *setting_widget;
|
||||
BoxWidget *box_widget;
|
||||
HomeActionWidget *home_action_widget;
|
||||
InfoActionWidget *info_action_widget;
|
||||
CleanerActionWidget *cleaner_action_widget;
|
||||
SettingActionWidget *setting_action_widget;
|
||||
BoxActionWidget *box_action_widget;
|
||||
SkinCenter *skin_center;
|
||||
// HomeActionWidget *home_action_widget;
|
||||
// InfoActionWidget *info_action_widget;
|
||||
// CleanerActionWidget *cleaner_action_widget;
|
||||
// SettingActionWidget *setting_action_widget;
|
||||
// BoxActionWidget *box_action_widget;
|
||||
// SkinCenter *skin_center;
|
||||
KylinMenu *main_menu;
|
||||
// QString version;
|
||||
QPoint drag_pos; //移动的距离
|
||||
bool mouse_press; //按下鼠标左键
|
||||
QPoint m_dragPosition; //移动的距离
|
||||
bool m_mousePressed; //按下鼠标左键
|
||||
QTranslator* translator; //翻译器
|
||||
LANGUAGE current_language; //当前语言
|
||||
QPixmap main_skin_pixmap;
|
||||
|
@ -161,6 +178,7 @@ private:
|
|||
QString arch;
|
||||
bool battery;
|
||||
bool sensor;
|
||||
int display_count;
|
||||
QStringList m_cpulist;
|
||||
QString m_currentCpuMode;
|
||||
QParallelAnimationGroup *spreadGroup;
|
||||
|
@ -169,11 +187,12 @@ private:
|
|||
bool statusFlag;
|
||||
// AutoStartWidget *auto_start;
|
||||
// CameraManager *camera_manager;
|
||||
UpgradeDialog *upgrade_dialog;
|
||||
// UpgradeDialog *upgrade_dialog;
|
||||
// QStringList skinlist;
|
||||
ShadowWidget *shadow_widget;
|
||||
int display_count;
|
||||
// ShadowWidget *shadow_widget;
|
||||
|
||||
DataWorker *m_dataWorker = nullptr;
|
||||
QWidget *centralWidget = nullptr;
|
||||
};
|
||||
|
||||
class GlobalData // define by hebing,just for transmit var
|
||||
|
|
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
|
||||
*
|
||||
* Authors:
|
||||
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "middlewidget.h"
|
||||
#include "../component/kylintoolbutton.h"
|
||||
#include "mainwindow.h"
|
||||
#include <QDebug>
|
||||
|
||||
MiddleWidget::MiddleWidget(QWidget *parent, QString arch, QString os)
|
||||
: QWidget(parent), cur_arch(arch), osname(os)
|
||||
{
|
||||
this->setFixedSize(900, 47);
|
||||
this->setAutoFillBackground(true);
|
||||
QPalette palette;
|
||||
palette.setColor(QPalette::Background, QColor(233,238,241));//#e9eef1
|
||||
this->setPalette(palette);
|
||||
|
||||
QStringList icon_list;
|
||||
QStringList text_list;
|
||||
// if(this->cur_arch == "aarch64" || this->osname == "Kylin" || this->osname == "YHKylin")
|
||||
// {
|
||||
// icon_list<<":/tool/res/menu/home"<<":/tool/res/menu/cleanup"<<":/tool/res/menu/sysinfo"<<":/tool/res/menu/toolkits";
|
||||
// text_list<< tr("KylinHome") << tr("Cleanup") << tr("Sysinfo") << tr("Toolkits");
|
||||
// }
|
||||
// else {
|
||||
icon_list<<":/tool/res/menu/home"<<":/tool/res/menu/cleanup"<<":/tool/res/menu/sysinfo"<<":/tool/res/menu/feature"<<":/tool/res/menu/toolkits";
|
||||
text_list<< tr("Home") << tr("Cleanup") << tr("Sysinfo") << tr("Feature") << tr("Toolkits");
|
||||
// }
|
||||
|
||||
QHBoxLayout *button_layout = new QHBoxLayout();
|
||||
|
||||
QSignalMapper *signal_mapper = new QSignalMapper(this);
|
||||
for(int i=0; i<icon_list.size(); i++)
|
||||
{
|
||||
KylinToolButton *tool_button = new KylinToolButton(icon_list.at(i), text_list.at(i));
|
||||
tool_button->setFixedSize(180, 47);
|
||||
button_list.append(tool_button);
|
||||
connect(tool_button, SIGNAL(clicked()), signal_mapper, SLOT(map()));
|
||||
signal_mapper->setMapping(tool_button, QString::number(i, 10));
|
||||
button_layout->addWidget(tool_button, 0, Qt::AlignBottom);
|
||||
}
|
||||
this->switchSelectedPageIndex(0);
|
||||
connect(signal_mapper, SIGNAL(mapped(QString)), this, SLOT(switchSelectedPageIndex(QString)));
|
||||
|
||||
button_layout->addStretch();
|
||||
button_layout->setSpacing(8);
|
||||
button_layout->setMargin(0);
|
||||
button_layout->setContentsMargins(15, 0, 15, 0);
|
||||
|
||||
setLayout(button_layout);
|
||||
is_move = false;
|
||||
}
|
||||
|
||||
MiddleWidget::~MiddleWidget()
|
||||
{
|
||||
for(int i=0; i<button_list.count(); i++)
|
||||
{
|
||||
KylinToolButton *btn = button_list.at(i);
|
||||
delete btn;
|
||||
btn = NULL;
|
||||
}
|
||||
button_list.clear();
|
||||
}
|
||||
|
||||
void MiddleWidget::initConnect()
|
||||
{
|
||||
// connect(this, SIGNAL(turnCurrentPage(int)), p_mainwindow, SLOT(setCurrentPageIndex(int)));
|
||||
}
|
||||
|
||||
void MiddleWidget::switchSelectedPageIndex(QString index)
|
||||
{
|
||||
bool ok;
|
||||
int current_index = index.toInt(&ok, 10);
|
||||
|
||||
for(int i=0; i<button_list.count(); i++)
|
||||
{
|
||||
KylinToolButton *tool_button = button_list.at(i);
|
||||
if(current_index == i)
|
||||
{
|
||||
tool_button->setMousePress(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
tool_button->setMousePress(false);
|
||||
}
|
||||
}
|
||||
emit turnCurrentPage(current_index);
|
||||
}
|
||||
|
||||
void MiddleWidget::showBoxTool()
|
||||
{
|
||||
// if(this->cur_arch == "aarch64" || this->osname == "Kylin" || this->osname == "YHKylin") {
|
||||
// this->switchSelectedPageIndex("3");
|
||||
// }
|
||||
// else {
|
||||
// this->switchSelectedPageIndex("4");
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
|
||||
*
|
||||
* Authors:
|
||||
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef MIDDLEWIDGET_H
|
||||
#define MIDDLEWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QMouseEvent>
|
||||
#include <QHBoxLayout>
|
||||
#include <QSignalMapper>
|
||||
#include <QVBoxLayout>
|
||||
#include "../component/kylinbutton.h"
|
||||
#include "../component/kylintoolbutton.h"
|
||||
|
||||
class MainWindow;
|
||||
|
||||
class MiddleWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MiddleWidget(QWidget *parent = 0, QString arch = "", QString os = "");
|
||||
~MiddleWidget();
|
||||
void setParentWindow(MainWindow* window) { p_mainwindow = window;}
|
||||
void initConnect();
|
||||
|
||||
signals:
|
||||
void turnCurrentPage(int index);
|
||||
|
||||
public slots:
|
||||
void switchSelectedPageIndex(QString index);
|
||||
void showBoxTool();
|
||||
|
||||
private:
|
||||
QPoint press_point;//鼠标按下去的点
|
||||
bool is_move;
|
||||
QList<KylinToolButton *> button_list;
|
||||
MainWindow *p_mainwindow;
|
||||
QString cur_arch;
|
||||
QString osname;
|
||||
};
|
||||
|
||||
#endif // MIDDLEWIDGET_H
|
|
@ -160,7 +160,8 @@ QPushButton#blackButton:pressed{
|
|||
}
|
||||
|
||||
QPushButton#underlineButton{
|
||||
background:transparent;
|
||||
/*background:transparent;*/
|
||||
background-color: rgba(0, 0, 0, 0);
|
||||
text-decoration:underline;
|
||||
color:#cfd8dc;
|
||||
font-family: "方正黑体_GBK";
|
||||
|
|
|
@ -25,12 +25,12 @@
|
|||
#include "../setting/settingmodel.h"
|
||||
#include "../setting/settingdelegate.h"
|
||||
|
||||
SettingWidget::SettingWidget(QStringList cpulist, QString cpu, QString cur_desktop, bool has_battery, QWidget *parent) :
|
||||
SettingWidget::SettingWidget(/*QStringList cpulist, QString cpu, */QString cur_desktop, /*bool has_battery, */QWidget *parent) :
|
||||
QWidget(parent)
|
||||
,m_cpuList(cpulist)
|
||||
,m_currentCpu(cpu)
|
||||
// ,m_cpuList(cpulist)
|
||||
// ,m_currentCpu(cpu)
|
||||
,desktop(cur_desktop)
|
||||
,battery(has_battery)
|
||||
// ,battery(has_battery)
|
||||
{
|
||||
this->setFixedSize(900, 403);
|
||||
// setStyleSheet("background-color: rgba(155, 255, 255, .238);");
|
||||
|
@ -76,8 +76,6 @@ SettingWidget::SettingWidget(QStringList cpulist, QString cpu, QString cur_deskt
|
|||
// stacked_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
stacked_widget->setVisible(false);
|
||||
|
||||
this->initUI();
|
||||
|
||||
//this->qtui = NULL;
|
||||
}
|
||||
|
||||
|
@ -130,8 +128,12 @@ void SettingWidget::onSettingItemEntered(const QModelIndex &index)
|
|||
qDebug() << "onSettingItemEntered:" << index.data().toString();*/
|
||||
}
|
||||
|
||||
void SettingWidget::initUI(/*QString skin*/)
|
||||
void SettingWidget::initSettingsUI(QStringList cpulist, QString cpu, bool has_battery/*, QString skin*/)
|
||||
{
|
||||
m_cpuList = cpulist;
|
||||
m_currentCpu = cpu;
|
||||
battery = has_battery;
|
||||
|
||||
theme_widget = new ThemeWidget(this);
|
||||
icon_widget = new IconWidget(this, desktop);
|
||||
mouse_widget = new MouseWidget(this, desktop);
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
#include "../setting/filemanagerwidget.h"
|
||||
#include "../component/quibo.h"
|
||||
|
||||
#include "../component/settingaction.h"
|
||||
//#include "../component/settingaction.h"
|
||||
|
||||
class MainWindow;
|
||||
class SettingListView;
|
||||
|
@ -55,10 +55,10 @@ class SettingWidget : public QWidget
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SettingWidget(QStringList cpulist, QString cpu, QString cur_desktop, bool has_battery = false, QWidget *parent = 0);
|
||||
explicit SettingWidget(/*QStringList cpulist, QString cpu, */QString cur_desktop, /*bool has_battery = false, */QWidget *parent = 0);
|
||||
~SettingWidget();
|
||||
void setParentWindow(MainWindow* window) { p_mainwindow = window;}
|
||||
void initUI(/*QString skin*/);
|
||||
void initSettingsUI(QStringList cpulist, QString cpu, bool has_battery = false /*QString skin*/);
|
||||
void resetSkin(QString skin);
|
||||
|
||||
signals:
|
||||
|
|
|
@ -19,9 +19,12 @@
|
|||
|
||||
#include "shadowwidget.h"
|
||||
#include <QPainter>
|
||||
#include <QtMath>
|
||||
#include <QPen>
|
||||
|
||||
ShadowWidget::ShadowWidget(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
,widget_color(QColor("#fca71d"))
|
||||
{
|
||||
widget_opacity = 1;
|
||||
}
|
||||
|
@ -32,11 +35,61 @@ void ShadowWidget::setOpacity(qreal opacity)
|
|||
update();
|
||||
}
|
||||
|
||||
void ShadowWidget::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
// if(event->button() == Qt::LeftButton)
|
||||
// {
|
||||
// m_mousePressed = true;
|
||||
// m_dragPosition = event->globalPos() - this->frameGeometry().topLeft();
|
||||
// event->accept();
|
||||
// }
|
||||
if(event->button() == Qt::LeftButton)
|
||||
{
|
||||
m_mousePressed = true;
|
||||
m_dragPosition = event->globalPos() - pos();
|
||||
}
|
||||
}
|
||||
|
||||
void ShadowWidget::mouseReleaseEvent(QMouseEvent *)
|
||||
{
|
||||
m_mousePressed = false;
|
||||
setWindowOpacity(1);
|
||||
}
|
||||
|
||||
void ShadowWidget::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if(m_mousePressed)
|
||||
{
|
||||
QPoint move_pos = event->globalPos();
|
||||
move(move_pos - m_dragPosition);
|
||||
setWindowOpacity(0.9);
|
||||
// event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void ShadowWidget::paintEvent(QPaintEvent *)
|
||||
{
|
||||
// QPainter painter(this);
|
||||
// painter.setOpacity(widget_opacity);
|
||||
// painter.setBrush(widget_color);
|
||||
// painter.setPen(Qt::NoPen);
|
||||
// painter.drawRect(rect());
|
||||
|
||||
QPainterPath path;
|
||||
path.setFillRule(Qt::WindingFill);
|
||||
path.addRect(10,10,this->width()-20,this->height()-20);
|
||||
QPainter painter(this);
|
||||
painter.setOpacity(widget_opacity);
|
||||
painter.setBrush(widget_color);
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.drawRect(rect());
|
||||
painter.setRenderHint(QPainter::Antialiasing,true);
|
||||
painter.fillPath(path,QBrush(Qt::white));
|
||||
// QColor color(0,0,0,50);
|
||||
QColor color(widget_color);
|
||||
for(int i = 0 ; i < 10 ; ++i)
|
||||
{
|
||||
QPainterPath path;
|
||||
path.setFillRule(Qt::WindingFill);
|
||||
path.addRect(10-i,10-i,this->width()-(10-i)*2,this->height()-(10-i)*2);
|
||||
color.setAlpha(150 - qSqrt(i)*50);
|
||||
painter.setPen(color);
|
||||
painter.drawPath(path);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#define SHADOWWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QMouseEvent>
|
||||
|
||||
class ShadowWidget : public QWidget
|
||||
{
|
||||
|
@ -39,9 +40,14 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseReleaseEvent(QMouseEvent *event);
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
void paintEvent(QPaintEvent *);
|
||||
|
||||
private:
|
||||
QPoint m_dragPosition; //移动的距离
|
||||
bool m_mousePressed; //按下鼠标左键
|
||||
qreal widget_opacity;
|
||||
QColor widget_color;
|
||||
};
|
||||
|
|
|
@ -678,23 +678,23 @@ void SkinCenter::mousePressEvent(QMouseEvent *event)
|
|||
{
|
||||
if(event->button() == Qt::LeftButton)
|
||||
{
|
||||
mouse_press = true;
|
||||
drag_pos = event->globalPos() - this->frameGeometry().topLeft();
|
||||
m_mousePressed = true;
|
||||
m_dragPosition = event->globalPos() - this->frameGeometry().topLeft();
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void SkinCenter::mouseReleaseEvent(QMouseEvent *)
|
||||
{
|
||||
mouse_press = false;
|
||||
m_mousePressed = false;
|
||||
}
|
||||
|
||||
void SkinCenter::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if(mouse_press)
|
||||
if(m_mousePressed)
|
||||
{
|
||||
QPoint move_pos = event->globalPos();
|
||||
move(move_pos - drag_pos);
|
||||
move(move_pos - m_dragPosition);
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,9 +78,9 @@ protected:
|
|||
|
||||
private:
|
||||
MainWindow *mainwindow;
|
||||
QPoint drag_pos; //移动的距离
|
||||
QPoint m_dragPosition; //移动的距离
|
||||
// bool mouse_enter;
|
||||
bool mouse_press; //按下鼠标左键
|
||||
bool m_mousePressed; //按下鼠标左键
|
||||
QWidget *baseWidget;
|
||||
SystemButton *close_btn;
|
||||
QLabel *indicator;
|
||||
|
|
36
src/src.pro
36
src/src.pro
|
@ -49,13 +49,17 @@ unix {
|
|||
|
||||
SOURCES += main.cpp\
|
||||
mainwindow.cpp \
|
||||
maintopwidget.cpp \
|
||||
middlewidget.cpp \
|
||||
mainbottomwidget.cpp \
|
||||
topbasewidget.cpp \
|
||||
titlewidget.cpp \
|
||||
loginwidget.cpp \
|
||||
# loginwidget.cpp \
|
||||
actionwidget.cpp \
|
||||
homeactionwidget.cpp \
|
||||
# homeactionwidget.cpp \
|
||||
infoactionwidget.cpp \
|
||||
cleaneractionwidget.cpp \
|
||||
settingactionwidget.cpp \
|
||||
# settingactionwidget.cpp \
|
||||
boxactionwidget.cpp \
|
||||
toolwidget.cpp \
|
||||
bottomcontentwidget.cpp \
|
||||
|
@ -72,7 +76,7 @@ SOURCES += main.cpp\
|
|||
../component/systembutton.cpp \
|
||||
../component/kylintitlebar.cpp \
|
||||
../component/threadpool.cpp \
|
||||
homepage.cpp \
|
||||
# homepage.cpp \
|
||||
../info/infounitwidget.cpp \
|
||||
../info/infogui.cpp \
|
||||
../info/infoitemline.cpp \
|
||||
|
@ -96,7 +100,7 @@ SOURCES += main.cpp\
|
|||
../component/agentlistitem.cpp \
|
||||
../component/quibo.cpp \
|
||||
../component/kylinfontdialog.cpp \
|
||||
skincenter.cpp \
|
||||
# skincenter.cpp \
|
||||
../component/kylinlistwidgetitem.cpp \
|
||||
../component/kylinlistwidget.cpp \
|
||||
../component/loadinglabel.cpp \
|
||||
|
@ -109,7 +113,7 @@ SOURCES += main.cpp\
|
|||
../dbusproxy/youkersystemdbus.cpp \
|
||||
../dbusproxy/youkersessiondbus.cpp \
|
||||
../info/devicemanager.cpp \
|
||||
../component/settingaction.cpp \
|
||||
# ../component/settingaction.cpp \
|
||||
kthread.cpp \
|
||||
aboutdialog.cpp \
|
||||
../cleaner/cleanlistwidget.cpp \
|
||||
|
@ -121,7 +125,7 @@ SOURCES += main.cpp\
|
|||
../component/cleansubbutton.cpp \
|
||||
../component/cardwidget.cpp \
|
||||
../component/itemcard.cpp \
|
||||
upgradedialog.cpp \
|
||||
# upgradedialog.cpp \
|
||||
../component/normalwidget.cpp \
|
||||
../component/normalcard.cpp \
|
||||
shadowwidget.cpp \
|
||||
|
@ -134,15 +138,19 @@ SOURCES += main.cpp\
|
|||
|
||||
HEADERS += mainwindow.h \
|
||||
kpplication.h \
|
||||
maintopwidget.h \
|
||||
middlewidget.h \
|
||||
mainbottomwidget.h \
|
||||
topbasewidget.h \
|
||||
titlewidget.h \
|
||||
actionwidget.h \
|
||||
homeactionwidget.h \
|
||||
# homeactionwidget.h \
|
||||
infoactionwidget.h \
|
||||
cleaneractionwidget.h \
|
||||
settingactionwidget.h \
|
||||
# settingactionwidget.h \
|
||||
boxactionwidget.h \
|
||||
toolwidget.h \
|
||||
loginwidget.h \
|
||||
# loginwidget.h \
|
||||
bottomcontentwidget.h \
|
||||
infowidget.h \
|
||||
cleanerwidget.h \
|
||||
|
@ -160,7 +168,7 @@ HEADERS += mainwindow.h \
|
|||
../component/systembutton.h \
|
||||
../component/kylintitlebar.h \
|
||||
../component/threadpool.h \
|
||||
homepage.h \
|
||||
# homepage.h \
|
||||
../info/infounitwidget.h \
|
||||
../info/infogui.h \
|
||||
../info/infoitemline.h \
|
||||
|
@ -185,7 +193,7 @@ HEADERS += mainwindow.h \
|
|||
../component/agentlistitem.h \
|
||||
../component/quibo.h \
|
||||
../component/kylinfontdialog.h \
|
||||
skincenter.h \
|
||||
# skincenter.h \
|
||||
../component/kylinlistwidgetitem.h \
|
||||
../component/kylinlistwidget.h \
|
||||
../component/loadinglabel.h \
|
||||
|
@ -198,7 +206,7 @@ HEADERS += mainwindow.h \
|
|||
../dbusproxy/youkersystemdbus.h \
|
||||
../dbusproxy/youkersessiondbus.h \
|
||||
../info/devicemanager.h \
|
||||
../component/settingaction.h \
|
||||
# ../component/settingaction.h \
|
||||
kthread.h \
|
||||
aboutdialog.h \
|
||||
../cleaner/cleanlistwidget.h \
|
||||
|
@ -210,7 +218,7 @@ HEADERS += mainwindow.h \
|
|||
../component/cleansubbutton.h \
|
||||
../component/cardwidget.h \
|
||||
../component/itemcard.h \
|
||||
upgradedialog.h \
|
||||
# upgradedialog.h \
|
||||
../component/normalwidget.h \
|
||||
../component/normalcard.h \
|
||||
shadowwidget.h \
|
||||
|
|
|
@ -0,0 +1,328 @@
|
|||
/*
|
||||
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
|
||||
*
|
||||
* Authors:
|
||||
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "topbasewidget.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QPixmap>
|
||||
#include <QPushButton>
|
||||
#include <QCursor>
|
||||
|
||||
|
||||
// enum SettingModuleID{
|
||||
// ThemePage = 0,
|
||||
// IconPage,
|
||||
// MousePage,
|
||||
// SoundPage,
|
||||
// PanelPage,
|
||||
// MenuPage,
|
||||
// WindowPage,
|
||||
// FontPage,
|
||||
// TouchPadPage,
|
||||
// EnergyPage,
|
||||
// FMPage
|
||||
// };
|
||||
|
||||
namespace {
|
||||
//const QMap<SettingModuleID::SettingModuleID, QString> titleMap()
|
||||
//{
|
||||
// QMap<SettingAction::SettingModuleID, QString> m;
|
||||
// m.insert(SettingAction::ThemePage, "a");
|
||||
// m.insert(SettingAction::IconPage, "b");
|
||||
// m.insert(SettingAction::MousePage, "c");
|
||||
// m.insert(SettingAction::SoundPage, "d");
|
||||
// return m;
|
||||
//}
|
||||
|
||||
//int filterTitleAccordModuleName(SettingAction::SettingModuleID id)
|
||||
//{
|
||||
// return titleMap().value(id);
|
||||
//}
|
||||
|
||||
const QMap<QString, QString> titleMap()
|
||||
{
|
||||
QMap<QString, QString> tMap;
|
||||
tMap.insert("ThemePage", QObject::tr("Choose the theme what you want"));
|
||||
tMap.insert("IconPage", QObject::tr("Set the desktop icon theme and the visibility of desktop icons"));
|
||||
tMap.insert("MousePage", QObject::tr("Replace the theme and size of the mouse pointer, and theme change need to restart system"));
|
||||
tMap.insert("SoundPage", QObject::tr("Set the sound theme you want"));
|
||||
tMap.insert("PanelPage", QObject::tr("Setting the panel mode of auto hide and icon size"));
|
||||
tMap.insert("MenuPage", QObject::tr("Manage display of the start menu"));
|
||||
tMap.insert("WindowPage", QObject::tr("Window Manager settings"));
|
||||
tMap.insert("FontPage", QObject::tr("According to personal preferences to set the system default font, click the 'Restore' button, can be restored to the state before the font settings"));
|
||||
tMap.insert("TouchPadPage", QObject::tr("Setting the relevant properties of your touchpad,make the operation more convenient"));
|
||||
tMap.insert("EnergyPage", QObject::tr("Save energy to let the computer longer standby time"));
|
||||
tMap.insert("FMPage", QObject::tr("Manage the file manager. Tips: if the thumbnail's cache time or size is set to -1, it will not be checked"));
|
||||
|
||||
return tMap;
|
||||
}
|
||||
|
||||
QString filterTitleAccordModuleName(QString moduleName)
|
||||
{
|
||||
return titleMap().value(moduleName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TopBaseWidget::TopBaseWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
m_titileMessage = "";
|
||||
|
||||
this->setFixedSize(900, 150);
|
||||
this->setAutoFillBackground(true);
|
||||
// this->setObjectName("transparentWidget");
|
||||
|
||||
this->initWidgets();
|
||||
}
|
||||
|
||||
TopBaseWidget::~TopBaseWidget()
|
||||
{
|
||||
if(img_label != NULL) {
|
||||
delete img_label;
|
||||
img_label = NULL;
|
||||
}
|
||||
if(suggest_label != NULL) {
|
||||
delete suggest_label;
|
||||
suggest_label = NULL;
|
||||
}
|
||||
|
||||
delete back_button;
|
||||
|
||||
//Segmentation fault
|
||||
QLayoutItem *child;
|
||||
while ((child = m_titleLeftLayout->takeAt(0)) != 0) {
|
||||
if (child->widget())
|
||||
child->widget()->deleteLater();
|
||||
delete child;
|
||||
}
|
||||
while ((child = m_titleRightLayout->takeAt(0)) != 0) {
|
||||
if (child->widget())
|
||||
child->widget()->deleteLater();
|
||||
delete child;
|
||||
}
|
||||
while ((child = m_toolLeftLayout->takeAt(0)) != 0) {
|
||||
if (child->widget())
|
||||
child->widget()->deleteLater();
|
||||
delete child;
|
||||
}
|
||||
while ((child = m_toolRightLayout->takeAt(0)) != 0) {
|
||||
if (child->widget())
|
||||
child->widget()->deleteLater();
|
||||
delete child;
|
||||
}
|
||||
while ((child = m_topLayout->takeAt(0)) != 0) {
|
||||
if (child->widget())
|
||||
child->widget()->deleteLater();
|
||||
delete child;
|
||||
}
|
||||
while ((child = m_bottomLayout->takeAt(0)) != 0) {
|
||||
if (child->widget())
|
||||
child->widget()->deleteLater();
|
||||
delete child;
|
||||
}
|
||||
delete m_layout;
|
||||
}
|
||||
|
||||
void TopBaseWidget::setTipMessage(const QString &message)
|
||||
{
|
||||
this->m_titileMessage = message;
|
||||
|
||||
suggest_label->setText(message);
|
||||
}
|
||||
|
||||
void TopBaseWidget::setImage(const QString &pic)
|
||||
{
|
||||
QPixmap label_pixmap(pic);
|
||||
img_label->setPixmap(label_pixmap);
|
||||
img_label->setFixedSize(label_pixmap.size());
|
||||
}
|
||||
|
||||
//QString TopBaseWidget::getModuleName() /*const*/
|
||||
//{
|
||||
// return this->m_moduleName;
|
||||
//}
|
||||
|
||||
//void SettingAction::setModuleName(const QString &name)
|
||||
//void TopBaseWidget::setModuleName(QString name)
|
||||
//{
|
||||
//// this->m_moduleName = name;
|
||||
//// back_button->setVisible(true);
|
||||
//// const QString title = filterTitleAccordModuleName(name);
|
||||
//// if (title.isEmpty() || title.isNull()) {
|
||||
//// suggest_label->setText(tr("There may be a mistake."));
|
||||
//// }
|
||||
//// else {
|
||||
//// suggest_label->setText(title);
|
||||
//// }
|
||||
//}
|
||||
|
||||
//void SettingActionWidget::displayActionSubPage(SettingAction::SettingModuleID moduleId)
|
||||
void TopBaseWidget::displayActionSubPage(QString moduleName)
|
||||
{
|
||||
// this->m_moduleName = moduleName;
|
||||
back_button->setVisible(true);
|
||||
|
||||
const QString title = filterTitleAccordModuleName(moduleName);
|
||||
if (title.isEmpty() || title.isNull()) {
|
||||
suggest_label->setText(tr("There may be a mistake."));
|
||||
}
|
||||
else {
|
||||
suggest_label->setText(title);
|
||||
}
|
||||
}
|
||||
|
||||
void TopBaseWidget::initTitlebarLeftContent()
|
||||
{
|
||||
QWidget *w = new QWidget;
|
||||
m_titleLeftLayout = new QHBoxLayout(w);
|
||||
m_titleLeftLayout->setContentsMargins(6, 0, 0, 0);
|
||||
m_titleLeftLayout->setSpacing(0);
|
||||
|
||||
QLabel *appLabel = new QLabel;
|
||||
appLabel->setStyleSheet("QLabel{background-color:transparent;color:#ffffff; font-size:12px;}");
|
||||
appLabel->setText(tr("Kylin Assistant"));
|
||||
m_titleLeftLayout->addWidget(appLabel);
|
||||
|
||||
m_topLayout->addWidget(w, 1, Qt::AlignLeft);
|
||||
}
|
||||
|
||||
void TopBaseWidget::initTitlebarRightContent()
|
||||
{
|
||||
QWidget *w = new QWidget;
|
||||
m_titleRightLayout = new QHBoxLayout(w);
|
||||
m_titleRightLayout->setContentsMargins(0, 0, 1, 0);
|
||||
m_titleRightLayout->setSpacing(0);
|
||||
|
||||
m_topLayout->addWidget(w, 1, Qt::AlignRight);
|
||||
|
||||
SystemButton *min_button = new SystemButton();
|
||||
SystemButton *close_button = new SystemButton();
|
||||
// SystemButton *skin_button = new SystemButton();
|
||||
SystemButton *main_menu_button = new SystemButton();
|
||||
min_button->loadPixmap(":/sys/res/sysBtn/min_button.png");
|
||||
close_button->loadPixmap(":/sys/res/sysBtn/close_button.png");
|
||||
// skin_button->loadPixmap(":/sys/res/sysBtn/skin_button.png");
|
||||
main_menu_button->loadPixmap(":/sys/res/sysBtn/main_menu.png");
|
||||
min_button->setFocusPolicy(Qt::NoFocus);
|
||||
close_button->setFocusPolicy(Qt::NoFocus);
|
||||
// skin_button->setFocusPolicy(Qt::NoFocus);
|
||||
main_menu_button->setFocusPolicy(Qt::NoFocus);
|
||||
|
||||
m_titleRightLayout->addWidget(main_menu_button);
|
||||
// m_titleRightLayout->addWidget(skin_button);
|
||||
m_titleRightLayout->addWidget(min_button);
|
||||
m_titleRightLayout->addWidget(close_button);
|
||||
|
||||
connect(main_menu_button, &SystemButton::clicked, this, [=] {
|
||||
emit this->showMenu();
|
||||
});
|
||||
// connect(skin_button, &SystemButton::clicked, this, [=] {
|
||||
// emit this->showSkinCenter();
|
||||
// });
|
||||
connect(min_button, &SystemButton::clicked, this, [=] {
|
||||
emit this->showMin();
|
||||
});
|
||||
connect(close_button, &SystemButton::clicked, this, [=] {
|
||||
emit this->closeApp();//window()->close();
|
||||
});
|
||||
}
|
||||
|
||||
void TopBaseWidget::initContentLeftContent()
|
||||
{
|
||||
QWidget *w = new QWidget;
|
||||
w->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
m_toolLeftLayout = new QHBoxLayout(w);
|
||||
m_toolLeftLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
img_label = new QLabel();
|
||||
suggest_label = new QLabel();
|
||||
|
||||
img_label->setScaledContents(true);//自动缩放,显示图像大小自动调整为Qlabel大小
|
||||
|
||||
suggest_label->setObjectName("whiteLabel");
|
||||
suggest_label->setWordWrap(true);//QLabel自动换行
|
||||
suggest_label->setFixedWidth(550);
|
||||
|
||||
m_toolLeftLayout->setSpacing(10);
|
||||
m_toolLeftLayout->addStretch();
|
||||
m_toolLeftLayout->addWidget(img_label, 0, Qt::AlignHCenter);
|
||||
m_toolLeftLayout->addWidget(suggest_label, 0, Qt::AlignHCenter);
|
||||
m_toolLeftLayout->addStretch();
|
||||
|
||||
// m_bottomLayout->addWidget(w);
|
||||
m_bottomLayout->addWidget(w, 1, Qt::AlignLeft);
|
||||
}
|
||||
|
||||
void TopBaseWidget::initActionRightContent()
|
||||
{
|
||||
QWidget *w = new QWidget;
|
||||
m_toolRightLayout = new QHBoxLayout(w);
|
||||
m_toolRightLayout->setContentsMargins(0, 3, 0, 10);
|
||||
m_toolRightLayout->setSpacing(0);
|
||||
|
||||
back_button = new QPushButton();
|
||||
back_button->setCursor(Qt::PointingHandCursor);
|
||||
back_button->setFixedSize(91,39);
|
||||
back_button->setFocusPolicy(Qt::NoFocus);
|
||||
QPixmap pixmap("://res/back-arrow.png");
|
||||
back_button->setIcon(pixmap);
|
||||
back_button->setIconSize(pixmap.size());
|
||||
back_button->setObjectName("backgroundButton");
|
||||
back_button->setText(tr("Back"));
|
||||
back_button->setVisible(false);
|
||||
connect(back_button, &QPushButton::clicked, this, [=] {
|
||||
suggest_label->setText(this->m_titileMessage);
|
||||
back_button->setVisible(false);
|
||||
emit this->notifyContentPageToMain();
|
||||
});
|
||||
|
||||
m_toolRightLayout->addWidget(back_button);
|
||||
m_bottomLayout->addWidget(w, 1, Qt::AlignRight);
|
||||
}
|
||||
|
||||
void TopBaseWidget::initWidgets()
|
||||
{
|
||||
m_layout = new QVBoxLayout(this);
|
||||
m_layout->setContentsMargins(0, 0, 0, 0);
|
||||
m_layout->setSpacing(0);
|
||||
|
||||
QWidget *topWidget = new QWidget;
|
||||
m_topLayout = new QHBoxLayout(topWidget);
|
||||
m_topLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_topLayout->setSpacing(0);
|
||||
m_layout->addWidget(topWidget, 0, Qt::AlignTop);
|
||||
|
||||
QWidget *bottomWidget = new QWidget;
|
||||
m_bottomLayout = new QHBoxLayout(bottomWidget);
|
||||
m_bottomLayout->setContentsMargins(19, 0, 0, 26);
|
||||
m_bottomLayout->setSpacing(0);
|
||||
m_layout->addWidget(bottomWidget, 0, Qt::AlignBottom);
|
||||
|
||||
this->setLayout(m_layout);
|
||||
|
||||
initTitlebarLeftContent();
|
||||
initTitlebarRightContent();
|
||||
initContentLeftContent();
|
||||
initActionRightContent();
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
|
||||
*
|
||||
* Authors:
|
||||
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TOPBASEWIDGET_H
|
||||
#define TOPBASEWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QMouseEvent>
|
||||
#include <QHBoxLayout>
|
||||
#include <QSignalMapper>
|
||||
#include <QVBoxLayout>
|
||||
#include "../component/kylinbutton.h"
|
||||
#include "../component/systembutton.h"
|
||||
|
||||
class TopBaseWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TopBaseWidget(QWidget *parent = 0);
|
||||
~TopBaseWidget();
|
||||
|
||||
void setTipMessage(const QString &message);
|
||||
void setImage(const QString &pic);
|
||||
|
||||
void initTitlebarLeftContent();
|
||||
void initTitlebarRightContent();
|
||||
void initContentLeftContent();
|
||||
void initActionRightContent();
|
||||
void initWidgets();
|
||||
|
||||
|
||||
// QString getModuleName() const;
|
||||
// void setModuleName(const QString &name);
|
||||
QString getModuleName();
|
||||
// void setModuleName(QString name);
|
||||
|
||||
// SettingModuleID getModuleNameID() const;
|
||||
// void setModuleNameID(const SettingModuleID &id);
|
||||
|
||||
public slots:
|
||||
void displayActionSubPage(QString moduleName);
|
||||
|
||||
signals:
|
||||
void notifyContentPageToMain();
|
||||
void showMenu();
|
||||
void showSkinCenter();
|
||||
void showMin();
|
||||
void closeApp();
|
||||
|
||||
private:
|
||||
QLabel *img_label = nullptr;
|
||||
QLabel *suggest_label = nullptr;
|
||||
QPushButton *back_button = nullptr;
|
||||
|
||||
QString desktop;
|
||||
// QString m_moduleName;
|
||||
// SettingModuleID m_id;
|
||||
QString m_titileMessage;
|
||||
|
||||
QVBoxLayout *m_layout = nullptr;
|
||||
QHBoxLayout *m_topLayout = nullptr;
|
||||
QHBoxLayout *m_titleRightLayout = nullptr;
|
||||
QHBoxLayout *m_bottomLayout = nullptr;
|
||||
QHBoxLayout *m_titleLeftLayout = nullptr;
|
||||
QHBoxLayout *m_toolLeftLayout = nullptr;
|
||||
QHBoxLayout *m_toolRightLayout = nullptr;
|
||||
};
|
||||
|
||||
#endif // TOPBASEWIDGET_H
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -483,23 +483,23 @@ void UpgradeDialog::mousePressEvent(QMouseEvent *event)
|
|||
{
|
||||
if(event->button() == Qt::LeftButton)
|
||||
{
|
||||
mouse_press = true;
|
||||
drag_pos = event->globalPos() - this->frameGeometry().topLeft();
|
||||
m_mousePressed = true;
|
||||
m_dragPosition = event->globalPos() - this->frameGeometry().topLeft();
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void UpgradeDialog::mouseReleaseEvent(QMouseEvent *)
|
||||
{
|
||||
mouse_press = false;
|
||||
m_mousePressed = false;
|
||||
}
|
||||
|
||||
void UpgradeDialog::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if(mouse_press)
|
||||
if(m_mousePressed)
|
||||
{
|
||||
QPoint move_pos = event->globalPos();
|
||||
move(move_pos - drag_pos);
|
||||
move(move_pos - m_dragPosition);
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,8 +69,8 @@ protected:
|
|||
void mouseMoveEvent(QMouseEvent *event);
|
||||
|
||||
private:
|
||||
QPoint drag_pos; //移动的距离
|
||||
bool mouse_press; //按下鼠标左键
|
||||
QPoint m_dragPosition; //移动的距离
|
||||
bool m_mousePressed; //按下鼠标左键
|
||||
QWidget *baseWidget;
|
||||
SystemButton *close_btn;
|
||||
QProgressBar *progressbar;
|
||||
|
|
Loading…
Reference in New Issue