Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Qt's Resource System #1742

Closed
wants to merge 9 commits into from
Closed

Use Qt's Resource System #1742

wants to merge 9 commits into from

Conversation

lukas-w
Copy link
Member

@lukas-w lukas-w commented Feb 6, 2015

LMMS has been using some custom code found in bin2res.cpp to embed resources like pixmaps in binary files. This PR removes that code and introduces the use of the resource system provided by Qt instead (http://qt-project.org/doc/qt-4.8/resources.html).

That means embedded resources are now available through Qt's classes:

embed::getIconPixmap("project_save");
// becomes
QPixmap("icons:project_save.png");

Qt's Resource System reads a list of files to embed from a .qrc file that looks something like this:

<RCC>
    <qresource prefix="lb302">
        <file>artwork.png</file>
        <file>logo.png</file>
    </qresource>
</RCC>

I didn't want to write all those files for every single plugin, so I wrote a CMake script that generates them instead, see GenQrc.cmake. It works like this:

ADD_GEN_QRC(RCC_OUT lmms.qrc PREFIX /icons
    lmms-icon.png happy-devs.png 
)
ADD_EXECUTABLE(lmms
    main.cpp some.cpp other.cpp sources.cpp ${RCC_OUT}
)

Also, a lot of plugins had the same "logo" (shown below) included that wasn't even visible in the UI. I removed those files in ec5b10b.
plugin logo

There's no direct user benefit in this, it's just some sort of cleaning up. Nevertheless, the changes are quite huge, so it'd be great if we could get a few people to test if all plugins' pixmaps/logos still load correctly, especially when using different themes.

Conflicts:
	src/gui/MainWindow.cpp
	src/gui/embed.cpp
Conflicts:
	src/core/BBTrackContainer.cpp
	src/gui/editors/AutomationEditor.cpp
	src/tracks/Pattern.cpp
Support for generated .rc files was added in CMake v2.8.9 to the
QT4_ADD_RESOURCES macro. In order to support older versions of CMake, this
commit includes the source of the new macro from v2.8.9 and uses it if
necessary.
@Spekular
Copy link
Member

Spekular commented Feb 6, 2015

@lukas-w Seems pretty great! I'll do some testing if I get the time.

@tresf
Copy link
Member

tresf commented Feb 6, 2015

If plugins had the ability to offer icons for each we should consider displaying them.

I understand the GUI has no such place for these currently, but the idea has value. For example, browsing FX plugins by name leaves a bit to be desired from a UI perspective.

@tresf
Copy link
Member

tresf commented Feb 6, 2015

Quite a bit of code cleanup here. Nice work @lukas-w.

As I understand it, this means we now specify the file extension for our pixmaps. Does this consequently introduce the availability of SVG artwork now?

I've reviewed the changes from a code perspective and they look great. 👍

-Tres

@curlymorphic
Copy link
Contributor

Nice work lukas :) I do like the Qt resource system.

As I understand it, this means we now specify the file extension for our pixmaps. Does this consequently introduce the availability of SVG artwork now?

According to the Qt documentation you cant load a svg directly into a QPixmap. If I am reading it correctly The Qtmodule that handles svg is not GPL, but someone else should read that before taking my word for it.

http://qt-project.org/doc/qt-4.8/qtsvg.html.

If plugins had the ability to offer icons for each we should consider displaying them.

I do like this idea, a picture paints a thousand words as they say. There are a few things that would need to be sorted. currently we display all plugin effects in a single list, native, Ladspa and vst and hopefully more formats to be supported in the future. Not all these formats support icons iirc. As Lukas has already pointed out most of the native plugins use the same icon (yes im guilty of this) So we would need to produce these.

@badosu
Copy link
Contributor

badosu commented Feb 7, 2015

Gonna test here! Amazing Yak-Shaving skills :-)

@badosu
Copy link
Contributor

badosu commented Feb 7, 2015

@lukas-w It is really hard to review the changes when your editor automatically fixes code style.

@lukas-w
Copy link
Member Author

lukas-w commented Feb 7, 2015

@lukas-w It is really hard to review the changes when your editor automatically fixes code style.

Yeah, sorry for that. It was too late when I noticed it.

@diizy
Copy link
Contributor

diizy commented Feb 23, 2015

@tresf "Does this consequently introduce the availability of SVG artwork now?"

No, because we already have that ability - it was implemented by Raine some time ago. We just haven't utilized it yet.

@tresf
Copy link
Member

tresf commented Feb 26, 2015

No, because we already have that ability - it was implemented by Raine some time ago. We just haven't utilized it yet.

👍

@lukas-w
Copy link
Member Author

lukas-w commented Mar 21, 2015

New approach: #1891

@lukas-w lukas-w closed this Mar 21, 2015
@lukas-w lukas-w deleted the qrc branch March 12, 2016 03:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants