mirror of
https://github.com/ONLYOFFICE/desktop-apps.git
synced 2026-04-07 14:09:22 +08:00
Implementation of calling native file dialog (Linux)
This commit is contained in:
@ -196,7 +196,8 @@ core_linux {
|
|||||||
$$PWD/src/windows/platform_linux/cwindowplatform.h \
|
$$PWD/src/windows/platform_linux/cwindowplatform.h \
|
||||||
$$PWD/src/platform_linux/cdialogopenssl.h \
|
$$PWD/src/platform_linux/cdialogopenssl.h \
|
||||||
$$PWD/src/platform_linux/cdialogcertificateinfo.h \
|
$$PWD/src/platform_linux/cdialogcertificateinfo.h \
|
||||||
$$PWD/src/platform_linux/singleapplication.h
|
$$PWD/src/platform_linux/singleapplication.h \
|
||||||
|
$$PWD/src/platform_linux/xdgdesktopportal.h
|
||||||
|
|
||||||
SOURCES += $$PWD/src/windows/platform_linux/cx11decoration.cpp \
|
SOURCES += $$PWD/src/windows/platform_linux/cx11decoration.cpp \
|
||||||
#$$PWD/src/windows/platform_linux/gtk_addon.cpp \
|
#$$PWD/src/windows/platform_linux/gtk_addon.cpp \
|
||||||
@ -204,7 +205,8 @@ core_linux {
|
|||||||
$$PWD/src/windows/platform_linux/cwindowplatform.cpp \
|
$$PWD/src/windows/platform_linux/cwindowplatform.cpp \
|
||||||
$$PWD/src/platform_linux/cdialogopenssl.cpp \
|
$$PWD/src/platform_linux/cdialogopenssl.cpp \
|
||||||
$$PWD/src/platform_linux/cdialogcertificateinfo.cpp \
|
$$PWD/src/platform_linux/cdialogcertificateinfo.cpp \
|
||||||
$$PWD/src/platform_linux/singleapplication.cpp
|
$$PWD/src/platform_linux/singleapplication.cpp \
|
||||||
|
$$PWD/src/platform_linux/xdgdesktopportal.cpp
|
||||||
|
|
||||||
contains(DEFINES, XDG_DESKTOP_PORTAL_KDE) {
|
contains(DEFINES, XDG_DESKTOP_PORTAL_KDE) {
|
||||||
HEADERS += $$PWD/src/platform_linux/kdefiledialog.h
|
HEADERS += $$PWD/src/platform_linux/kdefiledialog.h
|
||||||
@ -212,7 +214,7 @@ core_linux {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CONFIG += link_pkgconfig
|
CONFIG += link_pkgconfig
|
||||||
PKGCONFIG += glib-2.0 gtk+-3.0 atk
|
PKGCONFIG += glib-2.0 gtk+-3.0 atk dbus-1
|
||||||
LIBS += -lX11
|
LIBS += -lX11
|
||||||
|
|
||||||
LIBS += $$CORE_3DPARTY_PATH/icu/$$PLATFORM_BUILD/build/libicuuc.so.58
|
LIBS += $$CORE_3DPARTY_PATH/icu/$$PLATFORM_BUILD/build/libicuuc.so.58
|
||||||
|
|||||||
@ -47,6 +47,7 @@
|
|||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
# include <shobjidl.h>
|
# include <shobjidl.h>
|
||||||
#else
|
#else
|
||||||
|
# include "platform_linux/xdgdesktopportal.h"
|
||||||
# ifdef XDG_DESKTOP_PORTAL_KDE
|
# ifdef XDG_DESKTOP_PORTAL_KDE
|
||||||
# include "platform_linux/kdefiledialog.h"
|
# include "platform_linux/kdefiledialog.h"
|
||||||
# endif
|
# endif
|
||||||
@ -344,14 +345,12 @@ bool CFileDialogWrapper::modalSaveAs(QString& fileName, int selected)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
# ifdef XDG_DESKTOP_PORTAL_KDE
|
|
||||||
if (WindowHelper::getEnvInfo() == "KDE") {
|
if (WindowHelper::getEnvInfo() == "KDE") {
|
||||||
QStringList result = Kde::openNativeDialog(qobject_cast<QWidget*>(parent()),
|
QStringList result = XdgPortal::openNativeDialog(qobject_cast<QWidget*>(parent()),
|
||||||
Kde::Mode::SAVE, tr("Save As"),
|
PortalMode::SAVE, tr("Save As"),
|
||||||
n, "", f, &sf);
|
n, "", f, &sf);
|
||||||
return (result.size() > 0) ? result.at(0) : QString();
|
return (result.size() > 0) ? result.at(0) : QString();
|
||||||
}
|
}
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
return QFileDialog::getSaveFileName(p, tr("Save As"), n, f, &sf, _opts);
|
return QFileDialog::getSaveFileName(p, tr("Save As"), n, f, &sf, _opts);
|
||||||
};
|
};
|
||||||
@ -459,13 +458,11 @@ QStringList CFileDialogWrapper::modalOpen(const QString& path, const QString& fi
|
|||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
WindowHelper::CParentDisable oDisabler(qobject_cast<QWidget*>(parent()));
|
WindowHelper::CParentDisable oDisabler(qobject_cast<QWidget*>(parent()));
|
||||||
# ifdef XDG_DESKTOP_PORTAL_KDE
|
|
||||||
if (WindowHelper::getEnvInfo() == "KDE") {
|
if (WindowHelper::getEnvInfo() == "KDE") {
|
||||||
return Kde::openNativeDialog(qobject_cast<QWidget*>(parent()),
|
return XdgPortal::openNativeDialog(qobject_cast<QWidget*>(parent()),
|
||||||
Kde::Mode::OPEN, tr("Open Document"), "",
|
PortalMode::OPEN, tr("Open Document"), "",
|
||||||
path, _filter_, &_sel_filter, multi);
|
path, _filter_, &_sel_filter, multi);
|
||||||
}
|
}
|
||||||
# endif
|
|
||||||
return multi ? QFileDialog::getOpenFileNames(_parent, tr("Open Document"), path, _filter_, &_sel_filter, _opts) :
|
return multi ? QFileDialog::getOpenFileNames(_parent, tr("Open Document"), path, _filter_, &_sel_filter, _opts) :
|
||||||
QStringList(QFileDialog::getOpenFileName(_parent, tr("Open Document"), path, _filter_, &_sel_filter, _opts));
|
QStringList(QFileDialog::getOpenFileName(_parent, tr("Open Document"), path, _filter_, &_sel_filter, _opts));
|
||||||
#else
|
#else
|
||||||
|
|||||||
1095
win-linux/src/platform_linux/xdgdesktopportal.cpp
Normal file
1095
win-linux/src/platform_linux/xdgdesktopportal.cpp
Normal file
File diff suppressed because it is too large
Load Diff
25
win-linux/src/platform_linux/xdgdesktopportal.h
Normal file
25
win-linux/src/platform_linux/xdgdesktopportal.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#ifndef XDGDESKTOPPORTAL_H
|
||||||
|
#define XDGDESKTOPPORTAL_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
typedef enum PortalMode {
|
||||||
|
OPEN = 0, SAVE = 1, FOLDER = 2
|
||||||
|
} PortalMode;
|
||||||
|
|
||||||
|
namespace XdgPortal
|
||||||
|
{
|
||||||
|
QStringList openNativeDialog(QWidget *parent,
|
||||||
|
PortalMode mode,
|
||||||
|
const QString &title,
|
||||||
|
const QString &file_name,
|
||||||
|
const QString &path,
|
||||||
|
const QString &filter,
|
||||||
|
QString *sel_filter,
|
||||||
|
bool sel_multiple = false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // XDGDESKTOPPORTAL_H
|
||||||
Reference in New Issue
Block a user