summaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
authorTom Tanner <thosrtanner2@users.sourceforge.net>2015-07-18 10:44:49 +0100
committerTom Tanner <thosrtanner2@users.sourceforge.net>2015-07-18 10:44:49 +0100
commit050309749476aaa07afb00e7160abb4e5e693dcb (patch)
tree5c392338171c69b231378cfe1a2acbe917744b18 /src/mainwindow.cpp
parent3a39f9087099741dd6d2a5c811671e61dcd7174b (diff)
Allow user to select app icon or mo icon for generated shortcuts
Also fixes 'x' for toolbar not disappearing when it should Issue 701
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 946f3a73..bd880dac 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -1626,6 +1626,7 @@ void MainWindow::on_startButton_clicked()
static HRESULT CreateShortcut(LPCWSTR targetFileName, LPCWSTR arguments,
LPCSTR linkFileName, LPCWSTR description,
+ LPCTSTR iconFileName, int iconNumber,
LPCWSTR currentDirectory)
{
HRESULT result = E_INVALIDARG;
@@ -1676,6 +1677,15 @@ static HRESULT CreateShortcut(LPCWSTR targetFileName, LPCWSTR arguments,
}
}
+ if (iconFileName != nullptr) {
+ result = shellLink->SetIconLocation(iconFileName, iconNumber);
+ if (!SUCCEEDED(result)) {
+ qCritical("failed to load program icon: %ls %d", iconFileName, iconNumber);
+ shellLink->Release();
+ return result;
+ }
+ }
+
IPersistFile *persistFile;
result = shellLink->QueryInterface(IID_IPersistFile, (LPVOID*)&persistFile);
if (SUCCEEDED(result)) {
@@ -3283,16 +3293,20 @@ void MainWindow::addWindowsLink(Shortcut_Type const mapping)
} else {
QFileInfo const exeInfo(qApp->applicationFilePath());
// create link
+ QString executable = QDir::toNativeSeparators(selectedExecutable.m_BinaryInfo.absoluteFilePath());
+
std::wstring targetFile = ToWString(exeInfo.absoluteFilePath());
- std::wstring parameter = ToWString(QString("\"%1\" %2").arg(QDir::toNativeSeparators(selectedExecutable.m_BinaryInfo.absoluteFilePath()))
+ std::wstring parameter = ToWString(QString("\"%1\" %2").arg(executable)
.arg(selectedExecutable.m_Arguments));
std::wstring description = ToWString(selectedExecutable.m_BinaryInfo.fileName());
+ std::wstring iconFile = ToWString(executable);
std::wstring currentDirectory = ToWString(QDir::toNativeSeparators(exeInfo.absolutePath()));
if (CreateShortcut(targetFile.c_str()
, parameter.c_str()
, QDir::toNativeSeparators(linkName).toUtf8().constData()
, description.c_str()
+ , (selectedExecutable.m_UseOwnIcon ? iconFile.c_str() : nullptr), 0
, currentDirectory.c_str()) == 0) {
ui->linkButton->menu()->actions().at(static_cast<int>(mapping))->setIcon(QIcon(":/MO/gui/remove"));
} else {
@@ -3530,7 +3544,7 @@ void MainWindow::addAsExecutable()
m_OrganizerCore.executablesList()->addExecutable(name, binaryInfo.absoluteFilePath(),
arguments, targetInfo.absolutePath(),
ExecutableInfo::CloseMOStyle::DEFAULT_STAY, QString(),
- true, false);
+ true, false, false);
refreshExecutablesList();
}
} break;