forked from openkylin/quarkai
add mytitlebar, selectwidget, selectlistwidget and selectlistitem
This commit is contained in:
parent
cf24b5949c
commit
1ab816ed1a
|
@ -21,6 +21,7 @@
|
||||||
#include "ui_cleanerdetailwidget.h"
|
#include "ui_cleanerdetailwidget.h"
|
||||||
#include "../src/mainwindow.h"
|
#include "../src/mainwindow.h"
|
||||||
#include "../component/cleansubgroup.h"
|
#include "../component/cleansubgroup.h"
|
||||||
|
#include "../component/selectwidget.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QBoxLayout>
|
#include <QBoxLayout>
|
||||||
|
|
||||||
|
@ -1043,6 +1044,14 @@ void CleanerDetailWidget::showCustomPage()
|
||||||
int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2);
|
int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2);
|
||||||
cache_thumbnails_items->move(w_x, w_y);
|
cache_thumbnails_items->move(w_x, w_y);
|
||||||
cache_thumbnails_items->exec();
|
cache_thumbnails_items->exec();
|
||||||
|
|
||||||
|
/*SelectWidget *w = new SelectWidget;
|
||||||
|
w->loadData(tr("Thumbnails Cache Clean Items"), cache_thumbnails_list);
|
||||||
|
//子checkbox的状态被改变时,重新设置总按钮的状态
|
||||||
|
connect(w, SIGNAL(notifyMainCheckBox(int)), cache_software_btn, SLOT(resetMainStatus(int)));
|
||||||
|
w->exec();
|
||||||
|
delete w;*/
|
||||||
|
//kobe test 2018
|
||||||
}
|
}
|
||||||
else if(object_name == "cache-firefox")
|
else if(object_name == "cache-firefox")
|
||||||
{
|
{
|
||||||
|
|
|
@ -61,7 +61,7 @@ public slots:
|
||||||
// void receivePolicyKitSignal(bool status);
|
// void receivePolicyKitSignal(bool status);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void notifyMainCheckBox(int status);
|
// void notifyMainCheckBox(int status);
|
||||||
// void showActionAnimaiton();
|
// void showActionAnimaiton();
|
||||||
void sendScanOverStatus(bool status);
|
void sendScanOverStatus(bool status);
|
||||||
void startCleanSystem(QMap<QString, QVariant> itemsMap);
|
void startCleanSystem(QMap<QString, QVariant> itemsMap);
|
||||||
|
|
|
@ -0,0 +1,151 @@
|
||||||
|
/*
|
||||||
|
* 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 "mytitlebar.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "../../plugins/widgets/mytristatebutton.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
|
MyTitleBar::MyTitleBar(bool needMin, QWidget *parent)
|
||||||
|
:QFrame(parent)
|
||||||
|
, m_needMin(needMin)
|
||||||
|
{
|
||||||
|
this->setWindowFlags(Qt::FramelessWindowHint);//this->setWindowFlags(this->windowFlags() | Qt::FramelessWindowHint | Qt::WindowCloseButtonHint);
|
||||||
|
// this->setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint);//Attention: Qt::WindowCloseButtonHint make showMinimized() valid
|
||||||
|
|
||||||
|
this->setMouseTracking(true);
|
||||||
|
this->setFixedHeight(TITILE_BAR_HEIGHT);
|
||||||
|
|
||||||
|
this->setAutoFillBackground(true);
|
||||||
|
// this->setAttribute(Qt::WA_TranslucentBackground);
|
||||||
|
|
||||||
|
QPalette palette;
|
||||||
|
palette.setColor(QPalette::Background, QColor("#0d87ca"));
|
||||||
|
this->setPalette(palette);
|
||||||
|
|
||||||
|
initWidgets();
|
||||||
|
}
|
||||||
|
|
||||||
|
MyTitleBar::~MyTitleBar()
|
||||||
|
{
|
||||||
|
QLayoutItem *child;
|
||||||
|
while ((child = m_lLayout->takeAt(0)) != 0) {
|
||||||
|
if (child->widget())
|
||||||
|
child->widget()->deleteLater();
|
||||||
|
delete child;
|
||||||
|
}
|
||||||
|
while ((child = m_mLayout->takeAt(0)) != 0) {
|
||||||
|
if (child->widget())
|
||||||
|
child->widget()->deleteLater();
|
||||||
|
delete child;
|
||||||
|
}
|
||||||
|
while ((child = m_rLayout->takeAt(0)) != 0) {
|
||||||
|
if (child->widget())
|
||||||
|
child->widget()->deleteLater();
|
||||||
|
delete child;
|
||||||
|
}
|
||||||
|
delete m_layout;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyTitleBar::setLeftContent(QWidget *content)
|
||||||
|
{
|
||||||
|
QLayoutItem *child;
|
||||||
|
while ((child = m_lLayout->takeAt(0)) != 0) {
|
||||||
|
if (child->widget())
|
||||||
|
child->widget()->deleteLater();
|
||||||
|
delete child;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_lLayout->addWidget(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyTitleBar::setMiddleContent(QWidget *content)
|
||||||
|
{
|
||||||
|
QLayoutItem *child;
|
||||||
|
while ((child = m_mLayout->takeAt(0)) != 0) {
|
||||||
|
if (child->widget())
|
||||||
|
child->widget()->deleteLater();
|
||||||
|
delete child;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_mLayout->addWidget(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MyTitleBar::initLeftContent()
|
||||||
|
{
|
||||||
|
QWidget *w = new QWidget;
|
||||||
|
m_lLayout = new QHBoxLayout(w);
|
||||||
|
m_lLayout->setContentsMargins(6, 0, 0, 0);
|
||||||
|
m_lLayout->setSpacing(0);
|
||||||
|
|
||||||
|
QLabel *titleLabel = new QLabel;
|
||||||
|
titleLabel->setStyleSheet("QLabel{background-color:transparent;color:#ffffff; font-size:12px;}");
|
||||||
|
m_lLayout->addWidget(titleLabel);
|
||||||
|
|
||||||
|
m_layout->addWidget(w, 1, Qt::AlignLeft);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyTitleBar::initMiddleContent()
|
||||||
|
{
|
||||||
|
QWidget *w = new QWidget;
|
||||||
|
w->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||||
|
m_mLayout = new QHBoxLayout(w);
|
||||||
|
m_mLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
m_mLayout->setSpacing(0);
|
||||||
|
|
||||||
|
m_layout->addWidget(w);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyTitleBar::initRightContent()
|
||||||
|
{
|
||||||
|
QWidget *w = new QWidget;
|
||||||
|
m_rLayout = new QHBoxLayout(w);
|
||||||
|
m_rLayout->setContentsMargins(0, 0, 6, 0);
|
||||||
|
m_rLayout->setSpacing(0);
|
||||||
|
|
||||||
|
m_layout->addWidget(w, 1, Qt::AlignRight);
|
||||||
|
|
||||||
|
if (m_needMin) {
|
||||||
|
MyTristateButton *minBtn = new MyTristateButton;
|
||||||
|
minBtn->setObjectName("MinButton");
|
||||||
|
connect(minBtn, SIGNAL(clicked()), this, SIGNAL(minSignal()));
|
||||||
|
m_rLayout->addWidget(minBtn);
|
||||||
|
}
|
||||||
|
|
||||||
|
MyTristateButton *closeBtn = new MyTristateButton;
|
||||||
|
closeBtn->setObjectName("CloseButton");
|
||||||
|
connect(closeBtn, SIGNAL(clicked()), this, SIGNAL(closeSignal()));
|
||||||
|
m_rLayout->addWidget(closeBtn);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyTitleBar::initWidgets()
|
||||||
|
{
|
||||||
|
m_layout = new QHBoxLayout(this);
|
||||||
|
m_layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
m_layout->setSpacing(0);
|
||||||
|
|
||||||
|
initLeftContent();
|
||||||
|
initMiddleContent();
|
||||||
|
initRightContent();
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
* 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 MYTITLEBAR_H
|
||||||
|
#define MYTITLEBAR_H
|
||||||
|
|
||||||
|
#include <QFrame>
|
||||||
|
|
||||||
|
class QHBoxLayout;
|
||||||
|
|
||||||
|
class MyTitleBar : public QFrame
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
MyTitleBar(bool needMin = false, QWidget *parent = 0);
|
||||||
|
~MyTitleBar();
|
||||||
|
|
||||||
|
void setLeftContent(QWidget *content);
|
||||||
|
void setMiddleContent(QWidget *content);
|
||||||
|
|
||||||
|
void initLeftContent();
|
||||||
|
void initMiddleContent();
|
||||||
|
void initRightContent();
|
||||||
|
void initWidgets();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void minSignal();
|
||||||
|
void closeSignal();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_needMin;
|
||||||
|
QHBoxLayout *m_layout = nullptr;
|
||||||
|
QHBoxLayout *m_lLayout = nullptr;
|
||||||
|
QHBoxLayout *m_mLayout = nullptr;
|
||||||
|
QHBoxLayout *m_rLayout = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MYTITLEBAR_H
|
|
@ -0,0 +1,61 @@
|
||||||
|
/*
|
||||||
|
* 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 "selectlistitem.h"
|
||||||
|
|
||||||
|
SelectListItem::SelectListItem(QWidget *parent, QString description,int itemWidth) :
|
||||||
|
QWidget(parent)
|
||||||
|
, m_description(description)
|
||||||
|
{
|
||||||
|
m_mainLayout = new QHBoxLayout(this);
|
||||||
|
m_mainLayout->setSpacing(5);
|
||||||
|
m_mainLayout->setMargin(0);
|
||||||
|
|
||||||
|
m_checkBox = new QCheckBox(this);
|
||||||
|
m_checkBox->setFocusPolicy(Qt::NoFocus);
|
||||||
|
m_checkBox->setChecked(true);
|
||||||
|
|
||||||
|
connect(m_checkBox, &QCheckBox::clicked, [=] (bool checked) {
|
||||||
|
emit this->selectedSignal(checked, m_description);
|
||||||
|
});
|
||||||
|
|
||||||
|
m_descLabel = new QLabel(this);
|
||||||
|
m_descLabel->setFixedWidth(itemWidth - m_checkBox->width() - 10);
|
||||||
|
m_descLabel->setWordWrap(true);
|
||||||
|
m_descLabel->setText(description);
|
||||||
|
|
||||||
|
m_mainLayout->setAlignment(Qt::AlignLeft);
|
||||||
|
m_mainLayout->addWidget(m_checkBox);
|
||||||
|
m_mainLayout->addWidget(m_descLabel);
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectListItem::~SelectListItem()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SelectListItem::itemIsChecked()
|
||||||
|
{
|
||||||
|
return m_checkBox->isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString SelectListItem::itemDescription()
|
||||||
|
{
|
||||||
|
return this->m_description;
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
/*
|
||||||
|
* 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 SELECTLISTITEM_H
|
||||||
|
#define SELECTLISTITEM_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QCheckBox>
|
||||||
|
|
||||||
|
class SelectListItem : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit SelectListItem(QWidget *parent = 0, QString description = "", int itemWidth = 0);
|
||||||
|
~SelectListItem();
|
||||||
|
|
||||||
|
bool itemIsChecked();
|
||||||
|
QString itemDescription();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void selectedSignal(bool checked, QString description);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString m_description;
|
||||||
|
QHBoxLayout *m_mainLayout = nullptr;
|
||||||
|
QCheckBox *m_checkBox = nullptr;
|
||||||
|
QLabel *m_descLabel = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SELECTLISTITEM_H
|
|
@ -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 "selectlistwidget.h"
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
SelectListWidget::SelectListWidget(QWidget *parent) :
|
||||||
|
QWidget(parent)
|
||||||
|
{
|
||||||
|
m_gridLayout = new QGridLayout(this);
|
||||||
|
m_titleLabel = new QLabel;
|
||||||
|
m_titleLabel->setFixedSize(80,30);
|
||||||
|
m_titleLabel->setText(tr("Items:"));
|
||||||
|
m_countLabel = new QLabel;
|
||||||
|
m_countLabel->setFixedSize(100,30);
|
||||||
|
m_widget = new QWidget;
|
||||||
|
m_widget->setObjectName("transparentWidget");
|
||||||
|
m_listAreaWidgetLayout = new QVBoxLayout(m_widget);
|
||||||
|
m_scrollArea = new QScrollArea(this);
|
||||||
|
m_scrollArea->setWidgetResizable(true);
|
||||||
|
m_scrollArea->setWidget(m_widget);
|
||||||
|
|
||||||
|
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_gridLayout->addWidget(m_scrollArea,1,0,5,5);
|
||||||
|
|
||||||
|
resetToDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectListWidget::~SelectListWidget()
|
||||||
|
{
|
||||||
|
this->resetToDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SelectListWidget::loadListItems(const QString &title, const QStringList &cachelist, int itemWidth)
|
||||||
|
{
|
||||||
|
m_itemsMap.clear();
|
||||||
|
|
||||||
|
int count = cachelist.count();
|
||||||
|
m_countLabel->setText(QString::number(count));
|
||||||
|
|
||||||
|
foreach (QString cache, cachelist) {
|
||||||
|
SelectListItem *item = new SelectListItem(0, cache, itemWidth);
|
||||||
|
connect(item, SIGNAL(selectedSignal(bool,QString)), this, SLOT(onSelectedSignal(bool,QString)));
|
||||||
|
item->setMaximumSize(itemWidth, 30);
|
||||||
|
m_listAreaWidgetLayout->addWidget(item);
|
||||||
|
m_itemsMap.insert(cache, item);
|
||||||
|
}
|
||||||
|
m_listAreaWidgetLayout->addStretch();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SelectListWidget::removeOneItem(const QString &description)
|
||||||
|
{
|
||||||
|
SelectListItem *item = m_itemsMap.value(description);
|
||||||
|
if(item == Q_NULLPTR)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList SelectListWidget::getSelectedItems()
|
||||||
|
{
|
||||||
|
QStringList text_list;
|
||||||
|
|
||||||
|
/*foreach (QString text, m_itemsMap.keys()) {
|
||||||
|
|
||||||
|
}*/
|
||||||
|
QMap<QString, SelectListItem*>::iterator it;
|
||||||
|
for (it = m_itemsMap.begin(); it != m_itemsMap.end(); ++it) {
|
||||||
|
SelectListItem *item = static_cast<SelectListItem *>(it.value());
|
||||||
|
if (item->itemIsChecked())
|
||||||
|
text_list.append(item->itemDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
return text_list;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SelectListWidget::scanAllSubCheckbox()
|
||||||
|
{
|
||||||
|
int selectedCount = 0;
|
||||||
|
QMap<QString, SelectListItem*>::iterator it;
|
||||||
|
for (it = m_itemsMap.begin(); it != m_itemsMap.end(); ++it) {
|
||||||
|
SelectListItem *item = static_cast<SelectListItem *>(it.value());
|
||||||
|
if (item->itemIsChecked())
|
||||||
|
selectedCount += 1;
|
||||||
|
}
|
||||||
|
m_countLabel->setText(QString::number(selectedCount));
|
||||||
|
if (selectedCount == 0) {
|
||||||
|
emit this->notifyMainCheckBox(0);
|
||||||
|
}
|
||||||
|
else if (selectedCount == m_itemsMap.count()) {
|
||||||
|
emit this->notifyMainCheckBox(2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
emit this->notifyMainCheckBox(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
num_label->setText(QString::number(m));
|
||||||
|
if (m == 0) {
|
||||||
|
emit this->notifyMainCheckBox(0);
|
||||||
|
}
|
||||||
|
else if (m == count) {
|
||||||
|
emit this->notifyMainCheckBox(2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
emit this->notifyMainCheckBox(1);
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
void SelectListWidget::resetSubCheckbox(int status)
|
||||||
|
{
|
||||||
|
/*if(status == 0) {
|
||||||
|
for(int i=0; i<checkbox_list.count(); i++)
|
||||||
|
{
|
||||||
|
QCheckBox *checkbox = checkbox_list.at(i);
|
||||||
|
checkbox->setChecked(false);
|
||||||
|
}
|
||||||
|
num_label->setText("0");
|
||||||
|
}
|
||||||
|
else if(status == 2) {
|
||||||
|
for(int i=0; i<checkbox_list.count(); i++)
|
||||||
|
{
|
||||||
|
QCheckBox *checkbox = checkbox_list.at(i);
|
||||||
|
checkbox->setChecked(true);
|
||||||
|
}
|
||||||
|
int count = checkbox_list.count();
|
||||||
|
num_label->setText(QString::number(count));
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
void SelectListWidget::onSelectedSignal(bool checked, QString description)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SelectListWidget::resetToDefault()
|
||||||
|
{
|
||||||
|
m_itemsMap.clear();
|
||||||
|
while(m_listAreaWidgetLayout->count() > 0) {
|
||||||
|
QWidget* widget = m_listAreaWidgetLayout->itemAt(0)->widget();
|
||||||
|
m_listAreaWidgetLayout->removeWidget(widget);
|
||||||
|
delete widget;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
/*
|
||||||
|
* 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 SELECTLISTWIDGET_H
|
||||||
|
#define SELECTLISTWIDGET_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QScrollArea>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QEventLoop>
|
||||||
|
#include <QDesktopWidget>
|
||||||
|
#include <QCheckBox>
|
||||||
|
|
||||||
|
#include "selectlistitem.h"
|
||||||
|
|
||||||
|
class SelectListWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit SelectListWidget(QWidget *parent = 0);
|
||||||
|
~SelectListWidget();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void loadListItems(const QString &title, const QStringList &cachelist, int itemWidth);
|
||||||
|
void removeOneItem(const QString &description);
|
||||||
|
void resetToDefault();
|
||||||
|
QStringList getSelectedItems();
|
||||||
|
void resetSubCheckbox(int status);
|
||||||
|
void scanAllSubCheckbox();
|
||||||
|
void onSelectedSignal(bool checked, QString description);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void notifyMainCheckBox(int status);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QGridLayout *m_gridLayout = nullptr;
|
||||||
|
QScrollArea *m_scrollArea = nullptr;
|
||||||
|
QWidget *m_widget = nullptr;
|
||||||
|
QVBoxLayout *m_listAreaWidgetLayout = nullptr;
|
||||||
|
QLabel *m_titleLabel = nullptr;
|
||||||
|
QLabel *m_countLabel = nullptr;
|
||||||
|
QMap<QString, SelectListItem *> m_itemsMap;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SELECTLISTWIDGET_H
|
|
@ -0,0 +1,108 @@
|
||||||
|
/*
|
||||||
|
* 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 "selectwidget.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
|
SelectWidget::SelectWidget(bool needMin, QWidget *parent)
|
||||||
|
: QDialog(parent)
|
||||||
|
, m_mousePressed(false)
|
||||||
|
{
|
||||||
|
this->setWindowFlags(Qt::FramelessWindowHint);
|
||||||
|
this->setFixedSize(464, 500);
|
||||||
|
|
||||||
|
QWidget *containerW = new QWidget(this);
|
||||||
|
m_mainLayout = new QVBoxLayout(containerW);
|
||||||
|
m_mainLayout->setSpacing(0);
|
||||||
|
m_mainLayout->setMargin(0);
|
||||||
|
m_titleBar = new MyTitleBar(needMin, this);
|
||||||
|
m_titleBar->setFixedSize(this->width(), TITILE_BAR_HEIGHT);
|
||||||
|
m_listWidget = new SelectListWidget(this);
|
||||||
|
m_listWidget->setFixedSize(this->width(), this->height() - TITILE_BAR_HEIGHT);
|
||||||
|
m_mainLayout->addWidget(m_titleBar);
|
||||||
|
m_mainLayout->addWidget(m_listWidget);
|
||||||
|
|
||||||
|
connect(m_titleBar, SIGNAL(minSignal()),this, SLOT(hide()));
|
||||||
|
connect(m_titleBar, SIGNAL(closeSignal()),this, SLOT(close()));
|
||||||
|
connect(m_listWidget, SIGNAL(notifyMainCheckBox(int)), this, SIGNAL(notifyMainCheckBox(int)));
|
||||||
|
|
||||||
|
QDesktopWidget* desktop = QApplication::desktop();
|
||||||
|
this->move((desktop->width() - this->width())/2, (desktop->height() - this->height())/3);
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectWidget::~SelectWidget()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SelectWidget::loadData(const QString &title, const QStringList &cachelist)
|
||||||
|
{
|
||||||
|
m_listWidget->loadListItems(title, cachelist, this->width());
|
||||||
|
}
|
||||||
|
|
||||||
|
void SelectWidget::moveCenter()
|
||||||
|
{
|
||||||
|
/*QPoint pos = QCursor::pos();
|
||||||
|
QRect primaryGeometry;
|
||||||
|
for (QScreen *screen : qApp->screens()) {
|
||||||
|
if (screen->geometry().contains(pos)) {
|
||||||
|
primaryGeometry = screen->geometry();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (primaryGeometry.isEmpty()) {
|
||||||
|
primaryGeometry = qApp->primaryScreen()->geometry();
|
||||||
|
}
|
||||||
|
|
||||||
|
this->move(primaryGeometry.x() + (primaryGeometry.width() - this->width())/2,
|
||||||
|
primaryGeometry.y() + (primaryGeometry.height() - this->height())/2);
|
||||||
|
this->show();
|
||||||
|
this->raise();*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SelectWidget::mousePressEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (event->button() == Qt::LeftButton) {
|
||||||
|
this->m_dragPosition = event->globalPos() - frameGeometry().topLeft();
|
||||||
|
this->m_mousePressed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDialog::mousePressEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SelectWidget::mouseReleaseEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
this->m_mousePressed = false;
|
||||||
|
setWindowOpacity(1);
|
||||||
|
|
||||||
|
QDialog::mouseReleaseEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SelectWidget::mouseMoveEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (this->m_mousePressed) {
|
||||||
|
move(event->globalPos() - this->m_dragPosition);
|
||||||
|
setWindowOpacity(0.9);
|
||||||
|
}
|
||||||
|
|
||||||
|
QDialog::mouseMoveEvent(event);
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
* 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 SELECTWIDGET_H
|
||||||
|
#define SELECTWIDGET_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
|
||||||
|
#include "mytitlebar.h"
|
||||||
|
#include "selectlistwidget.h"
|
||||||
|
|
||||||
|
class SelectWidget : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
SelectWidget(bool needMin = false, QWidget *parent = 0);
|
||||||
|
~SelectWidget();
|
||||||
|
|
||||||
|
void loadData(const QString &title, const QStringList &cachelist);
|
||||||
|
void moveCenter();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void notifyMainCheckBox(int status);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void mousePressEvent(QMouseEvent *event);
|
||||||
|
void mouseReleaseEvent(QMouseEvent *event);
|
||||||
|
void mouseMoveEvent(QMouseEvent *event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QVBoxLayout *m_mainLayout = nullptr;
|
||||||
|
MyTitleBar *m_titleBar = nullptr;
|
||||||
|
SelectListWidget *m_listWidget = nullptr;
|
||||||
|
QPoint m_dragPosition; //移动的距离
|
||||||
|
bool m_mousePressed; //按下鼠标左键
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MAINWINDOW_H
|
|
@ -31,6 +31,7 @@
|
||||||
#define SHADOW_RIGHT_BOTTOM_PADDING 4
|
#define SHADOW_RIGHT_BOTTOM_PADDING 4
|
||||||
#define MAIN_WINDOW_WIDTH 900
|
#define MAIN_WINDOW_WIDTH 900
|
||||||
#define MAIN_WINDOW_HEIGHT 600
|
#define MAIN_WINDOW_HEIGHT 600
|
||||||
|
#define TITILE_BAR_HEIGHT 39
|
||||||
//const int windowShadowPadding = 10;
|
//const int windowShadowPadding = 10;
|
||||||
|
|
||||||
//#define VERSION "2.4.1"
|
//#define VERSION "2.4.1"
|
||||||
|
|
|
@ -102,6 +102,7 @@ QLabel#backgroundLabel::pressed{
|
||||||
|
|
||||||
QWidget#transparentWidget {
|
QWidget#transparentWidget {
|
||||||
/*border: none;*/
|
/*border: none;*/
|
||||||
|
/*background-color:rgba(255,255,255,0);*/
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
12
src/src.pro
12
src/src.pro
|
@ -47,7 +47,7 @@ unix {
|
||||||
OBJECTS_DIR = .obj
|
OBJECTS_DIR = .obj
|
||||||
}
|
}
|
||||||
|
|
||||||
SOURCES += main.cpp\
|
SOURCES += main.cpp \
|
||||||
mainwindow.cpp \
|
mainwindow.cpp \
|
||||||
maintopwidget.cpp \
|
maintopwidget.cpp \
|
||||||
middlewidget.cpp \
|
middlewidget.cpp \
|
||||||
|
@ -68,6 +68,11 @@ SOURCES += main.cpp\
|
||||||
../component/kylintitlebar.cpp \
|
../component/kylintitlebar.cpp \
|
||||||
../component/threadpool.cpp \
|
../component/threadpool.cpp \
|
||||||
../component/mythread.cpp \
|
../component/mythread.cpp \
|
||||||
|
../component/selectlistwidget.cpp \
|
||||||
|
../component/selectlistitem.cpp \
|
||||||
|
../component/selectwidget.cpp \
|
||||||
|
../component/mytitlebar.cpp \
|
||||||
|
../plugins/widgets/mytristatebutton.cpp \
|
||||||
../info/infounitwidget.cpp \
|
../info/infounitwidget.cpp \
|
||||||
../info/infogui.cpp \
|
../info/infogui.cpp \
|
||||||
../info/infoitemline.cpp \
|
../info/infoitemline.cpp \
|
||||||
|
@ -144,6 +149,11 @@ HEADERS += mainwindow.h \
|
||||||
../component/kylintitlebar.h \
|
../component/kylintitlebar.h \
|
||||||
../component/threadpool.h \
|
../component/threadpool.h \
|
||||||
../component/mythread.h \
|
../component/mythread.h \
|
||||||
|
../component/selectlistwidget.h \
|
||||||
|
../component/selectlistitem.h \
|
||||||
|
../component/selectwidget.h \
|
||||||
|
../component/mytitlebar.h \
|
||||||
|
../plugins/widgets/mytristatebutton.h \
|
||||||
../info/infounitwidget.h \
|
../info/infounitwidget.h \
|
||||||
../info/infogui.h \
|
../info/infogui.h \
|
||||||
../info/infoitemline.h \
|
../info/infoitemline.h \
|
||||||
|
|
Loading…
Reference in New Issue