mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2024-11-26 21:37:04 +08:00
add FpsItem
This commit is contained in:
parent
82a3f85f10
commit
5fc7ae7e89
@ -282,6 +282,21 @@ CustomWindow {
|
|||||||
id:http
|
id:http
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FpsItem{
|
||||||
|
id:fps_item
|
||||||
|
}
|
||||||
|
|
||||||
|
FluText{
|
||||||
|
text:"fps %1".arg(fps_item.fps)
|
||||||
|
opacity: 0.3
|
||||||
|
anchors{
|
||||||
|
bottom: parent.bottom
|
||||||
|
right: parent.right
|
||||||
|
bottomMargin: 5
|
||||||
|
rightMargin: 5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FluContentDialog{
|
FluContentDialog{
|
||||||
property string newVerson
|
property string newVerson
|
||||||
property string body
|
property string body
|
||||||
|
@ -283,6 +283,21 @@ CustomWindow {
|
|||||||
id:http
|
id:http
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FpsItem{
|
||||||
|
id:fps_item
|
||||||
|
}
|
||||||
|
|
||||||
|
FluText{
|
||||||
|
text:"fps %1".arg(fps_item.fps)
|
||||||
|
opacity: 0.3
|
||||||
|
anchors{
|
||||||
|
bottom: parent.bottom
|
||||||
|
right: parent.right
|
||||||
|
bottomMargin: 5
|
||||||
|
rightMargin: 5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FluContentDialog{
|
FluContentDialog{
|
||||||
property string newVerson
|
property string newVerson
|
||||||
property string body
|
property string body
|
||||||
|
19
example/src/component/FpsItem.cpp
Normal file
19
example/src/component/FpsItem.cpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#include "FpsItem.h"
|
||||||
|
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QQuickWindow>
|
||||||
|
|
||||||
|
FpsItem::FpsItem()
|
||||||
|
{
|
||||||
|
QTimer *timer = new QTimer(this);
|
||||||
|
connect(timer, &QTimer::timeout, this, [this]{
|
||||||
|
fps(_frameCount);
|
||||||
|
_frameCount = 0;
|
||||||
|
});
|
||||||
|
connect(this, &QQuickItem::windowChanged, this, [this]{
|
||||||
|
if (window()){
|
||||||
|
connect(window(), &QQuickWindow::afterRendering, this, [this]{ _frameCount++; }, Qt::DirectConnection);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
timer->start(1000);
|
||||||
|
}
|
19
example/src/component/FpsItem.h
Normal file
19
example/src/component/FpsItem.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#ifndef FPSITEM_H
|
||||||
|
#define FPSITEM_H
|
||||||
|
|
||||||
|
#include <QQuickItem>
|
||||||
|
#include "src/stdafx.h"
|
||||||
|
|
||||||
|
class FpsItem : public QQuickItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY_AUTO(int,fps)
|
||||||
|
public:
|
||||||
|
FpsItem();
|
||||||
|
|
||||||
|
private:
|
||||||
|
int _frameCount = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // FPSITEM_H
|
@ -11,6 +11,7 @@
|
|||||||
#include "AppInfo.h"
|
#include "AppInfo.h"
|
||||||
#include "src/component/CircularReveal.h"
|
#include "src/component/CircularReveal.h"
|
||||||
#include "src/component/FileWatcher.h"
|
#include "src/component/FileWatcher.h"
|
||||||
|
#include "src/component/FpsItem.h"
|
||||||
|
|
||||||
FRAMELESSHELPER_USE_NAMESPACE
|
FRAMELESSHELPER_USE_NAMESPACE
|
||||||
|
|
||||||
@ -49,6 +50,7 @@ int main(int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
qmlRegisterType<CircularReveal>("example", 1, 0, "CircularReveal");
|
qmlRegisterType<CircularReveal>("example", 1, 0, "CircularReveal");
|
||||||
qmlRegisterType<FileWatcher>("example", 1, 0, "FileWatcher");
|
qmlRegisterType<FileWatcher>("example", 1, 0, "FileWatcher");
|
||||||
|
qmlRegisterType<FpsItem>("example", 1, 0, "FpsItem");
|
||||||
appInfo->init(&engine);
|
appInfo->init(&engine);
|
||||||
const QUrl url(QStringLiteral("qrc:/example/qml/App.qml"));
|
const QUrl url(QStringLiteral("qrc:/example/qml/App.qml"));
|
||||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
|
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
|
||||||
|
Loading…
Reference in New Issue
Block a user