diff --git a/src/TaoEffectPlugin/Src/EffectsPlugin.cpp b/src/TaoEffectPlugin/Src/EffectsPlugin.cpp index 3d9332f..86b82e7 100644 --- a/src/TaoEffectPlugin/Src/EffectsPlugin.cpp +++ b/src/TaoEffectPlugin/Src/EffectsPlugin.cpp @@ -11,8 +11,8 @@ QJsonArray EffectsPlugin::infos() const { static QJsonArray arr{ QJsonObject{ - { "name", u8"特效" }, - { "title", u8"特效" }, + { "name", tr(u8"特效") }, + { "title", tr(u8"特效") }, { "children", QJsonArray{ QJsonObject{ { "name", u8"环" }, { "title", u8"环" }, { "url", "qrc:/Effect/Qml/ContentPage/Effect/RingPage.qml" } }, QJsonObject{ { "name", u8"璀璨星空" }, { "title", u8"璀璨星空" }, { "url", "qrc:/Effect/Qml/ContentPage/Effect/Swapper.qml" } }, diff --git a/src/TaoEffectPlugin/TaoEffectPlugin.pro b/src/TaoEffectPlugin/TaoEffectPlugin.pro index 1b9a519..053eae9 100644 --- a/src/TaoEffectPlugin/TaoEffectPlugin.pro +++ b/src/TaoEffectPlugin/TaoEffectPlugin.pro @@ -1,6 +1,7 @@ QT += core gui qml -TARGET = $$qtLibraryTarget(TaoEffect) +#TARGET = $$qtLibraryTarget(TaoEffect) +TARGET = TaoEffect TEMPLATE = lib CONFIG += plugin msvc { diff --git a/src/TaoQuick/Qml/EffectComponent/TCommon.qml b/src/TaoQuick/Qml/EffectComponent/TCommon.qml index ace6943..6657b1e 100644 --- a/src/TaoQuick/Qml/EffectComponent/TCommon.qml +++ b/src/TaoQuick/Qml/EffectComponent/TCommon.qml @@ -12,5 +12,6 @@ QtObject { # define highp #endif // GL_ES " + } diff --git a/src/TaoQuick/Src/taoquick_plugin.cpp b/src/TaoQuick/Src/taoquick_plugin.cpp deleted file mode 100644 index 99728ef..0000000 --- a/src/TaoQuick/Src/taoquick_plugin.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "taoquick_plugin.h" -#include - -void TaoQuickPlugin::registerTypes(const char *uri) -{ - Q_UNUSED(uri); - Q_INIT_RESOURCE(Qml); - qInfo() << "\033[35m" - << "Your application is using TaoQuick "; - qInfo() << " Version:" << TaoVer; - qInfo() << " Revision:" << TaoREVISIONSTR; - qInfo() << " Author: Jared Tao"; - qInfo() << " You can find more info about TaoQuick in website:" - << "\033[0m" - << "\033[31m" - << "https://github.com/jaredtao"; - - qInfo() << "\033[0m\033[32m" - << "Good luck to you." - << "\033[0m"; -} diff --git a/src/TaoQuick/Src/taoquick_plugin.h b/src/TaoQuick/Src/taoquick_plugin.h index 6875ede..124116e 100644 --- a/src/TaoQuick/Src/taoquick_plugin.h +++ b/src/TaoQuick/Src/taoquick_plugin.h @@ -1,12 +1,60 @@ #pragma once +#include +#include -#include +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) +#include + +class TaoQuickPlugin : public QQmlEngineExtensionPlugin -class TaoQuickPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) - + Q_PLUGIN_METADATA(IID QQmlEngineExtensionInterface_iid) public: - void registerTypes(const char *uri) override; + void initializeEngine(QQmlEngine* engine, const char* uri) override + { + Q_INIT_RESOURCE(Qml); + qInfo() << "\033[35m" + << "Your application is using TaoQuick "; + qInfo() << " Version:" << TaoVer; + qInfo() << " Revision:" << TaoREVISIONSTR; + qInfo() << " Author: Jared Tao"; + qInfo() << " You can find more info about TaoQuick in website:" + << "\033[0m" + << "\033[31m" + << "https://github.com/jaredtao"; + + qInfo() << "\033[0m\033[32m" + << "Good luck to you." + << "\033[0m"; + QQmlEngineExtensionPlugin::initializeEngine(engine, uri); + } }; + +#else +#include + +class TaoQuickPlugin : public QQmlExtensionPlugin { + Q_OBJECT + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) +public: + void registerTypes(const char* uri) override + { + Q_INIT_RESOURCE(Qml); + qInfo() << "\033[35m" + << "Your application is using TaoQuick "; + qInfo() << " Version:" << TaoVer; + qInfo() << " Revision:" << TaoREVISIONSTR; + qInfo() << " Author: Jared Tao"; + qInfo() << " You can find more info about TaoQuick in website:" + << "\033[0m" + << "\033[31m" + << "https://github.com/jaredtao"; + + qInfo() << "\033[0m\033[32m" + << "Good luck to you." + << "\033[0m"; + } +}; + +#endif diff --git a/src/TaoQuick/TaoQuick.pri b/src/TaoQuick/TaoQuick.pri index 9294191..3efc0e9 100644 --- a/src/TaoQuick/TaoQuick.pri +++ b/src/TaoQuick/TaoQuick.pri @@ -1,8 +1,7 @@ HEADERS += \ $$PWD/Src/taoquick_plugin.h -SOURCES += \ - $$PWD/Src/taoquick_plugin.cpp +SOURCES += RESOURCES += \ $$PWD/Image.qrc \ diff --git a/src/TaoQuick/TaoQuick.pro b/src/TaoQuick/TaoQuick.pro index b6f66f5..0e1b665 100644 --- a/src/TaoQuick/TaoQuick.pro +++ b/src/TaoQuick/TaoQuick.pro @@ -1,11 +1,12 @@ TEMPLATE = lib -TARGET = $$qtLibraryTarget(TaoQuick) - +#TARGET = $$qtLibraryTarget(TaoQuick) +TARGET = TaoQuick QT += qml quick -CONFIG += plugin c++11 qtquickcompiler +CONFIG += plugin c++11 qtquickcompiler qmltypes uri = TaoQuick - +QML_IMPORT_NAME = $$TARGET +QML_IMPORT_MAJOR_VERSION = 1 include(../TaoVersion.pri) include(../TaoBundle.pri) include(TaoQuick.pri) diff --git a/src/TaoQuickApp/Qml/MainPage.qml b/src/TaoQuickApp/Qml/MainPage.qml index 5022b8f..9a6330b 100644 --- a/src/TaoQuickApp/Qml/MainPage.qml +++ b/src/TaoQuickApp/Qml/MainPage.qml @@ -1,4 +1,4 @@ -import QtQuick 2.12 +import QtQuick 2.12 import "./Page" import TaoQuick 1.0 @@ -27,7 +27,10 @@ Item { } Connections { target: view - onPluginReady: { +// onPluginReady: { +// onPluginReady(pluginInfo) +// } + function onPluginReady(pluginInfo) { console.log("onPluginReady") var arr = null try { diff --git a/src/TaoQuickApp/Qml/Page/AboutDialog.qml b/src/TaoQuickApp/Qml/Page/AboutDialog.qml index 0eb9245..3ba5004 100644 --- a/src/TaoQuickApp/Qml/Page/AboutDialog.qml +++ b/src/TaoQuickApp/Qml/Page/AboutDialog.qml @@ -1,4 +1,4 @@ -import QtQuick 2.12 +import QtQuick 2.12 import QtQuick.Controls 2.12 import TaoQuick 1.0 @@ -54,7 +54,7 @@ Popup { Text { anchors.left: parent.left anchors.right: parent.right - text: appInfo.appName + " " + appInfo.appVersion + text: appInfo.appName + " " + appInfo.app font.pixelSize: 20 renderType: Text.NativeRendering diff --git a/src/TaoQuickApp/Qml/Page/MenuPage.qml b/src/TaoQuickApp/Qml/Page/MenuPage.qml index b112c8a..a931ffc 100644 --- a/src/TaoQuickApp/Qml/Page/MenuPage.qml +++ b/src/TaoQuickApp/Qml/Page/MenuPage.qml @@ -1,4 +1,4 @@ -import QtQuick 2.12 +import QtQuick 2.12 import QtQuick.Controls 2.12 import TaoQuick 1.0 import "qrc:/Tao/Qml" @@ -18,14 +18,15 @@ ListView { property var mainIndex: -1 property var subIndex: -1 Connections{ + target: view - onReTransed: { + function onReTransed() { var m = model.get(mainIndex) if (subIndex != -1) { var s = m.children.get(subIndex) - currentTitle = s.name + currentTitle = qsTranslate(s.name,s.name) } else { - currentTitle = m.name + currentTitle = qsTranslate(m.name,m.name) } } } @@ -41,14 +42,14 @@ ListView { id: btn width: root.width height: rowHeight - text: model.name + text: qsTranslate(model.name, model.name) textItem.leftPadding: 6 textHorizontalAlignment: Text.AlignLeft textColor: text === currentTitle ? gConfig.titleBackground : gConfig.textColor onClicked: { if (model.url) { - currentTitle = model.name + currentTitle = qsTranslate(model.name,model.name) currentUrl = model.url } else { if (!subListView.initOnce) { @@ -80,10 +81,10 @@ ListView { delegate: TGradientBtn { width: root.width height: rowHeight - text: model.name + text: qsTranslate(model.name, model.name) textColor: text === currentTitle ? gConfig.titleBackground : gConfig.textColor onClicked: { - currentTitle = model.name + currentTitle = qsTranslate(model.name,model.name) currentUrl = model.url subIndex = index } diff --git a/src/TaoQuickApp/Qml/Page/TitlePage.qml b/src/TaoQuickApp/Qml/Page/TitlePage.qml index 5f63ba8..9043a2a 100644 --- a/src/TaoQuickApp/Qml/Page/TitlePage.qml +++ b/src/TaoQuickApp/Qml/Page/TitlePage.qml @@ -173,7 +173,7 @@ Rectangle { width: langListView.width height: 36 text: modelData - color: containsMouse ? "lightgray" : pop.barColor + color: view.currentLang === modelData ? gConfig.titleBackground :( containsMouse ? "lightgray" : pop.barColor) onClicked: { pop.hide() view.reTrans(modelData) diff --git a/src/TaoQuickApp/Src/TaoView.cpp b/src/TaoQuickApp/Src/TaoView.cpp index 7b777eb..676252e 100644 --- a/src/TaoQuickApp/Src/TaoView.cpp +++ b/src/TaoQuickApp/Src/TaoView.cpp @@ -81,6 +81,7 @@ void TaoView::reTrans(const QString &lang) m_lang = lang; engine()->retranslate(); emit reTransed(); + emit currentLangChanged(); } void TaoView::loadPlugin(const QString &pluginPath) diff --git a/src/TaoQuickApp/Src/TaoView.h b/src/TaoQuickApp/Src/TaoView.h index bfc8d91..97f2e34 100644 --- a/src/TaoQuickApp/Src/TaoView.h +++ b/src/TaoQuickApp/Src/TaoView.h @@ -11,6 +11,7 @@ class TaoView : public QQuickView { Q_OBJECT Q_PROPERTY(QStringList languageList READ languageList NOTIFY languageListChanged) + Q_PROPERTY(QString currentLang READ currentLang NOTIFY currentLangChanged) public: explicit TaoView(QWindow *parent = nullptr); ~TaoView(); @@ -24,10 +25,15 @@ public: { return m_languageList; } + const QString ¤tLang() const + { + return m_lang; + } signals: void reTransed(); void languageListChanged(); void pluginReady(QString pluginInfo); + void currentLangChanged(); public slots: private: QString m_lang; diff --git a/src/TaoQuickApp/Src/main.cpp b/src/TaoQuickApp/Src/main.cpp index e9b0512..fa7efdc 100644 --- a/src/TaoQuickApp/Src/main.cpp +++ b/src/TaoQuickApp/Src/main.cpp @@ -1,4 +1,4 @@ -#include "TaoView.h" +#include "TaoView.h" #include "Logger/Logger.h" #include @@ -15,6 +15,8 @@ int main(int argc, char **argv) Logger::initLog(); TaoView view; + view.engine()->addImportPath(app.applicationDirPath()); + view.engine()->addPluginPath(app.applicationDirPath()); view.rootContext()->setContextProperty("view", &view); view.setSource(QUrl(QStringLiteral("qrc:/Qml/main.qml"))); view.moveToScreenCenter(); diff --git a/src/TaoQuickPlugin/Src/TaoQuickPlugin.cpp b/src/TaoQuickPlugin/Src/TaoQuickPlugin.cpp index 3177a37..eaed8e8 100644 --- a/src/TaoQuickPlugin/Src/TaoQuickPlugin.cpp +++ b/src/TaoQuickPlugin/Src/TaoQuickPlugin.cpp @@ -1,4 +1,4 @@ -#include "TaoQuickPlugin.h" +#include "TaoQuickPlugin.h" #include TaoQuickPlugin::TaoQuickPlugin(QObject *parent) : QObject (parent) { diff --git a/src/TaoQuickPlugin/TaoQuickPlugin.pro b/src/TaoQuickPlugin/TaoQuickPlugin.pro index 2b3e0a4..6df85f7 100644 --- a/src/TaoQuickPlugin/TaoQuickPlugin.pro +++ b/src/TaoQuickPlugin/TaoQuickPlugin.pro @@ -1,6 +1,7 @@ QT += core gui qml -TARGET = $$qtLibraryTarget(TaoQuickPlugin) +#TARGET = $$qtLibraryTarget(TaoQuickPlugin) +TARGET = TaoQuickPlugin TEMPLATE = lib CONFIG += plugin msvc {