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

theming? #10

Closed
anarcat opened this issue Jan 20, 2017 · 6 comments
Closed

theming? #10

anarcat opened this issue Jan 20, 2017 · 6 comments

Comments

@anarcat
Copy link

anarcat commented Jan 20, 2017

is there a way to change the colors and look of pext?

@TheLastProject
Copy link
Member

TheLastProject commented Jan 20, 2017

Pext is a Qt5 application, so should inherit your Qt5 theming. For now, you can change your system Qt theme, or put something like QT_STYLE_OVERRIDE=adwaita in front of the command line argument you use to start Pext.

In the future I do want to see if I can retrieve a list of systems themes so you can choose one from a drop-down menu in the top bar, or possibly see if I can add support for more "custom" themes using Qt Style Sheets.

EDIT: You can also play with QT_QUICK_CONTROLS_STYLE. Options like QT_QUICK_CONTROLS_STYLE=Flat actually affect the app layout.

EDIT 2: On my Debian system, a list of available options for QT_STYLE_OVERRIDE can be found in /usr/lib/x86_64-linux-gnu/qt5/plugins/styles (ignore the .so extension) and a list of available options for QT_QUICK_CONTROLS_STYLE can be found in /usr/lib/x86_64-linux-gnu/qt5/qml/QtQuick/Controls/Styles/.

@TheLastProject
Copy link
Member

35c255f implements the very basics to select a theme from the command line. Not all supported Qt5 themes are currently listed due to PyQt5 limitations, but it's a start. I'm leaving this issue open until I feel there is enough proper theming support.

@zamber
Copy link

zamber commented Mar 6, 2017

There's a better way to style it under GTK.

  1. https://wiki.archlinux.org/index.php/qt#Qt5
  2. https://wiki.archlinux.org/index.php/Uniform_look_for_Qt_and_GTK_applications#QGtkStyle
  3. sudo apt install qt5-style-plugins
  4. Make sure you have qt5ct (there's an Ubuntu PPA for it available).
  5. Add [ "$XDG_CURRENT_DESKTOP" = "KDE" ] || [ "$XDG_CURRENT_DESKTOP" = "GNOME" ] || export QT_QPA_PLATFORMTHEME="qt5ct" to your .bashrc/.zshrc/.profile.
  6. Open qt5ct adn set the GTK+ theme.
  7. ...
  8. PROFIT (now Qt5 apps should use your GTK theme).
  9. BONUS: when you're at it, change the fonts and icons in qt5ct to match your system settings.

@TheLastProject
Copy link
Member

TheLastProject commented Apr 9, 2017

Having researched more about this, there seem to be several possibilities to let users theme Pext to their wishes beyond @zamber's note. Putting this here for my own reference and in the hope someone may be able to help figure out what Telegram is doing and how possible that would be.

Qt Stylesheets (https://doc.qt.io/qt-5/stylesheet.html)

Just like CSS, pretty awesome and powerful-looking. However, not natively supported in QML and will need https://github.com/Ableton/aqt-stylesheets, a C++ plugin. Shipping this with Pext as a binary is obviously not an option, so this route will require setting up something like OpenBuildSystem so users can get binaries that will just work and the source code stays clean from binaries. While the most powerful solution, it is rather heavy-weight.

QML Style Singleton (https://wiki.qt.io/Qml_Styling#Approach_2:_Style_Singleton)

Not really a great solution. Bad code here will crash the whole app and thus make themes able to crash Pext as a whole. Also won't style dialog boxes and so that aren't part of the QML.

QPalette (https://doc.qt.io/qt-5/qpalette.html)

Simple solution, but very weak, would only allow users to change the colour of some text elements, basically. This is barely theming.

Figure out whatever Telegram is doing

Their solution involves .tdesktop-theme files which are .zip files containing a background image and something which seems like just a list of colours to use for everything. No clue if something like this can be used for Pext.

@TheLastProject
Copy link
Member

I started theming support based on QPalette in the feature/theming branch.

A basic theming file (which can already be loaded if put in ~/.config/pext/themes/pext_theme_dark/theme.conf and calling Pext with --theme=dark) will look like this:

Window: 53,53,53
WindowText: 0,0,0
Base: 25,25,25
AlternateBase: 53,53,53
ToolTipBase: 0,0,0 
ToolTipText: 0,0,0 
Text: 0,0,0 
Button: 53,53,53
ButtonText: 0,0,0
BrightText: 255,0,0
Link: 42,130,218
Highlight: 42,130,218
HighlightedText: 255,255,255

(This was based on https://gist.github.com/QuantumCD/6245215 for testing purposes)

It's still rather crude, but this seems to be the best way to go.

@TheLastProject
Copy link
Member

As of 687da11 I consider this fixed. I'll create a new issue about writing documentation for this. See https://github.com/Pext/pext_theme_eggplant for an example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants