From a6e629c3af61f16d8e1a9560e7f4f32bc661217a Mon Sep 17 00:00:00 2001 From: lordmulder Date: Sun, 5 Jun 2011 14:52:45 +0200 Subject: [PATCH] Show custom icons for some "known" folders. --- res/Icons.qrc | 198 ++++++++++++++++++++------------------- src/Config.h | 2 +- src/Model_FileSystem.cpp | 53 ++++++++++- 3 files changed, 151 insertions(+), 102 deletions(-) diff --git a/res/Icons.qrc b/res/Icons.qrc index f5ebc549..1409ed51 100644 --- a/res/Icons.qrc +++ b/res/Icons.qrc @@ -1,102 +1,104 @@ - MainIcon.ico - MainIcon.png - MainIcon2.png - icons/add.png - icons/accept.png - icons/application_view_list.png - icons/application_xp_terminal.png - icons/arrow_down.png - icons/arrow_up.png - icons/arrow_refresh.png - icons/bell.png - icons/bin.png - icons/bomb.png - icons/bug.png - icons/calendar.png - icons/cancel.png - icons/cd.png - icons/cd_add.png - icons/cd_burn.png - icons/cd_delete.png - icons/cd_edit.png - icons/cd_go.png - icons/clock_play.png - icons/cog.png - icons/comment.png - icons/compress.png - icons/computer.png - icons/controller.png - icons/control_pause_blue.png - icons/control_play_blue.png - icons/cross.png - icons/date.png - icons/delete.png - icons/disk.png - icons/door_out.png - icons/door_in.png - icons/drive.png - icons/drive_cd.png - icons/drive_disk.png - icons/drive_link.png - icons/drive_network.png - icons/exclamation.png - icons/error.png - icons/error_big.png - icons/feed.png - icons/folder.png - icons/folder_add.png - icons/folder_go.png - icons/folder_image.png - icons/folder_explore.png - icons/folder_page.png - icons/font.png - icons/group.png - icons/house.png - icons/hourglass.png - icons/information.png - icons/lightning.png - icons/media_play.png - icons/money_dollar.png - icons/monitor.png - icons/music.png - icons/network.png - icons/network_error.png - icons/palette.png - icons/package.png - icons/page_white_cplusplus.png - icons/page_white_add.png - icons/page_white_cd.png - icons/page_white_copy.png - icons/paste_plain.png - icons/photo.png - icons/play.png - icons/power_off.png - icons/power_on.png - icons/report.png - icons/resultset_next.png - icons/script.png - icons/script_edit.png - icons/server_error.png - icons/shield_admin.png - icons/shield_error.png - icons/shield_exclamation.png - icons/shield_green.png - icons/sound.png - icons/star.png - icons/table_edit.png - icons/tick.png - icons/timeline_marker.png - icons/transmit.png - icons/transmit_blue.png - icons/user.png - icons/user_suit.png - icons/user_comment.png - icons/wma.png - icons/world.png - icons/wrench.png - icons/zoom.png - + MainIcon.ico + MainIcon.png + MainIcon2.png + icons/add.png + icons/accept.png + icons/application_view_list.png + icons/application_xp_terminal.png + icons/arrow_down.png + icons/arrow_up.png + icons/arrow_refresh.png + icons/bell.png + icons/bin.png + icons/bomb.png + icons/bug.png + icons/calendar.png + icons/cancel.png + icons/cd.png + icons/cd_add.png + icons/cd_burn.png + icons/cd_delete.png + icons/cd_edit.png + icons/cd_go.png + icons/clock_play.png + icons/cog.png + icons/comment.png + icons/compress.png + icons/computer.png + icons/controller.png + icons/control_pause_blue.png + icons/control_play_blue.png + icons/cross.png + icons/date.png + icons/delete.png + icons/disk.png + icons/door_out.png + icons/door_in.png + icons/drive.png + icons/drive_cd.png + icons/drive_disk.png + icons/drive_link.png + icons/drive_network.png + icons/exclamation.png + icons/error.png + icons/error_big.png + icons/feed.png + icons/film.png + icons/folder.png + icons/folder_add.png + icons/folder_go.png + icons/folder_image.png + icons/folder_explore.png + icons/folder_page.png + icons/font.png + icons/group.png + icons/house.png + icons/hourglass.png + icons/information.png + icons/lightning.png + icons/media_play.png + icons/money_dollar.png + icons/monitor.png + icons/music.png + icons/network.png + icons/network_error.png + icons/palette.png + icons/package.png + icons/page_white_cplusplus.png + icons/page_white_add.png + icons/page_white_cd.png + icons/page_white_copy.png + icons/paste_plain.png + icons/photo.png + icons/picture.png + icons/play.png + icons/power_off.png + icons/power_on.png + icons/report.png + icons/resultset_next.png + icons/script.png + icons/script_edit.png + icons/server_error.png + icons/shield_admin.png + icons/shield_error.png + icons/shield_exclamation.png + icons/shield_green.png + icons/sound.png + icons/star.png + icons/table_edit.png + icons/tick.png + icons/timeline_marker.png + icons/transmit.png + icons/transmit_blue.png + icons/user.png + icons/user_suit.png + icons/user_comment.png + icons/wma.png + icons/world.png + icons/wrench.png + icons/zoom.png + diff --git a/src/Config.h b/src/Config.h index 125b07e2..10662745 100644 --- a/src/Config.h +++ b/src/Config.h @@ -30,7 +30,7 @@ #define VER_LAMEXP_MINOR_LO 2 #define VER_LAMEXP_TYPE Beta #define VER_LAMEXP_PATCH 7 -#define VER_LAMEXP_BUILD 566 +#define VER_LAMEXP_BUILD 567 /////////////////////////////////////////////////////////////////////////////// // Tools versions diff --git a/src/Model_FileSystem.cpp b/src/Model_FileSystem.cpp index 14738e58..aa13cf4e 100644 --- a/src/Model_FileSystem.cpp +++ b/src/Model_FileSystem.cpp @@ -24,6 +24,7 @@ #include #include +#include /////////////////////////////////////////////////////////////////////////////// // Dummy QFileIconProvider class @@ -43,9 +44,19 @@ private: const QIcon m_networkIcon; const QIcon m_floppyIcon; const QIcon m_folderIcon; + const QIcon m_homeIcon; + const QIcon m_desktopIcon; + const QIcon m_musicIcon; + const QIcon m_moviesIcon; + const QIcon m_picturesIcon; const QIcon m_emptyIcon; const QString m_folderType; const QString m_emptyType; + const QString m_homeDir; + const QString m_desktopDir; + const QString m_musicDir; + const QString m_moviesDir; + const QString m_picturesDir; }; QFileIconProviderEx::QFileIconProviderEx() @@ -55,6 +66,16 @@ QFileIconProviderEx::QFileIconProviderEx() m_cdromIcon(":/icons/drive_cd.png"), m_networkIcon(":/icons/drive_link.png"), m_floppyIcon(":/icons/drive_disk.png"), + m_homeIcon(":/icons/house.png"), + m_desktopIcon(":/icons/monitor.png"), + m_musicIcon(":/icons/music.png"), + m_moviesIcon(":/icons/film.png"), + m_picturesIcon(":/icons/picture.png"), + m_homeDir(QDir::fromNativeSeparators(QDesktopServices::storageLocation(QDesktopServices::HomeLocation))), + m_desktopDir(QDir::fromNativeSeparators(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation))), + m_musicDir(QDir::fromNativeSeparators(QDesktopServices::storageLocation(QDesktopServices::MusicLocation))), + m_moviesDir(QDir::fromNativeSeparators(QDesktopServices::storageLocation(QDesktopServices::MoviesLocation))), + m_picturesDir(QDir::fromNativeSeparators(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation))), m_folderType("Folder") { /* Nothing to do! */ @@ -62,7 +83,11 @@ QFileIconProviderEx::QFileIconProviderEx() QIcon QFileIconProviderEx::icon(const QFileInfo &info) const { - if(info.isRoot()) + if(info.isFile()) + { + return m_emptyIcon; + } + else if(info.isRoot()) { switch(GetDriveType(QWCHAR(QDir::toNativeSeparators(info.absoluteFilePath())))) { @@ -80,8 +105,30 @@ QIcon QFileIconProviderEx::icon(const QFileInfo &info) const break; } } - - return info.isFile() ? m_emptyIcon : m_folderIcon; + else if(!info.filePath().compare(m_homeDir, Qt::CaseInsensitive)) + { + return m_homeIcon; + } + else if(!info.filePath().compare(m_desktopDir, Qt::CaseInsensitive)) + { + return m_desktopIcon; + } + else if(!info.filePath().compare(m_musicDir, Qt::CaseInsensitive)) + { + return m_musicIcon; + } + else if(!info.filePath().compare(m_moviesDir, Qt::CaseInsensitive)) + { + return m_moviesIcon; + } + else if(!info.filePath().compare(m_picturesDir, Qt::CaseInsensitive)) + { + return m_picturesIcon; + } + else + { + return m_folderIcon; + } } ///////////////////////////////////////////////////////////////////////////////