Move icon loader to utility class

This commit is contained in:
Moritz Bunkus 2012-04-10 19:24:35 +02:00
parent 25dfbd2698
commit cabe0059d0
3 changed files with 38 additions and 3 deletions

View File

@ -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 <QFileDialog>
#include <QIcon>
#include <QList>
#include <QString>
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<int>{} << 32 << 48 << 64 << 128 << 256));
}
MainWindow::~MainWindow() {

18
src/mmg-qt/util/util.cpp Normal file
View File

@ -0,0 +1,18 @@
#include "common/common_pch.h"
#include <QIcon>
#include <QList>
#include <QString>
#include "common/qt.h"
#include "mmg-qt/util/util.h"
QIcon
Util::loadIcon(QString const &name,
QList<int> const &sizes) {
QIcon icon;
for (auto size : sizes)
icon.addFile(QString{":/icons/%1x%1/%2"}.arg(size).arg(name));
return icon;
}

15
src/mmg-qt/util/util.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef MTX_MMGQT_UTIL_H
#define MTX_MMGQT_UTIL_H
#include "common/common_pch.h"
class QIcon;
class QString;
template<typename T> class QList;
class Util {
public:
static QIcon loadIcon(QString const &name, QList<int> const &sizes);
};
#endif // MTX_MMGQT_UTIL_H