You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
114 lines
3.9 KiB
114 lines
3.9 KiB
6 months ago
|
#include "album.h"
|
||
|
#include "ui_album.h"
|
||
|
#include <QPixmap>
|
||
|
|
||
|
album::album(QWidget *parent)
|
||
|
: QMainWindow(parent)
|
||
|
, ui(new Ui::album)
|
||
|
{
|
||
|
|
||
|
ui->setupUi(this);
|
||
|
this->installEventFilter(this);
|
||
|
// showapp = new QLabel(this);
|
||
|
// showapp->setMaximumSize(800, 480);
|
||
|
// showapp->setMinimumSize(800, 480);
|
||
|
// showapp->setGeometry(0,0,800,480);
|
||
|
// showapp->setPixmap(QPixmap(":/album/images/8.jpg"));
|
||
|
floatingbutton= new FloatingButton (this);
|
||
|
// 将悬浮球的pressed()信号连接到槽函数onButtonPressed()上
|
||
|
connect(floatingbutton, &FloatingButton::pressed, this, &album::onButtonPressed);
|
||
|
}
|
||
|
|
||
|
album::~album()
|
||
|
{
|
||
|
delete ui;
|
||
|
}
|
||
|
void album::onButtonPressed()
|
||
|
{
|
||
|
emit album_close(false);
|
||
|
qDebug() << "悬浮球被按下了!";
|
||
|
}
|
||
|
void album::album_init()
|
||
|
{
|
||
|
}
|
||
|
bool album::eventFilter(QObject *watch, QEvent *evn)
|
||
|
{
|
||
|
// static int press_x;
|
||
|
// static int press_y;
|
||
|
// static int relea_x;
|
||
|
// static int relea_y;
|
||
|
|
||
|
// QMouseEvent *event = static_cast<QMouseEvent *>(evn);
|
||
|
|
||
|
// if(event->type()==QEvent::MouseButtonPress)
|
||
|
// {
|
||
|
// press_x = event->globalX();
|
||
|
// press_y = event->globalY();
|
||
|
// }
|
||
|
|
||
|
// if(event->type()==QEvent::MouseButtonRelease)
|
||
|
// {
|
||
|
// relea_x = event->globalX();
|
||
|
// relea_y = event->globalY();
|
||
|
// }
|
||
|
|
||
|
// //判断滑动方向(右滑)
|
||
|
// if((relea_x - press_x)>20 && event->type()==QEvent::MouseButtonRelease && qAbs(relea_y-press_y)<50)
|
||
|
// {
|
||
|
// int current_page = ui->stackedWidget->currentIndex();
|
||
|
// if(current_page<=2)
|
||
|
// {
|
||
|
// ui->label->setPixmap(ui->stackedWidget->currentWidget()->grab());
|
||
|
|
||
|
// QPropertyAnimation *animation1 = new QPropertyAnimation(ui->label,"geometry");
|
||
|
// animation1->setDuration(1000);
|
||
|
// animation1->setStartValue(QRect(0,0,this->width(),this->height()));
|
||
|
// animation1->setEndValue(QRect(this->width()*2,0,this->width(),this->height()));
|
||
|
// //animation1->start();
|
||
|
|
||
|
// ui->stackedWidget->setCurrentIndex(current_page+1);
|
||
|
|
||
|
// QPropertyAnimation *animation2 = new QPropertyAnimation(ui->stackedWidget->currentWidget(),"geometry");
|
||
|
// animation2->setDuration(1000);
|
||
|
// animation2->setStartValue(QRect(-this->width()*2,0,this->width(),this->height()));
|
||
|
// animation2->setEndValue(QRect(0,0,this->width(),this->height()));
|
||
|
|
||
|
// QParallelAnimationGroup *group = new QParallelAnimationGroup;
|
||
|
// group->addAnimation(animation1);
|
||
|
// group->addAnimation(animation2);
|
||
|
// group->start();
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
// //判断滑动方向(左滑)
|
||
|
// if((press_x - relea_x)>20 && event->type()==QEvent::MouseButtonRelease && qAbs(relea_y-press_y)<50)
|
||
|
// {
|
||
|
// int current_page = ui->stackedWidget->currentIndex();
|
||
|
// if(current_page>=0)
|
||
|
// {
|
||
|
// ui->label->setPixmap(ui->stackedWidget->currentWidget()->grab());
|
||
|
|
||
|
// QPropertyAnimation *animation1 = new QPropertyAnimation(ui->label,"geometry");
|
||
|
// animation1->setDuration(1000);
|
||
|
// animation1->setStartValue(QRect(0,0,this->width(),this->height()));
|
||
|
// animation1->setEndValue(QRect(-this->width(),0,this->width(),this->height()));
|
||
|
// //animation1->start();
|
||
|
|
||
|
// ui->stackedWidget->setCurrentIndex(current_page-1);
|
||
|
|
||
|
// QPropertyAnimation *animation2 = new QPropertyAnimation(ui->stackedWidget->currentWidget(),"geometry");
|
||
|
// animation2->setDuration(1000);
|
||
|
// animation2->setStartValue(QRect(this->width()*2,0,this->width(),this->height()));
|
||
|
// animation2->setEndValue(QRect(0,0,this->width(),this->height()));
|
||
|
|
||
|
// QParallelAnimationGroup *group = new QParallelAnimationGroup;
|
||
|
// group->addAnimation(animation1);
|
||
|
// group->addAnimation(animation2);
|
||
|
// group->start();
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
|
||
|
// return QWidget::eventFilter(watch,evn);
|
||
|
}
|