Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [select-dialog] Double-click to unable to open the file #2071

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading