mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 21:07:59 +03:00
Merge branch 'data_files_menu' into 'master'
Implement a context menu for data directories page Closes #8130 See merge request OpenMW/openmw!4458
This commit is contained in:
commit
cf3badb8a4
10 changed files with 97 additions and 3 deletions
|
@ -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();
|
||||
QStringList filepaths;
|
||||
|
||||
for (QListWidgetItem* item : ui.directoryListWidget->selectedItems())
|
||||
{
|
||||
QString path = qvariant_cast<Config::SettingValue>(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<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">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue