📜 ⬆️ ⬇️

Cross-platform application on Qt: Icon


After hundreds of debug launches, the standard icon must have gotten bored, so let's start by installing a new one. On this occasion, a separate article was written in the documentation , but everything turned out to be a bit more complicated. Each platform required its own approach, one line does not solve the problem.

First we need to prepare the source in different resolutions ( Windows , OS X , Linux ), which we will bake into the file icons. It is necessary to add that the resolutions for OS X in the table below are conditional, and ideally the icons of the same size should be of different levels of detail for conventional and Retina displays.
sixteen
32
4864
128256
512
1024
OS X *
*******
Linux*****
Windows****

Windows

For Windows, the documentation recommends using the icon editor from Visual Studio, but I could not find it in the express version of 2010. Instead, you can use a specialized utility , or Gimp . In the second case, simply add the source to the canvas (as layers, in descending order of size), export to the .ico format.
Next, you need to create an empty text file with the .rc extension, write a line like this into it:
IDI_ICON1 ICON DISCARDABLE "myapp.ico"
In the .pro file add the line:
win32:RC_FILE = myapp.rc
Bing !

OS X

The least fuss was with OS X, for which, besides the standard console * utility, there are convenient tools with an “intuitive interface”. We drag the necessary source codes on the places, we save a ready icon.
')


In the .pro file, you need to add the line:
macx:ICON = $${PWD}/myapp.icns
Fix : If the icon still does not appear, it is worthwhile to demolish the bundle with your hands (simple rebuilding may not work).

Linux

According to the specification , Linux does not require to convert the source of the icon into any build, you just need to copy (when installing) the files in a subdirectory like:
/ usr / share / icons / hicolor / RxR / apps, where R is the resolution of the icon
or
/ usr / share / icons / hicolor / scalable / apps - if you want to install a vector image in .svg format
However, this is not all, each icon theme has its own cache, and if it is not updated, it’s impossible to see the new icon. The cache is automatically updated during the regular installation of packages, or you can do it manually by running the command:
gtk-update-icon-cache /usr/share/icons/hicolor
It must be said that the binding of a specific icon with the application is in the file /usr/share/applications/myapp.desktop , in which you need to fill in the corresponding field (the name of the icon). The creation and filling of the required fields of this file will be discussed in one of the following articles devoted to the assembly and distribution of the distribution package of the program.

Cycle contents

PS Thank you wholeman for the addition.

Source: https://habr.com/ru/post/215079/


All Articles