aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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
4 files changed, 74 insertions, 60 deletions
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