Skip to content

Commit

Permalink
fix: [select-dialog] Double-click to unable to open the file
Browse files Browse the repository at this point in the history
When there are two choice boxes, double-click the file cannot be opened.

Log: fix issue
Bug: https://pms.uniontech.com/bug-view-261287.html
  • Loading branch information
GongHeng2017 authored and deepin-bot[bot] committed Jul 1, 2024
1 parent dffded2 commit a7f14d6
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
#include "dbus/filedialog_adaptor.h"
#include "utils/appexitcontroller.h"

#include <dfm-base/dfm_event_defines.h>
#include <dfm-base/base/application/application.h>
#include <dfm-base/base/application/settings.h>
#include <dfm-base/mimetype/dmimedatabase.h>
#include <dfm-base/utils/universalutils.h>

#include <dfm-framework/event/event.h>

Expand Down Expand Up @@ -53,6 +55,7 @@ QDBusObjectPath FileDialogManagerDBus::createDialog(QString key)
curDialogObjectMap[path] = handle;
connect(handle, &FileDialogHandleDBus::destroyed, this, &FileDialogManagerDBus::onDialogDestroy);
DIALOGCORE_NAMESPACE::AppExitController::instance().dismiss();
initEventsFilter();
return path;
}

Expand Down Expand Up @@ -139,3 +142,38 @@ void FileDialogManagerDBus::onAppExit()
});
}
}

void FileDialogManagerDBus::initEventsFilter()
{
dpfSignalDispatcher->installGlobalEventFilter(this, [this](DPF_NAMESPACE::EventType type, const QVariantList &params) -> bool {
if (type == GlobalEventType::kOpenFiles) {
quint64 eventWinId { params.at(0).toULongLong() };
QMap<QDBusObjectPath, QObject *>::iterator it = curDialogObjectMap.begin();
for (; it != curDialogObjectMap.end(); ++it) {
FileDialogHandleDBus *handle = qobject_cast<FileDialogHandleDBus *>(it.value());
if (!handle)
continue;
if (handle->winId() == eventWinId) {
FileDialog *dialog = qobject_cast<FileDialog *>(handle->widget());
if (!dialog)
continue;
dialog->onAcceptButtonClicked();
break;
}
}
return true;
}

static QList<DPF_NAMESPACE::EventType> filterTypeGroup { GlobalEventType::kOpenNewTab,
GlobalEventType::kOpenNewWindow,
GlobalEventType::kOpenAsAdmin,
GlobalEventType::kOpenFilesByApp,
GlobalEventType::kCreateSymlink,
GlobalEventType::kOpenInTerminal,
GlobalEventType::kHideFiles };
if (filterTypeGroup.contains(type))
return true;

return false;
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public slots:
private:
void onDialogDestroy();
void onAppExit();
void initEventsFilter();

QMap<QDBusObjectPath, QObject *> curDialogObjectMap;
bool lastWindowClosed { false };
Expand Down
27 changes: 0 additions & 27 deletions src/plugins/filedialog/filedialogplugin-core/views/filedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ FileDialog::FileDialog(const QUrl &url, QWidget *parent)
initializeUi();
initConnect();
initEventsConnect();
initEventsFilter();
}

FileDialog::~FileDialog()
Expand Down Expand Up @@ -1083,32 +1082,6 @@ void FileDialog::initEventsConnect()
dpfSignalDispatcher->subscribe("dfmplugin_workspace", "signal_View_RenameEndEdit", this, &FileDialog::handleRenameEndAcceptBtn);
}

void FileDialog::initEventsFilter()
{
dpfSignalDispatcher->installGlobalEventFilter(this, [this](DPF_NAMESPACE::EventType type, const QVariantList &params) -> bool {
if (type == GlobalEventType::kOpenFiles) {
onAcceptButtonClicked();
return true;
}

if (type == GlobalEventType::kOpenNewWindow && params.size() > 0) {
d->handleOpenNewWindow(params.at(0).toUrl());
return true;
}

static QList<DPF_NAMESPACE::EventType> filterTypeGroup { GlobalEventType::kOpenNewTab,
GlobalEventType::kOpenAsAdmin,
GlobalEventType::kOpenFilesByApp,
GlobalEventType::kCreateSymlink,
GlobalEventType::kOpenInTerminal,
GlobalEventType::kHideFiles };
if (filterTypeGroup.contains(type))
return true;

return false;
});
}

/*!
* \brief compiter -> fileview, fileview -> computerview
* \param scheme
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ public Q_SLOTS:
int exec();
void open();
void reject();
void onAcceptButtonClicked();

private Q_SLOTS:
void onAcceptButtonClicked();
void onRejectButtonClicked();
void onCurrentInputNameChanged();
void updateAcceptButtonState();
Expand All @@ -127,7 +127,6 @@ private Q_SLOTS:
void initializeUi();
void initConnect();
void initEventsConnect();
void initEventsFilter();
void updateViewState();
void adjustPosition(QWidget *w);
QString modelCurrentNameFilter() const;
Expand Down

0 comments on commit a7f14d6

Please sign in to comment.