diff options
author | Stefan Hacker <dd0t@users.sourceforge.net> | 2010-05-04 20:06:22 +0400 |
---|---|---|
committer | Stefan Hacker <dd0t@users.sourceforge.net> | 2010-05-04 20:07:33 +0400 |
commit | ec31de1b25acddc58c696bca767e2315a17986b6 (patch) | |
tree | 9c1ba85bf4fbb4008ff9aa2ed87d203ea1884cdd | |
parent | 532c3f2d2a2c554b7f367c79df3565b83a8f767d (diff) |
Add black/whitelist icon loading for Windows. Make lists match on full path as well as executable names
-rw-r--r-- | overlay/lib.cpp | 12 | ||||
-rw-r--r-- | src/mumble/Overlay.cpp | 19 |
2 files changed, 18 insertions, 13 deletions
diff --git a/overlay/lib.cpp b/overlay/lib.cpp index 9c06f639e..11bdeb671 100644 --- a/overlay/lib.cpp +++ b/overlay/lib.cpp @@ -545,8 +545,8 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE, DWORD fdwReason, LPVOID) { if (usewhitelist) { bool onwhitelist = false; while (buffer[pos] != 0 && pos < sizeof(buffer)) { - if (_stricmp(p+1, buffer + pos) == 0) { - fods("Overlay enabled for whitelisted %s", p+1); + if (_stricmp(procname, buffer + pos) == 0 || _stricmp(p+1, buffer + pos) == 0) { + fods("Overlay enabled for whitelisted '%s'", buffer + pos); onwhitelist = true; break; } @@ -559,9 +559,9 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE, DWORD fdwReason, LPVOID) { } } else { while (buffer[pos] != 0 && pos < sizeof(buffer)) { - if (_stricmp(p+1, buffer + pos) == 0) { + if (_stricmp(procname, buffer + pos) == 0 || _stricmp(p+1, buffer + pos) == 0) { bBlackListed = true; - fods("Overlay blacklist entry found for %s", p+1); + fods("Overlay blacklist entry found for '%s'", buffer + pos); return TRUE; } pos += strlen(buffer + pos) + 1; @@ -571,8 +571,8 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE, DWORD fdwReason, LPVOID) { // If there is no list in the registry fallback to using the default blacklist fods("Overlay fallback to default blacklist"); while (overlayBlacklist[i]) { - if (_stricmp(p+1, overlayBlacklist[i])==0) { - fods("Overlay blacklist entry found for %s", p+1); + if (_stricmp(procname, overlayBlacklist[i]) == 0 || _stricmp(p+1, overlayBlacklist[i])==0) { + fods("Overlay blacklist entry found for %s", overlayBlacklist[i]); bBlackListed = true; return TRUE; } diff --git a/src/mumble/Overlay.cpp b/src/mumble/Overlay.cpp index 4b9bc5703..4a2060e7b 100644 --- a/src/mumble/Overlay.cpp +++ b/src/mumble/Overlay.cpp @@ -106,13 +106,13 @@ OverlayConfig::OverlayConfig(Settings &st) : ConfigWidget(st) { } OverlayAppInfo OverlayConfig::applicationInfoForId(const QString &identifier) { -#ifdef Q_OS_MAC + QString qsAppName(identifier); + QIcon qiAppIcon; +#if defined(Q_OS_MAC) CFStringRef bundleId = NULL; CFURLRef bundleUrl = NULL; CFBundleRef bundle = NULL; OSStatus err = noErr; - QString qsAppName; - QIcon qiAppIcon; char buf[4096]; bundleId = CFStringCreateWithCharacters(kCFAllocatorDefault, reinterpret_cast<const UniChar *>(identifier.unicode()), identifier.length()); @@ -151,10 +151,14 @@ OverlayAppInfo OverlayConfig::applicationInfoForId(const QString &identifier) { if (bundle) CFRelease(bundle); - return OverlayAppInfo(qsAppName, qiAppIcon); -#else - return OverlayAppInfo(identifier); +#elif defined(Q_OS_WIN) + HICON icon = ExtractIcon(qWinAppInst(), identifier.utf16(), 0); + if (icon) { + qiAppIcon = QIcon(QPixmap::fromWinHICON(icon)); + DestroyIcon(icon); + } #endif + return OverlayAppInfo(qsAppName, qiAppIcon); } QString OverlayConfig::applicationIdentifierForPath(const QString &path) { @@ -187,7 +191,7 @@ QString OverlayConfig::applicationIdentifierForPath(const QString &path) { return qsIdentifier; #else - return QFileInfo(path).fileName(); + return QDir::toNativeSeparators(path); #endif } @@ -297,6 +301,7 @@ void OverlayConfig::on_qpbAdd_clicked() { OverlayAppInfo oai = applicationInfoForId(qsAppIdentifier); QListWidgetItem *qlwiApplication = new QListWidgetItem(oai.qiIcon, oai.qsDisplayName, sel); qlwiApplication->setData(Qt::UserRole, QVariant(qsAppIdentifier)); + sel->setCurrentItem(qlwiApplication); } } } |