Converted project to CPP and use Qt instead of Gtk.

This commit is contained in:
Johannes Findeisen 2026-07-16 00:44:52 +02:00
commit 966314dae7
10 changed files with 253 additions and 641 deletions

View file

@ -1,7 +1,7 @@
spacetray
=========
A panel Applet using GTK2 for showing the Status of a Hackerspace. Compatible with the SpaceAPI version >= 0.13.
A panel Applet using Qt5 for showing the Status of a Hackerspace. Compatible with the SpaceAPI version >= 0.13.
Installation:
@ -9,11 +9,8 @@ Installation:
Requirements:
- Standard tools like gcc, pkg-config etc.
- curl
- gtk+-2.0
- json-c
- libnotify - Only needed when compiling with libnotify support.
- Standard tools like g++, cmake etc.
- Qt5 (Widgets and Network modules)
Use the following command for getting the sources:
@ -25,67 +22,75 @@ Change into the new directory:
To compile the sources just run:
mkdir build
cd build
cmake ..
make
This will compile dooris with libnotify support.
This will compile spacetray with status icon and notification support.
If you don't want notifications run the following command:
Just copy "bin/spacetray" to a folder in your $PATH. I do:
make nonotify
Just copy "spacetray" to a folder in your $PATH. I do:
cp ./spacetray ~/bin/
cp ./bin/spacetray ~/bin/
You can copy the file to /usr/bin to make it available to all users but I don't. If you want that just run:
sudo cp ./spacetray /usr/bin/
sudo cp ./bin/spacetray /usr/bin/
Configuration:
--------------
Configuration needs to be done before compiling. There are some parameters you can set in the head of the spacetray.c file where variables are declared. A configuration file will at this point make no sense.
Configuration is done via command line arguments.
Usage:
------
Run spacetray with:
./spacetray &
./bin/spacetray <statusurl> &
Or if in your $PATH:
spacetray
spacetray <statusurl>
Status Icon "Pesthoernchen" colors:
Status Icon "lock" colors:
- Red = Door closed
- Yellow = Door open
- Red = Door open
- Green = Door closed
Themes:
-------
You can create your own icon theme by generating a C header file containing the icons as "static const GdkPixdata" data structure.
You can create your own icon theme by generating a C++ header file containing the icons as raw RGBA8888 pixel data in a `static const quint8` array.
This can be done using the following commands:
The format should look like this:
gdk-pixbuf-csource --struct PATH_TO_OPEN_IMAGE > ./themes/THEME_NAME.h
static const quint8 icon_open_data[] = {
0xRR, 0xGG, 0xBB, 0xAA, ...
};
gdk-pixbuf-csource --struct PATH_TO_CLOSED_IMAGE >> ./themes/THEME_NAME.h
static const quint8 icon_closed_data[] = {
0xRR, 0xGG, 0xBB, 0xAA, ...
};
Afterwards you need to rename the first generated struct to:
The image size used in the default theme is 52x48 pixels with 4 channels (RGBA).
icon_open_pixbuf
To create these arrays from a PNG image, you can use `ImageMagick` to convert the image to raw RGBA data and then format it into a C++ header.
The second must be renamed to:
Example using `magick` (ImageMagick 7):
icon_closed_pixbuf
magick icon_open.png -size 52x48 -depth 8 RGBA:icon_open.raw
hexdump -v -e '12/1 "0x%02x, " "\n"' icon_open.raw
in:
Or using a simple one-liner to generate the header content:
./themes/THEME_NAME.h
echo "static const quint8 icon_open_data[] = {" > themes/my_theme.h
magick icon_open.png -size 52x48 -depth 8 RGBA:- | hexdump -v -e '12/1 "0x%02x, " "\n"' >> themes/my_theme.h
echo "};" >> themes/my_theme.h
You can then use your custom icon theme when changing the line:
Repeat the process for `icon_closed_data` and append it to the same header file.
You can then use your custom icon theme by changing the line:
#include "themes/lock.h"
@ -95,5 +100,5 @@ to:
in:
./spacetray.c
./spacetray.cpp