2
* Copyright (C) 2013 National University of Defense Technology(NUDT) & Kylin Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; version 3.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
#include "updatedialog.h"
17
#include "ui_updatedialog.h"
18
#include <QMouseEvent>
20
UpdateDialog::UpdateDialog(QWidget *parent) :
22
ui(new Ui::UpdateDialog)
25
this->setAttribute(Qt::WA_DeleteOnClose);//防止内存泄漏
26
this->setWindowFlags(Qt::FramelessWindowHint);
27
this->setAttribute(Qt::WA_TranslucentBackground);
28
ui->btn_close->installEventFilter(this);
29
ui->btn_close->setStyleSheet("border-image:url(:/pixmap/image/closeBtn.png)");
30
ui->okButton->setStyleSheet("QPushButton {border-image:url(:/pixmap/image/ok.png);}"
31
"QPushButton:hover{border-image:url(:/pixmap/image/ok-hover.png);}");
33
ui->displaylabel->setWordWrap(true);
34
ui->displaylabel->setText("没有找到该软件,请尝试更新软件源。");
35
QObject::connect(ui->okButton,SIGNAL(clicked()),this,SLOT(update_software_source()));
36
QObject::connect(ui->closeButton,SIGNAL(clicked()),this,SLOT(hide()));
39
UpdateDialog::~UpdateDialog() {
43
void UpdateDialog::update_software_source() {
48
bool UpdateDialog::eventFilter(QObject *obj, QEvent *event) {
49
if(obj == ui->btn_close){
50
if(event->type() == QEvent::Enter){
51
ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeBtn-hover.png"));
52
}else if(event->type() == QEvent::Leave){
53
ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeBtn.png"));
54
}else if(event->type() == QEvent::MouseButtonPress){
55
ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeBtn-hover.png"));
56
}else if(event->type() == QEvent::MouseButtonRelease){
57
QMouseEvent *me = (QMouseEvent *)event;
58
QLabel *lb = (QLabel *)obj;
59
if(me->x() > 0 && me->x() < lb->width() && me->y() > 0 && me->y() < lb->height()){
63
ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeBtn.png"));
66
return QObject::eventFilter(obj, event);
69
return QObject::eventFilter(obj, event);
74
void UpdateDialog::mousePressEvent(QMouseEvent *event) {
75
if (event->button() == Qt::LeftButton) {
76
dragPos = event->globalPos() - frameGeometry().topLeft();
81
void UpdateDialog::mouseMoveEvent(QMouseEvent *event) {
82
if (event->buttons() & Qt::LeftButton ) {
83
move(event->globalPos() - dragPos);
84
setWindowOpacity(0.5);
89
void UpdateDialog::mouseReleaseEvent(QMouseEvent *event) {
90
if (event->button() == Qt::LeftButton) {