diff --git a/CHANGELOG.md b/CHANGELOG.md index c22ac65daf..cbd918ddb2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -274,6 +274,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 086707b053..45518b4fe4 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(); + QString filepaths; + + for (QListWidgetItem* item : ui.directoryListWidget->selectedItems()) + { + QString path = qvariant_cast(item->data(Qt::UserRole)).originalRepresentation; + filepaths += path + "\n"; + } + + if (!filepaths.isEmpty()) + { + clipboard->setText(filepaths); + } +} + +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 7e347c0844..5d03cdf800 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 1f537b1cc8..65236ca5ca 100644 --- a/apps/launcher/ui/datafilespage.ui +++ b/apps/launcher/ui/datafilespage.ui @@ -58,6 +58,9 @@ QAbstractItemView::ExtendedSelection + + Qt::CustomContextMenu + diff --git a/files/lang/launcher_de.ts b/files/lang/launcher_de.ts index 080fa5f57c..86773e5a54 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 99ab3ea974..a0319318e8 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 5d05d85138..569a460cd0 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 cee55f86de..879f24dc76 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 969c609bf3..f2cca2346c 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