mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
Add back drag and dropping to screenshots page
Fixes #4548 And #1503 was technically fixed when drag and drop was disabled but can also be closed as this does not reintroduce the issue Signed-off-by: leia uwu <leia@tutamail.com>
This commit is contained in:
parent
3656335666
commit
35526b53f9
3 changed files with 26 additions and 8 deletions
|
|
@ -69,6 +69,23 @@
|
||||||
#include <FileSystem.h>
|
#include <FileSystem.h>
|
||||||
#include "RWStorage.h"
|
#include "RWStorage.h"
|
||||||
|
|
||||||
|
class ScreenshotsFSModel : public QFileSystemModel {
|
||||||
|
bool canDropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) const override
|
||||||
|
{
|
||||||
|
QUrl root = QUrl::fromLocalFile(rootPath());
|
||||||
|
// this disables reordering items inside the model
|
||||||
|
// by rejecting drops if the file is already inside the folder
|
||||||
|
if (data->hasUrls()) {
|
||||||
|
for (auto& url : data->urls()) {
|
||||||
|
if (root.isParentOf(url)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QFileSystemModel::canDropMimeData(data, action, row, column, parent);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
using SharedIconCache = RWStorage<QString, QIcon>;
|
using SharedIconCache = RWStorage<QString, QIcon>;
|
||||||
using SharedIconCachePtr = std::shared_ptr<SharedIconCache>;
|
using SharedIconCachePtr = std::shared_ptr<SharedIconCache>;
|
||||||
|
|
||||||
|
|
@ -237,7 +254,7 @@ class CenteredEditingDelegate : public QStyledItemDelegate {
|
||||||
|
|
||||||
ScreenshotsPage::ScreenshotsPage(QString path, QWidget* parent) : QMainWindow(parent), ui(new Ui::ScreenshotsPage)
|
ScreenshotsPage::ScreenshotsPage(QString path, QWidget* parent) : QMainWindow(parent), ui(new Ui::ScreenshotsPage)
|
||||||
{
|
{
|
||||||
m_model.reset(new QFileSystemModel());
|
m_model.reset(new ScreenshotsFSModel());
|
||||||
m_filterModel.reset(new FilterModel());
|
m_filterModel.reset(new FilterModel());
|
||||||
m_filterModel->setSourceModel(m_model.get());
|
m_filterModel->setSourceModel(m_model.get());
|
||||||
m_model->setFilter(QDir::Files);
|
m_model->setFilter(QDir::Files);
|
||||||
|
|
|
||||||
|
|
@ -41,13 +41,14 @@
|
||||||
|
|
||||||
#include "settings/Setting.h"
|
#include "settings/Setting.h"
|
||||||
|
|
||||||
class QFileSystemModel;
|
|
||||||
class QIdentityProxyModel;
|
class QIdentityProxyModel;
|
||||||
class QItemSelection;
|
class QItemSelection;
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class ScreenshotsPage;
|
class ScreenshotsPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ScreenshotsFSModel;
|
||||||
|
|
||||||
struct ScreenShot;
|
struct ScreenShot;
|
||||||
class ScreenshotList;
|
class ScreenshotList;
|
||||||
class ImgurAlbumCreation;
|
class ImgurAlbumCreation;
|
||||||
|
|
@ -88,7 +89,7 @@ class ScreenshotsPage : public QMainWindow, public BasePage {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ScreenshotsPage* ui;
|
Ui::ScreenshotsPage* ui;
|
||||||
std::shared_ptr<QFileSystemModel> m_model;
|
std::shared_ptr<ScreenshotsFSModel> m_model;
|
||||||
std::shared_ptr<QIdentityProxyModel> m_filterModel;
|
std::shared_ptr<QIdentityProxyModel> m_filterModel;
|
||||||
QString m_folder;
|
QString m_folder;
|
||||||
bool m_valid = false;
|
bool m_valid = false;
|
||||||
|
|
|
||||||
|
|
@ -33,13 +33,13 @@
|
||||||
<enum>QAbstractItemView::SelectionMode::ExtendedSelection</enum>
|
<enum>QAbstractItemView::SelectionMode::ExtendedSelection</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="selectionBehavior">
|
<property name="selectionBehavior">
|
||||||
<enum>QAbstractItemView::SelectionBehavior::SelectRows</enum>
|
<enum>QAbstractItemView::SelectionBehavior::SelectItems</enum>
|
||||||
</property>
|
|
||||||
<property name="movement">
|
|
||||||
<enum>QListView::Movement::Static</enum>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="verticalScrollMode">
|
<property name="verticalScrollMode">
|
||||||
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
<enum>QAbstractItemView::ScrollMode::ScrollPerPixel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="movement">
|
||||||
|
<enum>QListView::Movement::Snap</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue