From 2d7551ba490ab4b9d449c4f090fadd29fa39faac Mon Sep 17 00:00:00 2001 From: Znurre Date: Sun, 18 Feb 2018 20:29:22 +0100 Subject: [PATCH 1/4] Alias QPushButton::default to QPushButton::isDefault --- src/declarativepushbutton.cpp | 32 +++++++++++++++++++++++ src/declarativepushbutton_p.h | 42 +++++++++++++++++++++++++++++++ src/declarativewidgets_plugin.cpp | 3 ++- src/src.pro | 6 +++-- 4 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 src/declarativepushbutton.cpp create mode 100644 src/declarativepushbutton_p.h diff --git a/src/declarativepushbutton.cpp b/src/declarativepushbutton.cpp new file mode 100644 index 0000000..74e5cea --- /dev/null +++ b/src/declarativepushbutton.cpp @@ -0,0 +1,32 @@ +/* + declarativeloaderwidget_p.h + + This file is part of DeclarativeWidgets, library and tools for creating QtWidget UIs with QML. + + Copyright (C) 2013-2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Lova Widmark + + Licensees holding valid commercial KDAB DeclarativeWidgets licenses may use this file in + accordance with DeclarativeWidgets Commercial License Agreement provided with the Software. + + Contact info@kdab.com if any conditions of this licensing are not clear to you. + + 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 2 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 "declarativepushbutton_p.h" + +DeclarativePushButton::DeclarativePushButton(QWidget *parent) : QPushButton(parent) +{ +} diff --git a/src/declarativepushbutton_p.h b/src/declarativepushbutton_p.h new file mode 100644 index 0000000..0714ed6 --- /dev/null +++ b/src/declarativepushbutton_p.h @@ -0,0 +1,42 @@ +/* + declarativeloaderwidget_p.h + + This file is part of DeclarativeWidgets, library and tools for creating QtWidget UIs with QML. + + Copyright (C) 2013-2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Lova Widmark + + Licensees holding valid commercial KDAB DeclarativeWidgets licenses may use this file in + accordance with DeclarativeWidgets Commercial License Agreement provided with the Software. + + Contact info@kdab.com if any conditions of this licensing are not clear to you. + + 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 2 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 DECLARATIVEPUSHBUTTON_P_H +#define DECLARATIVEPUSHBUTTON_P_H + +#include + +class DeclarativePushButton : public QPushButton +{ + Q_OBJECT + Q_PROPERTY(bool isDefault READ isDefault WRITE setDefault) + + public: + explicit DeclarativePushButton(QWidget *parent = 0); +}; + +#endif // DECLARATIVEPUSHBUTTON_P_H diff --git a/src/declarativewidgets_plugin.cpp b/src/declarativewidgets_plugin.cpp index 02a7be2..9a05a08 100644 --- a/src/declarativewidgets_plugin.cpp +++ b/src/declarativewidgets_plugin.cpp @@ -68,6 +68,7 @@ #include "scrollareawidgetcontainer_p.h" #include "stackedwidgetwidgetcontainer_p.h" #include "toolbarwidgetcontainer_p.h" +#include "declarativepushbutton_p.h" #include #include @@ -178,7 +179,7 @@ void ExtensionpluginPlugin::registerTypes(const char *uri) qmlRegisterExtendedType(uri, 1, 0, "MessageBox"); qmlRegisterExtendedType(uri, 1, 0, "PlainTextEdit"); qmlRegisterExtendedType(uri, 1, 0, "ProgressBar"); - qmlRegisterExtendedType(uri, 1, 0, "PushButton"); + qmlRegisterExtendedType(uri, 1, 0, "PushButton"); qmlRegisterExtendedType(uri, 1, 0, "RadioButton"); qmlRegisterExtendedType >(uri, 1, 0, "ScrollArea"); qmlRegisterExtendedType(uri, 1, 0, "ScrollBar"); diff --git a/src/src.pro b/src/src.pro index d8c0224..0e93feb 100644 --- a/src/src.pro +++ b/src/src.pro @@ -85,7 +85,8 @@ HEADERS = \ stackedwidgetwidgetcontainer_p.h \ staticdialogmethodattached_p.h \ toolbarwidgetcontainer_p.h \ - widgetcontainerinterface_p.h + widgetcontainerinterface_p.h \ + declarativepushbutton_p.h SOURCES = \ abstractdeclarativeobject.cpp \ @@ -135,4 +136,5 @@ SOURCES = \ scrollareawidgetcontainer.cpp \ stackedwidgetwidgetcontainer.cpp \ staticdialogmethodattached.cpp \ - toolbarwidgetcontainer.cpp + toolbarwidgetcontainer.cpp \ + declarativepushbutton.cpp From 4f4b99dada3370319a10afc3de3ef8b33aa0249a Mon Sep 17 00:00:00 2001 From: Znurre Date: Mon, 19 Feb 2018 21:21:29 +0100 Subject: [PATCH 2/4] Fix copyright header --- src/declarativepushbutton.cpp | 2 +- src/declarativepushbutton_p.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/declarativepushbutton.cpp b/src/declarativepushbutton.cpp index 74e5cea..7ab95fa 100644 --- a/src/declarativepushbutton.cpp +++ b/src/declarativepushbutton.cpp @@ -1,5 +1,5 @@ /* - declarativeloaderwidget_p.h + declarativepushbutton.cpp This file is part of DeclarativeWidgets, library and tools for creating QtWidget UIs with QML. diff --git a/src/declarativepushbutton_p.h b/src/declarativepushbutton_p.h index 0714ed6..84be315 100644 --- a/src/declarativepushbutton_p.h +++ b/src/declarativepushbutton_p.h @@ -1,5 +1,5 @@ /* - declarativeloaderwidget_p.h + declarativepushbutton_p.h This file is part of DeclarativeWidgets, library and tools for creating QtWidget UIs with QML. From ae1d0ee7d6b4a5516288bc040d777fde481b4c39 Mon Sep 17 00:00:00 2001 From: Znurre Date: Mon, 26 Mar 2018 12:08:28 +0200 Subject: [PATCH 3/4] Changed year in copyright header --- src/declarativepushbutton.cpp | 2 +- src/declarativepushbutton_p.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/declarativepushbutton.cpp b/src/declarativepushbutton.cpp index 7ab95fa..e99cf5e 100644 --- a/src/declarativepushbutton.cpp +++ b/src/declarativepushbutton.cpp @@ -3,7 +3,7 @@ This file is part of DeclarativeWidgets, library and tools for creating QtWidget UIs with QML. - Copyright (C) 2013-2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Copyright (C) 2013-2018 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com Author: Lova Widmark Licensees holding valid commercial KDAB DeclarativeWidgets licenses may use this file in diff --git a/src/declarativepushbutton_p.h b/src/declarativepushbutton_p.h index 84be315..a33a66f 100644 --- a/src/declarativepushbutton_p.h +++ b/src/declarativepushbutton_p.h @@ -3,7 +3,7 @@ This file is part of DeclarativeWidgets, library and tools for creating QtWidget UIs with QML. - Copyright (C) 2013-2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Copyright (C) 2013-2018 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com Author: Lova Widmark Licensees holding valid commercial KDAB DeclarativeWidgets licenses may use this file in From 5739971c1a29c5b2e602d6c42ffa2e7cc10c03c3 Mon Sep 17 00:00:00 2001 From: Znurre Date: Thu, 29 Mar 2018 17:29:39 +0200 Subject: [PATCH 4/4] Rework DeclarativePushButton into an extension class --- ...=> declarativeabstractbuttonextension.cpp} | 9 +-- ...=> declarativeabstractbuttonextension_p.h} | 21 +++---- src/declarativepushbuttonextension.cpp | 61 +++++++++++++++++++ src/declarativepushbuttonextension_p.h | 56 +++++++++++++++++ src/declarativewidgets_plugin.cpp | 4 +- src/src.pro | 6 +- 6 files changed, 138 insertions(+), 19 deletions(-) rename src/{declarativepushbutton.cpp => declarativeabstractbuttonextension.cpp} (77%) rename src/{declarativepushbutton_p.h => declarativeabstractbuttonextension_p.h} (68%) create mode 100644 src/declarativepushbuttonextension.cpp create mode 100644 src/declarativepushbuttonextension_p.h diff --git a/src/declarativepushbutton.cpp b/src/declarativeabstractbuttonextension.cpp similarity index 77% rename from src/declarativepushbutton.cpp rename to src/declarativeabstractbuttonextension.cpp index e99cf5e..195cbb2 100644 --- a/src/declarativepushbutton.cpp +++ b/src/declarativeabstractbuttonextension.cpp @@ -1,9 +1,9 @@ /* - declarativepushbutton.cpp + declarativeabstractbuttonextension.cpp This file is part of DeclarativeWidgets, library and tools for creating QtWidget UIs with QML. - Copyright (C) 2013-2018 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com Author: Lova Widmark Licensees holding valid commercial KDAB DeclarativeWidgets licenses may use this file in @@ -25,8 +25,9 @@ along with this program. If not, see . */ -#include "declarativepushbutton_p.h" +#include "declarativeabstractbuttonextension_p.h" -DeclarativePushButton::DeclarativePushButton(QWidget *parent) : QPushButton(parent) +DeclarativeAbstractButtonExtension::DeclarativeAbstractButtonExtension(QObject *parent) + : DeclarativeWidgetExtension(parent) { } diff --git a/src/declarativepushbutton_p.h b/src/declarativeabstractbuttonextension_p.h similarity index 68% rename from src/declarativepushbutton_p.h rename to src/declarativeabstractbuttonextension_p.h index a33a66f..5177d33 100644 --- a/src/declarativepushbutton_p.h +++ b/src/declarativeabstractbuttonextension_p.h @@ -1,9 +1,9 @@ /* - declarativepushbutton_p.h + declarativeabstractbuttonextension_p.h This file is part of DeclarativeWidgets, library and tools for creating QtWidget UIs with QML. - Copyright (C) 2013-2018 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com Author: Lova Widmark Licensees holding valid commercial KDAB DeclarativeWidgets licenses may use this file in @@ -25,18 +25,17 @@ along with this program. If not, see . */ -#ifndef DECLARATIVEPUSHBUTTON_P_H -#define DECLARATIVEPUSHBUTTON_P_H +#ifndef DECLARATIVEABSTRACTBUTTONEXTENSION_P_H +#define DECLARATIVEABSTRACTBUTTONEXTENSION_P_H -#include +#include "declarativewidgetextension.h" -class DeclarativePushButton : public QPushButton +class DeclarativeAbstractButtonExtension : public DeclarativeWidgetExtension { - Q_OBJECT - Q_PROPERTY(bool isDefault READ isDefault WRITE setDefault) + Q_OBJECT - public: - explicit DeclarativePushButton(QWidget *parent = 0); +public: + explicit DeclarativeAbstractButtonExtension(QObject *parent = Q_NULLPTR); }; -#endif // DECLARATIVEPUSHBUTTON_P_H +#endif // DECLARATIVEABSTRACTBUTTONEXTENSION_P_H diff --git a/src/declarativepushbuttonextension.cpp b/src/declarativepushbuttonextension.cpp new file mode 100644 index 0000000..25a6132 --- /dev/null +++ b/src/declarativepushbuttonextension.cpp @@ -0,0 +1,61 @@ +/* + declarativepushbuttonextension.cpp + + This file is part of DeclarativeWidgets, library and tools for creating QtWidget UIs with QML. + + Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Lova Widmark + + Licensees holding valid commercial KDAB DeclarativeWidgets licenses may use this file in + accordance with DeclarativeWidgets Commercial License Agreement provided with the Software. + + Contact info@kdab.com if any conditions of this licensing are not clear to you. + + 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 2 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 "declarativepushbuttonextension_p.h" + +#include + +DeclarativePushButtonExtension::DeclarativePushButtonExtension(QObject *parent) + : DeclarativeAbstractButtonExtension(parent) +{ +} + +bool DeclarativePushButtonExtension::isDefault() const +{ + return pushButton()->isDefault(); +} + +void DeclarativePushButtonExtension::setIsDefault(bool isDefault) +{ + QPushButton *button = pushButton(); + + if (button->isDefault() == isDefault) + return; + + button->setDefault(isDefault); + + emit isDefaultChanged(); +} + +QPushButton *DeclarativePushButtonExtension::pushButton() const +{ + QPushButton *pushButton = qobject_cast(extendedObject()); + + Q_ASSERT(pushButton); + + return pushButton; +} diff --git a/src/declarativepushbuttonextension_p.h b/src/declarativepushbuttonextension_p.h new file mode 100644 index 0000000..d2f566e --- /dev/null +++ b/src/declarativepushbuttonextension_p.h @@ -0,0 +1,56 @@ +/* + declarativepushbuttonextension_p.h + + This file is part of DeclarativeWidgets, library and tools for creating QtWidget UIs with QML. + + Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Lova Widmark + + Licensees holding valid commercial KDAB DeclarativeWidgets licenses may use this file in + accordance with DeclarativeWidgets Commercial License Agreement provided with the Software. + + Contact info@kdab.com if any conditions of this licensing are not clear to you. + + 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 2 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 DECLARATIVEPUSHBUTTONEXTENSION_P_H +#define DECLARATIVEPUSHBUTTONEXTENSION_P_H + +#include "declarativeabstractbuttonextension_p.h" + +QT_BEGIN_NAMESPACE +class QPushButton; +QT_END_NAMESPACE + +class DeclarativePushButtonExtension : public DeclarativeAbstractButtonExtension +{ + Q_OBJECT + + Q_PROPERTY(bool isDefault READ isDefault WRITE setIsDefault NOTIFY isDefaultChanged) + +public: + explicit DeclarativePushButtonExtension(QObject *parent = Q_NULLPTR); + + bool isDefault() const; + void setIsDefault(bool isDefault); + +Q_SIGNALS: + void isDefaultChanged(); + +private: + QPushButton *pushButton() const; +}; + +#endif // DECLARATIVEPUSHBUTTONEXTENSION_P_H diff --git a/src/declarativewidgets_plugin.cpp b/src/declarativewidgets_plugin.cpp index 1202222..f8bc35d 100644 --- a/src/declarativewidgets_plugin.cpp +++ b/src/declarativewidgets_plugin.cpp @@ -48,6 +48,7 @@ #include "declarativeline_p.h" #include "declarativeloaderwidget_p.h" #include "declarativemessagebox_p.h" +#include "declarativepushbuttonextension_p.h" #include "declarativeqmlcontext_p.h" #include "declarativequickwidgetextension_p.h" #include "declarativeseparator_p.h" @@ -69,7 +70,6 @@ #include "scrollareawidgetcontainer_p.h" #include "stackedwidgetwidgetcontainer_p.h" #include "toolbarwidgetcontainer_p.h" -#include "declarativepushbutton_p.h" #include #include @@ -182,7 +182,7 @@ void ExtensionpluginPlugin::registerTypes(const char *uri) qmlRegisterExtendedType(uri, 1, 0, "MessageBox"); qmlRegisterExtendedType(uri, 1, 0, "PlainTextEdit"); qmlRegisterExtendedType(uri, 1, 0, "ProgressBar"); - qmlRegisterExtendedType(uri, 1, 0, "PushButton"); + qmlRegisterExtendedType(uri, 1, 0, "PushButton"); qmlRegisterExtendedType(uri, 1, 0, "RadioButton"); qmlRegisterExtendedType >(uri, 1, 0, "ScrollArea"); qmlRegisterExtendedType(uri, 1, 0, "ScrollBar"); diff --git a/src/src.pro b/src/src.pro index 015f00a..dc8b562 100644 --- a/src/src.pro +++ b/src/src.pro @@ -87,7 +87,8 @@ HEADERS = \ toolbarwidgetcontainer_p.h \ widgetcontainerinterface_p.h \ declarativesizepolicy_p.h \ - declarativepushbutton_p.h + declarativeabstractbuttonextension_p.h \ + declarativepushbuttonextension_p.h SOURCES = \ abstractdeclarativeobject.cpp \ @@ -139,4 +140,5 @@ SOURCES = \ staticdialogmethodattached.cpp \ toolbarwidgetcontainer.cpp \ declarativesizepolicy.cpp \ - declarativepushbutton.cpp + declarativeabstractbuttonextension.cpp \ + declarativepushbuttonextension.cpp