Skip to content
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
126 changes: 0 additions & 126 deletions src/declarativeicon.cpp

This file was deleted.

82 changes: 82 additions & 0 deletions src/declarativeiconloader.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
declarativeiconloader.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: Kevin Krammer <[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 "declarativeiconloader_p.h"

DeclarativeIconLoader::DeclarativeIconLoader(QObject *parent)
: QObject(parent)
{
}

QString DeclarativeIconLoader::themeName() const
{
return QIcon::themeName();
}

void DeclarativeIconLoader::setThemeName(const QString &name)
{
if (name == QIcon::themeName())
return;

QIcon::setThemeName(name);

emit themeNameChanged(name);
}

QStringList DeclarativeIconLoader::themeSearchPaths() const
{
return QIcon::themeSearchPaths();
}

void DeclarativeIconLoader::setThemeSearchPaths(const QStringList &paths)
{
if (paths == QIcon::themeSearchPaths())
return;

QIcon::setThemeSearchPaths(paths);

emit themeSearchPathsChanged(paths);
}

QIcon DeclarativeIconLoader::fromTheme(const QString &name)
{
return QIcon::fromTheme(name);
}

QIcon DeclarativeIconLoader::fromFileName(const QString &fileName)
{
return QIcon(fileName);
}

QObject *DeclarativeIconLoader::instance(QQmlEngine *engine, QJSEngine *scriptEngine)
{
Q_UNUSED(engine);
Q_UNUSED(scriptEngine);

return new DeclarativeIconLoader();
}
69 changes: 21 additions & 48 deletions src/declarativeicon_p.h → src/declarativeiconloader_p.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/*
declarativeicon_p.h
declarativeiconloader_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]
Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, [email protected]
Author: Kevin Krammer <[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.
Expand All @@ -25,24 +26,26 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef DECLARATIVEICON_P_H
#define DECLARATIVEICON_P_H

#include <QtGlobal>
#ifndef DECLARATIVEICONLOADER_P_H
#define DECLARATIVEICONLOADER_P_H

#include <QIcon>
#include <QObject>
#include <qqml.h>
#include <QStringList>

class DeclarativeIconAttached : public QObject
QT_BEGIN_NAMESPACE
class QQmlEngine;
class QJSEngine;
QT_END_NAMESPACE

class DeclarativeIconLoader : public QObject
{
Q_OBJECT
Q_PROPERTY(QString themeName READ themeName WRITE setThemeName NOTIFY themeNameChanged)
Q_PROPERTY(QStringList themeSearchPaths READ themeSearchPaths WRITE setThemeSearchPaths NOTIFY themeSearchPathsChanged)
Q_OBJECT

public:
explicit DeclarativeIconAttached(QObject *parent = 0);
Q_PROPERTY(QString themeName READ themeName WRITE setThemeName NOTIFY themeNameChanged)
Q_PROPERTY(QStringList themeSearchPaths READ themeSearchPaths WRITE setThemeSearchPaths NOTIFY themeSearchPathsChanged)

public:
explicit DeclarativeIconLoader(QObject *parent = Q_NULLPTR);

QString themeName() const;
void setThemeName(const QString &name);
Expand All @@ -53,41 +56,11 @@ class DeclarativeIconAttached : public QObject
Q_INVOKABLE QIcon fromTheme(const QString &name);
Q_INVOKABLE QIcon fromFileName(const QString &fileName);

Q_SIGNALS:
static QObject *instance(QQmlEngine *engine, QJSEngine *scriptEngine);

Q_SIGNALS:
void themeNameChanged(const QString &themeName);
void themeSearchPathsChanged(const QStringList &themeSearchPaths);
};

class DeclarativeIcon : public QObject
{
Q_OBJECT
Q_PROPERTY(QIcon icon READ icon WRITE setIcon NOTIFY iconChanged)
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
Q_PROPERTY(bool isNull READ isNull NOTIFY isNullChanged)

public:
explicit DeclarativeIcon(QObject *parent = 0);
~DeclarativeIcon();

QIcon icon() const;
void setIcon(const QIcon &icon);

QString name() const;

bool isNull() const;

static DeclarativeIconAttached *qmlAttachedProperties(QObject *parent);

Q_SIGNALS:
void iconChanged(const QIcon &icon);
void nameChanged(const QString &name);
void isNullChanged(bool isNull);

private:
class Private;
Private *const d;
};

QML_DECLARE_TYPEINFO(DeclarativeIcon, QML_HAS_ATTACHED_PROPERTIES)

#endif // DECLARATIVEICON_P_H
#endif // DECLARATIVEICONLOADER_P_H
Loading