From 2e543bfe0ab034f93f36a8bab414b11491e3726f Mon Sep 17 00:00:00 2001 From: Gary Wang Date: Wed, 8 Apr 2020 18:16:45 +0800 Subject: [PATCH] feat: add an icon... --- CMakeLists.txt | 56 ++++++++++++- icons/app-icon.svg | 172 ++++++++++++++++++++++++++++++++++++++++ mainwindow.ui | 4 + pineapple-music.desktop | 12 +++ resources.qrc | 1 + 5 files changed, 243 insertions(+), 2 deletions(-) create mode 100755 icons/app-icon.svg create mode 100644 pineapple-music.desktop diff --git a/CMakeLists.txt b/CMakeLists.txt index dca0df8..ce8051e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.5) project(pineapple-music LANGUAGES CXX) +include (GNUInstallDirs) + set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOUIC ON) @@ -13,7 +15,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(Qt5 COMPONENTS Widgets Multimedia REQUIRED) -add_executable(pineapple-music +set (EXE_NAME pmusic) + +add_executable(${EXE_NAME} main.cpp mainwindow.cpp mainwindow.h @@ -25,4 +29,52 @@ add_executable(pineapple-music resources.qrc ) -target_link_libraries(pineapple-music PRIVATE Qt5::Widgets Qt5::Multimedia) +target_link_libraries(${EXE_NAME} PRIVATE Qt5::Widgets Qt5::Multimedia) + +# Helper macros for install settings +macro (pmusic_convert_to_relative_path _var) + # Make sure _var is a relative path + if (IS_ABSOLUTE "${${_var}}") + file (RELATIVE_PATH ${_var} "${CMAKE_INSTALL_PREFIX}" "${${_var}}") + endif () +endmacro () + +# Install settings +if (WIN32) + # FIXME: try to avoid install to a "bin" subfolder under windows... + # when fixed, don't forget to update the CI config file... + set (BIN_INSTALL_DIR "") # seems useless, don't know why... +elseif (UNIX) + if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX /usr) + endif () + + set (BIN_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}") # relative, usually "bin" + pmusic_convert_to_relative_path(BIN_INSTALL_DIR) + set (LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}") # "lib" or "lib64" + pmusic_convert_to_relative_path(LIB_INSTALL_DIR) + + # install icon + install ( + FILES icons/app-icon.svg + DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/48x48/apps" + RENAME pineapple-music.svg + ) + + # install shortcut + install ( + FILES pineapple-music.desktop + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications" + ) +endif() + +set (INSTALL_TARGETS_DEFAULT_ARGS + RUNTIME DESTINATION ${BIN_INSTALL_DIR} + LIBRARY DESTINATION ${LIB_INSTALL_DIR} + ARCHIVE DESTINATION ${LIB_INSTALL_DIR} COMPONENT Devel +) + +install ( + TARGETS ${EXE_NAME} + ${INSTALL_TARGETS_DEFAULT_ARGS} +) diff --git a/icons/app-icon.svg b/icons/app-icon.svg new file mode 100755 index 0000000..d660386 --- /dev/null +++ b/icons/app-icon.svg @@ -0,0 +1,172 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/mainwindow.ui b/mainwindow.ui index c9b0d1d..4cea614 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -19,6 +19,10 @@ Pineapple Player + + + :/icons/icons/app-icon.svg:/icons/icons/app-icon.svg + /****** Slider ******/ diff --git a/pineapple-music.desktop b/pineapple-music.desktop new file mode 100644 index 0000000..f4db60f --- /dev/null +++ b/pineapple-music.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Categories=Player;Audio; +Comment=Pineapple Music Audio Player. +Exec=pmusic %F +GenericName=Music +Icon=pineapple-music +Keywords=Picture;Image;Viewer;Jpg;Jpeg;Png; +MimeType=application/ogg;application/x-ogg;audio/ogg;audio/vorbis;audio/x-vorbis;audio/x-vorbis+ogg;video/ogg;video/x-ogm;video/x-ogm+ogg;video/x-theora+ogg;video/x-theora;audio/x-speex;audio/opus;application/x-flac;audio/flac;audio/x-flac;audio/x-ms-asf;audio/x-ms-asx;audio/x-ms-wax;audio/x-ms-wma;video/x-ms-asf;video/x-ms-asf-plugin;video/x-ms-asx;video/x-ms-wm;video/x-ms-wmv;video/x-ms-wmx;video/x-ms-wvx;video/x-msvideo;audio/x-pn-windows-acm;video/divx;video/msvideo;video/vnd.divx;video/avi;video/x-avi;application/vnd.rn-realmedia;application/vnd.rn-realmedia-vbr;audio/vnd.rn-realaudio;audio/x-pn-realaudio;audio/x-pn-realaudio-plugin;audio/x-real-audio;audio/x-realaudio;video/vnd.rn-realvideo;audio/mpeg;audio/mpg;audio/mp1;audio/mp2;audio/mp3;audio/x-mp1;audio/x-mp2;audio/x-mp3;audio/x-mpeg;audio/x-mpg;video/mp2t;video/mpeg;video/mpeg-system;video/x-mpeg;video/x-mpeg2;video/x-mpeg-system;application/mpeg4-iod;application/mpeg4-muxcodetable;application/x-extension-m4a;application/x-extension-mp4;audio/aac;audio/m4a;audio/mp4;audio/x-m4a;audio/x-aac;video/mp4;video/mp4v-es;video/x-m4v;application/x-quicktime-media-link;application/x-quicktimeplayer;video/quicktime;application/x-matroska;audio/x-matroska;video/x-matroska;video/webm;audio/webm;audio/3gpp;audio/3gpp2;audio/AMR;audio/AMR-WB;video/3gp;video/3gpp;video/3gpp2;x-scheme-handler/mms;x-scheme-handler/mmsh;x-scheme-handler/rtsp;x-scheme-handler/rtp;x-scheme-handler/rtmp;x-scheme-handler/icy;x-scheme-handler/icyx;application/x-cd-image;x-content/video-vcd;x-content/video-svcd;x-content/video-dvd;x-content/audio-cdda;x-content/audio-player;application/ram;application/xspf+xml;audio/mpegurl;audio/x-mpegurl;audio/scpls;audio/x-scpls;text/google-video-pointer;text/x-google-video-pointer;video/vnd.mpegurl;application/vnd.apple.mpegurl;application/vnd.ms-asf;application/vnd.ms-wpl;application/sdp;audio/dv;video/dv;audio/x-aiff;audio/x-pn-aiff;video/x-anim;video/x-nsv;video/fli;video/flv;video/x-flc;video/x-fli;video/x-flv;audio/wav;audio/x-pn-au;audio/x-pn-wav;audio/x-wav;audio/x-adpcm;audio/ac3;audio/eac3;audio/vnd.dts;audio/vnd.dts.hd;audio/vnd.dolby.heaac.1;audio/vnd.dolby.heaac.2;audio/vnd.dolby.mlp;audio/basic;audio/midi;audio/x-ape;audio/x-gsm;audio/x-musepack;audio/x-tta;audio/x-wavpack;audio/x-shorten;application/x-shockwave-flash;application/x-flash-video;misc/ultravox;image/vnd.rn-realpix;audio/x-it;audio/x-mod;audio/x-s3m;audio/x-xm;application/mxf; +Name=Pineapple Music +StartupNotify=false +Type=Application +Terminal=false diff --git a/resources.qrc b/resources.qrc index 7eb5e16..c34920d 100644 --- a/resources.qrc +++ b/resources.qrc @@ -11,5 +11,6 @@ icons/window-minimize.png icons/media-playback-pause.png icons/audio-volume-muted.png + icons/app-icon.svg