first commit
commit
312418aded
|
@ -0,0 +1,43 @@
|
|||
# C++ objects and libs
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.a
|
||||
*.la
|
||||
*.lai
|
||||
*.so
|
||||
*.dll
|
||||
*.dylib
|
||||
|
||||
# Qt-es
|
||||
object_script.*.Release
|
||||
object_script.*.Debug
|
||||
*_plugin_import.cpp
|
||||
/.qmake.cache
|
||||
/.qmake.stash
|
||||
*.pro.user
|
||||
*.pro.user.*
|
||||
*.qbs.user
|
||||
*.qbs.user.*
|
||||
*.moc
|
||||
moc_*.cpp
|
||||
moc_*.h
|
||||
qrc_*.cpp
|
||||
ui_*.h
|
||||
*.qmlc
|
||||
*.jsc
|
||||
Makefile*
|
||||
#*build-*
|
||||
|
||||
# Qt unit tests
|
||||
target_wrapper.*
|
||||
|
||||
# QtCreator
|
||||
*.autosave
|
||||
|
||||
# QtCreator Qml
|
||||
*.qmlproject.user
|
||||
*.qmlproject.user.*
|
||||
|
||||
# QtCreator CMake
|
||||
CMakeLists.txt.user*
|
|
@ -0,0 +1,7 @@
|
|||
TEMPLATE = subdirs
|
||||
|
||||
SUBDIRS += \
|
||||
src/FluentUI.pro \
|
||||
example
|
||||
|
||||
example.depends = src/FluentUI.pro
|
|
@ -0,0 +1,46 @@
|
|||
QT += quick
|
||||
CONFIG += c++11
|
||||
|
||||
|
||||
DEFINES += QT_DEPRECATED_WARNINGS QT_NO_WARNING_OUTPUT
|
||||
|
||||
SOURCES += \
|
||||
main.cpp
|
||||
|
||||
RESOURCES += qml.qrc
|
||||
|
||||
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||
!isEmpty(target.path): INSTALLS += target
|
||||
|
||||
|
||||
|
||||
#### 如果你正在使用静态库.a 那么你还需要将下面的配置注释取消掉。
|
||||
#### 其它项目使用方法也是如此。
|
||||
|
||||
# DEFINES += STATICLIB
|
||||
|
||||
# LIBNAME = FluentUI
|
||||
|
||||
# CONFIG(debug, debug|release) {
|
||||
# contains(QMAKE_HOST.os,Windows) {
|
||||
# LIBNAME = FluentUI
|
||||
# }else{
|
||||
# LIBNAME = FluentUI_debug
|
||||
# }
|
||||
# }
|
||||
|
||||
# # Additional import path used to resolve QML modules in Qt Creator's code model
|
||||
# QML_IMPORT_PATH = $$OUT_PWD/../bin/
|
||||
|
||||
# # Additional import path used to resolve QML modules just for Qt Quick Designer
|
||||
# QML_DESIGNER_IMPORT_PATH = $$OUT_PWD/../bin/
|
||||
|
||||
# INCLUDEPATH += $$OUT_PWD/../bin/FluentUI/
|
||||
# DEPENDPATH += $$OUT_PWD/../bin/FluentUI/
|
||||
|
||||
# LIBS += -L$$OUT_PWD/../bin/FluentUI/ -l$${LIBNAME}
|
||||
# PRE_TARGETDEPS += $$OUT_PWD/../bin/FluentUI/lib$${LIBNAME}.a
|
||||
|
||||
### 注意:静态库 .so .dylib .dll 是自动安装的Qt qml plugin目录中,不需要此步配置
|
|
@ -0,0 +1,22 @@
|
|||
#include <QGuiApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <time.h>
|
||||
#include <QDebug>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
clock_t start,finish;
|
||||
double totaltime;
|
||||
start=clock();
|
||||
qputenv("QSG_RENDER_LOOP","basic");
|
||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QGuiApplication app(argc, argv);
|
||||
QQmlApplicationEngine engine;
|
||||
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
|
||||
if (engine.rootObjects().isEmpty())
|
||||
return -1;
|
||||
finish=clock();
|
||||
totaltime=(double)(finish-start)/CLOCKS_PER_SEC;
|
||||
qDebug() << "startup time :" << totaltime << "s";
|
||||
return app.exec();
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
import QtQuick 2.15
|
||||
import QtQuick.Window 2.15
|
||||
import QtQuick.Layouts 1.15
|
||||
import FluentUI 1.0
|
||||
|
||||
Window {
|
||||
id:rootwindow
|
||||
visible: true
|
||||
width: 480
|
||||
height: 700
|
||||
|
||||
ColumnLayout{
|
||||
spacing: 5
|
||||
|
||||
FluentUI{
|
||||
width: 20
|
||||
height: 20
|
||||
}
|
||||
|
||||
StandardButton{
|
||||
|
||||
}
|
||||
|
||||
FilledButton{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>main.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
|
@ -0,0 +1,27 @@
|
|||
#include "FluentUI.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
FluentUI::FluentUI(QQuickItem *parent)
|
||||
: QQuickPaintedItem(parent)
|
||||
{
|
||||
// By default, QQuickItem does not draw anything. If you subclass
|
||||
// QQuickItem to create a visual item, you will need to uncomment the
|
||||
// following line and re-implement updatePaintNode()
|
||||
|
||||
// setFlag(ItemHasContents, true);
|
||||
}
|
||||
|
||||
void FluentUI::paint(QPainter *painter)
|
||||
{
|
||||
QPen pen(QColorConstants::Red, 2);
|
||||
QBrush brush(QColorConstants::Red);
|
||||
|
||||
painter->setPen(pen);
|
||||
painter->setBrush(brush);
|
||||
painter->drawRect(0, 0, 100, 100);
|
||||
}
|
||||
|
||||
FluentUI::~FluentUI()
|
||||
{
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef FLUENTUI_H
|
||||
#define FLUENTUI_H
|
||||
|
||||
#include <QtQuick/QQuickPaintedItem>
|
||||
|
||||
class FluentUI : public QQuickPaintedItem
|
||||
{
|
||||
Q_OBJECT
|
||||
QML_ELEMENT
|
||||
Q_DISABLE_COPY(FluentUI)
|
||||
public:
|
||||
explicit FluentUI(QQuickItem *parent = nullptr);
|
||||
void paint(QPainter *painter) override;
|
||||
~FluentUI() override;
|
||||
signals:
|
||||
|
||||
};
|
||||
|
||||
#endif // FLUENTUI_H
|
|
@ -0,0 +1,44 @@
|
|||
QT += qml quick svg
|
||||
CONFIG += plugin c++11
|
||||
TEMPLATE = lib
|
||||
TARGET = FluentUI
|
||||
TARGET = $$qtLibraryTarget($$TARGET)
|
||||
uri = FluentUI
|
||||
|
||||
##########################################
|
||||
CONFIG += sharedlib # staticlib or sharedlib
|
||||
#** 多次切换编译构建模式,建议先清理缓存。项目右键->清理
|
||||
|
||||
#*[staticlib] 构建静态库.a
|
||||
#需要修改example.pro,请打开后按说明操作
|
||||
|
||||
#*[sharedlib] 构建动态库 .dll .so .dylib
|
||||
#会自动安装到Qt qmlplugin目录中
|
||||
#无需其它配置即可运行demo以及其它项目中使用
|
||||
#发布目标平台前必须每个平台都要构建一次。
|
||||
##########################################
|
||||
|
||||
RESOURCES += \
|
||||
res.qrc
|
||||
|
||||
|
||||
# Input
|
||||
HEADERS += \
|
||||
FluentUI.h \
|
||||
qml_plugin.h \
|
||||
|
||||
|
||||
SOURCES += \
|
||||
FluentUI.cpp \
|
||||
qml_plugin.cpp \
|
||||
|
||||
|
||||
|
||||
DEFINES += VERSION_IN=\\\"1.0.0\\\"
|
||||
DEFINES += URI_STR=\\\"$$uri\\\"
|
||||
|
||||
contains(QMAKE_HOST.os,Windows) {
|
||||
include(./build_windows.pri)
|
||||
}else{
|
||||
include(./build_macos.pri)
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
module FluentUI
|
||||
plugin FluentUI
|
||||
classname FluentUIQmlPlugin
|
||||
typeinfo plugin.qmltypes
|
|
@ -0,0 +1,17 @@
|
|||
OUTP = $$OUT_PWD/../bin/FluentUI/
|
||||
|
||||
DESTDIR += $$OUTP
|
||||
|
||||
QMAKE_MOC_OPTIONS += -Muri=$$uri
|
||||
QMAKE_PRE_LINK += chmod -R 777 $$PWD/macos_install.sh;
|
||||
QMAKE_PRE_LINK += $$PWD/macos_install.sh PRESET $$PWD/ $$OUTP;
|
||||
|
||||
CONFIG(sharedlib){
|
||||
INST_QMLPATH = $$[QT_INSTALL_QML]/$$replace(uri, \\., /)
|
||||
|
||||
QMAKE_POST_LINK += $$PWD/macos_install.sh INSTALL $$PWD/ $$OUTP $$INST_QMLPATH;
|
||||
|
||||
exists($$PWD/../../dev.pri){
|
||||
include($$PWD/../../dev.pri)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
OUTP = $$OUT_PWD/../bin/FluentUI
|
||||
BUILDBIN_PATH = $$replace(OUTP, src/../bin, bin)
|
||||
QTQMLFLUENT_PATH = $$[QT_INSTALL_QML]/FluentUI
|
||||
PRESET_PATH = $$PWD/build-preset
|
||||
SOLIBFILE_PATH = $$OUT_PWD/libFluentUI.so
|
||||
ANDROID = NO
|
||||
|
||||
#QT_BIN_PATH = $$[QT_INSTALL_BINS]
|
||||
#PLUGIN_NAME = $$uri
|
||||
#PLUGIN_VERSION = "1.0"
|
||||
#PLUGIN_PARENT_PATH = $$BUILD_ROOT/build-preset/plugins
|
||||
#PLUGIN_QMLTYPES_PATH = $$BUILD_ROOT/build-preset/plugins/$$uri/plugin.qmltypes
|
||||
|
||||
android{
|
||||
ANDROID=YES
|
||||
QMAKE_PRE_LINK *= md $$replace(OUTP, /, \\)
|
||||
}else{
|
||||
DESTDIR += $$OUTP
|
||||
}
|
||||
|
||||
#QMLTYPESSCRIPT = "$$PWD\create_qmltypes.bat" "$$QT_BIN_PATH" "$$PLUGIN_NAME" "$$PLUGIN_VERSION" "$$PLUGIN_PARENT_PATH" "$$PLUGIN_QMLTYPES_PATH"
|
||||
SHAREDSCRIPT = "$$PWD\win_install.bat" SHARED "$$PWD" "$$PRESET_PATH" "$$BUILDBIN_PATH" "$$QTQMLFLUENT_PATH" $$ANDROID "$$SOLIBFILE_PATH"
|
||||
STATICSCRIPT = "$$PWD\win_install.bat" STATIC "$$PWD" "$$PRESET_PATH" "$$BUILDBIN_PATH" "$$QTQMLFLUENT_PATH" $$ANDROID "$$SOLIBFILE_PATH"
|
||||
|
||||
#QMAKE_POST_LINK *= $$replace(QMLTYPESSCRIPT, /, \\)
|
||||
|
||||
CONFIG(sharedlib){
|
||||
QMAKE_POST_LINK *= $$replace(SHAREDSCRIPT, /, \\)
|
||||
}
|
||||
else{
|
||||
QMAKE_POST_LINK *= $$replace(STATICSCRIPT, /, \\)
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
//@uri FluentUI
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
import QtQuick.Controls.Material 2.15
|
||||
|
||||
Rectangle {
|
||||
id: button
|
||||
width: 100
|
||||
height: 40
|
||||
radius: 4
|
||||
color: Material.accent
|
||||
border.color: Material.accent
|
||||
|
||||
Text {
|
||||
id: buttonText
|
||||
text: "Button"
|
||||
color: "white"
|
||||
font.pixelSize: 14
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
console.log("Button clicked")
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
import QtQuick 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
import QtQuick.Controls.Material 2.15
|
||||
|
||||
Rectangle {
|
||||
id: button
|
||||
|
||||
property int startPadding : 15
|
||||
property int endPadding : 15
|
||||
property int topPadding: 8
|
||||
property int bottomPadding: 8
|
||||
property bool disabled: false
|
||||
radius: 4
|
||||
color: "#FFFFFF"
|
||||
|
||||
width: childrenRect.width
|
||||
height: childrenRect.height
|
||||
|
||||
border.color: "#eeeeee"
|
||||
border.width: 1
|
||||
|
||||
Text {
|
||||
id: buttonText
|
||||
text: "Standard Button"
|
||||
color: "#000000"
|
||||
font.pixelSize: 13
|
||||
leftPadding: button.startPadding
|
||||
rightPadding: button.endPadding
|
||||
topPadding: button.topPadding
|
||||
bottomPadding: button.bottomPadding
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
console.log("Button clicked")
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
|
||||
SET QT_BIN_PATH=%1
|
||||
SET BAT_PLUGIN_NAME=%2
|
||||
SET BAT_PLUGIN_VERSION=%3
|
||||
SET BAT_PLUGIN_PARENT_PATH=%4
|
||||
SET BAT_PLUGIN_QMLTYPES_PATH=%5
|
||||
|
||||
echo "------create_qmltypes-------"
|
||||
echo %QT_BIN_PATH%
|
||||
echo %BAT_PLUGIN_NAME%
|
||||
echo %BAT_PLUGIN_VERSION%
|
||||
echo %BAT_PLUGIN_PARENT_PATH%
|
||||
echo %BAT_PLUGIN_QMLTYPES_PATH%
|
||||
echo "-------------"
|
||||
|
||||
%QT_BIN_PATH%\qmlplugindump.exe -nonrelocatable %BAT_PLUGIN_NAME% %BAT_PLUGIN_VERSION% %BAT_PLUGIN_PARENT_PATH% > %BAT_PLUGIN_QMLTYPES_PATH%
|
|
@ -0,0 +1,14 @@
|
|||
RUN_TYPE=$1
|
||||
PRESET_PATH=$2
|
||||
BUILDER_BIN_PATH=$3
|
||||
QT_QML_FLUENT_PATH=$4
|
||||
|
||||
echo ${RUN_TYPE}
|
||||
if [ ${RUN_TYPE} = "PRESET" ]; then
|
||||
cp -r ${PRESET_PATH}/FluentUI.h ${BUILDER_BIN_PATH}
|
||||
cp -r ${PRESET_PATH}/build-preset/* ${BUILDER_BIN_PATH}
|
||||
else
|
||||
rm -rf ${QT_QML_FLUENT_PATH=}
|
||||
mkdir -pv ${QT_QML_FLUENT_PATH=}
|
||||
cp -r ${BUILDER_BIN_PATH}/* ${QT_QML_FLUENT_PATH=}
|
||||
fi
|
|
@ -0,0 +1,16 @@
|
|||
#include "qml_plugin.h"
|
||||
|
||||
void FluentUIQmlPlugin::registerTypes(const char *uri)
|
||||
{
|
||||
int major = 1;
|
||||
int minor = 0;
|
||||
qmlRegisterType<FluentUI>(uri, major, minor, "FluentUI");
|
||||
qmlRegisterType(QUrl("qrc:/com.zzc/controls/StandardButton.qml"),uri,major,minor,"StandardButton");
|
||||
qmlRegisterType(QUrl("qrc:/com.zzc/controls/FilledButton.qml"),uri,major,minor,"FilledButton");
|
||||
}
|
||||
|
||||
void FluentUIQmlPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
#pragma once
|
||||
|
||||
#include <QQmlExtensionPlugin>
|
||||
#include <FluentUI.h>
|
||||
|
||||
class FluentUIQmlPlugin : public QQmlExtensionPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
|
||||
|
||||
public:
|
||||
void registerTypes(const char *uri) override;
|
||||
|
||||
void initializeEngine(QQmlEngine *engine, const char *uri) override;
|
||||
};
|
|
@ -0,0 +1,6 @@
|
|||
<RCC>
|
||||
<qresource prefix="/com.zzc">
|
||||
<file>controls/StandardButton.qml</file>
|
||||
<file>controls/FilledButton.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
SET PWD_PATH=%2
|
||||
SET PRESET_PATH=%3
|
||||
SET BUILDER_BIN_PATH=%4
|
||||
SET QT_QML_FLUENT_PATH=%5
|
||||
SET ANDROID=%6
|
||||
SET LIBFILE_PATH=%7
|
||||
|
||||
echo "--------win_install-------"
|
||||
echo %RUN_TYPE%
|
||||
echo %PWD_PATH%
|
||||
echo %PRESET_PATH%
|
||||
echo %BUILDER_BIN_PATH%
|
||||
echo %QT_QML_FLUENT_PATH%
|
||||
echo "--------------------------"
|
||||
|
||||
copy /y %PWD_PATH%\Toou2D.h %BUILDER_BIN_PATH% & copy /y %PRESET_PATH%\* %BUILDER_BIN_PATH%\
|
||||
|
||||
if %ANDROID% == YES copy /y %LIBFILE_PATH% %BUILDER_BIN_PATH%
|
||||
|
||||
if %1 == SHARED (
|
||||
echo running install to qtqml folder
|
||||
rmdir /s /q %QT_QML_FLUENT_PATH% & md %QT_QML_FLUENT_PATH%
|
||||
copy /y %BUILDER_BIN_PATH% %QT_QML_FLUENT_PATH%
|
||||
)
|
Loading…
Reference in New Issue