diff --git a/CHANGELOG.md b/CHANGELOG.md index 15049ef1376..97941564a31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -275,6 +275,7 @@ Feature #8067: Support Game Mode on macOS Feature #8078: OpenMW-CS Terrain Equalize Tool Feature #8087: Creature movement flags are not exposed + Feature #8130: Launcher: Add the ability to open a selected data directory in the file browser Feature #8145: Starter spell flag is not exposed Task #5859: User openmw-cs.cfg has comment talking about settings.cfg Task #5896: Do not use deprecated MyGUI properties diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index 086707b0532..9bb54fdb8e6 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -1,7 +1,9 @@ #include "datafilespage.hpp" #include "maindialog.hpp" +#include #include +#include #include #include #include @@ -244,6 +246,31 @@ void Launcher::DataFilesPage::buildView() &DataFilesPage::navMeshToolFinished); buildArchiveContextMenu(); + buildDataFilesContextMenu(); +} + +void Launcher::DataFilesPage::slotCopySelectedItemsPaths() +{ + QClipboard* clipboard = QApplication::clipboard(); + QStringList filepaths; + + for (QListWidgetItem* item : ui.directoryListWidget->selectedItems()) + { + QString path = qvariant_cast(item->data(Qt::UserRole)).originalRepresentation; + filepaths.push_back(path); + } + + if (!filepaths.isEmpty()) + { + clipboard->setText(filepaths.join("\n")); + } +} + +void Launcher::DataFilesPage::slotOpenSelectedItemsPaths() +{ + QListWidgetItem* item = ui.directoryListWidget->currentItem(); + QUrl confFolderUrl = QUrl::fromLocalFile(qvariant_cast(item->data(Qt::UserRole)).value); + QDesktopServices::openUrl(confFolderUrl); } void Launcher::DataFilesPage::buildArchiveContextMenu() @@ -256,6 +283,18 @@ void Launcher::DataFilesPage::buildArchiveContextMenu() mArchiveContextMenu->addAction(tr("&Uncheck Selected"), this, SLOT(slotUncheckMultiSelectedItems())); } +void Launcher::DataFilesPage::buildDataFilesContextMenu() +{ + connect(ui.directoryListWidget, &QListWidget::customContextMenuRequested, this, + &DataFilesPage::slotShowDataFilesContextMenu); + + mDataFilesContextMenu = new QMenu(ui.directoryListWidget); + mDataFilesContextMenu->addAction( + tr("&Copy Path(s) to Clipboard"), this, &Launcher::DataFilesPage::slotCopySelectedItemsPaths); + mDataFilesContextMenu->addAction( + tr("&Open Path in File Explorer"), this, &Launcher::DataFilesPage::slotOpenSelectedItemsPaths); +} + bool Launcher::DataFilesPage::loadSettings() { ui.navMeshMaxSizeSpinBox->setValue(getMaxNavMeshDbFileSizeMiB()); @@ -832,6 +871,12 @@ void Launcher::DataFilesPage::slotShowArchiveContextMenu(const QPoint& pos) mArchiveContextMenu->exec(globalPos); } +void Launcher::DataFilesPage::slotShowDataFilesContextMenu(const QPoint& pos) +{ + QPoint globalPos = ui.directoryListWidget->viewport()->mapToGlobal(pos); + mDataFilesContextMenu->exec(globalPos); +} + void Launcher::DataFilesPage::setCheckStateForMultiSelectedItems(bool checked) { Qt::CheckState checkState = checked ? Qt::Checked : Qt::Unchecked; diff --git a/apps/launcher/datafilespage.hpp b/apps/launcher/datafilespage.hpp index 7e347c08443..5d03cdf800c 100644 --- a/apps/launcher/datafilespage.hpp +++ b/apps/launcher/datafilespage.hpp @@ -42,6 +42,7 @@ namespace Launcher ContentSelectorView::ContentSelector* mSelector; Ui::DataFilesPage ui; QMenu* mArchiveContextMenu; + QMenu* mDataFilesContextMenu; public: explicit DataFilesPage(const Files::ConfigurationManager& cfg, Config::GameSettings& gameSettings, @@ -79,6 +80,7 @@ namespace Launcher void moveSources(QListWidget* sourceList, int step); void slotShowArchiveContextMenu(const QPoint& pos); + void slotShowDataFilesContextMenu(const QPoint& pos); void slotCheckMultiSelectedItems(); void slotUncheckMultiSelectedItems(); @@ -129,6 +131,7 @@ namespace Launcher void addArchivesFromDir(const QString& dir); void buildView(); void buildArchiveContextMenu(); + void buildDataFilesContextMenu(); void setCheckStateForMultiSelectedItems(bool checked); void setProfile(int index, bool savePrevious); void setProfile(const QString& previous, const QString& current, bool savePrevious); @@ -140,6 +143,8 @@ namespace Launcher void reloadCells(QStringList selectedFiles); void refreshDataFilesView(); void updateNavMeshProgress(int minDataSize); + void slotCopySelectedItemsPaths(); + void slotOpenSelectedItemsPaths(); /** * Returns the file paths of all selected content files diff --git a/apps/launcher/ui/datafilespage.ui b/apps/launcher/ui/datafilespage.ui index 1f537b1cc84..65236ca5ca9 100644 --- a/apps/launcher/ui/datafilespage.ui +++ b/apps/launcher/ui/datafilespage.ui @@ -58,6 +58,9 @@ QAbstractItemView::ExtendedSelection + + Qt::CustomContextMenu + diff --git a/components/contentselector/view/contentselector.cpp b/components/contentselector/view/contentselector.cpp index 2bcb73689e2..bce136b3351 100644 --- a/components/contentselector/view/contentselector.cpp +++ b/components/contentselector/view/contentselector.cpp @@ -320,17 +320,17 @@ void ContentSelectorView::ContentSelector::slotCheckMultiSelectedItems() void ContentSelectorView::ContentSelector::slotCopySelectedItemsPaths() { QClipboard* clipboard = QApplication::clipboard(); - QString filepaths; + QStringList filepaths; for (const QModelIndex& index : ui->addonView->selectionModel()->selectedIndexes()) { int row = mAddonProxyModel->mapToSource(index).row(); const ContentSelectorModel::EsmFile* file = mContentModel->item(row); - filepaths += file->filePath() + "\n"; + filepaths.push_back(file->filePath()); } if (!filepaths.isEmpty()) { - clipboard->setText(filepaths); + clipboard->setText(filepaths.join("\n")); } } diff --git a/files/lang/launcher_de.ts b/files/lang/launcher_de.ts index 080fa5f57c3..86773e5a54f 100644 --- a/files/lang/launcher_de.ts +++ b/files/lang/launcher_de.ts @@ -390,6 +390,14 @@ to default Morrowind fonts. Check this box if you still prefer original fonts ov This archive is enabled in an openmw.cfg other than the user one + + &Copy Path(s) to Clipboard + + + + &Open Path in File Explorer + + Launcher::GraphicsPage diff --git a/files/lang/launcher_en.ts b/files/lang/launcher_en.ts index 99ab3ea974f..a0319318e8f 100644 --- a/files/lang/launcher_en.ts +++ b/files/lang/launcher_en.ts @@ -390,6 +390,14 @@ to default Morrowind fonts. Check this box if you still prefer original fonts ov Delete + + &Copy Path(s) to Clipboard + + + + &Open Path in File Explorer + + Launcher::GraphicsPage diff --git a/files/lang/launcher_fr.ts b/files/lang/launcher_fr.ts index 5d05d85138e..569a460cd00 100644 --- a/files/lang/launcher_fr.ts +++ b/files/lang/launcher_fr.ts @@ -390,6 +390,14 @@ to default Morrowind fonts. Check this box if you still prefer original fonts ov This archive is enabled in an openmw.cfg other than the user one Cette archive est activée dans un fichier openmw.cfg qui n'est pas celui de l'utilisateur. + + &Copy Path(s) to Clipboard + &Copier l'emplacement dans le presse papier + + + &Open Path in File Explorer + &Ouvrir l'emplacement dans l'explorateur de fichiers + Launcher::GraphicsPage diff --git a/files/lang/launcher_ru.ts b/files/lang/launcher_ru.ts index cee55f86def..879f24dc762 100644 --- a/files/lang/launcher_ru.ts +++ b/files/lang/launcher_ru.ts @@ -392,6 +392,14 @@ to default Morrowind fonts. Check this box if you still prefer original fonts ov This archive is enabled in an openmw.cfg other than the user one Этот архив включен в openmw.cfg, не являющемся пользовательским + + &Copy Path(s) to Clipboard + &Скопировать пути в буфер обмена + + + &Open Path in File Explorer + &Открыть путь в диспетчере файлов + Launcher::GraphicsPage diff --git a/files/lang/launcher_sv.ts b/files/lang/launcher_sv.ts index 969c609bf3b..f2cca2346ca 100644 --- a/files/lang/launcher_sv.ts +++ b/files/lang/launcher_sv.ts @@ -393,6 +393,14 @@ de ordinarie fonterna i Morrowind. Bocka denna ruta om du ändå föredrar ordin This archive is enabled in an openmw.cfg other than the user one Detta arkiv är aktiverat i en annan openmw.cfg än användarens + + &Copy Path(s) to Clipboard + &Kopiera sökväg(ar) till klippbordet + + + &Open Path in File Explorer + Öppna katalogen i filutforskaren + Launcher::GraphicsPage