aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2020-11-06 20:44:12 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2020-11-06 20:44:12 +0200
commit7965f73b64018bbac155c4e2c3208350dae69954 (patch)
treea45bd6937ec853ad1846116e605ae7497be4c475
parentAdd tabler-icons (diff)
downloadsmolbote-7965f73b64018bbac155c4e2c3208350dae69954.tar.xz
Remove data/resources.qrc
-rw-r--r--Kconfig3
-rw-r--r--data/poi_window.svg7
-rw-r--r--data/resources.qrc5
-rw-r--r--src/about/aboutdialog.cpp17
-rw-r--r--src/browser.cpp6
-rw-r--r--src/meson.build13
-rw-r--r--src/util.h98
-rw-r--r--subprojects/rcc.wrap8
-rw-r--r--windows/icon.rc (renamed from data/windows.rc)0
-rw-r--r--windows/poi.ico (renamed from data/poi.ico)bin45842 -> 45842 bytes
10 files changed, 85 insertions, 72 deletions
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_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 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="300" height="300" version="1.1">
+ <circle cx="150" cy="150" r="100" stroke="#000000" stroke-width="6" fill="#e60026"></circle>
+ <circle cx="150" cy="150" r="87" stroke="#000000" stroke-width="4" fill="#e5e4e2"></circle>
+ <path d="M230,150 A80,80 0 0 0 150,70 L150,150 Z" />
+ <path d="M70,150 A80,80 0 0 0 150,230 L150,150 Z" />
+</svg>
+
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 @@
-<RCC>
- <qresource prefix="/">
- <file alias="icons/poi.svg">poi.svg</file>
- </qresource>
-</RCC>
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 <version.h>
@@ -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 xmlns="http://www.w3.org/2000/svg" width="300" height="300" version="1.1">
- <circle cx="150" cy="150" r="100" stroke="#000000" stroke-width="6" fill="#e60026"></circle>
- <circle cx="150" cy="150" r="87" stroke="#000000" stroke-width="4" fill="#e5e4e2"></circle>
- <path d="M230,150 A80,80 0 0 0 150,70 L150,150 Z" />
- <path d="M70,150 A80,80 0 0 0 150,230 L150,150 Z" />
-</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)
"<li>spdlog</li>"
"<li><a href='https://github.com/Taywee/args'>args.hxx</a></li>"
"<li><a href='https://github.com/itay-grudev/SingleApplication'>SingleApplication</a></li>"
-#ifdef CONFIG_USEBREAKPAD
- "<li><a href='https://chromium.googlesource.com/breakpad/breakpad'>Breakpad</a></li>"
-#endif
"</ul></p>"));
}
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<QString>("poi.name").value());
- setWindowIcon(QIcon(conf.value<QString>("poi.icon").value()));
+ setWindowIcon(Util::icon<Util::AppWindowIcon>());
setApplicationVersion(QVersionNumber::fromString(QLatin1String(poi_Version)).toString());
if(const auto _translation = conf.value<QString>("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 <QIcon>
#include <QPainter>
#include <QStringList>
@@ -20,53 +21,74 @@ namespace Util {
const QStringList files(const QString &location, const QStringList &nameFilters = QStringList());
-template <QStyle::StandardPixmap id>
-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<int>(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/data/windows.rc b/windows/icon.rc
index 050404d..050404d 100644
--- a/data/windows.rc
+++ b/windows/icon.rc
diff --git a/data/poi.ico b/windows/poi.ico
index 69d15e2..69d15e2 100644
--- a/data/poi.ico
+++ b/windows/poi.ico
Binary files differ