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

Load window icons from a custom icon theme #2088

Merged
merged 3 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion client/gui_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,16 @@ int main(int argc, char **argv) { return client_main(argc, argv); }
*/
void ui_main()
{
// Load window icons
QIcon::setThemeSearchPaths(get_data_dirs() + QIcon::themeSearchPaths());
QIcon::setFallbackThemeName(QIcon::themeName());
QIcon::setThemeName(QStringLiteral("icons"));

qApp->setWindowIcon(QIcon::fromTheme(QStringLiteral("freeciv21-client")));

if (true) {
tileset_init(tileset);
tileset_load_tiles(tileset);
qApp->setWindowIcon(QIcon(*get_icon_sprite(tileset)));
if (!load_theme(gui_options->gui_qt_default_theme_name)) {
gui_clear_theme();
}
Expand Down
18 changes: 0 additions & 18 deletions client/tileset/tilespec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ struct named_sprites {
*treaty_thumb[2], // 0=disagree, 1=agree
*arrow[ARROW_LAST], // 0=right arrow, 1=plus, 2=minus

*icon,

*events[E_COUNT],

// The panel sprites for showing tax % allocations.
Expand Down Expand Up @@ -2556,8 +2554,6 @@ static void tileset_lookup_sprite_tags(struct tileset *t)
}
}

SET_SPRITE(icon, QStringLiteral("icon.freeciv"));

for (i = 0; i < E_COUNT; i++) {
const char *tag = get_event_tag(static_cast<event_type>(i));

Expand Down Expand Up @@ -5294,20 +5290,6 @@ const QPixmap *get_cursor_sprite(const struct tileset *t,
return t->sprites.cursor[cursor].frame[frame];
}

/**
Return a sprite for the Freeciv21 icon. Icons are used by the operating
system/window manager. Usually Freeciv21 has to tell the OS what icon to
use.

Note that this function will return nullptr before the sprites are loaded.
The GUI code must be sure to call tileset_load_tiles before setting the
top-level icon.
*/
const QPixmap *get_icon_sprite(const struct tileset *t)
{
return t->sprites.icon;
}

/**
Returns a sprite with the "user-attention" crosshair graphic.

Expand Down
1 change: 0 additions & 1 deletion client/tileset/tilespec.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ const QPixmap *get_cursor_sprite(const struct tileset *t,
int *hot_y, int frame);
const struct citybar_sprites *get_citybar_sprites(const struct tileset *t);
const struct editor_sprites *get_editor_sprites(const struct tileset *t);
const QPixmap *get_icon_sprite(const struct tileset *t);
const QPixmap *get_attention_crosshair_sprite(const struct tileset *t);
const QPixmap *get_indicator_sprite(const struct tileset *t,
enum indicator_type indicator,
Expand Down
26 changes: 2 additions & 24 deletions cmake/FreecivInstall.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ if(WIN32 OR MSYS OR MINGW)
${CMAKE_SOURCE_DIR}/data/icons/128x128/freeciv21-server.ico
DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT freeciv21)

install(
FILES
${CMAKE_SOURCE_DIR}/data/icons/128x128/freeciv21-client.png
DESTINATION ${CMAKE_INSTALL_BINDIR}/data/misc
COMPONENT freeciv21)
endif()

# MSYS2 and MINGW specific installation
Expand Down Expand Up @@ -189,12 +183,7 @@ if(UNIX AND NOT APPLE)
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/metainfo
COMPONENT freeciv21
)
install(
FILES
${CMAKE_SOURCE_DIR}/data/icons/128x128/freeciv21-client.png
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/freeciv21/misc
COMPONENT freeciv21
)

if(FREECIV_ENABLE_MANPAGES)
install(
FILES
Expand Down Expand Up @@ -224,12 +213,7 @@ if(UNIX AND NOT APPLE)
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/metainfo
COMPONENT freeciv21
)
install(
FILES
${CMAKE_SOURCE_DIR}/data/icons/128x128/freeciv21-server.png
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/freeciv21/misc
COMPONENT freeciv21
)

if(FREECIV_ENABLE_MANPAGES)
install(
FILES
Expand Down Expand Up @@ -262,12 +246,6 @@ if(UNIX AND NOT APPLE)
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/metainfo
COMPONENT freeciv21
)
install(
FILES
${CMAKE_SOURCE_DIR}/data/icons/128x128/freeciv21-modpack.png
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/freeciv21/misc
COMPONENT freeciv21
)

if(FREECIV_ENABLE_MANPAGES)
install(
Expand Down
27 changes: 27 additions & 0 deletions data/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,33 @@ if (FREECIV_ENABLE_CLIENT OR FREECIV_ENABLE_CIVMANUAL)
COMPONENT freeciv21)
endif()

# Icons
if (FREECIV_ENABLE_CLIENT OR FREECIV_ENABLE_SERVER OR
FREECIV_ENABLE_RULEDIT OR FREECIV_ENABLE_FCMP_QT)
install(FILES ${CMAKE_SOURCE_DIR}/data/icons/index.theme
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/freeciv21/icons
lmoureaux marked this conversation as resolved.
Show resolved Hide resolved
COMPONENT freeciv21)

if (FREECIV_ENABLE_CLIENT OR FREECIV_ENABLE_RULEDIT)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/icons
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/freeciv21
COMPONENT freeciv21
FILES_MATCHING PATTERN "freeciv21-client.png")
endif()
if (FREECIV_ENABLE_SERVER)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/icons
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/freeciv21
COMPONENT freeciv21
FILES_MATCHING PATTERN "freeciv21-server.png")
endif()
if (FREECIV_ENABLE_FCMP_QT)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/icons
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/freeciv21
COMPONENT freeciv21
FILES_MATCHING PATTERN "freeciv21-modpack.png")
endif()
endif()

if (FREECIV_ENABLE_CLIENT)
# Tilesets
add_tileset(NAME amplio2)
Expand Down
3 changes: 1 addition & 2 deletions data/amplio2.tilespec
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ files =
"misc/overlays.spec",
"misc/citybar.spec",
"misc/shields-large.spec",
"misc/editor.spec",
"misc/icons.spec"
"misc/editor.spec"


; Include color definitions
Expand Down
3 changes: 1 addition & 2 deletions data/cimpletoon.tilespec
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ files =
"misc/overlays.spec",
"misc/citybar.spec",
"misc/shields-large.spec",
"misc/editor.spec",
"misc/icons.spec"
"misc/editor.spec"


; Include color definitions
Expand Down
1 change: 0 additions & 1 deletion data/hex2t.tilespec
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ files =
"misc/space.spec",
"misc/techs.spec",
"misc/treaty.spec",
"misc/icons.spec",
"misc/editor.spec",
"amplio2/nuke.spec"

Expand Down
1 change: 0 additions & 1 deletion data/hexemplio.tilespec
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ files =
"misc/space.spec",
"misc/techs.spec",
"misc/treaty.spec",
"misc/icons.spec",
"misc/editor.spec",
"misc/units.spec",
"amplio2/nuke.spec",
Expand Down
20 changes: 20 additions & 0 deletions data/icons/index.theme
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[Icon Theme]
Name=Freeciv21
Comment=Freeciv21 Icons

Directories=16x16,32x32,48x48,64x64,128x128

[16x16]
Size=16

[32x32]
Size=32

[48x48]
Size=48

[64x64]
Size=64

[128x128]
Size=128
1 change: 0 additions & 1 deletion data/isophex.tilespec
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ files =
"misc/space.spec",
"misc/techs.spec",
"misc/treaty.spec",
"misc/icons.spec",
"misc/editor.spec",
"isotrident/nuke.spec",
"isotrident/cities.spec",
Expand Down
1 change: 0 additions & 1 deletion data/isotrident.tilespec
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ files =
"misc/space.spec",
"misc/techs.spec",
"misc/treaty.spec",
"misc/icons.spec",
"misc/editor.spec",
"isotrident/fog.spec",
"isotrident/nuke.spec",
Expand Down
15 changes: 1 addition & 14 deletions data/misc/icons.spec
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@

[spec]

; Format and options of this spec file:
options = "+Freeciv-spec-Devel-2019-Jul-03"

[info]

artists = "
James Blewitt, Hugo Flávio, Louis Moureaux (civicon)
yd (mpicon)
"

[extra]
sprites =
{ "tag", "file"
"icon.freeciv", "misc/freeciv21-client"
; misc/mpicon.png is referenced directly from configure.ac
}
; This file is only present for backward compatibility.
1 change: 0 additions & 1 deletion data/toonhex.tilespec
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ files =
"misc/space.spec",
"misc/techs.spec",
"misc/treaty.spec",
"misc/icons.spec",
"misc/editor.spec",
"cimpletoon/orient_units.spec",
"amplio2/nuke.spec",
Expand Down
1 change: 0 additions & 1 deletion data/trident.tilespec
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ files =
"misc/space.spec",
"misc/techs.spec",
"misc/treaty.spec",
"misc/icons.spec",
"misc/editor.spec",
"trident/fog.spec",
"trident/cities.spec",
Expand Down
2 changes: 1 addition & 1 deletion dist/net.longturn.freeciv21.desktop.in
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Comment[pt]=Jogo de estratégia por turnos inspirado na História da civilizaç
Comment[ru]=Пошаговая стратегическая игра, вдохновлённая историей человеческой цивилизации
Comment[sv]=Turordningsbaserat strategispel inspirerat av den mänskliga historien
Exec=@CMAKE_INSTALL_FULL_BINDIR@/freeciv21-client %u
Icon=@CMAKE_INSTALL_FULL_DATAROOTDIR@/freeciv21/misc/freeciv21-client.png
Icon=@CMAKE_INSTALL_FULL_DATAROOTDIR@/freeciv21/icons/128x128/freeciv21-client.png
StartupNotify=true
MimeType=x-scheme-handler/fc21;
X-KDE-Protocols=fc21;
Expand Down
2 changes: 1 addition & 1 deletion dist/net.longturn.freeciv21.modpack.desktop.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ GenericName[ru]=Стратегическая игра
Comment=Download and install add-ons for Freeciv21
Comment[ru]=Скачивайте и устанавливайте дополнения для Freeciv21
Exec=@CMAKE_INSTALL_FULL_BINDIR@/freeciv21-modpack-qt
Icon=@CMAKE_INSTALL_FULL_DATAROOTDIR@/freeciv21/misc/freeciv21-modpack.png
Icon=@CMAKE_INSTALL_FULL_DATAROOTDIR@/freeciv21/icons/128x128/freeciv21-modpack.png
StartupNotify=true
Terminal=false
Type=Application
Expand Down
2 changes: 1 addition & 1 deletion dist/net.longturn.freeciv21.ruledit.desktop.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ GenericName[ru]=Стратегическая игра
Comment=Edit Freeciv21 game rules
Comment[ru]=Меняйте любые правила Freeciv21 и создавайте новые
Exec=@CMAKE_INSTALL_FULL_BINDIR@/freeciv21-ruledit
Icon=@CMAKE_INSTALL_FULL_DATAROOTDIR@/freeciv21/misc/freeciv21-client.png
Icon=@CMAKE_INSTALL_FULL_DATAROOTDIR@/freeciv21/icons/128x128/freeciv21-client.png
StartupNotify=true
Terminal=false
Type=Application
Expand Down
2 changes: 1 addition & 1 deletion dist/net.longturn.freeciv21.server.desktop.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Comment[pt]=Jogo de estratégia por turnos inspirado na História da civilizaç
Comment[ru]=Пошаговая стратегическая игра, вдохновлённая историей человеческой цивилизации
Comment[sv]=Turordningsbaserat strategispel inspirerat av den mänskliga historien
Exec=@CMAKE_INSTALL_FULL_BINDIR@/freeciv21-server
Icon=@CMAKE_INSTALL_FULL_DATAROOTDIR@/freeciv21/misc/freeciv21-server.png
Icon=@CMAKE_INSTALL_FULL_DATAROOTDIR@/freeciv21/icons/128x128/freeciv21-server.png
StartupNotify=true
Terminal=true
Type=Application
Expand Down
7 changes: 7 additions & 0 deletions tools/fcmp/mpgui_qt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ int main(int argc, char **argv)
QCoreApplication::setApplicationVersion(freeciv21_version());
app.setDesktopFileName(QStringLiteral("net.longturn.freeciv21.modpack"));

// Load window icons
QIcon::setThemeSearchPaths(get_data_dirs() + QIcon::themeSearchPaths());
QIcon::setFallbackThemeName(QIcon::themeName());
QIcon::setThemeName(QStringLiteral("icons"));

qApp->setWindowIcon(QIcon::fromTheme(QStringLiteral("freeciv21-modpack")));

// Delegate option parsing to the common function.
fcmp_parse_cmdline(app);

Expand Down
7 changes: 7 additions & 0 deletions tools/ruledit/ruledit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ int main(int argc, char **argv)
QCoreApplication::setApplicationVersion(freeciv21_version());
app.setDesktopFileName(QStringLiteral("net.longturn.freeciv21.ruledit"));

// Load window icons
QIcon::setThemeSearchPaths(get_data_dirs() + QIcon::themeSearchPaths());
QIcon::setFallbackThemeName(QIcon::themeName());
QIcon::setThemeName(QStringLiteral("icons"));

qApp->setWindowIcon(QIcon::fromTheme(QStringLiteral("freeciv21-client")));

log_init();

init_nls();
Expand Down
Loading