diff --git a/src/controls/AboutDialog.qml b/src/controls/AboutDialog.qml index b27dbc4..a5436ca 100644 --- a/src/controls/AboutDialog.qml +++ b/src/controls/AboutDialog.qml @@ -1,231 +1,231 @@ /* * Copyright 2018 Camilo Higuita * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.0 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 import org.kde.kirigami 2.7 as Kirigami import org.kde.mauikit 1.0 as Maui Maui.Dialog { - id: control - property string appName : Maui.App.name - property string appVersion : Maui.App.version - property string organizationName : Maui.App.org - property string organizationDomain : Maui.App.domain - property string appDescription : Maui.App.description - property string appLink: "www.maui-project.org" - property string appDonation: "" - property string appIcon: Maui.App.iconName - - defaultButtons: false - widthHint: 0.9 - heightHint: 0.8 - - maxWidth: unit * 400 - maxHeight: unit * 250 - - page.padding: space.small - - - footBar.middleContent: ToolButton - { - icon.name: "link" - onClicked: Maui.FM.openUrl(control.appLink) - - } - - footBar.rightContent: ToolButton - { - icon.name: "love" - onClicked: Maui.FM.openUrl(control.appDonation) - - } - - footBar.leftContent: ToolButton - { - icon.name: "documentinfo" - } - - RowLayout - { - id: layout - anchors.centerIn: parent - width: parent.width - height: parent.height * 0.7 - - - Item - { - Layout.fillHeight: true - Layout.margins: space.small - Layout.alignment: Qt.AlignHCenter | Qt.AlignTop - Layout.minimumWidth: iconSizes.huge - Layout.maximumWidth: iconSizes.huge - Layout.preferredWidth: iconSizes.huge - Layout.minimumHeight: iconSizes.huge - - clip: true - - Image - { - source: control.appIcon - width: iconSizes.huge - height: width - sourceSize.width: width - sourceSize.height: height - horizontalAlignment: Qt.AlignHCenter - asynchronous: true - - fillMode: Image.PreserveAspectFit - } - } - - Item - { - id: _descriptionItem - Layout.fillWidth: true - Layout.fillHeight: true - Layout.alignment: Qt.AlignLeft | Qt.AlignTop - ScrollView - { - anchors.fill: parent - - contentHeight: _columnInfo.implicitHeight - - padding: 0 - clip: true - - ColumnLayout - { - - id: _columnInfo - width: parent.width - spacing: 0 - Label - { - Layout.fillWidth: true - Layout.alignment: Qt.AlignLeft - clip: true - width: parent.width - height: parent.height - color: Kirigami.Theme.textColor - text: appName - font.weight: Font.Bold - font.bold: true - font.pointSize: fontSizes.huge - } - - Label - { - Layout.fillWidth: true - // Layout.preferredHeight: fontSizes.default - - Layout.alignment: Qt.AlignLeft - clip: true - - width: parent.width - height: parent.height - color: Qt.lighter(Kirigami.Theme.textColor, 1.2) - text: appVersion - font.pointSize: fontSizes.default - - } - - Label - { - id: body - // Layout.fillWidth: true - // Layout.fillHeight: true - Layout.preferredWidth:_descriptionItem.width - - padding: 0 - // placeholderText: qsTr("App description") - enabled: false - text: appDescription -// textFormat : TextEdit.AutoText - color: Kirigami.Theme.textColor - font.pointSize: fontSizes.default - wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere - - clip: true - // background: Rectangle - // { - // color: "transparent" - // } - } - - Kirigami.Separator - { - Layout.fillWidth: true - Layout.preferredHeight: 1 - Layout.alignment: Qt.AlignLeft - Layout.margins: space.big - opacity: 0.4 - } - - Label - { - color: Kirigami.Theme.textColor - Layout.preferredWidth:_descriptionItem.width - - text: qsTr("Built with MauiKit " + Maui.App.mauikitVersion + " and Kirigami." ) - font.pointSize: fontSizes.default - wrapMode: TextEdit.WrapAnywhere - - - } - } - - } - - } - - - - - - - // Item - // { - // Layout.fillWidth: true - // Layout.fillHeight: true - // Layout.row: 5 - // Layout.column: 2 - // Layout.margins: space.big - // Layout.alignment: Qt.AlignLeft | Qt.AlignTop - // - // Label - // { - // color: textColor - // width: parent.width - // height: parent.height - // - // text: "MauiKit " + app.mauikit + " Qt " +app.qt - // font.pointSize: fontSizes.default - // wrapMode: TextEdit.WrapAnywhere - // - // } - // } - - } - + id: control + property string appName : Maui.App.name + property string appVersion : Maui.App.version + property string organizationName : Maui.App.org + property string organizationDomain : Maui.App.domain + property string appDescription : Maui.App.description + property string appLink: "www.maui-project.org" + property string appDonation: "" + property string appIcon: Maui.App.iconName + + defaultButtons: false + widthHint: 0.9 + heightHint: 0.8 + + maxWidth: unit * 400 + maxHeight: unit * 250 + + page.padding: space.small + + + footBar.middleContent: ToolButton + { + icon.name: "link" + onClicked: Maui.FM.openUrl(control.appLink) + + } + + footBar.rightContent: ToolButton + { + icon.name: "love" + onClicked: Maui.FM.openUrl(control.appDonation) + + } + + footBar.leftContent: ToolButton + { + icon.name: "documentinfo" + } + + RowLayout + { + id: layout + anchors.centerIn: parent + width: parent.width + height: parent.height * 0.7 + + + Item + { + Layout.fillHeight: true + Layout.margins: space.small + Layout.alignment: Qt.AlignHCenter | Qt.AlignTop + Layout.minimumWidth: iconSizes.huge + Layout.maximumWidth: iconSizes.huge + Layout.preferredWidth: iconSizes.huge + Layout.minimumHeight: iconSizes.huge + + clip: true + + Image + { + source: control.appIcon + width: iconSizes.huge + height: width + sourceSize.width: width + sourceSize.height: height + horizontalAlignment: Qt.AlignHCenter + asynchronous: true + + fillMode: Image.PreserveAspectFit + } + } + + Item + { + id: _descriptionItem + Layout.fillWidth: true + Layout.fillHeight: true + Layout.alignment: Qt.AlignLeft | Qt.AlignTop + ScrollView + { + anchors.fill: parent + + contentHeight: _columnInfo.implicitHeight + + padding: 0 + clip: true + + ColumnLayout + { + + id: _columnInfo + width: parent.width + spacing: 0 + Label + { + Layout.fillWidth: true + Layout.alignment: Qt.AlignLeft + clip: true + width: parent.width + height: parent.height + color: Kirigami.Theme.textColor + text: appName + font.weight: Font.Bold + font.bold: true + font.pointSize: fontSizes.huge + } + + Label + { + Layout.fillWidth: true + // Layout.preferredHeight: fontSizes.default + + Layout.alignment: Qt.AlignLeft + clip: true + + width: parent.width + height: parent.height + color: Qt.lighter(Kirigami.Theme.textColor, 1.2) + text: appVersion + font.pointSize: fontSizes.default + + } + + Label + { + id: body + // Layout.fillWidth: true + // Layout.fillHeight: true + Layout.preferredWidth:_descriptionItem.width + + padding: 0 + // placeholderText: qsTr("App description") + enabled: false + text: appDescription + // textFormat : TextEdit.AutoText + color: Kirigami.Theme.textColor + font.pointSize: fontSizes.default + wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere + + clip: true + // background: Rectangle + // { + // color: "transparent" + // } + } + + Kirigami.Separator + { + Layout.fillWidth: true + Layout.preferredHeight: 1 + Layout.alignment: Qt.AlignLeft + Layout.margins: space.big + opacity: 0.4 + } + + Label + { + color: Kirigami.Theme.textColor + Layout.preferredWidth:_descriptionItem.width + + text: qsTr("Built with MauiKit " + Maui.App.mauikitVersion + " and Kirigami." ) + font.pointSize: fontSizes.default + wrapMode: TextEdit.WrapAnywhere + + + } + } + + } + + } + + + + + + + // Item + // { + // Layout.fillWidth: true + // Layout.fillHeight: true + // Layout.row: 5 + // Layout.column: 2 + // Layout.margins: space.big + // Layout.alignment: Qt.AlignLeft | Qt.AlignTop + // + // Label + // { + // color: textColor + // width: parent.width + // height: parent.height + // + // text: "MauiKit " + app.mauikit + " Qt " +app.qt + // font.pointSize: fontSizes.default + // wrapMode: TextEdit.WrapAnywhere + // + // } + // } + + } + } diff --git a/src/mauikit.cpp b/src/mauikit.cpp index 4f30d0a..0e8c4d2 100644 --- a/src/mauikit.cpp +++ b/src/mauikit.cpp @@ -1,179 +1,176 @@ /* * Copyright 2018 Camilo Higuita * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "mauikit.h" #include #include "fm.h" #include "fmh.h" #include "mauimodel.h" #include "mauilist.h" #include "placeslist.h" #include "fmlist.h" #include "pathlist.h" #include "tagsmodel.h" #include "tagslist.h" #include "storemodel.h" #include "storelist.h" #include "handy.h" #include "documenthandler.h" #include "mauiaccounts.h" #include "mauiapp.h" #ifdef Q_OS_ANDROID #include "mauiandroid.h" #else #include "mauikde.h" #endif #if defined Q_OS_ANDROID || defined APPIMAGE_PACKAGE #include #include #endif QUrl MauiKit::componentUrl(const QString &fileName) const { #ifdef MAUI_APP return QUrl(QStringLiteral("qrc:/maui/kit/") + fileName); #else return QUrl(resolveFileUrl(fileName)); #endif } void MauiKit::registerTypes(const char *uri) { Q_ASSERT(uri == QLatin1String("org.kde.mauikit")); qmlRegisterSingletonType(componentUrl(QStringLiteral("Style.qml")), uri, 1, 0, "Style"); qmlRegisterType(componentUrl(QStringLiteral("ToolBar.qml")), uri, 1, 0, "ToolBar"); qmlRegisterType(componentUrl(QStringLiteral("ApplicationWindow.qml")), uri, 1, 0, "ApplicationWindow"); qmlRegisterType(componentUrl(QStringLiteral("Page.qml")), uri, 1, 0, "Page"); qmlRegisterType(componentUrl(QStringLiteral("ShareDialog.qml")), uri, 1, 0, "ShareDialog"); qmlRegisterType(componentUrl(QStringLiteral("PieButton.qml")), uri, 1, 0, "PieButton"); qmlRegisterType(componentUrl(QStringLiteral("SideBar.qml")), uri, 1, 0, "SideBar"); qmlRegisterType(componentUrl(QStringLiteral("Holder.qml")), uri, 1, 0, "Holder"); qmlRegisterType(componentUrl(QStringLiteral("GlobalDrawer.qml")), uri, 1, 0, "GlobalDrawer"); qmlRegisterType(componentUrl(QStringLiteral("ListDelegate.qml")), uri, 1, 0, "ListDelegate"); qmlRegisterType(componentUrl(QStringLiteral("SelectionBar.qml")), uri, 1, 0, "SelectionBar"); qmlRegisterType(componentUrl(QStringLiteral("IconDelegate.qml")), uri, 1, 0, "IconDelegate"); qmlRegisterType(componentUrl(QStringLiteral("LabelDelegate.qml")), uri, 1, 0, "LabelDelegate"); qmlRegisterType(componentUrl(QStringLiteral("NewDialog.qml")), uri, 1, 0, "NewDialog"); qmlRegisterType(componentUrl(QStringLiteral("Dialog.qml")), uri, 1, 0, "Dialog"); qmlRegisterType(componentUrl(QStringLiteral("AboutDialog.qml")), uri, 1, 0, "AboutDialog"); qmlRegisterType(componentUrl(QStringLiteral("Popup.qml")), uri, 1, 0, "Popup"); qmlRegisterType(componentUrl(QStringLiteral("TextField.qml")), uri, 1, 0, "TextField"); qmlRegisterType(componentUrl(QStringLiteral("Badge.qml")), uri, 1, 0, "Badge"); qmlRegisterType(componentUrl(QStringLiteral("GridView.qml")), uri, 1, 0, "GridView"); qmlRegisterType(componentUrl(QStringLiteral("ColorsBar.qml")), uri, 1, 0, "ColorsBar"); qmlRegisterType(componentUrl(QStringLiteral("ImageViewer.qml")), uri, 1, 0, "ImageViewer"); /** STORE CONTROLS, MODELS AND INTERFACES **/ qmlRegisterType("StoreList", 1, 0, "StoreList"); qmlRegisterType("StoreModel", 1, 0, "StoreModel"); qmlRegisterType(componentUrl(QStringLiteral("private/StoreDelegate.qml")), uri, 1, 0, "StoreDelegate"); qmlRegisterType(componentUrl(QStringLiteral("Store.qml")), uri, 1, 0, "Store"); /** BROWSING CONTROLS **/ qmlRegisterType(componentUrl(QStringLiteral("ListBrowser.qml")), uri, 1, 0, "ListBrowser"); qmlRegisterType(componentUrl(QStringLiteral("GridBrowser.qml")), uri, 1, 0, "GridBrowser"); /** FM CONTROLS, MODELS AND INTERFACES **/ qmlRegisterType(uri, 1, 0, "PlacesList"); qmlRegisterType(uri, 1, 0, "FMList"); qmlRegisterType(uri, 1, 0, "PathList"); qmlRegisterSingletonType(uri, 1, 0, "FM", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject* { Q_UNUSED(engine) Q_UNUSED(scriptEngine) return new FM; }); // qmlRegisterSingletonType(componentUrl(QStringLiteral("private/FileBrowser.qml")), uri, 1, 0, "FileMenu"); qmlRegisterType(componentUrl(QStringLiteral("FileBrowser.qml")), uri, 1, 0, "FileBrowser"); qmlRegisterType(componentUrl(QStringLiteral("PlacesSidebar.qml")), uri, 1, 0, "PlacesSidebar"); qmlRegisterType(componentUrl(QStringLiteral("FilePreviewer.qml")), uri, 1, 0, "FilePreviewer"); qmlRegisterType(componentUrl(QStringLiteral("FileDialog.qml")), uri, 1, 0, "FileDialog"); qmlRegisterType(componentUrl(QStringLiteral("PathBar.qml")), uri, 1, 0, "PathBar"); qmlRegisterType(componentUrl(QStringLiteral("SyncDialog.qml")), uri, 1, 0, "SyncDialog"); //to be rename to accountsDialog /** EDITOR CONTROLS **/ qmlRegisterType("DocumentHandler", 1, 0, "DocumentHandler"); qmlRegisterType(componentUrl(QStringLiteral("Editor.qml")), uri, 1, 0, "Editor"); /** PLATFORMS SPECIFIC CONTROLS **/ #ifdef Q_OS_ANDROID qmlRegisterSingletonType(uri, 1, 0, "Android", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject* { Q_UNUSED(engine) Q_UNUSED(scriptEngine) return new MAUIAndroid; }); #else qmlRegisterType(componentUrl(QStringLiteral("Terminal.qml")), uri, 1, 0, "Terminal"); qmlRegisterSingletonType(uri, 1, 0, "KDE", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject* { Q_UNUSED(engine) Q_UNUSED(scriptEngine) return new MAUIKDE; }); #endif /** DATA MODELING TEMPLATED INTERFACES **/ qmlRegisterType(); //ABSTRACT BASE LIST qmlRegisterType(uri, 1, 0, "BaseModel"); //BASE MODEL /** TAGGING INTERFACES AND MODELS **/ qmlRegisterType("TagsList", 1, 0, "TagsList"); qmlRegisterType("TagsModel", 1, 0, "TagsModel"); qmlRegisterType(componentUrl(QStringLiteral("private/TagList.qml")), uri, 1, 0, "TagList"); qmlRegisterType(componentUrl(QStringLiteral("TagsBar.qml")), uri, 1, 0, "TagsBar"); qmlRegisterType(componentUrl(QStringLiteral("TagsDialog.qml")), uri, 1, 0, "TagsDialog"); /** MAUI APPLICATION SPECIFIC PROPS **/ qmlRegisterType(); - qmlRegisterSingletonType(uri, 1, 0, "App", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject* { - Q_UNUSED(engine) - Q_UNUSED(scriptEngine) - return MauiApp::instance(); - }); + qmlRegisterUncreatableType(uri, 1, 0, "App", "Cannot be created App"); /** HELPERS **/ + qmlRegisterSingletonType(uri, 1, 0, "Handy", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject* { Q_UNUSED(engine) Q_UNUSED(scriptEngine) return new Handy; }); #if defined Q_OS_ANDROID || defined APPIMAGE_PACKAGE QIcon::setThemeSearchPaths({":/icons/luv-icon-theme"}); QIcon::setThemeName("Luv"); QQuickStyle::setStyle(":/style"); #endif qmlProtectModule(uri, 1); } diff --git a/src/utils/mauiapp.cpp b/src/utils/mauiapp.cpp index dc04ea5..a7982ff 100644 --- a/src/utils/mauiapp.cpp +++ b/src/utils/mauiapp.cpp @@ -1,50 +1,58 @@ /* * * Copyright (C) 2019 camilo * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "mauiapp.h" #include "utils.h" #include "mauiaccounts.h" MauiApp::MauiApp(QObject *parent) : QObject(parent), m_accounts(new MauiAccounts(this)) { -// QObject::connect(UTIL::app, &QCoreApplication::aboutToQuit, []() -// { -// delete MauiApp::m_instance; -// }); + // QObject::connect(UTIL::app, &QCoreApplication::aboutToQuit, []() + // { + // delete MauiApp::m_instance; + // }); } MauiApp::~MauiApp() {} MauiApp * MauiApp::m_instance = nullptr; MauiApp * MauiApp::instance() { - if(MauiApp::m_instance == nullptr) - MauiApp::m_instance = new MauiApp(); - - return MauiApp::m_instance; + if(MauiApp::m_instance == nullptr) + MauiApp::m_instance = new MauiApp(); + + return MauiApp::m_instance; } - MauiAccounts * MauiApp::getAccounts() const { - return this->m_accounts; + return this->m_accounts; } +MauiApp * MauiApp::qmlAttachedProperties(QObject* object) +{ + if(MauiApp::m_instance == nullptr) + MauiApp::m_instance = new MauiApp(object); + + return MauiApp::m_instance; +} + + diff --git a/src/utils/mauiapp.h b/src/utils/mauiapp.h index b9428be..b618cf9 100644 --- a/src/utils/mauiapp.h +++ b/src/utils/mauiapp.h @@ -1,127 +1,134 @@ /* * * Copyright (C) 2019 camilo * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef MAUIAPP_H #define MAUIAPP_H #include +#include + #include "handy.h" #include "fmh.h" #ifndef STATIC_MAUIKIT #include "mauikit_export.h" #endif class MauiAccounts; #ifdef STATIC_MAUIKIT class MauiApp : public QObject #else class MAUIKIT_EXPORT MauiApp : public QObject #endif { Q_OBJECT Q_PROPERTY(QString name READ getName CONSTANT) Q_PROPERTY(QString version READ getVersion CONSTANT) Q_PROPERTY(QString org READ getOrg CONSTANT) Q_PROPERTY(QString domain READ getDomain CONSTANT) Q_PROPERTY(QString iconName READ getIconName WRITE setIconName NOTIFY iconNameChanged) Q_PROPERTY(QString description READ getDescription WRITE setDescription NOTIFY descriptionChanged) Q_PROPERTY(QString mauikitVersion READ getMauikitVersion CONSTANT) Q_PROPERTY(QString qtVersion READ getQtVersion CONSTANT) Q_PROPERTY(MauiAccounts * accounts READ getAccounts CONSTANT FINAL) -public: +public: + static MauiApp *qmlAttachedProperties(QObject *object); + static MauiApp *instance(); static QString getName() { return Handy::appInfo().value(FMH::MODEL_NAME[FMH::MODEL_KEY::NAME]).toString(); } static QString getVersion() { return Handy::appInfo().value(FMH::MODEL_NAME[FMH::MODEL_KEY::VERSION]).toString(); } static QString getOrg() { return Handy::appInfo().value(FMH::MODEL_NAME[FMH::MODEL_KEY::ORG]).toString(); } static QString getDomain() { return Handy::appInfo().value(FMH::MODEL_NAME[FMH::MODEL_KEY::DOMAIN]).toString(); } static QString getMauikitVersion() { return Handy::appInfo().value("mauikit_version").toString(); } static QString getQtVersion() { return Handy::appInfo().value("qt_version").toString(); } QString getDescription() const { return description; } void setDescription(const QString &value) { if(description == value) return; description = value; emit this->descriptionChanged(description); } QString getIconName() const { return iconName; } void setIconName(const QString &value) { if(iconName == value) return; iconName = value; emit this->iconNameChanged(iconName); } MauiAccounts *getAccounts() const; ~MauiApp(); private: static MauiApp *m_instance; MauiApp(QObject *parent = nullptr); MauiApp(const MauiApp &other) = delete; MauiAccounts *m_accounts; QString description; QString iconName; signals: void iconNameChanged(QString iconName); void descriptionChanged(QString description); }; + +QML_DECLARE_TYPEINFO(MauiApp, QML_HAS_ATTACHED_PROPERTIES) + #endif // MAUIAPP_H