Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

整理代码,并修复一些bug #8

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
File renamed without changes.
18 changes: 6 additions & 12 deletions QFramer.pro
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ CONFIG(debug, debug|release) {

# source
SOURCES += \
main.cpp \
mainwindow/mainwindow.cpp \
mainwindow/settingmenu.cpp \
dialogs/aboutdialog.cpp \
dialogs/bgskinpopup.cpp \
dialogs/settingdialog.cpp \
Expand All @@ -46,21 +49,17 @@ SOURCES += \
functionpages/mathplot.cpp \
functionpages/rightfloatwindow.cpp \
functionpages/uielement.cpp \
mainwindow/centerwindow.cpp \
mainwindow/mainwindow.cpp \
mainwindow/settingmenu.cpp \
mainwindow/settingmenucontroller.cpp \
mainwindow/thememenu.cpp \
qcustomplot/fcustomplot.cpp \
qcustomplot/qcustomplot.cpp \
main.cpp \
functionpages/waterwidget.cpp \
functionpages/waterview.cpp \
functionpages/animationgradientlabel.cpp \
functionpages/qssbuilder.cpp

# header
HEADERS += \
mainwindow/mainwindow.h \
mainwindow/settingmenu.h \
dialogs/aboutdialog.h \
dialogs/bgskinpopup.h \
dialogs/settingdialog.h \
Expand All @@ -70,11 +69,6 @@ HEADERS += \
functionpages/mathplot.h \
functionpages/rightfloatwindow.h \
functionpages/uielement.h \
mainwindow/centerwindow.h \
mainwindow/mainwindow.h \
mainwindow/settingmenu.h \
mainwindow/settingmenucontroller.h \
mainwindow/thememenu.h \
qcustomplot/fcustomplot.h \
qcustomplot/qcustomplot.h \
functionpages/waterwidget.h \
Expand All @@ -84,7 +78,7 @@ HEADERS += \

# resources
RESOURCES += \
QFramer.qrc
QFrame.qrc

# QT4.8 applciation icon
contains(QT_MAJOR_VERSION, 4){
Expand Down
232 changes: 79 additions & 153 deletions QFramer/fcenterwindow.cpp → QFramer/FCenterWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
**
** Copyright (C) 2014 dragondjf
**
** QFramer is a frame based on Qt5.3, you will be more efficient with it.
** As an Qter, Qt give us a nice coding experience. With user interactive experience(UE)
** QFramer is a frame based on Qt5.3, you will be more efficient with it.
** As an Qter, Qt give us a nice coding experience. With user interactive experience(UE)
** become more and more important in modern software, deveployers should consider business and UE.
** So, QFramer is born. QFramer's goal is to be a mature solution
** So, QFramer is born. QFramer's goal is to be a mature solution
** which you only need to be focus on your business but UE for all Qters.
**
** Version : 0.2.5.0
Expand All @@ -17,19 +17,19 @@
** Lincence: LGPL V2
** QQ: 465398889
** Email: [email protected], [email protected], [email protected]
**
**
****************************************************************************/

#include "fcenterwindow.h"
#include "ftitlebar.h"
#include <QPushButton>
#include "FCenterWindow.h"
#include <QStackedWidget>
#include <QVBoxLayout>
#include <QTime>
#include <QLabel>
#include <QPixmap>
#include <QEasingCurve>
#include <QPropertyAnimation>
#include <QParallelAnimationGroup>
#include <QEasingCurve>
#include <QLabel>
#include <QTime>

#include "FTitleBar.h"

FCenterWindow::FCenterWindow(QWidget *parent)
:QFrame(parent)
Expand Down Expand Up @@ -57,197 +57,124 @@ void FCenterWindow::initUI()
navlayout->setContentsMargins(0, 0 ,0 ,0);
navlayout->setSpacing(0);

mainLayout = new QVBoxLayout;
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(FTitleBar::getInstace());
mainLayout->addLayout(navlayout);
mainLayout->setContentsMargins(0, 0 ,0 ,0);
mainLayout->setSpacing(0);
setLayout(mainLayout);
}

void FCenterWindow::swicthLayout(QBoxLayout::Direction direction)
void FCenterWindow::initConnect()
{
navlayout->setDirection(direction);
connect(navagationBar, SIGNAL(indexChanged(int)), this, SLOT(switchscreen(int)));
}

void FCenterWindow::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_Left) {
int count = navagationBar->count();
int index = (navagationBar->currentIndex() + count - 1) % count;
navagationBar->setCurrentIndex(index);
} else if(event->key() == Qt::Key_Right) {
int count = navagationBar->count();
int index = (navagationBar->currentIndex() + 1) % count;
navagationBar->setCurrentIndex(index);
} else if (event->key() == Qt::Key_F1) {
setAlignment(FNavgationBar::TopCenter);
} else if (event->key() == Qt::Key_F2) {
QTime time = QTime::currentTime();
qsrand(static_cast<uint>(time.msec() + time.second() * 1000));
setAlignment(static_cast<FNavgationBar::AlignmentDirection>(qrand() % 12));
} else {
QFrame::keyPressEvent(event);
}
}

void FCenterWindow::setAlignment(Alignment_Direction direction)
void FCenterWindow::setAlignment(FNavgationBar::AlignmentDirection direction)
{
switch (direction) {
case TopLeft:
navagationBar->setObjectName(QString("FNavgationBar_bottom"));
navagationBar->setAlignment_topLeft();
navagationBar->resize(QSize(stackWidget->width(), navagationBar->height()));
navagationBar->adjustSize();
swicthLayout(QBoxLayout::TopToBottom);
break;
case TopCenter:
navagationBar->setObjectName(QString("FNavgationBar_bottom"));
navagationBar->setAlignment_topCenter();
navagationBar->resize(QSize(stackWidget->width(), navagationBar->height()));
navagationBar->adjustSize();

swicthLayout(QBoxLayout::TopToBottom);
break;
case TopRight:
case FNavgationBar::TopLeft:
case FNavgationBar::TopCenter:
case FNavgationBar::TopRight:
navagationBar->setObjectName(QString("FNavgationBar_bottom"));
navagationBar->setAlignment_topRight();
navagationBar->setAlignment(direction);
navagationBar->resize(QSize(stackWidget->width(), navagationBar->height()));
navagationBar->adjustSize();
swicthLayout(QBoxLayout::TopToBottom);
break;
case RightTop:
navagationBar->setObjectName(QString("FNavgationBar_left"));
navagationBar->setAlignment_rightTop();
navagationBar->resize(QSize(navagationBar->width(), stackWidget->height()));
navagationBar->adjustSize();
swicthLayout(QBoxLayout::RightToLeft);
break;
case RightCenter:
navagationBar->setObjectName(QString("FNavgationBar_left"));
navagationBar->setAlignment_rightCenter();
navagationBar->resize(QSize(navagationBar->width(), stackWidget->height()));
navagationBar->adjustSize();
swicthLayout(QBoxLayout::RightToLeft);
navlayout->setDirection(QBoxLayout::TopToBottom);
break;
case RightBottom:
case FNavgationBar::RightTop:
case FNavgationBar::RightCenter:
case FNavgationBar::RightBottom:
navagationBar->setObjectName(QString("FNavgationBar_left"));
navagationBar->setAlignment_rightBottom();
navagationBar->setAlignment(direction);
navagationBar->resize(QSize(navagationBar->width(), stackWidget->height()));
navagationBar->adjustSize();
swicthLayout(QBoxLayout::RightToLeft);
break;
case BottomRight:
navagationBar->setObjectName(QString("FNavgationBar_top"));
navagationBar->setAlignment_bottomRight();
navagationBar->resize(QSize(stackWidget->width(), navagationBar->height()));
navagationBar->adjustSize();
swicthLayout(QBoxLayout::BottomToTop);
break;
case BottomCenter:
navagationBar->setObjectName(QString("FNavgationBar_top"));
navagationBar->setAlignment_bottomCenter();
navagationBar->resize(QSize(stackWidget->width(), navagationBar->height()));
navagationBar->adjustSize();
swicthLayout(QBoxLayout::BottomToTop);
navlayout->setDirection(QBoxLayout::RightToLeft);
break;
case BottomLeft:
case FNavgationBar::BottomRight:
case FNavgationBar::BottomCenter:
case FNavgationBar::BottomLeft:
navagationBar->setObjectName(QString("FNavgationBar_top"));
navagationBar->setAlignment_bottomLeft();
navagationBar->setAlignment(direction);
navagationBar->resize(QSize(stackWidget->width(), navagationBar->height()));
navagationBar->adjustSize();
swicthLayout(QBoxLayout::BottomToTop);
navlayout->setDirection(QBoxLayout::BottomToTop);
break;
case LeftBottom:
case FNavgationBar::LeftBottom:
case FNavgationBar::LeftCenter:
case FNavgationBar::LeftTop:
navagationBar->setObjectName(QString("FNavgationBar_right"));
navagationBar->setAlignment_leftBottom();
navagationBar->setAlignment(direction);
navagationBar->resize(QSize(navagationBar->width(), stackWidget->height()));
navagationBar->adjustSize();
swicthLayout(QBoxLayout::LeftToRight);
break;
case LeftCenter:
navagationBar->setObjectName(QString("FNavgationBar_right"));
navagationBar->setAlignment_leftCenter();
navagationBar->resize(QSize(navagationBar->width(), stackWidget->height()));
navagationBar->adjustSize();
swicthLayout(QBoxLayout::LeftToRight);
break;
case LeftTop:
navagationBar->setObjectName(QString("FNavgationBar_right"));
navagationBar->setAlignment_leftTop();
navagationBar->resize(QSize(navagationBar->width(), stackWidget->height()));
navagationBar->adjustSize();
swicthLayout(QBoxLayout::LeftToRight);
break;
default:
navlayout->setDirection(QBoxLayout::LeftToRight);
break;
}
}


void FCenterWindow::initConnect()
{
connect(navagationBar, SIGNAL(indexChanged(int)), this, SLOT(switchscreen(int)));
}


void FCenterWindow::addWidget(const QString &tile, const QString &obejctName, QWidget *widget)
void FCenterWindow::addWidget(QWidget *widget, const QString &tile, const QString &objectName)
{
navagationBar->addNavgationTile(tile, obejctName);
widget->setObjectName(obejctName);
if (!widget) return;
navagationBar->addNavgationTile(tile, objectName);
widget->setObjectName(objectName.isEmpty() ? tile : objectName);
stackWidget->addWidget(widget);
setAlignment(FNavgationBar::TopCenter);
}

FNavgationBar* FCenterWindow::getNavgationBar(){
FNavgationBar* FCenterWindow::getNavgationBar()
{
return navagationBar;
}

void FCenterWindow::switchscreen(const int index)
{
int n = 0;
if (index == stackWidget->currentIndex())
{
AnimationDirection animation = animationTop;
if (index == stackWidget->currentIndex()) {
return;
}
else if(index > stackWidget->currentIndex())
{
n = 2;
}
else if (index < stackWidget->currentIndex())
{
n = 6;
} else if (index > stackWidget->currentIndex()) {
animation = FCenterWindow::animationRight;
} else if (index < stackWidget->currentIndex()) {
animation = FCenterWindow::animationLeft;
}

stackWidget->setCurrentIndex(index);
// QTime time = QTime::currentTime();
// qsrand(static_cast<uint>(time.msec() + time.second() * 1000));
// int n = qrand() % 9;
// animation = static_cast<AnimationDirection>(n);

// QTime time;
// time= QTime::currentTime();
// qsrand(time.msec()+time.second()*1000);
// int n = qrand()%9;
// n = 0;
switch (n) {
case 0:
cloudAntimation(animationTop);
break;
case 1:
cloudAntimation(animationTopRight);
break;
case 2:
cloudAntimation(animationRight);
break;
case 3:
cloudAntimation(animationBottomRight);
break;
case 4:
cloudAntimation(animationBottom);
break;
case 5:
cloudAntimation(animationBottomLeft);
break;
case 6:
cloudAntimation(animationLeft);
break;
case 7:
cloudAntimation(animationTopLeft);
break;
case 8:
cloudAntimation(animationCenter);
break;
default:
break;
}
stackWidget->setCurrentIndex(index);
cloudAntimation(animation);
preindex = index;

}


void FCenterWindow::switchscreen()
void FCenterWindow::swicthLayout(QBoxLayout::Direction direction)
{
stackWidget->setCurrentIndex(currentIndex);
navlayout->setDirection(direction);
}

void FCenterWindow::cloudAntimation(animation_Direction direction)
void FCenterWindow::cloudAntimation(AnimationDirection direction)
{
// TODO : not read
QLabel* circle = new QLabel(stackWidget->currentWidget());
QLabel* line = new QLabel(this);
line->setObjectName(QString("AntimationLine"));
Expand All @@ -259,11 +186,10 @@ void FCenterWindow::cloudAntimation(animation_Direction direction)
circle->setPixmap(stackWidget->widget(preindex)->grab());
#endif

// circle->setScaledContents(true);
// circle->setScaledContents(true);
circle->show();
circle->resize(stackWidget->currentWidget()->size());
QPropertyAnimation *animation = new QPropertyAnimation(circle, "geometry");

animation->setDuration(1000);
animation->setStartValue(circle->geometry());

Expand Down
Loading