rewrite theme ui module

This commit is contained in:
balloonflower 2018-02-11 19:02:25 +08:00
parent c083579f9c
commit 145dff4807
27 changed files with 566 additions and 1943 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,143 +0,0 @@
/*
* 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 CLEANERDETAILWIDGET_H
#define CLEANERDETAILWIDGET_H
#include <QWidget>
#include "cleaneritems.h"
#include "cleanlistwidget.h"
class QLabel;
class QBoxLayout;
class QHBoxLayout;
class QGridLayout;
class SessionDispatcher;
class SystemDispatcher;
class Toolkits;
class MainWindow;
class CleanSubGroup;
//1110
class CardWidget;
class ItemCard;
//namespace Ui {
//class CleanerDetailWidget;
//}
class CleanerDetailWidget : public QWidget
{
Q_OBJECT
public:
explicit CleanerDetailWidget(QWidget *parent = 0, SessionDispatcher *seroxy = 0, SystemDispatcher *syproxy = 0, MainWindow *window = 0, Toolkits *kits = 0, QString skin = ":/background/res/skin/1.png");
~CleanerDetailWidget();
void setUIData();
void setLanguage();
void initConnect();
void getAllSelectedItems();
void resetCurrentSkin(QString skin);
public slots:
void showCustomPage();
void showReciveData(const QStringList &data);
void receiveCleanSignal();
void showReciveStatus(const QString &status);
void CleanUIAndData();
// void receivePolicyKitSignal(bool status);
signals:
void notifyMainCheckBox(int status);
// void showActionAnimaiton();
void sendScanOverStatus(bool status);
private:
void initTitleBar();
private:
// Ui::CleanerDetailWidget *ui;
MainWindow *parentWindow;
SessionDispatcher *sessionproxy;
SystemDispatcher *systemproxy;
Toolkits *toolKits;
QMap<QString, QVariant> argsData;
CleanListWidget *cache_apt_items ;
CleanSubGroup *cache_apt_btn;
CleanListWidget *cache_software_items ;
CleanSubGroup *cache_software_btn;
CleanListWidget *cache_thumbnails_items ;
CleanSubGroup *cache_thumbnails_btn;
CleanListWidget *cache_firefox_items ;
CleanSubGroup *cache_firefox_btn;
CleanListWidget *cache_chromium_items ;
CleanSubGroup *cache_chromium_btn;
CleanListWidget *package_unneed_items ;
CleanSubGroup *package_unneed_btn;
CleanListWidget *package_oldkernel_items ;
CleanSubGroup *package_oldkernel_btn;
CleanListWidget *package_configfile_items ;
CleanSubGroup *package_configfile_btn;
CleanListWidget *cookies_firefox_items ;
CleanSubGroup *cookies_firefox_btn;
CleanListWidget *cookies_chromium_items ;
CleanSubGroup *cookies_chromium_btn;
CleanSubGroup *trace_firefox_btn;
CleanSubGroup *trace_chromium_btn;
CleanSubGroup *trace_system_btn;
CleanSubGroup *trace_bash_btn;
CleanListWidget *trace_x11_items ;
CleanSubGroup *trace_x11_btn;
QStringList cache_apt_list;
QStringList cache_software_list;
QStringList cache_thumbnails_list;
QStringList cache_firefox_list;
QStringList cache_chromium_list;
QStringList package_unneed_list;
QStringList package_oldkernel_list;
QStringList package_configfile_list;
QStringList cookies_firefox_list;
QStringList cookies_chromium_list;
QString trace_firefox_count;
QString trace_chromium_count;
QString trace_system_count;
QString trace_bash_size;
QString trace_bash_path;
QStringList trace_x11_list;
// QGridLayout *grid_layout;
// int rowIndex;
// int columnIndex;
int subCount;
bool scanResult;
QString cur_skin;
//1110
CardWidget *custom_list_widget;
// QList<CleanSubGroup *> custom_card_list;
QList<ItemCard *> custom_card_list;
QWidget *skin_widget;
};
#endif // CLEANERDETAILWIDGET_H

View File

@ -62,6 +62,7 @@ CleanerDetailWidget::CleanerDetailWidget(QWidget *parent, MainWindow *window, To
m_scrollArea = new QScrollArea(this);
m_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_scrollArea->setWidgetResizable(true);
m_scrollArea->setStyleSheet("QScrollArea{border: none;background-color: #ffffff;}");
areaWidget = new QWidget(/*this*/);
areaWidget->setObjectName("transparentWidget");
m_scrollArea->setWidget(areaWidget);

View File

@ -1,191 +0,0 @@
/*
* 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 "cleaneritems.h"
#include "mainwindow.h"
#include <QDebug>
//CleanerItems::CleanerItems(QStringList &arglist, QStringList &statuslist, int height, const QString title_text, QWidget *parent)
// : QWidget(parent),titleName(title_text)/*, widgetHeight(height)*/
CleanerItems::CleanerItems(QStringList &arglist, QStringList &statuslist, QString skin, int height, const QString title_text, QWidget *parent)
:QWidget(parent),titleName(title_text)
{
setWindowFlags(Qt::FramelessWindowHint);
this->setFixedSize(900, 403);
// this->setObjectName("transparentWidget");
// this->setWindowFlags(Qt::FramelessWindowHint);
this->setAutoFillBackground(true);
QPalette palette;
palette.setBrush(QPalette::Window, QBrush(Qt::white));
this->setPalette(palette);
QVBoxLayout *button_layout = new QVBoxLayout;
int count = arglist.count();
// QSignalMapper *signal_mapper = new QSignalMapper(this);
for(int i=0; i<count; i++)
{
QCheckBox *checkbox = new QCheckBox(arglist.at(i));
checkbox->setFocusPolicy(Qt::NoFocus);
checkbox->setCheckState(Qt::Checked);
checkbox->setStatusTip(statuslist.at(i));
checkbox_list.append(checkbox);
// connect(checkbox, SIGNAL(clicked()), signal_mapper, SLOT(map()));
connect(checkbox, SIGNAL(clicked()), this, SLOT(scanAllSubCheckbox()));
// signal_mapper->setMapping(checkbox, QString::number(i, 10));
button_layout->addWidget(checkbox);
}
button_layout->setSpacing(15);
button_layout->setMargin(0);
button_layout->setContentsMargins(0, 10, 0, 0);
// connect(signal_mapper, SIGNAL(mapped(QString)), this, SLOT(switchPageIndex(QString)));
// setLayout(button_layout);
okBtn = new QPushButton();
okBtn->setFixedSize(91, 25);
okBtn->setObjectName("blackButton");
okBtn->setFocusPolicy(Qt::NoFocus);
QHBoxLayout *btn_layout = new QHBoxLayout();
btn_layout->addStretch();
btn_layout->addWidget(okBtn);
btn_layout->setMargin(0);
btn_layout->setContentsMargins(0, 0, 15, 10);
group_box = new QGroupBox();
group_box->setStyleSheet("QGroupBox{border: 1px solid #e0e0e0;border-radius: 2px;margin-top: 15px;font-size:14px;}QGroupBox:title{subcontrol-origin: margin;subcontrol-position: top left;padding: 6px 3px;color: #00609a;font-family: 方正黑体_GBK;font-weight:bold;}");
group_box->setTitle(titleName);
QFont group_box_font = group_box->font();
group_box_font.setBold(true);
group_box->setFont(group_box_font);
group_box->setFixedWidth(380);
group_box->setLayout(button_layout);
group_box->setContentsMargins(10, 10, 10, 10);
QHBoxLayout *group_layout = new QHBoxLayout();
group_layout->addWidget(group_box);
group_layout->setMargin(0);
group_layout->setContentsMargins(10, 10, 10, 0);
QVBoxLayout *main_layout = new QVBoxLayout();
// main_layout->addWidget(title_bar);
main_layout->addLayout(group_layout);
// main_layout->addWidget(group_box);
main_layout->addStretch();
main_layout->addLayout(btn_layout);
main_layout->setSpacing(0);
main_layout->setMargin(0);
main_layout->setContentsMargins(0, 0, 0, 0);
setLayout(main_layout);
this->initConnect();
this->setLanguage();
}
CleanerItems::~CleanerItems()
{
}
void CleanerItems::initConnect()
{
// connect(title_bar,SIGNAL(closeDialog()), this, SLOT(onCloseButtonClicked()));
connect(okBtn,SIGNAL(clicked()), this, SLOT(onCloseButtonClicked()));
}
void CleanerItems::onCloseButtonClicked()
{
emit this->sendoksignal();
this->close();
}
//void CleanerItems::initTitleBar(QString skin)
//{
// title_bar->setTitleWidth(410);
// title_bar->setTitleName(titleName);
//// title_bar->setTitleBackgound(":/background/res/skin/1.png");
// title_bar->setTitleBackgound(skin);
//}
//void CleanerItems::resetTitleSkin(QString skin)
//{
// title_bar->resetBackground(skin);
//}
int CleanerItems::getItemCount()
{
return checkbox_list.count();
}
QStringList CleanerItems::getSelectedItems()
{
QStringList text_list;
int count = checkbox_list.count();
for(int i=0; i<count; i++)
{
QCheckBox *checkbox = checkbox_list.at(i);
if (checkbox->isChecked()) {
// text_list.append(checkbox->text());
text_list.append(checkbox->statusTip());
}
}
return text_list;
}
void CleanerItems::setLanguage()
{
okBtn->setText(tr("OK"));
}
void CleanerItems::scanAllSubCheckbox() {
int count = checkbox_list.count();
int m = 0;
for(int i=0; i<count; i++)
{
QCheckBox *checkbox = checkbox_list.at(i);
if (checkbox->isChecked()) {
m +=1;
}
}
if (m == 0) {
emit this->notifyMainCheckBox(0);
}
else if (m == count) {
emit this->notifyMainCheckBox(2);
}
else {
emit this->notifyMainCheckBox(1);
}
}
void CleanerItems::resetSubCheckbox(int status) {
if(status == 0) {
for(int i=0; i<checkbox_list.count(); i++)
{
QCheckBox *checkbox = checkbox_list.at(i);
checkbox->setChecked(false);
}
}
else if(status == 2) {
for(int i=0; i<checkbox_list.count(); i++)
{
QCheckBox *checkbox = checkbox_list.at(i);
checkbox->setChecked(true);
}
}
}

View File

@ -1,63 +0,0 @@
/*
* 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 CLEANERITEMS_H
#define CLEANERITEMS_H
#include <QWidget>
#include <QPushButton>
class MainWindow;
class QCheckBox;
class QGroupBox;
class CleanerItems : public QWidget
{
Q_OBJECT
public:
explicit CleanerItems(QStringList &arglist, QStringList &statuslist, QString skin = ":/background/res/skin/1.png", int height = 0, const QString title_text = "UbuntuKylin", QWidget *parent = 0);
~CleanerItems();
void setParentWindow(MainWindow* window) { p_mainwindow = window;}
void setLanguage();
void initConnect();
int getItemCount();
QStringList getSelectedItems();
public slots:
void resetSubCheckbox(int status);
void scanAllSubCheckbox();
void onCloseButtonClicked();
signals:
void notifyMainCheckBox(int status);
void sendoksignal();
private:
QList<QCheckBox *> checkbox_list;
MainWindow *p_mainwindow;
QString titleName;
QPushButton *okBtn;
QGroupBox *group_box;
};
#endif // CLEANERITEMS_H

View File

@ -1,196 +0,0 @@
/*
* 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 "cleaneritems.h"
#include "mainwindow.h"
#include <QDebug>
//CleanerItems::CleanerItems(QStringList &arglist, QStringList &statuslist, int height, const QString title_text, QWidget *parent)
// : QWidget(parent),titleName(title_text)/*, widgetHeight(height)*/
CleanerItems::CleanerItems(QStringList &arglist, QStringList &statuslist, QString skin, int height, const QString title_text, QDialog *parent)
:QDialog(parent),titleName(title_text)
{
setWindowFlags(Qt::FramelessWindowHint);
this->setStyleSheet("QDialog{border: 1px solid gray;border-radius:2px}");//设定边框宽度以及颜色
this->setWindowIcon(QIcon(":/res/youker-assistant.png"));
this->setFixedSize(410, height);
// this->setObjectName("transparentWidget");
// this->setWindowFlags(Qt::FramelessWindowHint);
this->setAutoFillBackground(true);
QPalette palette;
palette.setBrush(QPalette::Window, QBrush(Qt::white));
this->setPalette(palette);
title_bar = new KylinTitleBar();
initTitleBar(skin);
QVBoxLayout *button_layout = new QVBoxLayout;
int count = arglist.count();
// QSignalMapper *signal_mapper = new QSignalMapper(this);
for(int i=0; i<count; i++)
{
QCheckBox *checkbox = new QCheckBox(arglist.at(i));
checkbox->setFocusPolicy(Qt::NoFocus);
checkbox->setCheckState(Qt::Checked);
checkbox->setStatusTip(statuslist.at(i));
checkbox_list.append(checkbox);
// connect(checkbox, SIGNAL(clicked()), signal_mapper, SLOT(map()));
connect(checkbox, SIGNAL(clicked()), this, SLOT(scanAllSubCheckbox()));
// signal_mapper->setMapping(checkbox, QString::number(i, 10));
button_layout->addWidget(checkbox);
}
button_layout->setSpacing(15);
button_layout->setMargin(0);
button_layout->setContentsMargins(0, 10, 0, 0);
// connect(signal_mapper, SIGNAL(mapped(QString)), this, SLOT(switchPageIndex(QString)));
// setLayout(button_layout);
okBtn = new QPushButton();
okBtn->setFixedSize(91, 25);
okBtn->setObjectName("blackButton");
okBtn->setFocusPolicy(Qt::NoFocus);
QHBoxLayout *btn_layout = new QHBoxLayout();
btn_layout->addStretch();
btn_layout->addWidget(okBtn);
btn_layout->setMargin(0);
btn_layout->setContentsMargins(0, 0, 15, 10);
group_box = new QGroupBox();
group_box->setStyleSheet("QGroupBox{border: 1px solid #e0e0e0;border-radius: 2px;margin-top: 15px;font-size:14px;}QGroupBox:title{subcontrol-origin: margin;subcontrol-position: top left;padding: 6px 3px;color: #00609a;font-family: 方正黑体_GBK;font-weight:bold;}");
group_box->setTitle(titleName);
QFont group_box_font = group_box->font();
group_box_font.setBold(true);
group_box->setFont(group_box_font);
group_box->setFixedWidth(380);
group_box->setLayout(button_layout);
group_box->setContentsMargins(10, 10, 10, 10);
QHBoxLayout *group_layout = new QHBoxLayout();
group_layout->addWidget(group_box);
group_layout->setMargin(0);
group_layout->setContentsMargins(10, 10, 10, 0);
QVBoxLayout *main_layout = new QVBoxLayout();
main_layout->addWidget(title_bar);
main_layout->addLayout(group_layout);
// main_layout->addWidget(group_box);
main_layout->addStretch();
main_layout->addLayout(btn_layout);
main_layout->setSpacing(0);
main_layout->setMargin(0);
main_layout->setContentsMargins(0, 0, 0, 0);
setLayout(main_layout);
this->initConnect();
this->setLanguage();
}
CleanerItems::~CleanerItems()
{
}
void CleanerItems::initConnect()
{
connect(title_bar,SIGNAL(closeDialog()), this, SLOT(onCloseButtonClicked()));
connect(okBtn,SIGNAL(clicked()), this, SLOT(onCloseButtonClicked()));
}
void CleanerItems::onCloseButtonClicked()
{
this->close();
}
void CleanerItems::initTitleBar(QString skin)
{
title_bar->setTitleWidth(410);
title_bar->setTitleName(titleName);
// title_bar->setTitleBackgound(":/background/res/skin/1.png");
title_bar->setTitleBackgound(skin);
}
void CleanerItems::resetTitleSkin(QString skin)
{
title_bar->resetBackground(skin);
}
int CleanerItems::getItemCount()
{
return checkbox_list.count();
}
QStringList CleanerItems::getSelectedItems()
{
QStringList text_list;
int count = checkbox_list.count();
for(int i=0; i<count; i++)
{
QCheckBox *checkbox = checkbox_list.at(i);
if (checkbox->isChecked()) {
// text_list.append(checkbox->text());
text_list.append(checkbox->statusTip());
}
}
return text_list;
}
void CleanerItems::setLanguage()
{
okBtn->setText(tr("OK"));
}
void CleanerItems::scanAllSubCheckbox() {
int count = checkbox_list.count();
int m = 0;
for(int i=0; i<count; i++)
{
QCheckBox *checkbox = checkbox_list.at(i);
if (checkbox->isChecked()) {
m +=1;
}
}
if (m == 0) {
emit this->notifyMainCheckBox(0);
}
else if (m == count) {
emit this->notifyMainCheckBox(2);
}
else {
emit this->notifyMainCheckBox(1);
}
}
void CleanerItems::resetSubCheckbox(int status) {
if(status == 0) {
for(int i=0; i<checkbox_list.count(); i++)
{
QCheckBox *checkbox = checkbox_list.at(i);
checkbox->setChecked(false);
}
}
else if(status == 2) {
for(int i=0; i<checkbox_list.count(); i++)
{
QCheckBox *checkbox = checkbox_list.at(i);
checkbox->setChecked(true);
}
}
}

View File

@ -1,71 +0,0 @@
/*
* 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 CLEANERITEMS_H
#define CLEANERITEMS_H
#include <QWidget>
#include <QDialog>
#include "../component/kylintitlebar.h"
class MainWindow;
class QCheckBox;
class QGroupBox;
//class CleanerItems : public QWidget
class CleanerItems : public QDialog
{
Q_OBJECT
public:
// explicit CleanerItems(QStringList &arglist, QStringList &statuslist, int height = 0, const QString title_text = "UbuntuKylin", QWidget *parent = 0);
explicit CleanerItems(QStringList &arglist, QStringList &statuslist, QString skin = ":/background/res/skin/1.png", int height = 0, const QString title_text = "UbuntuKylin", QDialog *parent = 0);
~CleanerItems();
void setParentWindow(MainWindow* window) { p_mainwindow = window;}
void setLanguage();
void initConnect();
int getItemCount();
QStringList getSelectedItems();
void resetTitleSkin(QString skin);
public slots:
void resetSubCheckbox(int status);
void scanAllSubCheckbox();
void onCloseButtonClicked();
private:
void initTitleBar(QString skin);
signals:
void notifyMainCheckBox(int status);
private:
QList<QCheckBox *> checkbox_list;
MainWindow *p_mainwindow;
KylinTitleBar *title_bar;
QString titleName;
QPushButton *okBtn;
QGroupBox *group_box;
QString cur_skin;
};
#endif // CLEANERITEMS_H

View File

@ -123,7 +123,7 @@ void MyTitleBar::initRightContent()
{
QWidget *w = new QWidget;
m_rLayout = new QHBoxLayout(w);
m_rLayout->setContentsMargins(0, 0, 6, 0);
m_rLayout->setContentsMargins(0, 0, 0, 0);
m_rLayout->setSpacing(0);
m_layout->addWidget(w, 1, Qt::AlignRight);

View File

@ -21,6 +21,7 @@
#include "utils.h"
#include <QApplication>
#include <QGraphicsDropShadowEffect>
SelectCategoryWidget::SelectCategoryWidget(CleanerCategoryID id, const QString &title, bool needMin, QWidget *parent)
: QDialog(parent)
@ -34,6 +35,7 @@ SelectCategoryWidget::SelectCategoryWidget(CleanerCategoryID id, const QString &
m_mainLayout = new QVBoxLayout(containerW);
m_mainLayout->setSpacing(0);
m_mainLayout->setMargin(0);
m_mainLayout->setContentsMargins(0,0,0,0);
m_titleBar = new MyTitleBar(title, needMin, this);
m_titleBar->setFixedSize(this->width(), TITILE_BAR_HEIGHT);
m_listWidget = new SelectListWidget(true, this);
@ -45,6 +47,13 @@ SelectCategoryWidget::SelectCategoryWidget(CleanerCategoryID id, const QString &
connect(m_titleBar, SIGNAL(closeSignal()), this, SLOT(onClose()));
connect(m_listWidget, SIGNAL(notifyMainCheckBox(int)), this, SIGNAL(notifyMainCheckBox(int)));
//边框阴影效果
// QGraphicsDropShadowEffect *shadow_effect = new QGraphicsDropShadowEffect(this);
// shadow_effect->setBlurRadius(5);
// shadow_effect->setColor(QColor(0, 0, 0, 127));
// shadow_effect->setOffset(2, 4);
// this->setGraphicsEffect(shadow_effect);
QDesktopWidget* desktop = QApplication::desktop();
this->move((desktop->width() - this->width())/2, (desktop->height() - this->height())/3);
}

View File

@ -25,9 +25,12 @@ SelectListItem::SelectListItem(QWidget *parent, QString description, QString tip
, m_tip(tipMsg)
, m_hasTip(hasTip)
{
this->setStyleSheet("QWidget{padding: 2px 0;} QWidget:hover{background-color:rgba(43,182,234,0.1);border-radius:2px;}");//#2bb6ea
m_mainLayout = new QHBoxLayout(this);
m_mainLayout->setSpacing(5);
m_mainLayout->setSpacing(0);
m_mainLayout->setMargin(0);
m_mainLayout->setContentsMargins(0,0,0,0);
m_checkBox = new QCheckBox(this);
m_checkBox->setFocusPolicy(Qt::NoFocus);
@ -38,7 +41,7 @@ SelectListItem::SelectListItem(QWidget *parent, QString description, QString tip
});
m_descLabel = new QLabel(this);
m_descLabel->setFixedWidth(itemWidth - m_checkBox->width() - 10);
m_descLabel->setFixedWidth(itemWidth - m_checkBox->width());
m_descLabel->setWordWrap(true);
m_descLabel->setText(description);

View File

@ -24,11 +24,16 @@ SelectListWidget::SelectListWidget(bool hasTip, QWidget *parent) :
QWidget(parent)
, m_hasTip(hasTip)
{
this->setStyleSheet("QWidget{background-color:transparent;}");
m_gridLayout = new QGridLayout(this);
m_widget = new QWidget;
m_gridLayout->setVerticalSpacing(0);
m_widget = new QWidget(this);
m_widget->setObjectName("transparentWidget");
m_listAreaWidgetLayout = new QVBoxLayout(m_widget);
m_listAreaWidgetLayout->setContentsMargins(0,0,0,0);
m_scrollArea = new QScrollArea(this);
m_scrollArea->setStyleSheet("QScrollArea{border:none;background-color:#ffffff;}");
m_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_scrollArea->setWidgetResizable(true);
m_scrollArea->setWidget(m_widget);
@ -37,13 +42,10 @@ SelectListWidget::SelectListWidget(bool hasTip, QWidget *parent) :
}
else {
m_titleLabel = new QLabel;
m_titleLabel->setFixedSize(80,30);
m_titleLabel->setText(tr("Items:"));
m_countLabel = new QLabel;
m_countLabel->setFixedSize(100,30);
m_gridLayout->addWidget(m_titleLabel,0,0,1,1);
m_gridLayout->addItem(new QSpacerItem(10,10),0,0,1,3);
m_gridLayout->addWidget(m_countLabel,0,1,1,1);
m_titleLabel->setFixedHeight(30);
m_titleLabel->setStyleSheet("QLabel{background-color:rgb(233 ,238, 241);color:#000000;font-family: 方正黑体_GBK;font-size:12px;text-align:left;}");
m_titleLabel->setText(tr("Clean Items:"));
m_gridLayout->addWidget(m_titleLabel,0,0,1,5/*, Qt::AlignLeft | Qt::AlignVCenter*/);
m_gridLayout->addWidget(m_scrollArea,1,0,5,5);
}
@ -60,7 +62,7 @@ void SelectListWidget::loadListItems(const QString &title, const QStringList &ca
m_itemsMap.clear();
int count = cachelist.count();
m_countLabel->setText(QString::number(count));
m_titleLabel->setText(QString("%1 %2").arg(tr("Clean Items:")).arg(QString::number(count)));
foreach (QString cache, cachelist) {
SelectListItem *item = new SelectListItem(0, cache, "", false, itemWidth);
@ -124,7 +126,7 @@ void SelectListWidget::scanAllSubCheckbox()
selectedCount += 1;
}
if (!m_hasTip)
m_countLabel->setText(QString::number(selectedCount));
m_titleLabel->setText(QString("%1 %2").arg(tr("Clean Items:")).arg(QString::number(selectedCount)));
if (selectedCount == 0) {
emit this->notifyMainCheckBox(0);

View File

@ -58,7 +58,7 @@ private:
QWidget *m_widget = nullptr;
QVBoxLayout *m_listAreaWidgetLayout = nullptr;
QLabel *m_titleLabel = nullptr;
QLabel *m_countLabel = nullptr;
// QLabel *m_countLabel = nullptr;
QMap<QString, SelectListItem *> m_itemsMap;
};

View File

@ -21,6 +21,7 @@
#include "utils.h"
#include <QApplication>
#include <QGraphicsDropShadowEffect>
SelectWidget::SelectWidget(CleanerModuleID id, const QString &title, bool needMin, QWidget *parent)
: QDialog(parent)
@ -45,6 +46,13 @@ SelectWidget::SelectWidget(CleanerModuleID id, const QString &title, bool needMi
connect(m_titleBar, SIGNAL(closeSignal()), this, SLOT(onClose()));
connect(m_listWidget, SIGNAL(notifyMainCheckBox(int)), this, SIGNAL(notifyMainCheckBox(int)));
// //边框阴影效果
// QGraphicsDropShadowEffect *shadow_effect = new QGraphicsDropShadowEffect(this);
// shadow_effect->setBlurRadius(5);
// shadow_effect->setColor(QColor(0, 0, 0, 127));
// shadow_effect->setOffset(2, 4);
// this->setGraphicsEffect(shadow_effect);
QDesktopWidget* desktop = QApplication::desktop();
this->move((desktop->width() - this->width())/2, (desktop->height() - this->height())/3);
}

1
debian/changelog vendored
View File

@ -21,5 +21,6 @@ kylin-assistant (1.0.0-0ubuntu1) bionic; urgency=low
* Rewrite mainwindow.
* Add shadow effect for window.
* Rewrite cleaner ui module.
* Rewrite theme ui module.
-- lixiang <lixiang@kylinos.cn> Mon, 29 Jan 2018 17:54:44 +0800

View File

@ -45,6 +45,7 @@ InfoGui::InfoGui(QWidget *parent)
m_scrollArea = new QScrollArea;
m_scrollArea->setWidgetResizable(true);
m_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_scrollArea->setStyleSheet("QScrollArea{border: none;background-color: #ffffff;}");
m_vLayout->setSpacing(10);
m_vLayout->setMargin(0);

View File

@ -97,6 +97,8 @@ void InfoUnitWidget::setInfoVendor(const QString &vendor)
painterPath.addEllipse(QRect(0, 0, 48, 48));
const QPixmap pixmap = QPixmap(vendor).scaled(48, 48, Qt::KeepAspectRatio, Qt::SmoothTransformation);
if (pixmap.isNull())
return;
QPixmap pic(48, 48);
pic.fill(Qt::transparent);

View File

@ -44,7 +44,10 @@ ShredDialog::ShredDialog(QWidget *parent) :
setWindowFlags(Qt::FramelessWindowHint);
// this->setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint);//Attention: Qt::WindowCloseButtonHint make showMinimized() valid
this->setStyleSheet("QDialog{border: 1px solid white;border-radius:1px;background-color: #ffffff;}");
this->setWindowIcon(QIcon(":/res/kylin-assistant.png"));
this->setWindowTitle(tr("Kylin Shred Manager"));
this->setWindowIcon(QIcon(":/model/res/plugin/shredder.png"));
this->setFixedSize(500, 471);
// process_plugin = plugin;

View File

@ -70,6 +70,9 @@ StartupWidget::StartupWidget(QWidget *parent)
// this->setAutoFillBackground(true);
// this->setMouseTracking(true);
this->setWindowTitle(tr("Kylin Startup Manager"));
this->setWindowIcon(QIcon(":/model/res/plugin/startupmanager.png"));
this->setFixedSize(500, 645);
m_titleWidget = new StartupTitleWidget(this);

View File

@ -29,6 +29,7 @@
#include <QHBoxLayout>
#include <QApplication>
#include <QScreen>
#include <QGraphicsDropShadowEffect>
SystemMonitor::SystemMonitor(QWidget *parent)
: QFrame(parent)
@ -46,6 +47,9 @@ SystemMonitor::SystemMonitor(QWidget *parent)
this->setMouseTracking(true);
// installEventFilter(this);
this->setWindowTitle(tr("Kylin System Monitor"));
this->setWindowIcon(QIcon(":/model/res/plugin/processmanager.png"));
this->resize(900, 600);
setMinimumSize(640, 480);
@ -56,6 +60,13 @@ SystemMonitor::SystemMonitor(QWidget *parent)
this->initPanelStack();
this->initConnections();
//边框阴影效果
QGraphicsDropShadowEffect *shadow_effect = new QGraphicsDropShadowEffect(this);
shadow_effect->setBlurRadius(5);
shadow_effect->setColor(QColor(0, 0, 0, 127));
shadow_effect->setOffset(2, 4);
this->setGraphicsEffect(shadow_effect);
this->moveCenter();
}
@ -360,7 +371,7 @@ void SystemMonitor::closeEvent(QCloseEvent *event)
event->accept();
}
void SystemMonitor::paintEvent(QPaintEvent *event)
/*void SystemMonitor::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing, true);
@ -379,7 +390,7 @@ void SystemMonitor::paintEvent(QPaintEvent *event)
painter.drawRoundedRect(r, 4, 4);
QFrame::paintEvent(event);
}
}*/
void SystemMonitor::mousePressEvent(QMouseEvent *event)
{

View File

@ -58,7 +58,7 @@ public slots:
protected:
void resizeEvent(QResizeEvent *e) override;
void paintEvent(QPaintEvent *);
// void paintEvent(QPaintEvent *);
void closeEvent(QCloseEvent *event);
void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;

View File

@ -0,0 +1,185 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin 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 "themedelegate.h"
#include <QPainter>
#include <QDebug>
namespace {
const int THEME_IMAGE_MARGIN = 10;
}
ThemeDelegate::ThemeDelegate(QObject *parent)
: QStyledItemDelegate(parent)
, m_textColor(QColor("rgba(0,153,68,0.3)"))
{
//"#009944" "#e60012"
}
QWidget *ThemeDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
Q_UNUSED(index)
Q_UNUSED(option)
return QStyledItemDelegate::createEditor(parent, option, index);
}
void ThemeDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
if (!index.isValid()) {
return;
}
QStyledItemDelegate::setEditorData(editor, index);
}
void ThemeDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
QStyledItemDelegate::setModelData(editor, model, index);
}
void ThemeDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QList<QVariant> datas = index.model()->data(index, Qt::DisplayRole).toList();
if (!datas.isEmpty()) {
// Draw background
drawBackground(option, painter);//or draw shadow effect: "://res/theme-cover.png"
// Draw theme image
drawImage(option, index, painter);
// Draw title text
drawTitle(option, index, painter);
}
}
QSize ThemeDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
Q_UNUSED(option)
return index.model()->data(index, Qt::SizeHintRole).toSize();
}
void ThemeDelegate::drawBackground(const QStyleOptionViewItem &option, QPainter *painter) const
{
painter->setRenderHint(QPainter::Antialiasing, true);
QRect rect = option.rect;
rect.setSize(QSize(rect.width() - 1, rect.height() - 1));
QColor bgColor;
QColor borderColor;
if ((option.state & QStyle::State_MouseOver) && (option.state & QStyle::State_Selected) == 0) {
bgColor = QColor("#e0f4f9");
borderColor = QColor("#999999");
}
else if (option.state & QStyle::State_Selected) {
bgColor = QColor("#2bb6ea");
borderColor = QColor("#e0f4f9");
}
else {
bgColor = QColor("#999999");
borderColor = QColor("#ffffff");
}
QPainterPath path;
path.addRoundedRect(rect.x(), rect.y(), rect.width(), rect.height(), 3, 4);
painter->fillPath(path, QBrush(bgColor));
QPen borderPen(QBrush(borderColor), 1);
painter->setPen(borderPen);
painter->drawPath(path);
}
void ThemeDelegate::drawImage(const QStyleOptionViewItem &option, const QModelIndex& index, QPainter *painter) const
{
painter->setRenderHint(QPainter::Antialiasing, true);
QRect rect = option.rect;
const int pixmapSize = rect.width() - THEME_IMAGE_MARGIN * 2;
QList<QVariant> datas = index.model()->data(index, Qt::DisplayRole).toList();
//QString data = index.data().toString();
const QString name = datas[0].toString();
const QString picture = datas[1].toString();
const QString defaultPic = datas[2].toString();
bool isCurrent = datas[3].toBool();
// Theme image
QSize imageSize;
imageSize.setWidth(option.rect.width() - THEME_IMAGE_MARGIN * 2);
imageSize.setHeight(imageSize.width());
/*if ((option.state & QStyle::State_MouseOver) && (option.state & QStyle::State_Selected) == 0) {
}
else if (option.state & QStyle::State_Selected) {
}*/
QPixmap pixmap = QPixmap(picture);
if (!pixmap.isNull())
pixmap = pixmap.scaled(imageSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
else
pixmap = QPixmap(defaultPic).scaled(imageSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
QPixmap scalePixmap = pixmap.scaled(pixmapSize, pixmapSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
painter->drawPixmap(rect.x() + THEME_IMAGE_MARGIN, rect.y() + THEME_IMAGE_MARGIN, pixmapSize, pixmapSize, scalePixmap);
if (isCurrent) {
painter->drawPixmap(rect.x() + 2*THEME_IMAGE_MARGIN, rect.y() + 2*THEME_IMAGE_MARGIN, 22, 22, QPixmap("://res/choose.png"));
}
}
void ThemeDelegate::drawTitle(const QStyleOptionViewItem &option, const QModelIndex &index, QPainter *painter) const
{
painter->setRenderHint(QPainter::Antialiasing, false);
QRect rect = option.rect;
QFont font;
font.setPixelSize(12);
QPen pen(m_textColor);
QList<QVariant> datas = index.model()->data(index, Qt::DisplayRole).toList();
// QString data = index.data().toString();
QString name = datas[0].toString();
painter->setPen(pen);
QFont textFont(painter->font());
textFont.setPixelSize(12);
textFont.setWeight(24);
const QFontMetrics fm(textFont);
QSize textSize(qMin(fm.width(name) + 18, rect.width()), fm.height() + 2);
const int textHeight = rect.height() * 0.78;
const QRectF textRect = QRect(rect.x(), rect.y() + textHeight + 5, rect.width(), rect.height() - textHeight);
// Draw theme name text background
/*QRect bgRect(rect.x() + (rect.width() - textSize.width()) / 2, textRect.y()+ (textRect.height() - textSize.height()) / 2, textSize.width(), textSize.height());
if (option.state & QStyle::State_Selected) {
QPainterPath textPainterPath;
textPainterPath.addRoundedRect(bgRect, 2, 2);
painter->fillPath(textPainterPath, QBrush(QColor("#2ca7f8")));
}*/
painter->setFont(textFont);
painter->drawText(textRect, fm.elidedText(name, Qt::ElideMiddle, rect.width()), QTextOption(Qt::AlignCenter));
}

View File

@ -0,0 +1,46 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin 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 THEMEDELEGATE_H
#define THEMEDELEGATE_H
#include <QStyledItemDelegate>
class ThemeDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
explicit ThemeDelegate(QObject *parent = nullptr);
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE;
void setEditorData(QWidget* editor, const QModelIndex& index) const Q_DECL_OVERRIDE;
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const Q_DECL_OVERRIDE;
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const Q_DECL_OVERRIDE;
QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const Q_DECL_OVERRIDE;
void drawBackground(const QStyleOptionViewItem &option, QPainter *painter) const;
void drawImage(const QStyleOptionViewItem &option, const QModelIndex& index, QPainter *painter) const;
void drawTitle(const QStyleOptionViewItem &option, const QModelIndex& index, QPainter *painter) const;
private:
QColor m_textColor;
};
#endif // THEMEDELEGATE_H

168
setting/theme/themeview.cpp Normal file
View File

@ -0,0 +1,168 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin 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 "themeview.h"
#include "themedelegate.h"
#include <QApplication>
#include <QMouseEvent>
#include <QDebug>
namespace {
const QSize THEME_ITEM_DEFAULT_SIZE = QSize(139, 160);
}
ThemeView::ThemeView(QWidget *parent)
: QListView(parent)
, m_itemSize(THEME_ITEM_DEFAULT_SIZE)
, m_prevModelIndex(QModelIndex())
{
setMouseTracking(true);
m_delegate = new ThemeDelegate(this);
setItemDelegate(m_delegate);
m_model = new QStandardItemModel(this);
setModel(m_model);
setEditTriggers(QAbstractItemView::NoEditTriggers);
setResizeMode(QListView::Adjust);
setViewMode(QListView::IconMode);
setSelectionMode(QAbstractItemView::SingleSelection);
setUniformItemSizes(true);
setSpacing(60);
setDragEnabled(false);
connect(this, &ThemeView::doubleClicked, this, &ThemeView::onItemClicked);
connect(this, &ThemeView::clicked, this, &ThemeView::onItemClicked);
connect(selectionModel(), &QItemSelectionModel::currentChanged, this, [=] (const QModelIndex &current) {
if (!current.isValid())
return;
if (m_prevModelIndex.isValid()) {//update the previous model index's data
QList<QVariant> datas = m_prevModelIndex.model()->data(m_prevModelIndex, Qt::DisplayRole).toList();
if (!datas.isEmpty()) {
datas.replace(3, QVariant(false));
m_model->setData(m_prevModelIndex, QVariant(datas), Qt::DisplayRole);
m_model->setData(m_prevModelIndex, QVariant(m_itemSize), Qt::SizeHintRole);
}
}
m_prevModelIndex = current;
});
}
ThemeView::~ThemeView()
{
this->clearData();
}
void ThemeView::clearData()
{
setAutoScroll(false);
for (int i = 0; i < this->m_model->rowCount(); ++i) {
this->m_model->removeRow(i);
}
setAutoScroll(true);
m_prevModelIndex = QModelIndex();
}
QModelIndex ThemeView::loadThemeData(const QString &name, bool isCurrrent)
{
QVariantList datas;
datas.append(QVariant(name));//theme name
datas.append(QVariant(QString(":/gtk/res/theme/%1.png").arg(name)));//theme picture
datas.append(QVariant(":/gtk/res/theme/disappear.png"));//default picture
datas.append(QVariant(isCurrrent));
QModelIndex index;
const int existIndex = isExist(name);
if (existIndex != -1) {//it exist, then update data
index = m_model->index(existIndex, 0);
}
else {//it not exist, then new item
QStandardItem *item = new QStandardItem();
QList<QStandardItem *> items;
items.append(item);
m_model->appendRow(items);
index = m_model->index(m_model->rowCount() - 1, 0);
}
m_model->setData(index, QVariant(datas), Qt::DisplayRole);
m_model->setData(index, QVariant(m_itemSize), Qt::SizeHintRole);
return index;
}
QSize ThemeView::itemSize() const
{
return m_itemSize;
}
int ThemeView::isExist(const QString &name) const
{
for (int i = 0; i < m_model->rowCount(); i++) {
const QVariantList datas = m_model->data(m_model->index(i, 0), Qt::DisplayRole).toList();
if (!datas.isEmpty() && datas[0].toString() == name) {
return i;
}
}
return -1;
}
void ThemeView::onItemClicked(const QModelIndex &index)
{
if (!index.isValid())
return;
QList<QVariant> datas = index.model()->data(index, Qt::DisplayRole).toList();
if (!datas.isEmpty()) {
const QString name = datas[0].toString();
const int ti = isExist(name);
if (ti != -1) {//it must be exist, then update the current model index's data
datas.replace(3, QVariant(true));
m_model->setData(index, QVariant(datas), Qt::DisplayRole);
m_model->setData(index, QVariant(m_itemSize), Qt::SizeHintRole);
setCurrentIndex(index);
emit this->sendSelectThemeName(name);
}
}
}
void ThemeView::loadOneTheme(const QString &name, bool isCurrrent)
{
QModelIndex index = loadThemeData(name, isCurrrent);
if (isCurrrent)
setCurrentIndex(index);
scrollTo(m_model->index(index.row() + 1, 0, index.parent()));
}
void ThemeView::mousePressEvent(QMouseEvent *e)
{
if (!indexAt(e->pos()).isValid()) {
this->selectionModel()->clearSelection();
}
QListView::mousePressEvent(e);
}

58
setting/theme/themeview.h Normal file
View File

@ -0,0 +1,58 @@
/*
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin 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 THEMEVIEW_H
#define THEMEVIEW_H
#include <QListView>
#include <QStandardItemModel>
class ThemeDelegate;
class ThemeView : public QListView
{
Q_OBJECT
public:
explicit ThemeView(QWidget *parent = 0);
~ThemeView();
void loadOneTheme(const QString &name, bool isCurrrent = false);
QModelIndex loadThemeData(const QString &name, bool isCurrrent = false);
void clearData();
int isExist(const QString &name) const;
QSize itemSize() const;
public slots:
void onItemClicked(const QModelIndex &index);
signals:
void sendSelectThemeName(QString themeName);
protected:
void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
private:
ThemeDelegate *m_delegate = nullptr;
QStandardItemModel *m_model = nullptr;
QSize m_itemSize;
QModelIndex m_prevModelIndex;
};
#endif // THEMEVIEW_H

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
@ -18,6 +18,8 @@
*/
#include "themewidget.h"
#include "theme/themeview.h"
#include <QStandardItemModel>
#include <QSignalMapper>
#include <QListWidgetItem>
@ -32,15 +34,26 @@ ThemeWidget::ThemeWidget(QWidget *parent) :
// this->resize(parent->size());
// this->setFixedSize(900, 403);
label = new QLabel(this);
label->setObjectName("tipLabel");
label->setGeometry(QRect(30, 15, 860, 50));
label->setFixedHeight(30);
// label->setGeometry(QRect(30, 15, 860, 50));
label->setText(tr("Please choose theme which you need"));
list_widget = new NormalWidget(119, 139, 20, this);
/*list_widget = new NormalWidget(119, 139, 20, this);
list_widget->setGeometry(QRect(30, 55, 860, 330));
list_widget->calculate_data();
list_widget->calculate_data();*/
m_themeView = new ThemeView(this);
connect(m_themeView, SIGNAL(sendSelectThemeName(QString)), this, SLOT(changeTheme(QString)));
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
layout->setMargin(0);
layout->addWidget(label);
layout->addWidget(m_themeView);
this->setLayout(layout);
}
QString ThemeWidget::settingModuleName()
@ -53,9 +66,21 @@ void ThemeWidget::onReceiveThemeList(const QString &currentTheme, const QStringL
// qDebug() << "currentTheme="<<currentTheme<<", themeList="<<themeList;
if (!themeList.isEmpty()) {
m_themeView->clearData();
syslist.clear();
syslist = themeList;
this->resetUI();
//kobe test 2018
for (const QString theme : themeList) {
if(currentTheme == theme)
m_themeView->loadOneTheme(theme, true);
else
m_themeView->loadOneTheme(theme, false);
}
/*this->resetUI();
list_widget->resetData();
QSignalMapper *signal_mapper = new QSignalMapper(this);
@ -72,7 +97,7 @@ void ThemeWidget::onReceiveThemeList(const QString &currentTheme, const QStringL
signal_mapper->setMapping(card, QString::number(i, 10));
connect(signal_mapper, SIGNAL(mapped(QString)), this, SLOT(switchUsingLogo(QString)));
connect(card, SIGNAL(sendSelectThemeName(QString)), this, SLOT(changeTheme(QString)));
}
}*/
}
}
@ -113,13 +138,14 @@ ThemeWidget::~ThemeWidget()
void ThemeWidget::resetUI()
{
for(int i=0; i<card_list.count(); i++)
//kobe test 2018
/*for(int i=0; i<card_list.count(); i++)
{
NormalCard *card = card_list.at(i);
delete card;
card = NULL;
}
card_list.clear();
card_list.clear();*/
}
void ThemeWidget::initConnect() {
@ -129,7 +155,8 @@ void ThemeWidget::initConnect() {
void ThemeWidget::switchUsingLogo(QString index)
{
bool ok;
//kobe test 2018
/*bool ok;
int current_index = index.toInt(&ok, 10);
for(int i=0; i<card_list.count(); i++)
{
@ -142,7 +169,7 @@ void ThemeWidget::switchUsingLogo(QString index)
{
card->showUsingLogo(false);
}
}
}*/
}
void ThemeWidget::changeTheme(QString name)

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2013 ~ 2015 National University of Defense Technology(NUDT) & Kylin Ltd.
* Copyright (C) 2013 ~ 2018 National University of Defense Technology(NUDT) & Tianjin Kylin Ltd.
*
* Authors:
* Kobe Lee xiangli@ubuntukylin.com/kobe24_lixiang@126.com
@ -28,6 +28,7 @@ class QLabel;
class QPushButton;
class QListWidget;
class QListWidgetItem;
class ThemeView;
#include "settingmodulelpage.h"
@ -36,7 +37,7 @@ class ThemeWidget : public SettingModulePage
{
Q_OBJECT
public:
explicit ThemeWidget(QWidget *parent = 0/*, SessionDispatcher *proxy = 0*/);
explicit ThemeWidget(QWidget *parent = 0);
~ThemeWidget();
void initConnect();
@ -57,8 +58,9 @@ signals:
void changeSystemTheme(const QString &name);
private:
ThemeView *m_themeView = nullptr;
QStringList syslist;
NormalWidget *list_widget;
// NormalWidget *list_widget;
QList<NormalCard *> card_list;
QLabel *label;
};

View File

@ -94,6 +94,8 @@ SOURCES += main.cpp \
# ../setting/deadpixelwidget.cpp \
../setting/energywidget.cpp \
../setting/filemanagerwidget.cpp \
../setting/theme/themeview.cpp \
../setting/theme/themedelegate.cpp \
../component/agentlistitem.cpp \
../component/quibo.cpp \
../component/kylinfontdialog.cpp \
@ -174,6 +176,8 @@ HEADERS += mainwindow.h \
# ../setting/deadpixelwidget.h \
../setting/energywidget.h \
../setting/filemanagerwidget.h \
../setting/theme/themeview.h \
../setting/theme/themedelegate.h \
../component/agentlistitem.h \
../component/quibo.h \
../component/kylinfontdialog.h \