Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Alias QPushButton::default to QPushButton::isDefault #13

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/declarativeabstractbuttonextension.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
declarativeabstractbuttonextension.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 <znurree@gmail.com>

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 <http://www.gnu.org/licenses/>.
*/

#include "declarativeabstractbuttonextension_p.h"

DeclarativeAbstractButtonExtension::DeclarativeAbstractButtonExtension(QObject *parent)
: DeclarativeWidgetExtension(parent)
{
}
41 changes: 41 additions & 0 deletions src/declarativeabstractbuttonextension_p.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
declarativeabstractbuttonextension_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 <znurree@gmail.com>

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 <http://www.gnu.org/licenses/>.
*/

#ifndef DECLARATIVEABSTRACTBUTTONEXTENSION_P_H
#define DECLARATIVEABSTRACTBUTTONEXTENSION_P_H

#include "declarativewidgetextension.h"

class DeclarativeAbstractButtonExtension : public DeclarativeWidgetExtension
{
Q_OBJECT

public:
explicit DeclarativeAbstractButtonExtension(QObject *parent = Q_NULLPTR);
};

#endif // DECLARATIVEABSTRACTBUTTONEXTENSION_P_H
61 changes: 61 additions & 0 deletions src/declarativepushbuttonextension.cpp
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, info@kdab.com
Author: Lova Widmark <znurree@gmail.com>

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 <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;
}
56 changes: 56 additions & 0 deletions src/declarativepushbuttonextension_p.h
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, info@kdab.com
Author: Lova Widmark <znurree@gmail.com>

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 <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
3 changes: 2 additions & 1 deletion src/declarativewidgets_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include "declarativeloaderwidget_p.h"
#include "declarativemessagebox_p.h"
#include "declarativepixmap_p.h"
#include "declarativepushbuttonextension_p.h"
#include "declarativeqmlcontext_p.h"
#include "declarativequickwidgetextension_p.h"
#include "declarativeseparator_p.h"
Expand Down Expand Up @@ -185,7 +186,7 @@ void ExtensionpluginPlugin::registerTypes(const char *uri)
qmlRegisterExtendedType<DeclarativeMessageBox, DeclarativeWidgetExtension>(uri, 1, 0, "MessageBox");
qmlRegisterExtendedType<QPlainTextEdit, DeclarativeWidgetExtension>(uri, 1, 0, "PlainTextEdit");
qmlRegisterExtendedType<QProgressBar, DeclarativeWidgetExtension>(uri, 1, 0, "ProgressBar");
qmlRegisterExtendedType<QPushButton, DeclarativeWidgetExtension>(uri, 1, 0, "PushButton");
qmlRegisterExtendedType<QPushButton, DeclarativePushButtonExtension>(uri, 1, 0, "PushButton");
qmlRegisterExtendedType<QRadioButton, DeclarativeWidgetExtension>(uri, 1, 0, "RadioButton");
qmlRegisterExtendedType<QScrollArea, DeclarativeContainerWidgetExtension<ScrollAreaWidgetContainer> >(uri, 1, 0, "ScrollArea");
qmlRegisterExtendedType<QScrollBar, DeclarativeWidgetExtension>(uri, 1, 0, "ScrollBar");
Expand Down
8 changes: 6 additions & 2 deletions src/src.pro
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ HEADERS = \
staticdialogmethodattached_p.h \
toolbarwidgetcontainer_p.h \
widgetcontainerinterface_p.h \
declarativesizepolicy_p.h
declarativesizepolicy_p.h \
declarativeabstractbuttonextension_p.h \
declarativepushbuttonextension_p.h

SOURCES = \
abstractdeclarativeobject.cpp \
Expand Down Expand Up @@ -137,4 +139,6 @@ SOURCES = \
stackedwidgetwidgetcontainer.cpp \
staticdialogmethodattached.cpp \
toolbarwidgetcontainer.cpp \
declarativesizepolicy.cpp
declarativesizepolicy.cpp \
declarativeabstractbuttonextension.cpp \
declarativepushbuttonextension.cpp