From 1ab816ed1ae9b29f19bbb18218110e380163a31b Mon Sep 17 00:00:00 2001 From: balloonflower Date: Fri, 9 Feb 2018 15:54:05 +0800 Subject: [PATCH] add mytitlebar, selectwidget, selectlistwidget and selectlistitem --- cleaner/cleanerdetailwidget.cpp | 9 ++ cleaner/cleanerdetailwidget.h | 2 +- component/mytitlebar.cpp | 151 ++++++++++++++++++++++++++++ component/mytitlebar.h | 54 ++++++++++ component/selectlistitem.cpp | 61 ++++++++++++ component/selectlistitem.h | 49 ++++++++++ component/selectlistwidget.cpp | 168 ++++++++++++++++++++++++++++++++ component/selectlistwidget.h | 63 ++++++++++++ component/selectwidget.cpp | 108 ++++++++++++++++++++ component/selectwidget.h | 56 +++++++++++ component/utils.h | 1 + src/res/qss/kylin-assistant.qss | 5 +- src/src.pro | 12 ++- 13 files changed, 735 insertions(+), 4 deletions(-) create mode 100644 component/mytitlebar.cpp create mode 100644 component/mytitlebar.h create mode 100644 component/selectlistitem.cpp create mode 100644 component/selectlistitem.h create mode 100644 component/selectlistwidget.cpp create mode 100644 component/selectlistwidget.h create mode 100644 component/selectwidget.cpp create mode 100644 component/selectwidget.h diff --git a/cleaner/cleanerdetailwidget.cpp b/cleaner/cleanerdetailwidget.cpp index c1ce7e4..8b6dbf8 100644 --- a/cleaner/cleanerdetailwidget.cpp +++ b/cleaner/cleanerdetailwidget.cpp @@ -21,6 +21,7 @@ #include "ui_cleanerdetailwidget.h" #include "../src/mainwindow.h" #include "../component/cleansubgroup.h" +#include "../component/selectwidget.h" #include #include @@ -1043,6 +1044,14 @@ void CleanerDetailWidget::showCustomPage() int w_y = parentWindow->frameGeometry().topLeft().y() + (600 /2) - (280 / 2); cache_thumbnails_items->move(w_x, w_y); 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") { diff --git a/cleaner/cleanerdetailwidget.h b/cleaner/cleanerdetailwidget.h index 2d6a552..bdd8996 100644 --- a/cleaner/cleanerdetailwidget.h +++ b/cleaner/cleanerdetailwidget.h @@ -61,7 +61,7 @@ public slots: // void receivePolicyKitSignal(bool status); signals: - void notifyMainCheckBox(int status); +// void notifyMainCheckBox(int status); // void showActionAnimaiton(); void sendScanOverStatus(bool status); void startCleanSystem(QMap itemsMap); diff --git a/component/mytitlebar.cpp b/component/mytitlebar.cpp new file mode 100644 index 0000000..8a2f214 --- /dev/null +++ b/component/mytitlebar.cpp @@ -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 . + */ + +#include "mytitlebar.h" +#include "utils.h" +#include "../../plugins/widgets/mytristatebutton.h" + +#include +#include +#include +#include + +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(); +} diff --git a/component/mytitlebar.h b/component/mytitlebar.h new file mode 100644 index 0000000..dec045f --- /dev/null +++ b/component/mytitlebar.h @@ -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 . + */ + +#ifndef MYTITLEBAR_H +#define MYTITLEBAR_H + +#include + +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 diff --git a/component/selectlistitem.cpp b/component/selectlistitem.cpp new file mode 100644 index 0000000..9a52f47 --- /dev/null +++ b/component/selectlistitem.cpp @@ -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 . + */ + +#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; +} diff --git a/component/selectlistitem.h b/component/selectlistitem.h new file mode 100644 index 0000000..b3e1f24 --- /dev/null +++ b/component/selectlistitem.h @@ -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 . + */ + +#ifndef SELECTLISTITEM_H +#define SELECTLISTITEM_H + +#include +#include +#include +#include +#include + +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 diff --git a/component/selectlistwidget.cpp b/component/selectlistwidget.cpp new file mode 100644 index 0000000..53f63e8 --- /dev/null +++ b/component/selectlistwidget.cpp @@ -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 . + */ + +#include "selectlistwidget.h" +#include + +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::iterator it; + for (it = m_itemsMap.begin(); it != m_itemsMap.end(); ++it) { + SelectListItem *item = static_cast(it.value()); + if (item->itemIsChecked()) + text_list.append(item->itemDescription()); + } + + return text_list; +} + +void SelectListWidget::scanAllSubCheckbox() +{ + int selectedCount = 0; + QMap::iterator it; + for (it = m_itemsMap.begin(); it != m_itemsMap.end(); ++it) { + SelectListItem *item = static_cast(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; iisChecked()) { + 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; isetChecked(false); + } + num_label->setText("0"); + } + else if(status == 2) { + for(int i=0; isetChecked(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; + } +} diff --git a/component/selectlistwidget.h b/component/selectlistwidget.h new file mode 100644 index 0000000..40c30ac --- /dev/null +++ b/component/selectlistwidget.h @@ -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 . + */ + +#ifndef SELECTLISTWIDGET_H +#define SELECTLISTWIDGET_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#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 m_itemsMap; +}; + +#endif // SELECTLISTWIDGET_H diff --git a/component/selectwidget.cpp b/component/selectwidget.cpp new file mode 100644 index 0000000..af0631d --- /dev/null +++ b/component/selectwidget.cpp @@ -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 . + */ + +#include "selectwidget.h" +#include "utils.h" + +#include + +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); +} diff --git a/component/selectwidget.h b/component/selectwidget.h new file mode 100644 index 0000000..ad21450 --- /dev/null +++ b/component/selectwidget.h @@ -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 . + */ + +#ifndef SELECTWIDGET_H +#define SELECTWIDGET_H + +#include +#include +#include + +#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 diff --git a/component/utils.h b/component/utils.h index 5c1bc92..805a62e 100644 --- a/component/utils.h +++ b/component/utils.h @@ -31,6 +31,7 @@ #define SHADOW_RIGHT_BOTTOM_PADDING 4 #define MAIN_WINDOW_WIDTH 900 #define MAIN_WINDOW_HEIGHT 600 +#define TITILE_BAR_HEIGHT 39 //const int windowShadowPadding = 10; //#define VERSION "2.4.1" diff --git a/src/res/qss/kylin-assistant.qss b/src/res/qss/kylin-assistant.qss index e51c593..7fa642b 100644 --- a/src/res/qss/kylin-assistant.qss +++ b/src/res/qss/kylin-assistant.qss @@ -101,8 +101,9 @@ QLabel#backgroundLabel::pressed{ }*/ QWidget#transparentWidget { - /*border: none;*/ - background-color: transparent; + /*border: none;*/ + /*background-color:rgba(255,255,255,0);*/ + background-color: transparent; } /*QPushButton{ diff --git a/src/src.pro b/src/src.pro index 3343088..36cde77 100644 --- a/src/src.pro +++ b/src/src.pro @@ -47,7 +47,7 @@ unix { OBJECTS_DIR = .obj } -SOURCES += main.cpp\ +SOURCES += main.cpp \ mainwindow.cpp \ maintopwidget.cpp \ middlewidget.cpp \ @@ -68,6 +68,11 @@ SOURCES += main.cpp\ ../component/kylintitlebar.cpp \ ../component/threadpool.cpp \ ../component/mythread.cpp \ + ../component/selectlistwidget.cpp \ + ../component/selectlistitem.cpp \ + ../component/selectwidget.cpp \ + ../component/mytitlebar.cpp \ + ../plugins/widgets/mytristatebutton.cpp \ ../info/infounitwidget.cpp \ ../info/infogui.cpp \ ../info/infoitemline.cpp \ @@ -144,6 +149,11 @@ HEADERS += mainwindow.h \ ../component/kylintitlebar.h \ ../component/threadpool.h \ ../component/mythread.h \ + ../component/selectlistwidget.h \ + ../component/selectlistitem.h \ + ../component/selectwidget.h \ + ../component/mytitlebar.h \ + ../plugins/widgets/mytristatebutton.h \ ../info/infounitwidget.h \ ../info/infogui.h \ ../info/infoitemline.h \