-
Notifications
You must be signed in to change notification settings - Fork 475
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] Use image provider to load icons
Not implemented AwesomeIcons Some improvements can be made in properties like "name" and "source" to make the code even simpler
- Loading branch information
Showing
11 changed files
with
88 additions
and
52 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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* QML Material - An application framework implementing Material Design. | ||
* Copyright (C) 2015 Ricardo Vieira <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation, either version 2.1 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 Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include <qqmlextensionplugin.h> | ||
|
||
#include <qqmlengine.h> | ||
#include <qquickimageprovider.h> | ||
#include <QImage> | ||
#include <QPainter> | ||
|
||
class MaterialIconProvider : public QQuickImageProvider | ||
{ | ||
public: | ||
MaterialIconProvider() | ||
: QQuickImageProvider(QQuickImageProvider::Pixmap) | ||
{ | ||
} | ||
|
||
QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) | ||
{ | ||
int width = 100; | ||
int height = 50; | ||
QImage icon = QImage("/lib/qt/qml/Material/icons/" + id + ".svg"); | ||
|
||
if (size) | ||
*size = QSize(width, height); | ||
|
||
return QPixmap::fromImage(icon); | ||
} | ||
}; | ||
|
||
class ImageProviderExtensionPlugin : public QQmlExtensionPlugin | ||
{ | ||
Q_OBJECT | ||
Q_PLUGIN_METADATA(IID "Material") | ||
public: | ||
void registerTypes(const char *uri) | ||
{ | ||
Q_UNUSED(uri); | ||
} | ||
|
||
void initializeEngine(QQmlEngine *engine, const char *uri) | ||
{ | ||
Q_UNUSED(uri); | ||
engine->addImageProvider("material", new MaterialIconProvider); | ||
} | ||
|
||
}; | ||
|
||
#include "materialiconprovider.moc" |
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,10 @@ | ||
TEMPLATE = lib | ||
CONFIG += plugin | ||
QT += qml quick | ||
|
||
TARGET = materialiconprovider | ||
|
||
SOURCES += materialiconprovider.cpp | ||
|
||
target.path = $$[QT_INSTALL_QML]/Material | ||
INSTALLS = target |
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,4 +1,4 @@ | ||
TEMPLATE = subdirs | ||
SUBDIRS = modules/Material modules/Material/Extras modules/QtQuick/Controls/Styles/Material tests | ||
SUBDIRS = modules/Material modules/Material/Extras modules/QtQuick/Controls/Styles/Material plugins tests | ||
|
||
OTHER_FILES = README.md CHANGELOG.md |
6e8f92d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Start using some CPP code in material project now? Would you consider adding more cpp code in this project?
6e8f92d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SunRain Yep, see #359.