Skip to content

Commit ce04b29

Browse files
committed
Preload application icon for About page
1 parent 5b260f7 commit ce04b29

File tree

5 files changed

+16
-12
lines changed

5 files changed

+16
-12
lines changed

src/about.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <QString>
33
#include <QTabWidget>
44
#include <QTabBar>
5+
#include <QPixmap>
56

67
extern "C" {
78
#include <libavformat/avformat.h>
@@ -24,11 +25,12 @@ extern "C" {
2425
#define PROGRAM_VER "<html><head/><body><p><span style=\" font-size:12pt;\">%1</span></p></body></html>"
2526
#define ABOUT_HTML "<html><head/><body><p>%1</p><p>%2</p></body></html>"
2627

27-
AboutDialog::AboutDialog(const Config &config, QWidget *parent) :
28+
AboutDialog::AboutDialog(const Config &config, const QPixmap &icon, QWidget *parent) :
2829
QDialog(parent),
2930
ui(std::make_unique<Ui::AboutDialog>())
3031
{
3132
ui->setupUi(this);
33+
ui->label->setPixmap(icon);
3234
ui->tabs->setCurrentIndex(0);
3335
ui->program_ver->setText(QString(PROGRAM_VER).arg(QString(tr("Version %1")).arg(
3436
#ifdef PROJECT_VERSION_GIT

src/about.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace Ui {
1010
class AboutDialog;
1111
}
1212
class QLabel;
13+
class QPixmap;
1314

1415
class AboutDialog : public QDialog
1516
{
@@ -22,6 +23,6 @@ class AboutDialog : public QDialog
2223

2324
public:
2425
void closeEvent(QCloseEvent *event) override { event->accept(); }
25-
explicit AboutDialog(const Config &config, QWidget *parent = nullptr);
26+
explicit AboutDialog(const Config &config, const QPixmap &icon, QWidget *parent = nullptr);
2627
~AboutDialog() override;
2728
};

src/main.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020
#include <QStyle>
2121
#include <QStyleOption>
2222
#include <QIcon>
23+
#include <QPixmap>
24+
2325
#include <fmt/core.h>
2426
#include <fmt/chrono.h>
25-
2627
#include "main.hpp"
2728
#include "sync.hpp"
2829
#include "config.hpp"
@@ -36,11 +37,12 @@
3637
#define LOG_FILENAME EXECUTABLE_NAME ".log"
3738

3839
Application::Application(QWidget *parent) :
39-
QMainWindow(parent),
40-
ui(std::make_unique<Ui::MainWindow>()),
41-
config(std::make_unique<Config>()),
42-
style(QApplication::style()),
43-
settings(EXECUTABLE_NAME, EXECUTABLE_NAME)
40+
QMainWindow(parent),
41+
ui(std::make_unique<Ui::MainWindow>()),
42+
icon(std::make_unique<QPixmap>(":/icons/easyaudiosync256.png")),
43+
config(std::make_unique<Config>()),
44+
style(QApplication::style()),
45+
settings(EXECUTABLE_NAME, EXECUTABLE_NAME)
4446
{
4547
config->check_features();
4648
config->load(settings);
@@ -214,7 +216,7 @@ void Application::on_action_settings_triggered()
214216

215217
void Application::on_action_about_triggered()
216218
{
217-
auto dialog = new AboutDialog(*config, this);
219+
auto dialog = new AboutDialog(*config, *icon, this);
218220
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
219221
dialog->setModal(true);
220222
dialog->show();

src/main.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
class Sync;
2020
struct Config;
2121
class QLineEdit;
22+
class QPixmap;
2223

2324
namespace Ui {
2425
class MainWindow;
@@ -52,6 +53,7 @@ public slots:
5253

5354
private:
5455
std::unique_ptr<Ui::MainWindow> ui;
56+
std::unique_ptr<QPixmap> icon;
5557
std::unique_ptr<Config> config;
5658
QStyle *style;
5759
QSettings settings;

src/ui/about.ui

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@
3939
<property name="text">
4040
<string/>
4141
</property>
42-
<property name="pixmap">
43-
<pixmap resource="../../assets/icons/icons.qrc">:/icons/easyaudiosync256.png</pixmap>
44-
</property>
4542
<property name="scaledContents">
4643
<bool>true</bool>
4744
</property>

0 commit comments

Comments
 (0)