Skip to content

Commit

Permalink
Merge pull request #3 from linuxdeploy/fix_icons_not_being_loaded
Browse files Browse the repository at this point in the history
Fix icons not being loaded
contributes to linuxdeploy/linuxdeploy-plugin-qt#17
  • Loading branch information
azubieta authored Nov 1, 2018
2 parents cea753b + c40563b commit c1210ec
Show file tree
Hide file tree
Showing 6 changed files with 458 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ addons:
- qt510-meta-minimal
- qt510declarative
- qt510webengine
- qt510svg
- qt510imageformats
- mesa-common-dev
- cmake
install:
Expand Down
3 changes: 3 additions & 0 deletions QtWidgetsApplication/QtWidgetsApplication.pro
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ icon.files = QtWidgetsApplication.png
desktop_entry.path = $$PREFIX/share/applications
desktop_entry.files = QtWidgetsApplication.desktop
INSTALLS += target icon desktop_entry

RESOURCES += \
resources/icons/icons.qrc
336 changes: 336 additions & 0 deletions QtWidgetsApplication/QtWidgetsApplication.pro.user

Large diffs are not rendered by default.

18 changes: 8 additions & 10 deletions QtWidgetsApplication/mainwindow.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QAction *action = new QAction(this);
QIcon icon;
auto iconThemeName = QStringLiteral("list-add");
if (QIcon::hasThemeIcon(iconThemeName)) {
icon = QIcon::fromTheme(iconThemeName);
} else {
icon.addFile(QStringLiteral("."), QSize(), QIcon::Normal, QIcon::Off);
}
action->setIcon(icon);
ui->mainToolBar->addAction(action);

// There is no warranty that a given icon will be present in the target platform icons theme
// therefore we must provide a fallback
QIcon addIcon = QIcon::fromTheme("list-add", QIcon(":/scalable/list-add.svg"));
QAction *addAction = new QAction(addIcon, tr("&Add..."), this);

ui->mainToolBar->addAction(addAction);
}

MainWindow::~MainWindow()
Expand Down
5 changes: 5 additions & 0 deletions QtWidgetsApplication/resources/icons/icons.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/">
<file>scalable/list-add.svg</file>
</qresource>
</RCC>
104 changes: 104 additions & 0 deletions QtWidgetsApplication/resources/icons/scalable/list-add.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c1210ec

Please sign in to comment.