mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2025-07-03 00:25:25 +08:00
first commit
This commit is contained in:
27
src/FluentUI.cpp
Normal file
27
src/FluentUI.cpp
Normal file
@ -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()
|
||||
{
|
||||
}
|
19
src/FluentUI.h
Normal file
19
src/FluentUI.h
Normal file
@ -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
|
44
src/FluentUI.pro
Normal file
44
src/FluentUI.pro
Normal file
@ -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)
|
||||
}
|
4
src/build-preset/qmldir
Normal file
4
src/build-preset/qmldir
Normal file
@ -0,0 +1,4 @@
|
||||
module FluentUI
|
||||
plugin FluentUI
|
||||
classname FluentUIQmlPlugin
|
||||
typeinfo plugin.qmltypes
|
17
src/build_macos.pri
Normal file
17
src/build_macos.pri
Normal file
@ -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)
|
||||
}
|
||||
}
|
32
src/build_windows.pri
Normal file
32
src/build_windows.pri
Normal file
@ -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, /, \\)
|
||||
}
|
28
src/controls/FilledButton.qml
Normal file
28
src/controls/FilledButton.qml
Normal file
@ -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")
|
||||
}
|
||||
}
|
||||
}
|
40
src/controls/StandardButton.qml
Normal file
40
src/controls/StandardButton.qml
Normal file
@ -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")
|
||||
}
|
||||
}
|
||||
}
|
16
src/create_qmltypes.bat
Normal file
16
src/create_qmltypes.bat
Normal file
@ -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%
|
14
src/macos_install.sh
Normal file
14
src/macos_install.sh
Normal file
@ -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
|
16
src/qml_plugin.cpp
Normal file
16
src/qml_plugin.cpp
Normal file
@ -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)
|
||||
{
|
||||
|
||||
}
|
||||
|
15
src/qml_plugin.h
Normal file
15
src/qml_plugin.h
Normal file
@ -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;
|
||||
};
|
6
src/res.qrc
Normal file
6
src/res.qrc
Normal file
@ -0,0 +1,6 @@
|
||||
<RCC>
|
||||
<qresource prefix="/com.zzc">
|
||||
<file>controls/StandardButton.qml</file>
|
||||
<file>controls/FilledButton.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
25
src/win_install.bat
Normal file
25
src/win_install.bat
Normal file
@ -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%
|
||||
)
|
Reference in New Issue
Block a user