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 2 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
32 changes: 32 additions & 0 deletions src/declarativepushbutton.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
declarativepushbutton.cpp

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, [email protected]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change the date in the copyright notices to 2018 please?

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 "declarativepushbutton_p.h"

DeclarativePushButton::DeclarativePushButton(QWidget *parent) : QPushButton(parent)
{
}
42 changes: 42 additions & 0 deletions src/declarativepushbutton_p.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
declarativepushbutton_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, [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 DECLARATIVEPUSHBUTTON_P_H
#define DECLARATIVEPUSHBUTTON_P_H

#include <QPushButton>

class DeclarativePushButton : public QPushButton
{
Q_OBJECT
Q_PROPERTY(bool isDefault READ isDefault WRITE setDefault)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general all properties of classes exposed to QML should either be CONSTANT or NOTIFYable to properly work as inputs into property bindings.

The QML engine will issue warnings for them accordingly.

Obviously this is a problem with lots of widget properties, as they were not designed with that in mind and the classes are way older than QML itself.

The DeclarativeWidgetExtension fixes that for some of the main ones as good as it can, maybe we should consider a derived extension for QAbstractButton and then one for QPushButton derived from that, with the goal to ideally fix them in Qt itself at some point

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback. I will have a look at doing this.


public:
explicit DeclarativePushButton(QWidget *parent = 0);
};

#endif // DECLARATIVEPUSHBUTTON_P_H
3 changes: 2 additions & 1 deletion src/declarativewidgets_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
#include "scrollareawidgetcontainer_p.h"
#include "stackedwidgetwidgetcontainer_p.h"
#include "toolbarwidgetcontainer_p.h"
#include "declarativepushbutton_p.h"

#include <QButtonGroup>
#include <QCalendarWidget>
Expand Down Expand Up @@ -178,7 +179,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<DeclarativePushButton, DeclarativeWidgetExtension>(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
6 changes: 4 additions & 2 deletions src/src.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -135,4 +136,5 @@ SOURCES = \
scrollareawidgetcontainer.cpp \
stackedwidgetwidgetcontainer.cpp \
staticdialogmethodattached.cpp \
toolbarwidgetcontainer.cpp
toolbarwidgetcontainer.cpp \
declarativepushbutton.cpp