diff --git a/src/mmg-qt/main_window.cpp b/src/mmg-qt/main_window.cpp index 970a66a12..176f231f8 100644 --- a/src/mmg-qt/main_window.cpp +++ b/src/mmg-qt/main_window.cpp @@ -6,8 +6,12 @@ #include "mmg-qt/util/file_identifier.h" #include "mmg-qt/util/file_type_filter.h" #include "mmg-qt/util/settings.h" +#include "mmg-qt/util/util.h" #include +#include +#include +#include MainWindow::MainWindow(QWidget *parent) : QMainWindow{parent} @@ -15,9 +19,7 @@ MainWindow::MainWindow(QWidget *parent) { ui->setupUi(this); - QIcon icon{":/icons/32x32/mkvmergeGUI.png"}; - icon.addFile(":/icons/64x64/mkvmergeGUI.png"); - setWindowIcon(icon); + setWindowIcon(Util::loadIcon(Q("mkvmergeGUI.png"), QList{} << 32 << 48 << 64 << 128 << 256)); } MainWindow::~MainWindow() { diff --git a/src/mmg-qt/util/util.cpp b/src/mmg-qt/util/util.cpp new file mode 100644 index 000000000..42c2fd781 --- /dev/null +++ b/src/mmg-qt/util/util.cpp @@ -0,0 +1,18 @@ +#include "common/common_pch.h" + +#include +#include +#include + +#include "common/qt.h" +#include "mmg-qt/util/util.h" + +QIcon +Util::loadIcon(QString const &name, + QList const &sizes) { + QIcon icon; + for (auto size : sizes) + icon.addFile(QString{":/icons/%1x%1/%2"}.arg(size).arg(name)); + + return icon; +} diff --git a/src/mmg-qt/util/util.h b/src/mmg-qt/util/util.h new file mode 100644 index 000000000..9dc368284 --- /dev/null +++ b/src/mmg-qt/util/util.h @@ -0,0 +1,15 @@ +#ifndef MTX_MMGQT_UTIL_H +#define MTX_MMGQT_UTIL_H + +#include "common/common_pch.h" + +class QIcon; +class QString; +template class QList; + +class Util { +public: + static QIcon loadIcon(QString const &name, QList const &sizes); +}; + +#endif // MTX_MMGQT_UTIL_H