From be3eda82f2d9a36ee35f385af002dc2ddb67b7a9 Mon Sep 17 00:00:00 2001
From: Linloir <3145078758@qq.com>
Date: Fri, 16 Dec 2022 17:54:22 +0800
Subject: [PATCH] [UI][UPD] Minor updates - Tested version (Can build & run)
---
FinalProject/FinalProject.vcxproj | 4 +++-
FinalProject/FinalProject.vcxproj.filters | 12 +++++++---
FinalProject/editorpage.cpp | 2 +-
FinalProject/mainwindow.cpp | 10 +++++---
FinalProject/mainwindow.h | 2 ++
FinalProject/pagewidget.cpp | 29 +++++++++++++----------
6 files changed, 39 insertions(+), 20 deletions(-)
diff --git a/FinalProject/FinalProject.vcxproj b/FinalProject/FinalProject.vcxproj
index 6a70627..48f579f 100644
--- a/FinalProject/FinalProject.vcxproj
+++ b/FinalProject/FinalProject.vcxproj
@@ -108,6 +108,7 @@
+
@@ -135,10 +136,11 @@
-
+
+
diff --git a/FinalProject/FinalProject.vcxproj.filters b/FinalProject/FinalProject.vcxproj.filters
index fcb368b..8b472f3 100644
--- a/FinalProject/FinalProject.vcxproj.filters
+++ b/FinalProject/FinalProject.vcxproj.filters
@@ -141,6 +141,9 @@
Source Files\Qt Widgets\Pages\About Page
+
+ Source Files\Qt Widgets\GUI Components
+
@@ -191,9 +194,6 @@
Header Files\Qt Widgets\GUI Components
-
- Header Files\Qt Widgets\Pages\About Page
-
@@ -220,6 +220,12 @@
Header Files\Qt Widgets\GUI Components
+
+ Header Files\Qt Widgets\Pages\About Page
+
+
+ Header Files\Qt Widgets\GUI Components
+
diff --git a/FinalProject/editorpage.cpp b/FinalProject/editorpage.cpp
index 47abe62..94ae9df 100644
--- a/FinalProject/editorpage.cpp
+++ b/FinalProject/editorpage.cpp
@@ -82,7 +82,7 @@ PushButton* EditorPage::getPageTextButton(QWidget* context) {
_textButtonWidget = new QWidget(_textButton);
_textButtonLayout = new QHBoxLayout(_textButtonWidget);
_textButtonLayout->setContentsMargins(0, 0, 0, 0);
- _textButtonLayout->setSpacing(8);
+ _textButtonLayout->setSpacing(12);
_textButtonWidget->setLayout(_textButtonLayout);
// Generate text button contents
diff --git a/FinalProject/mainwindow.cpp b/FinalProject/mainwindow.cpp
index 2ba2e39..dee9516 100644
--- a/FinalProject/mainwindow.cpp
+++ b/FinalProject/mainwindow.cpp
@@ -29,11 +29,9 @@ MainWindow::MainWindow(QWidget *parent)
}
if (previousPage != nullptr) {
previousPage->offStage();
- return;
}
if (currentPage != nullptr) {
currentPage->onStage();
- return;
}
});
_sideBar->setMouseTracking(true);
@@ -45,8 +43,12 @@ MainWindow::MainWindow(QWidget *parent)
// Create editor page and connect to side bar
_editorPage = new EditorPage(_placeHolderWidget);
_editorPage->setMouseTracking(true);
- _editorPage->show();
_sideBar->addPage(_editorPage);
+
+ // Create about page and connect to side bar
+ _aboutPage = new AboutPage(_placeHolderWidget);
+ _aboutPage->setMouseTracking(true);
+ _sideBar->addPage(_aboutPage);
}
MainWindow::~MainWindow() {
@@ -63,6 +65,7 @@ void MainWindow::resizePages(QResizeEvent* event) {
// Resize the editor page
_editorPage->resize(size);
+ _aboutPage->resize(size);
}
void MainWindow::showEvent(QShowEvent* event) {
@@ -71,6 +74,7 @@ void MainWindow::showEvent(QShowEvent* event) {
// Resize all the pages based on the placeholder widget
_editorPage->resize(_placeHolderWidget->size());
+ _aboutPage->resize(_placeHolderWidget->size());
}
bool MainWindow::eventFilter(QObject* object, QEvent* event) {
diff --git a/FinalProject/mainwindow.h b/FinalProject/mainwindow.h
index 2fee9ba..d6f63c0 100644
--- a/FinalProject/mainwindow.h
+++ b/FinalProject/mainwindow.h
@@ -5,6 +5,7 @@
#include "framelesswindow.h"
#include "sidebar.h"
#include "editorpage.h"
+#include "aboutpage.h"
class MainWindow : public FramelessWindow
{
@@ -21,6 +22,7 @@ private:
// Side bar and corresponding pages
SideBar* _sideBar = nullptr;
EditorPage* _editorPage = nullptr;
+ AboutPage* _aboutPage = nullptr;
// Place holder widget for resizing pages
QWidget* _placeHolderWidget = nullptr;
diff --git a/FinalProject/pagewidget.cpp b/FinalProject/pagewidget.cpp
index e836091..ec5d3a3 100644
--- a/FinalProject/pagewidget.cpp
+++ b/FinalProject/pagewidget.cpp
@@ -13,26 +13,31 @@ PageWidget::PageWidget(QWidget* parent) : QWidget(parent) {
// Construct content widget
_contentWidget = new QWidget(this);
_stretchLayout->addWidget(_contentWidget);
+ _contentWidget->show();
// Add opacity effect to real content
_pageOpacityEffect = new QGraphicsOpacityEffect(_contentWidget);
_pageOpacityEffect->setOpacity(0);
_contentWidget->setGraphicsEffect(_pageOpacityEffect);
+
+ // Move offstage
+ move(_originPagePosition + QPoint(0, 150));
+ hide();
}
PageWidget::~PageWidget() {}
void PageWidget::onStage() {
// Move up and fade in
- QParallelAnimationGroup* onStageAnimation = new QParallelAnimationGroup(_contentWidget);
- QPropertyAnimation* moveAnimation = new QPropertyAnimation(_contentWidget, "pos");
+ QParallelAnimationGroup* onStageAnimation = new QParallelAnimationGroup(this);
+ QPropertyAnimation* moveAnimation = new QPropertyAnimation(this, "pos");
QPropertyAnimation* fadeInAnimation = new QPropertyAnimation(_pageOpacityEffect, "opacity");
- moveAnimation->setDuration(300);
- moveAnimation->setEasingCurve(QEasingCurve::OutCubic);
- moveAnimation->setStartValue(_contentWidget->pos());
+ moveAnimation->setDuration(600);
+ moveAnimation->setEasingCurve(QEasingCurve::OutExpo);
+ moveAnimation->setStartValue(pos());
moveAnimation->setEndValue(_originPagePosition);
- fadeInAnimation->setDuration(300);
- fadeInAnimation->setEasingCurve(QEasingCurve::OutQuad);
+ fadeInAnimation->setDuration(500);
+ fadeInAnimation->setEasingCurve(QEasingCurve::InQuad);
fadeInAnimation->setStartValue(_pageOpacityEffect->opacity());
fadeInAnimation->setEndValue(0.999);
onStageAnimation->addAnimation(moveAnimation);
@@ -40,20 +45,19 @@ void PageWidget::onStage() {
onStageAnimation->start(QAbstractAnimation::DeleteWhenStopped);
// Show page
- _contentWidget->show();
+ show();
}
void PageWidget::offStage() {
// Move down and fade out
- QParallelAnimationGroup* offStageAnimation = new QParallelAnimationGroup(_contentWidget);
+ QParallelAnimationGroup* offStageAnimation = new QParallelAnimationGroup(this);
//QPropertyAnimation* moveAnimation = new QPropertyAnimation(_contentWidget, "pos");
QPropertyAnimation* fadeOutAnimation = new QPropertyAnimation(_pageOpacityEffect, "opacity");
//moveAnimation->setDuration(300);
//moveAnimation->setEasingCurve(QEasingCurve::OutCubic);
//moveAnimation->setStartValue(_contentWidget->pos());
//moveAnimation->setEndValue(_originPagePosition - QPoint(0, 100));
- fadeOutAnimation->setDuration(300);
- fadeOutAnimation->setEasingCurve(QEasingCurve::OutQuad);
+ fadeOutAnimation->setDuration(200);
fadeOutAnimation->setStartValue(_pageOpacityEffect->opacity());
fadeOutAnimation->setEndValue(0);
//offStageAnimation->addAnimation(moveAnimation);
@@ -62,6 +66,7 @@ void PageWidget::offStage() {
// Connect animation finished signal to hide page
connect(offStageAnimation, &QParallelAnimationGroup::finished, [=]() {
- _contentWidget->hide();
+ move(_originPagePosition + QPoint(0, 150));
+ hide();
});
}
\ No newline at end of file