-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
1,173 additions
and
1,054 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
37 changes: 37 additions & 0 deletions
37
cntp-appicontool/platformgenerators/androidplatformicongenerator.cpp
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,37 @@ | ||
#include "androidplatformicongenerator.h" | ||
|
||
#include <QDir> | ||
#include <QImage> | ||
#include <QPainter> | ||
#include <QSize> | ||
#include <QSvgRenderer> | ||
|
||
AndroidPlatformIconGenerator::AndroidPlatformIconGenerator(QObject* parent) : | ||
PlatformIconGenerator{parent} { | ||
} | ||
|
||
void AndroidPlatformIconGenerator::renderPng(QString output, QSizeF size) { | ||
QImage image(size.toSize(), QImage::Format_ARGB32); | ||
image.fill(Qt::transparent); | ||
|
||
QPainter imagePainter(&image); | ||
|
||
QSvgRenderer renderer(inputSvg().toUtf8()); | ||
renderer.render(&imagePainter, QRect(QPoint(0, 0), size.toSize())); | ||
imagePainter.end(); | ||
|
||
image.save(output); | ||
} | ||
|
||
void AndroidPlatformIconGenerator::generateIcon() { | ||
QDir androidDir(outputFile()); | ||
QDir resDir(androidDir.absoluteFilePath("res")); | ||
|
||
QSizeF baseline{48, 48}; | ||
renderPng(resDir.absoluteFilePath("drawable-ldpi/icon.png"), baseline * 0.75); | ||
renderPng(resDir.absoluteFilePath("drawable-mdpi/icon.png"), baseline * 1); | ||
renderPng(resDir.absoluteFilePath("drawable-hdpi/icon.png"), baseline * 1.5); | ||
renderPng(resDir.absoluteFilePath("drawable-xhdpi/icon.png"), baseline * 2); | ||
renderPng(resDir.absoluteFilePath("drawable-xxhdpi/icon.png"), baseline * 3); | ||
renderPng(resDir.absoluteFilePath("drawable-xxxhdpi/icon.png"), baseline * 4); | ||
} |
21 changes: 21 additions & 0 deletions
21
cntp-appicontool/platformgenerators/androidplatformicongenerator.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,21 @@ | ||
#ifndef ANDROIDPLATFORMICONGENERATOR_H | ||
#define ANDROIDPLATFORMICONGENERATOR_H | ||
|
||
#include "platformicongenerator.h" | ||
|
||
class AndroidPlatformIconGenerator : public PlatformIconGenerator { | ||
Q_OBJECT | ||
public: | ||
explicit AndroidPlatformIconGenerator(QObject* parent = nullptr); | ||
|
||
signals: | ||
|
||
private: | ||
void renderPng(QString output, QSizeF size); | ||
|
||
// PlatformIconGenerator interface | ||
public: | ||
void generateIcon(); | ||
}; | ||
|
||
#endif // ANDROIDPLATFORMICONGENERATOR_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
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
Oops, something went wrong.