Code Monkey home page Code Monkey logo

Comments (4)

shundhammer avatar shundhammer commented on August 26, 2024

Default: Using the Desktop Environment's Font Settings

QDirStat is a Qt 5 -based application; it behaves just the same as other applications using the Qt libs.

That means that by default, it uses the settings of your desktop environment, if possible. This works at least for the major desktop environments like KDE Plasma, GNOME, Xfce.

So in most cases, it should work to simply use your desktop's settings configuration dialog or applet where you can change the font settings.

If you don't know where that is, check the desktop's menu; most of those menus and configuration programs have a search box. Type "fonts' there.

Xfce4

When I do that in my Xfce4, it gives me one search result, Xfce4's "Appearance" applet:

xfce4-appearance-tab-1-style

In this first tab named "Style" you can select a desktop theme. Those usually come with some initial font settings.

xfce4-appearance-tab-2-fonts

In the third tab "Fonts" you can make very detailed selections for the base font (typically a proportional font) and a monospace font that is typically used for constant-width texts such as terminal windows.

DPI

Be aware that the DPI (Dots Per Inch) setting may also influence how large those fonts might appear; it overrides the monitor's hardware settings with that value.

Scale Factor

xfce4-appearance-tab-4-settings

Modern desktops also let you configure a scale factor. This is useful if you either have a very high-resolution ("HiDPI") monitor or a small laptop monitor with high resolution, or if you are vision impaired:

Here you can select to up-scale everything in a window, from fonts and icons (!) to the general size of user interface elements ("widgets").

Notice that sometimes this is restricted to non-fractional (integer) numbers like 1, 2, 3; sometimes multiples of 0.25 can be used like 1.25, 1.5, 1.75; sometimes all fractional numbers (1.83, 2.47) can be used. Try what works in your environment.

Apply to Non-Native Applications

In some cases, a desktop has a setting named something like "apply settings to non-native applications"; that means that KDE Plasma will try to use those font sizes and theme settings to non-KDE applicatoins as well. Similar for GNOME and non-Gtk (non-GNOME) applications.

KDE Plasma, Gnome

It's very similar in most other modern desktop environments. The dialogs look different, but the principles are very much the same.

from qdirstat.

shundhammer avatar shundhammer commented on August 26, 2024

qt5ct

qt5ct is a standalone graphical configuration program for all Qt 5 applications on your machine:

qt5ct-tab-1-appearance

qt5ct-tab-2-fonts

qt5ct-tab-3-icons

qt5ct-tab-4-interface

Installing qt5ct

  • openSUSE Leap 15.x / Tumbleweed / SLE-15-SPx / SLES-12-SPx:

     sudo zypper in qt5ct
    
  • Ubuntu / Kubuntu / Xubuntu / Debian:

    sudo apt install qt5ct
    

Usage

  • Start it and set fonts (and widget themes and whatever else you'd like to set):

    qt5ct
    

    (with your normal user account, not with sudo!)

  • Set this environment variable to tell the Qt libs to use those settings, not the settings from your desktop environment:

    export QT_QPA_PLATFORMTHEME="qt5ct"
    
  • Put that environment variable in your shell startup scripts (~/.bashrc or ~/.zshrc or ~/environment)

  • If you use QDirStat as root, or with sudo, do the same for root.

Config File Location

The values are stored at

~/.config/qt5ct/qt5ct.conf

Unfortunately the relevant part here is stored as a QByteArray, i.e. in a very much unreadable hexdump-like binary format:

[Fonts]
fixed=@Variant(\0\0\0@\0\0\0 \0\x44\0\x65\0j\0\x61\0V\0u\0 \0S\0\x61\0n\0s\0 \0M\0o\0n\0o@$\0\0\0\0\0\0\xff\xff\xff\xff\x5\x1\0\x32\x10)
general=@Variant(\0\0\0@\0\0\0\x14\0\x44\0r\0o\0i\0\x64\0 \0S\0\x61\0n\0s@&\0\0\0\0\0\0\xff\xff\xff\xff\x5\x1\0\x32\x10)

[Appearance]
color_scheme_path=/usr/share/qt5ct/colors/airy.conf
custom_palette=false
icon_theme=Adwaita
standard_dialogs=default
style=Fusion

But you can simply copy that file to the root user's home directory (with sudo, of course).

from qdirstat.

shundhammer avatar shundhammer commented on August 26, 2024

Qt Environment Variables

QT_SCALE_FACTOR

This is very similar to that "Window Scaling" factor that some desktops have, but it's limited to Qt applications. You can set it generally for all Qt applications, e.g. in your shell startup files (~/.bashrc or ยด~/zshrc` etc.):

export QT_SCALE_FACTOR=1.5

(It may depend on your exact Qt version if fractional numbers are supported)

...or you can add it to each individual command line:

QT_SCALE_FACTOR=2  qdirstat

Tip: Add it to the .desktop File

You can do that specifically for QDirStat if you edit the command line in the qdirstat.desktop file. One caveat is that a .desktop file executes the binary directly, not wrapped into an extra shell instance, so you can't just use the above command there; you have to wrap it in a shell invocation:

sh -c "QT_SCALE_FACTOR=2  qdirstat %f"

So the whole .desktop file looks like this:

[Desktop Entry]
Type=Application
Name=QDirStat
Exec=sh -c "QT_SCALE_FACTOR=2 qdirstat %f"
Icon=qdirstat
GenericName=QDirStat Directory Statistics
Terminal=false
MimeType=inode/directory;inode/mount-point;
Categories=Qt;System;Filesystem;
Keywords=directory;tree;size;statistic;disk;space;

QT_SCALE_FACTOR_ROUNDING_POLICY

This indicates how to treat fractional factors. Values:

  • PassThrough: Use the value as-is.
  • Round: Round to the next integer number
  • Ceil: Round up
  • Floor: Round down
  • RoundPreferFloor: Round up for 0.75 and above

See also https://doc.qt.io/qt-5/qt.html#HighDpiScaleFactorRoundingPolicy-enum

The default for this may be different between Qt versions.

Example

export QT_SCALE_FACTOR_ROUNDING_POLICY=PassThrough
QT_SCALE_FACTOR=1.41 qdirstat

QT_SCREEN_SCALE_FACTORS

This is meant to be used for a multi-screen setup where each screen has a different resolution or physical size, so you need a different scale factor for each one:

QT_SCREEN_SCALE_FACTORS="1.5;2" qdirstat

Notice the quotes " to protect the semicolon ; from the shell.

Further Reading

There are many more environment variables that can be used with Qt, but that can get complicated quickly, and it might depend on the exact Qt 5.x version on your system.

For more information, see https://doc.qt.io/qt-5/highdpi.html#high-dpi-support-in-qt.

from qdirstat.

shundhammer avatar shundhammer commented on August 26, 2024

This is intended as documentation.

If you have a problem in this area, please open a new GitHub issue.

from qdirstat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.