mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-01 21:06:41 +00:00
Implement a context menu for data directories page (feature 8130)
This commit is contained in:
parent
43f25fea5d
commit
f0543c5500
9 changed files with 94 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#include "datafilespage.hpp"
|
||||
#include "maindialog.hpp"
|
||||
|
||||
#include <QClipboard>
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
#include <QFileDialog>
|
||||
#include <QList>
|
||||
#include <QMessageBox>
|
||||
|
@ -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<Config::SettingValue>(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<Config::SettingValue>(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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -58,6 +58,9 @@
|
|||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
|
|
|
@ -390,6 +390,14 @@ to default Morrowind fonts. Check this box if you still prefer original fonts ov
|
|||
<source>This archive is enabled in an openmw.cfg other than the user one</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>&Copy Path(s) to Clipboard</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>&Open Path in File Explorer</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Launcher::GraphicsPage</name>
|
||||
|
|
|
@ -390,6 +390,14 @@ to default Morrowind fonts. Check this box if you still prefer original fonts ov
|
|||
<source>Delete</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>&Copy Path(s) to Clipboard</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>&Open Path in File Explorer</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Launcher::GraphicsPage</name>
|
||||
|
|
|
@ -390,6 +390,14 @@ to default Morrowind fonts. Check this box if you still prefer original fonts ov
|
|||
<source>This archive is enabled in an openmw.cfg other than the user one</source>
|
||||
<translation>Cette archive est activée dans un fichier openmw.cfg qui n'est pas celui de l'utilisateur.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>&Copy Path(s) to Clipboard</source>
|
||||
<translation>&Copier l'emplacement dans le presse papier</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>&Open Path in File Explorer</source>
|
||||
<translation>&Ouvrir l'emplacement dans l'explorateur de fichiers</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Launcher::GraphicsPage</name>
|
||||
|
|
|
@ -392,6 +392,14 @@ to default Morrowind fonts. Check this box if you still prefer original fonts ov
|
|||
<source>This archive is enabled in an openmw.cfg other than the user one</source>
|
||||
<translation>Этот архив включен в openmw.cfg, не являющемся пользовательским</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>&Copy Path(s) to Clipboard</source>
|
||||
<translation>&Скопировать пути в буфер обмена</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>&Open Path in File Explorer</source>
|
||||
<translation>&Открыть путь в диспетчере файлов</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Launcher::GraphicsPage</name>
|
||||
|
|
|
@ -393,6 +393,14 @@ de ordinarie fonterna i Morrowind. Bocka denna ruta om du ändå föredrar ordin
|
|||
<source>This archive is enabled in an openmw.cfg other than the user one</source>
|
||||
<translation>Detta arkiv är aktiverat i en annan openmw.cfg än användarens</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>&Copy Path(s) to Clipboard</source>
|
||||
<translation>&Kopiera sökväg(ar) till klippbordet</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>&Open Path in File Explorer</source>
|
||||
<translation>Öppna katalogen i filutforskaren</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Launcher::GraphicsPage</name>
|
||||
|
|
Loading…
Reference in a new issue