mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-21 21:17:49 +02:00
allow to open directory from context menu
This commit is contained in:
parent
45bb09d9df
commit
7b73c20229
@ -477,6 +477,13 @@ void CModListView::onCustomContextMenu(const QPoint &point)
|
||||
tr("Update"),
|
||||
[this](ModState mod){ doUpdateMod(mod.getID()); }
|
||||
);
|
||||
#ifndef VCMI_MOBILE
|
||||
addContextEntry(
|
||||
mod.isInstalled(),
|
||||
tr("Open directory"),
|
||||
[this](ModState mod){ openModDictionary(mod.getID()); }
|
||||
);
|
||||
#endif
|
||||
|
||||
contextMenu->exec(ui->allModsView->viewport()->mapToGlobal(point));
|
||||
}
|
||||
@ -667,6 +674,18 @@ void CModListView::doUpdateMod(const QString & modName)
|
||||
}
|
||||
}
|
||||
|
||||
void CModListView::openModDictionary(const QString & modName)
|
||||
{
|
||||
QString tmp = modName;
|
||||
tmp.replace(".", "/Mods/");
|
||||
|
||||
ResourcePath resID(std::string("Mods/") + tmp.toStdString(), EResType::DIRECTORY);
|
||||
// Get location of the mod, in case-insensitive way
|
||||
QString modDir = pathToQString(*CResourceHandler::get()->getResourceName(resID));
|
||||
|
||||
Helper::revealDirectoryInFileBrowser(modDir);
|
||||
}
|
||||
|
||||
void CModListView::on_uninstallButton_clicked()
|
||||
{
|
||||
QString modName = ui->allModsView->currentIndex().data(ModRoles::ModNameRole).toString();
|
||||
|
@ -85,6 +85,9 @@ public:
|
||||
/// update mod by name
|
||||
void doUpdateMod(const QString & modName);
|
||||
|
||||
/// open mod dictionary by name
|
||||
void openModDictionary(const QString & modName);
|
||||
|
||||
/// returns true if mod is available in repository and can be installed
|
||||
bool isModAvailable(const QString & modName);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user