Windows: add instance icon to shortcut
Signed-off-by: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com>
This commit is contained in:
parent
b83f9be1bd
commit
4d4dfab388
@ -2107,11 +2107,28 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered()
|
|||||||
auto icon = APPLICATION->icons()->icon(m_selectedInstance->iconKey());
|
auto icon = APPLICATION->icons()->icon(m_selectedInstance->iconKey());
|
||||||
|
|
||||||
QString iconPath;
|
QString iconPath;
|
||||||
|
bool iconGenerated = false;
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
// TODO
|
iconPath = FS::PathCombine(m_selectedInstance->instanceRoot(), "icon.ico");
|
||||||
// need to convert icon to ICO format and save it somewhere...
|
|
||||||
iconPath = "";
|
QFile iconFile(iconPath);
|
||||||
|
if (!iconFile.open(QFile::WriteOnly))
|
||||||
|
{
|
||||||
|
QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create instance shortcut!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!icon->icon().pixmap(64, 64).save(&iconFile, "ICO"))
|
||||||
|
{
|
||||||
|
iconFile.close();
|
||||||
|
iconFile.remove();
|
||||||
|
QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create instance shortcut!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
iconFile.close();
|
||||||
|
iconGenerated = true;
|
||||||
#else
|
#else
|
||||||
iconPath = icon->getFilePath();
|
iconPath = icon->getFilePath();
|
||||||
#endif
|
#endif
|
||||||
@ -2121,6 +2138,10 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (iconGenerated)
|
||||||
|
{
|
||||||
|
QFile::remove(iconPath);
|
||||||
|
}
|
||||||
QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create instance shortcut!"));
|
QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create instance shortcut!"));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user