From 7965f73b64018bbac155c4e2c3208350dae69954 Mon Sep 17 00:00:00 2001
From: Aqua-sama
Date: Fri, 6 Nov 2020 20:44:12 +0200
Subject: Remove data/resources.qrc
---
Kconfig | 3 --
data/poi.ico | Bin 45842 -> 0 bytes
data/poi_window.svg | 7 ++++
data/resources.qrc | 5 ---
data/windows.rc | 1 -
src/about/aboutdialog.cpp | 17 ++------
src/browser.cpp | 6 +--
src/meson.build | 13 +++---
src/util.h | 98 ++++++++++++++++++++++++++++------------------
subprojects/rcc.wrap | 8 ++--
windows/icon.rc | 1 +
windows/poi.ico | Bin 0 -> 45842 bytes
12 files changed, 86 insertions(+), 73 deletions(-)
delete mode 100644 data/poi.ico
create mode 100644 data/poi_window.svg
delete mode 100644 data/resources.qrc
delete mode 100644 data/windows.rc
create mode 100644 windows/icon.rc
create mode 100644 windows/poi.ico
diff --git a/Kconfig b/Kconfig
index 8a2f934..5567816 100644
--- a/Kconfig
+++ b/Kconfig
@@ -2,9 +2,6 @@ menu "Application"
config POI_NAME
string "Application name"
default "smolbote"
- config POI_ICON
- string "Path to icon"
- default ":/icons/poi.svg"
config POI_CFG_PATH
string "Configuration location"
default "~/.config/smolbote/smolbote.cfg"
diff --git a/data/poi.ico b/data/poi.ico
deleted file mode 100644
index 69d15e2..0000000
Binary files a/data/poi.ico and /dev/null differ
diff --git a/data/poi_window.svg b/data/poi_window.svg
new file mode 100644
index 0000000..a348cab
--- /dev/null
+++ b/data/poi_window.svg
@@ -0,0 +1,7 @@
+
+
diff --git a/data/resources.qrc b/data/resources.qrc
deleted file mode 100644
index b872d19..0000000
--- a/data/resources.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
- poi.svg
-
-
diff --git a/data/windows.rc b/data/windows.rc
deleted file mode 100644
index 050404d..0000000
--- a/data/windows.rc
+++ /dev/null
@@ -1 +0,0 @@
-IDI_ICON1 ICON DISCARDABLE "poi.ico"
diff --git a/src/about/aboutdialog.cpp b/src/about/aboutdialog.cpp
index 894b1ec..f42d551 100644
--- a/src/about/aboutdialog.cpp
+++ b/src/about/aboutdialog.cpp
@@ -7,6 +7,7 @@
*/
#include "aboutdialog.h"
+#include "../poi_logos.h"
#include "ui_aboutdialog.h"
#include
@@ -26,18 +27,11 @@ AboutDialog::AboutDialog(QWidget *parent)
: QDialog(parent)
, ui(new Ui::AboutDialog)
{
- //setAttribute(Qt::WA_DeleteOnClose, true);
+ setAttribute(Qt::WA_DeleteOnClose, true);
ui->setupUi(this);
- const QByteArray icon_svg = R"SVG(
-
-)SVG";
- ui->appIcon_svg->load(icon_svg);
+ constexpr auto icon_svg = logos::get([] { return std::string_view("poi_window.svg"); });
+ ui->appIcon_svg->load(QByteArray(icon_svg.data(), icon_svg.size()));
ui->appName_label->setText(qApp->applicationName());
ui->appVersion_label->setText(qApp->applicationVersion());
@@ -66,9 +60,6 @@ AboutDialog::AboutDialog(QWidget *parent)
"spdlog"
"args.hxx"
"SingleApplication"
-#ifdef CONFIG_USEBREAKPAD
- "Breakpad"
-#endif
"
"));
}
diff --git a/src/browser.cpp b/src/browser.cpp
index a04f87d..aec3ad1 100644
--- a/src/browser.cpp
+++ b/src/browser.cpp
@@ -38,7 +38,7 @@ Browser::Browser(int &argc, char *argv[], bool allowSecondary)
Configuration conf;
setApplicationName(conf.value("poi.name").value());
- setWindowIcon(QIcon(conf.value("poi.icon").value()));
+ setWindowIcon(Util::icon());
setApplicationVersion(QVersionNumber::fromString(QLatin1String(poi_Version)).toString());
if(const auto _translation = conf.value("browser.translation")) {
@@ -128,8 +128,8 @@ Browser::~Browser()
void Browser::about()
{
- auto *dlg = new AboutDialog;
- dlg->exec();
+ auto *dlg = new AboutDialog(activeWindow());
+ dlg->show();
}
void Browser::aboutPlugins()
diff --git a/src/meson.build b/src/meson.build
index 062dae4..f3ef381 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -10,11 +10,14 @@ poi_settings_h = custom_target('default_config_value',
command: [ python3, '@INPUT0@', '--kconfig=@INPUT1@', '--dotconfig=@INPUT2@', '--input=@INPUT3@', '--output=@OUTPUT@' ]
)
+poi_logos_h = custom_target('poi_logos_h',
+ input: files('../data/poi.svg', '../data/poi_window.svg'),
+ output: 'poi_logos.h',
+ command: [ python3, rcc_exe, '-o=@OUTPUT@', 'dump', '-ns=logos', '@INPUT@' ])
poi_icons_h = custom_target('poi_icons_h',
input: icons,
- output: 'icons.h',
- command: [ python3, rcc_exe, '-o=@OUTPUT@', 'dump', '-ns=icons', '@INPUT@' ]
-)
+ output: 'poi_icons.h',
+ command: [ python3, rcc_exe, '-o=@OUTPUT@', 'dump', '-ns=icons', '@INPUT@' ])
subdir('about')
subdir('webengine')
@@ -29,8 +32,6 @@ poi_sourceset.add(mod_qt5.preprocess(
'mainwindow/addressbar.ui', 'mainwindow/widgets/searchform.ui',
'bookmarks/bookmarksform.ui', 'bookmarks/editbookmarkdialog.ui',
'session/savesessiondialog.ui', 'session/sessiondialog.ui' ],
- qresources: '../data/resources.qrc',
- rcc_extra_arguments: ['--format-version=1'],
dependencies: dep_qt5
))
@@ -57,6 +58,6 @@ poi_sourceset.add(files(
'subwindow/subwindow.cpp',
'subwindow/tabwidget.cpp',
),
- version_h, poi_settings_h, poi_icons_h
+ version_h, poi_settings_h, poi_icons_h, poi_logos_h
)
diff --git a/src/util.h b/src/util.h
index 6882854..8431a5b 100644
--- a/src/util.h
+++ b/src/util.h
@@ -9,7 +9,8 @@
#ifndef SMOLBOTE_UTIL_H
#define SMOLBOTE_UTIL_H
-#include "icons.h"
+#include "poi_icons.h"
+#include "poi_logos.h"
#include
#include
#include
@@ -20,53 +21,74 @@ namespace Util {
const QStringList files(const QString &location, const QStringList &nameFilters = QStringList());
-template
-inline QIcon icon()
+constexpr auto AppIcon = QStyle::SP_CustomBase + 1;
+constexpr auto AppWindowIcon = QStyle::SP_CustomBase + 2;
+
+[[nodiscard]] inline QPixmap render(const auto &data, const QSize size = QSize())
{
- using namespace std::literals;
+ QSvgRenderer renderer;
+ renderer.load(QByteArray(data.data(), static_cast(data.size())));
- constexpr auto data = icons::get([] {
- switch(id) {
- case QStyle::SP_ArrowBack:
- return "arrow-left.svg"sv;
- case QStyle::SP_ArrowForward:
- return "arrow-right.svg"sv;
- case QStyle::SP_BrowserStop:
- return "circle-x.svg"sv;
- case QStyle::SP_BrowserReload:
- return "refresh.svg"sv;
- case QStyle::SP_DirHomeIcon:
- return "home.svg"sv;
- default:
- return "__unknown__"sv;
- }
- });
+ QPixmap pm(size.isValid() ? size : renderer.defaultSize());
+ pm.fill(Qt::transparent);
- QIcon m;
+ QPainter painter(&pm);
+ renderer.render(&painter, pm.rect());
- // This is a horrible hack that will one day be hopefully fixed:
- // When rendering an svg, you can't actually pick a stroke color through
- // QPainter::setBrush or QPainter::setPen. So instead, replace the stroke
- // color in the data (stroke="currentColor") and then rerender it.
+ return pm;
+}
- QSvgRenderer renderer;
- QByteArray arr(data.data(), data.size());
- for(const auto mode : { QIcon::Normal /*, QIcon::Disabled, QIcon::Active, QIcon::Selected*/ }) {
- for(const auto toggle : { QIcon::On, QIcon::Off }) {
- renderer.load(arr.replace("currentColor", (toggle == QIcon::On ? "black" : "gray")));
+template *QStyle::StandardPixmap*/ unsigned int id>
+inline QIcon icon()
+{
+ using namespace std::literals;
+
+ if constexpr(id >= QStyle::SP_CustomBase) {
+ constexpr auto data = logos::get([] {
+ switch(id) {
+ case AppIcon:
+ return "poi.svg"sv;
+ case AppWindowIcon:
+ return "poi_window.svg"sv;
+ default:
+ return "__unknown__"sv;
+ }
+ });
+ return QIcon(render(data));
+ } else {
- QPixmap pm(renderer.defaultSize());
- pm.fill(Qt::transparent);
+ constexpr auto data = icons::get([] {
+ switch(id) {
+ case QStyle::SP_ArrowBack:
+ return "arrow-left.svg"sv;
+ case QStyle::SP_ArrowForward:
+ return "arrow-right.svg"sv;
+ case QStyle::SP_BrowserStop:
+ return "circle-x.svg"sv;
+ case QStyle::SP_BrowserReload:
+ return "refresh.svg"sv;
+ case QStyle::SP_DirHomeIcon:
+ return "home.svg"sv;
+ default:
+ return "__unknown__"sv;
+ }
+ });
- QPainter painter(&pm);
- painter.setBrush(Qt::green);
- painter.setPen(Qt::green);
- renderer.render(&painter, pm.rect());
+ QIcon m;
+ // This is a horrible hack that will one day be hopefully fixed:
+ // When rendering an svg, you can't actually pick a stroke color through
+ // QPainter::setBrush or QPainter::setPen. So instead, replace the stroke
+ // color in the data (stroke="currentColor") and then rerender it.
- m.addPixmap(pm, mode, toggle);
+ QByteArray arr(data.data(), data.size());
+ for(const auto mode : { QIcon::Normal /*, QIcon::Disabled, QIcon::Active, QIcon::Selected*/ }) {
+ for(const auto toggle : { QIcon::On, QIcon::Off }) {
+ const auto pm = render(arr.replace("currentColor", (toggle == QIcon::On ? "black" : "gray")));
+ m.addPixmap(pm, mode, toggle);
+ }
}
+ return m;
}
- return m;
}
} // namespace Util
diff --git a/subprojects/rcc.wrap b/subprojects/rcc.wrap
index c0986d2..a2a3fd4 100644
--- a/subprojects/rcc.wrap
+++ b/subprojects/rcc.wrap
@@ -1,5 +1,5 @@
[wrap-file]
-directory = rcc-0.1.1
-source_url = https://neueland.iserlohn-fortress.net/cgit/rcc/snapshot/rcc-0.1.1.tar.xz
-source_filename = rcc-0.1.1.tar.xz
-source_hash = 6093e2a7a6634d3288834b88e7e1afc12d6583581bb3eadd29995990c1a20f6c
+directory = rcc-0.1.2
+source_url = https://neueland.iserlohn-fortress.net/cgit/rcc/snapshot/rcc-0.1.2.tar.xz
+source_filename = rcc-0.1.2.tar.xz
+source_hash = e40e6669e10d18f0f5d512ee3e175ff9ad61587ba4070b5fd3b45a4cf9f029ee
diff --git a/windows/icon.rc b/windows/icon.rc
new file mode 100644
index 0000000..050404d
--- /dev/null
+++ b/windows/icon.rc
@@ -0,0 +1 @@
+IDI_ICON1 ICON DISCARDABLE "poi.ico"
diff --git a/windows/poi.ico b/windows/poi.ico
new file mode 100644
index 0000000..69d15e2
Binary files /dev/null and b/windows/poi.ico differ
--
cgit v1.2.1