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
Native look of file choosing dialog on GTK Linux systems #2221
Conversation
BOOtak
commented
Jul 3, 2016
•
edited
edited
Screenshots attached |
I'm not sure how this affects the possibility of It also appears that the GTK version used for the file picker is now 2 instead of 3, which is afaik not the preferred choice for a DE that natively uses 3. This still doesn't give a native filepicker for e.g. KDE and probably other DEs. Consider the following example. #include <QtWidgets/QApplication>
#include <QtWidgets/QFileDialog>
int main(int argc, char **argv)
{
QApplication *qa = new QApplication(argc, argv);
QFileDialog::getOpenFileName
(
nullptr,
"Open File",
"/home",
"Images (*.png *.xpm *.jpg)"
);
delete qa;
qa = nullptr;
return 0;
} compile it with and run
As you can see, the native system filepicker is used automatically. In my case KDE 5's file picker. I suspect this behaviour is consistent across OSes and DEs, since Qt prefers native when possible. Perhaps it is a better idea to let Qt itself choose the system native dialog. It is only when a lot of If you ask me this is the solution. Less option forcing and hacking around a problem by inserting 3 other problems at the same time. View #987 (comment) for some background and the possible fix for |
@ManuelSchneid3r it's more you then PR as Qt 5.7 is unsupported by TDesktop client. Compile project with 5.6 and everything will be just fine. |
@melvinvermeeren TL;DR: please read project's source code carefully before writing comments next time. I have no idea why I should spend my time to explain obvious things.
No. I've changed GTK version for absolutely different reason (read my commit message carefully) and it has no connection at all with file picker's theme.
Again, qgtk2 is a theme engine and will be applied only to GTK file picker if it will be used. As written in Qt docs,
I see you haven't read project source code at all as project's QFileDialog utilizes only common set of options which every native implementation has for sure.
Your example will be compiled with system Qt which already built with all possible platforms ant theme engines. Tdesktop uses it's own static version of Qt patched and built from source code. Let me enhance your example and show what would happen if we compile it with static Qt: QT += core gui network widgets
CONFIG += plugin static c++14
QT_TDESKTOP_VERSION = 5.6.0
QT_TDESKTOP_PATH = $$(QT_TDESKTOP_PATH)
INCLUDEPATH += $${QT_TDESKTOP_PATH}/include/QtGui/$${QT_TDESKTOP_VERSION}/QtGui \
$${QT_TDESKTOP_PATH}/include/QtCore/$${QT_TDESKTOP_VERSION}/QtCore \
$${QT_TDESKTOP_PATH}/include
SOURCES += \
./test.cpp
INCLUDEPATH += \
/usr/local/include
QTPLUGIN.platformthemes += qgtk2
LIBS += $${QT_TDESKTOP_PATH}/plugins/platforminputcontexts/libcomposeplatforminputcontextplugin.a \
$${QT_TDESKTOP_PATH}/plugins/platforminputcontexts/libibusplatforminputcontextplugin.a \
$${QT_TDESKTOP_PATH}/plugins/platforminputcontexts/libfcitxplatforminputcontextplugin.a This is test.pro file copy-pasted from Telegram.pro with slight modification (some parts are thrown away). Let's build project: And launch it: WTF, right? QTPLUGIN.platformthemes += qgtk2 So, solution provided in this PR only applies correct theme to GTK file picker, no less, no more. It doesn't influence KDE or other platforms which have their own picker. |
@BOOtak Thanks for explaining more about the state of things with tdesktop itself, I didn't know all of this yet. Even so, instead of changing even more inside tdesktop itself, wouldn't it be a better idea to change the configuration of the static Qt build to include support for native filepickers in the same way the system Qt does? Even if this increases the binary by a few M it shouldn't pose a problem. I just can't help but feel that the problems are being solved in a nonstandard ways and will most likely cause further issues later on, there have been too many cases of this already with tdesktop imo. Kind of off-topic, but I'd like to see a truly native tdesktop one day. |
@BOOtak I don't like the idea of removing the "appindicator3" loading (which requires "gtk-3", if I understand correctly the difference between "appindicator" and "appindicator3" libraries). For example, Ubuntu 15.04 has libappindicator3.so but doesn't have libappindicator.so, so removing the gtk-3 version of libappindicator will turn off the tray icon support on all the systems, that rely on libappindicator3.so, which I think is not acceptable. |
Exactly!
That is an issue indeed. Is it clear why I've removed gtk-3 libs? (Hint: to avoid mixing gtk-2 and gtk-3 symbols which would cause app's crash). So, static linking with libappindicator should do the trick/ i'll rebase my changes on top of latest master branch and try to link appindicator statically. |
…n GTK systems. Remove gtk-3 support as Qt's gtk theme engine supports only gtk-2. (Keeping gtk-3 in place would cause mix of gtk-2 and gtk-3 symbols loaded a tthe same time and will lead to error) Signed-off-by: Kirill Leyfer <leyfer.kirill@gmail.com> (github: BOOtak)
libappindicator can't be statically linked as I know (at least I could not do that at the time I tried), so I started to load it dynamically and load the needed version of gtk library. I'm afraid the only way to make things working with both appindicator, appindicator3 and gtk file picker is to write specific code for gtk file picker usage instead of Qt file pickers, which will work both with dynamically loaded gtk2 lib and gtk3 lib :( PS I guess that is the reason I had to add "-style=0" synthetic argument to QApplication, because if not added Qt tried to load gtk library dynamically -- sometimes loading gtk2 while I loaded gtk3 for appindicator3 -- and everything crashed :/ |
@BOOtak I don't see this comment on github.. I call methods from libgtk together with libappindicator methods, I guess they should be from the same version of libgtk. I'll try to implement (copy paste :) my own gtk file dialog that'll work with both gtk2 and gtk3, I hope this will work. |
Another problem is that adding "QTPLUGIN.platformthemes += qgtk2" statically links a huge amount of libraries, which were not in dependencies for the currently deployed build. |
@john-preston those new libs should be mentioned in documentation and travis build agent as soon as we handle all other issues. |
@BOOtak The problem with them is not the inconsistency of docs or travis failing. The problem is that the binary may stop launching on some systems where it does work now. A new version can't be deployed that will just stop working on some systems. |
I've pushed to master branch a version with self-made GtkFileDialog (based on Qt theme plugin code), it works for me in Ubuntu 12.04 for both gtk-2 and gtk-3. |
That is definitely better solution than mine! I'll test that. Thank you anyway for paying attention to this problem as previous look of file choosing was horrible :) |
In the latest 0.9.57 version gtk file chooser should be used if it is available. Please check. |
File chooser on gentoo with KDE is broken now. GTK file chooser is also available, cause I have some GTK apps installed, but native file chooser is really much better. |
@kvaster was it native file chooser before? All systems I've tested with old tdesktop version were using Qt inner file chooser implementation, that was not like "kdialog" in KDE, for example. Can you test https://telegram.org/dl/desktop/linux (without updating to alpha -- disable autoupdate in Settings) version and say if it is really better (native?), than the new 0.9.57 alpha? If it does -- maybe you can tell me, how I can understand in the code (read some env variable?) do I need to try to use GTK file chooser or not. |
Seems you're right - it was opening Qt inner file chooser. I will try to figure out today if there is reliable method to detect KDE and to open Qt file chooser instead of gtk. On kde Qt chooser looks much better in my opinion. |
$ echo $DESKTOP_SESSION
$ echo $KDE_FULL_SESSION
From KDE docs on
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |