This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework DeclarativePushButton into an extension class
- Loading branch information
Showing
6 changed files
with
138 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, [email protected] | ||
Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, [email protected] | ||
Author: Lova Widmark <[email protected]> | ||
Licensees holding valid commercial KDAB DeclarativeWidgets licenses may use this file in | ||
|
@@ -25,8 +25,9 @@ | |
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "declarativepushbutton_p.h" | ||
#include "declarativeabstractbuttonextension_p.h" | ||
|
||
DeclarativePushButton::DeclarativePushButton(QWidget *parent) : QPushButton(parent) | ||
DeclarativeAbstractButtonExtension::DeclarativeAbstractButtonExtension(QObject *parent) | ||
: DeclarativeWidgetExtension(parent) | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, [email protected] | ||
Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, [email protected] | ||
Author: Lova Widmark <[email protected]> | ||
Licensees holding valid commercial KDAB DeclarativeWidgets licenses may use this file in | ||
|
@@ -25,18 +25,17 @@ | |
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef DECLARATIVEPUSHBUTTON_P_H | ||
#define DECLARATIVEPUSHBUTTON_P_H | ||
#ifndef DECLARATIVEABSTRACTBUTTONEXTENSION_P_H | ||
#define DECLARATIVEABSTRACTBUTTONEXTENSION_P_H | ||
|
||
#include <QPushButton> | ||
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, [email protected] | ||
Author: Lova Widmark <[email protected]> | ||
Licensees holding valid commercial KDAB DeclarativeWidgets licenses may use this file in | ||
accordance with DeclarativeWidgets Commercial License Agreement provided with the Software. | ||
Contact [email protected] 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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "declarativepushbuttonextension_p.h" | ||
|
||
#include <QPushButton> | ||
|
||
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<QPushButton*>(extendedObject()); | ||
|
||
Q_ASSERT(pushButton); | ||
|
||
return pushButton; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, [email protected] | ||
Author: Lova Widmark <[email protected]> | ||
Licensees holding valid commercial KDAB DeclarativeWidgets licenses may use this file in | ||
accordance with DeclarativeWidgets Commercial License Agreement provided with the Software. | ||
Contact [email protected] 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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters