Skip to content

Commit 3619054

Browse files
committed
add option to resolve symbol link target
1 parent 97937d5 commit 3619054

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

src/Launchy/OptionItem.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ const int OPTION_FADEIN_DEFAULT = 10;
8383
const char* OPTION_FADEOUT = "GenOps/fadeout";
8484
const int OPTION_FADEOUT_DEFAULT = 20;
8585

86+
const char* OPTION_RESOLVE_SYM_LINK_TARGET = "GenOps/ResolveSymLinkTarget";
87+
const bool OPTION_RESOLVE_SYM_LINK_TARGET_DEFAULT = true;
88+
8689
const char* OPTION_SKIN = "GenOps/skin";
8790
const char* OPTION_SKIN_DEFAULT = "Default";
8891

src/Launchy/OptionItem.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ extern const int OPTION_FADEIN_DEFAULT;
9191
extern const char* OPTION_FADEOUT;
9292
extern const int OPTION_FADEOUT_DEFAULT;
9393

94+
extern const char* OPTION_RESOLVE_SYM_LINK_TARGET;
95+
extern const bool OPTION_RESOLVE_SYM_LINK_TARGET_DEFAULT;
96+
9497
// skin
9598
extern const char* OPTION_SKIN;
9699
extern const char* OPTION_SKIN_DEFAULT;

src/Launchy/Windows/IconProviderWin.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636

3737
#include <QProcessEnvironment>
3838

39+
#include "LaunchyLib/LaunchyLib.h"
40+
41+
#include "OptionItem.h"
3942
#include "UtilWin.h"
4043

4144
namespace launchy {
@@ -74,6 +77,23 @@ QIcon IconProviderWin::icon(const QFileInfo& info) const {
7477
}
7578
else {
7679

80+
bool bResolveSymLink
81+
= g_settings->value(OPTION_RESOLVE_SYM_LINK_TARGET,
82+
OPTION_RESOLVE_SYM_LINK_TARGET_DEFAULT).toBool();
83+
84+
QString filePath;
85+
86+
// resolve sym link target
87+
if (bResolveSymLink && info.isSymLink()) {
88+
filePath = QDir::toNativeSeparators(info.symLinkTarget());
89+
90+
qDebug() << "IconProviderWin::icon, sym link, target path:" << filePath
91+
<< "file path:" << info.filePath();
92+
}
93+
else {
94+
filePath = QDir::toNativeSeparators(info.filePath());
95+
}
96+
7797
unsigned int flags = SHGFI_ICON | SHGFI_SYSICONINDEX | SHGFI_ICONLOCATION;
7898

7999
if (m_preferredSize <= 16) {
@@ -89,7 +109,6 @@ QIcon IconProviderWin::icon(const QFileInfo& info) const {
89109
flags |= SHIL_JUMBO;
90110
}
91111

92-
QString filePath = QDir::toNativeSeparators(info.filePath());
93112

94113
qDebug() << "IconProviderWin::icon, file path:" << filePath
95114
<< ", flags:" << flags;

0 commit comments

Comments
 (0)