Optimize and use SVG images where possible (#281)

SVG images have been optimized with svgo, this will slightly reduce package size though the main reason for this was to remove unneeded markup.

Image paths have been changed and merged, now the directory tree looks like this:

img
├── app
├── material
│   ├── black
│   └── white
└── preview

The reason to merge the paths is to avoid duplicate files for buttons and configuration.

SVG icons are used by default now, PNG images have not been deleted from the images directory, but they were deleted from the graphics.qrc resource file.

All image paths were updated accordingly, except in the tray icon, I could not make it work using the SVG image.
This commit is contained in:
Alfredo Ramos
2018-07-23 17:43:01 -05:00
committed by Dharkael
parent 9748ae015e
commit d09580b873
219 changed files with 303 additions and 2300 deletions

View File

@@ -37,7 +37,7 @@ ConfigWindow::ConfigWindow(QWidget *parent) : QTabWidget(parent) {
setAttribute(Qt::WA_DeleteOnClose);
const int size = GlobalValues::buttonBaseSize() * 12;
setMinimumSize(size, size);
setWindowIcon(QIcon(":img/flameshot.png"));
setWindowIcon(QIcon(":img/app/flameshot.svg"));
setWindowTitle(tr("Configuration"));
auto changedSlot = [this](QString s){
@@ -59,17 +59,17 @@ ConfigWindow::ConfigWindow(QWidget *parent) : QTabWidget(parent) {
// visuals
m_visuals = new VisualsEditor();
addTab(m_visuals, QIcon(modifier + "graphics.png"),
addTab(m_visuals, QIcon(modifier + "graphics.svg"),
tr("Interface"));
// filename
m_filenameEditor = new FileNameEditor();
addTab(m_filenameEditor, QIcon(modifier + "name_edition.png"),
addTab(m_filenameEditor, QIcon(modifier + "name_edition.svg"),
tr("Filename Editor"));
// general
m_generalConfig = new GeneneralConf();
addTab(m_generalConfig, QIcon(modifier + "config.png"),
addTab(m_generalConfig, QIcon(modifier + "config.svg"),
tr("General"));
// connect update sigslots

View File

@@ -191,7 +191,7 @@ void Controller::enableTrayIcon() {
m_trayIcon = new QSystemTrayIcon();
m_trayIcon->setToolTip("Flameshot");
m_trayIcon->setContextMenu(trayIconMenu);
QIcon trayicon = QIcon::fromTheme("flameshot-tray", QIcon(":img/flameshot.png"));
QIcon trayicon = QIcon::fromTheme("flameshot-tray", QIcon(":img/app/flameshot.png"));
m_trayIcon->setIcon(trayicon);
auto trayIconActivated = [this](QSystemTrayIcon::ActivationReason r){

View File

@@ -74,7 +74,7 @@ ArrowTool::ArrowTool(QObject *parent) : AbstractTwoPointTool(parent) {
QIcon ArrowTool::icon(const QColor &background, bool inEditor) const {
Q_UNUSED(inEditor);
return QIcon(iconPath(background) + "arrow-bottom-left.png");
return QIcon(iconPath(background) + "arrow-bottom-left.svg");
}
QString ArrowTool::name() const {
return tr("Arrow");

View File

@@ -28,7 +28,7 @@ BlurTool::BlurTool(QObject *parent) : AbstractTwoPointTool(parent) {
QIcon BlurTool::icon(const QColor &background, bool inEditor) const {
Q_UNUSED(inEditor);
return QIcon(iconPath(background) + "blur.png");
return QIcon(iconPath(background) + "blur.svg");
}
QString BlurTool::name() const {
return tr("Blur");

View File

@@ -28,7 +28,7 @@ CircleTool::CircleTool(QObject *parent) : AbstractTwoPointTool(parent) {
QIcon CircleTool::icon(const QColor &background, bool inEditor) const {
Q_UNUSED(inEditor);
return QIcon(iconPath(background) + "circle-outline.png");
return QIcon(iconPath(background) + "circle-outline.svg");
}
QString CircleTool::name() const {
return tr("Circle");

View File

@@ -29,7 +29,7 @@ bool CopyTool::closeOnButtonPressed() const {
QIcon CopyTool::icon(const QColor &background, bool inEditor) const {
Q_UNUSED(inEditor);
return QIcon(iconPath(background) + "content-copy.png");
return QIcon(iconPath(background) + "content-copy.svg");
}
QString CopyTool::name() const {
return tr("Copy");

View File

@@ -28,7 +28,7 @@ bool ExitTool::closeOnButtonPressed() const {
QIcon ExitTool::icon(const QColor &background, bool inEditor) const {
Q_UNUSED(inEditor);
return QIcon(iconPath(background) + "close.png");
return QIcon(iconPath(background) + "close.svg");
}
QString ExitTool::name() const {
return tr("Exit");

View File

@@ -29,7 +29,7 @@ bool ImgurUploaderTool::closeOnButtonPressed() const {
QIcon ImgurUploaderTool::icon(const QColor &background, bool inEditor) const {
Q_UNUSED(inEditor);
return QIcon(iconPath(background) + "cloud-upload.png");
return QIcon(iconPath(background) + "cloud-upload.svg");
}
QString ImgurUploaderTool::name() const {
return tr("Image Uploader");

View File

@@ -28,7 +28,7 @@ bool AppLauncher::closeOnButtonPressed() const {
QIcon AppLauncher::icon(const QColor &background, bool inEditor) const {
Q_UNUSED(inEditor);
return QIcon(iconPath(background) + "open_with.png");
return QIcon(iconPath(background) + "open_with.svg");
}
QString AppLauncher::name() const {
return tr("App Launcher");

View File

@@ -52,7 +52,7 @@ AppLauncherWidget::AppLauncherWidget(const QPixmap &p, QWidget *parent):
QWidget(parent), m_pixmap(p)
{
setAttribute(Qt::WA_DeleteOnClose);
setWindowIcon(QIcon(":img/flameshot.png"));
setWindowIcon(QIcon(":img/app/flameshot.svg"));
setWindowTitle(tr("Open With"));
m_keepOpen = ConfigHandler().keepOpenAppLauncherValue();

View File

@@ -36,7 +36,7 @@ LineTool::LineTool(QObject *parent) : AbstractTwoPointTool(parent) {
QIcon LineTool::icon(const QColor &background, bool inEditor) const {
Q_UNUSED(inEditor);
return QIcon(iconPath(background) + "line.png");
return QIcon(iconPath(background) + "line.svg");
}
QString LineTool::name() const {
return tr("Line");

View File

@@ -36,7 +36,7 @@ MarkerTool::MarkerTool(QObject *parent) : AbstractTwoPointTool(parent) {
QIcon MarkerTool::icon(const QColor &background, bool inEditor) const {
Q_UNUSED(inEditor);
return QIcon(iconPath(background) + "marker.png");
return QIcon(iconPath(background) + "marker.svg");
}
QString MarkerTool::name() const {
return tr("Marker");

View File

@@ -28,7 +28,7 @@ bool MoveTool::closeOnButtonPressed() const {
QIcon MoveTool::icon(const QColor &background, bool inEditor) const {
Q_UNUSED(inEditor);
return QIcon(iconPath(background) + "cursor-move.png");
return QIcon(iconPath(background) + "cursor-move.svg");
}
QString MoveTool::name() const {
return tr("Move");

View File

@@ -24,7 +24,7 @@ PencilTool::PencilTool(QObject *parent) : AbstractPathTool(parent) {
QIcon PencilTool::icon(const QColor &background, bool inEditor) const {
Q_UNUSED(inEditor);
return QIcon(iconPath(background) + "pencil.png");
return QIcon(iconPath(background) + "pencil.svg");
}
QString PencilTool::name() const {
return tr("Pencil");

View File

@@ -28,7 +28,7 @@ bool PinTool::closeOnButtonPressed() const {
QIcon PinTool::icon(const QColor &background, bool inEditor) const {
Q_UNUSED(inEditor);
return QIcon(iconPath(background) + "pin.png");
return QIcon(iconPath(background) + "pin.svg");
}
QString PinTool::name() const {
return tr("Pin Tool");

View File

@@ -28,7 +28,7 @@ RectangleTool::RectangleTool(QObject *parent) : AbstractTwoPointTool(parent) {
QIcon RectangleTool::icon(const QColor &background, bool inEditor) const {
Q_UNUSED(inEditor);
return QIcon(iconPath(background) + "square.png");
return QIcon(iconPath(background) + "square.svg");
}
QString RectangleTool::name() const {
return tr("Rectangle");

View File

@@ -28,7 +28,7 @@ bool RedoTool::closeOnButtonPressed() const {
QIcon RedoTool::icon(const QColor &background, bool inEditor) const {
Q_UNUSED(inEditor);
return QIcon(iconPath(background) + "redo-variant.png");
return QIcon(iconPath(background) + "redo-variant.svg");
}
QString RedoTool::name() const {
return tr("Redo");

View File

@@ -29,7 +29,7 @@ bool SaveTool::closeOnButtonPressed() const {
QIcon SaveTool::icon(const QColor &background, bool inEditor) const {
Q_UNUSED(inEditor);
return QIcon(iconPath(background) + "content-save.png");
return QIcon(iconPath(background) + "content-save.svg");
}
QString SaveTool::name() const {
return tr("Save");

View File

@@ -32,7 +32,7 @@ bool SelectionTool::closeOnButtonPressed() const {
QIcon SelectionTool::icon(const QColor &background, bool inEditor) const {
Q_UNUSED(inEditor);
return QIcon(iconPath(background) + "square-outline.png");
return QIcon(iconPath(background) + "square-outline.svg");
}
QString SelectionTool::name() const {
return tr("Rectangular Selection");

View File

@@ -28,7 +28,7 @@ bool SizeIndicatorTool::closeOnButtonPressed() const {
QIcon SizeIndicatorTool::icon(const QColor &background, bool inEditor) const {
return inEditor ? QIcon() :
QIcon(iconPath(background) + "size_indicator.png");
QIcon(iconPath(background) + "size_indicator.svg");
}
QString SizeIndicatorTool::name() const {
return tr("Selection Size Indicator");

View File

@@ -38,32 +38,32 @@ TextConfig::TextConfig(QWidget *parent) : QWidget(parent) {
QColor bgColor(palette().background().color());
QString iconPrefix = ColorUtils::colorIsDark(bgColor) ?
PathInfo::whiteConfigIconPath() :
PathInfo::blackConfigIconPath();
PathInfo::whiteIconPath() :
PathInfo::blackIconPath();
m_strikeOutButton = new QPushButton(
QIcon(iconPrefix + "format_strikethrough.png"), "");
QIcon(iconPrefix + "format_strikethrough.svg"), "");
m_strikeOutButton->setCheckable(true);
connect(m_strikeOutButton, &QPushButton::clicked,
this, &TextConfig::fontStrikeOutChanged);
m_strikeOutButton->setToolTip(tr("StrikeOut"));
m_underlineButton = new QPushButton(
QIcon(iconPrefix + "format_underlined.png"), "");
QIcon(iconPrefix + "format_underlined.svg"), "");
m_underlineButton->setCheckable(true);
connect(m_underlineButton, &QPushButton::clicked,
this, &TextConfig::fontUnderlineChanged);
m_underlineButton->setToolTip(tr("Underline"));
m_weightButton = new QPushButton(
QIcon(iconPrefix + "format_bold.png"), "");
QIcon(iconPrefix + "format_bold.svg"), "");
m_weightButton->setCheckable(true);
connect(m_weightButton, &QPushButton::clicked,
this, &TextConfig::weightButtonPressed);
m_weightButton->setToolTip(tr("Bold"));
m_italicButton = new QPushButton(
QIcon(iconPrefix + "format_italic.png"), "");
QIcon(iconPrefix + "format_italic.svg"), "");
m_italicButton->setCheckable(true);
connect(m_italicButton, &QPushButton::clicked,
this, &TextConfig::fontItalicChanged);

View File

@@ -43,7 +43,7 @@ bool TextTool::showMousePreview() const {
QIcon TextTool::icon(const QColor &background, bool inEditor) const {
Q_UNUSED(inEditor);
return QIcon(iconPath(background) + "text.png");
return QIcon(iconPath(background) + "text.svg");
}
QString TextTool::name() const {

View File

@@ -28,7 +28,7 @@ bool UndoTool::closeOnButtonPressed() const {
QIcon UndoTool::icon(const QColor &background, bool inEditor) const {
Q_UNUSED(inEditor);
return QIcon(iconPath(background) + "undo-variant.png");
return QIcon(iconPath(background) + "undo-variant.svg");
}
QString UndoTool::name() const {
return tr("Undo");

View File

@@ -21,22 +21,13 @@
#include <QDir>
const QString PathInfo::whiteIconPath() {
return ":/img/buttonIconsWhite/";
return ":/img/material/white/";
}
const QString PathInfo::blackIconPath() {
return ":/img/buttonIconsBlack/";
return ":/img/material/black/";
}
const QString PathInfo::whiteConfigIconPath() {
return ":/img/configWhite/";
}
const QString PathInfo::blackConfigIconPath() {
return ":/img/configBlack/";
}
QStringList PathInfo::translationsPaths() {
QString binaryPath = QFileInfo(qApp->applicationDirPath())
.absoluteFilePath();

View File

@@ -25,10 +25,6 @@ const QString whiteIconPath();
const QString blackIconPath();
const QString whiteConfigIconPath();
const QString blackConfigIconPath();
QStringList translationsPaths();
} // namespace

View File

@@ -83,7 +83,7 @@ bool ScreenshotSaver::saveToFilesystemGUI(const QPixmap &capture) {
QMessageBox::Warning,
QObject::tr("Save Error"),
msg);
saveErrBox.setWindowIcon(QIcon(":img/flameshot.png"));
saveErrBox.setWindowIcon(QIcon(":img/app/flameshot.svg"));
saveErrBox.exec();
}
}

View File

@@ -27,7 +27,7 @@
InfoWindow::InfoWindow(QWidget *parent) : QWidget(parent) {
setAttribute(Qt::WA_DeleteOnClose);
setWindowIcon(QIcon(":img/flameshot.png"));
setWindowIcon(QIcon(":img/app/flameshot.svg"));
setWindowTitle(tr("About"));
m_layout = new QVBoxLayout(this);

View File

@@ -66,9 +66,9 @@ ColorPickerWidget::ColorPickerWidget(QPixmap *p, QWidget *parent) :
QColor background = this->palette().background().color();
bool isDark = ColorUtils::colorIsDark(background);
QString modifier = isDark ? PathInfo::whiteConfigIconPath() :
PathInfo::blackConfigIconPath();
QIcon grabIcon(modifier + "colorize.png");
QString modifier = isDark ? PathInfo::whiteIconPath() :
PathInfo::blackIconPath();
QIcon grabIcon(modifier + "colorize.svg");
m_colorGrabButton = new QPushButton(grabIcon, "");
updateGrabButton(false);
connect(m_colorGrabButton, &QPushButton::pressed,