diff options
-rw-r--r-- | vcl/unx/gtk3_kde5/kde5_filepicker.cxx | 45 | ||||
-rw-r--r-- | vcl/unx/gtk3_kde5/kde5_filepicker.hxx | 3 | ||||
-rw-r--r-- | vcl/unx/gtk3_kde5/kde5_filepicker_ipc.cxx | 27 |
3 files changed, 31 insertions, 44 deletions
diff --git a/vcl/unx/gtk3_kde5/kde5_filepicker.cxx b/vcl/unx/gtk3_kde5/kde5_filepicker.cxx index db7d04cf7d4a..456ba645808b 100644 --- a/vcl/unx/gtk3_kde5/kde5_filepicker.cxx +++ b/vcl/unx/gtk3_kde5/kde5_filepicker.cxx @@ -32,17 +32,6 @@ #include <QtWidgets/QWidget> #include <QtWidgets/QApplication> -// The dialog should check whether LO also supports the protocol -// provided by KIO, and KFileWidget::dirOperator() is only 4.3+ . -// Moreover it's only in this somewhat internal KFileWidget class, -// which may not necessarily be what QFileDialog::fileWidget() returns, -// but that's hopefully not a problem in practice. -//#if Qt_VERSION_MAJOR == 4 && Qt_VERSION_MINOR >= 2 -//#define ALLOW_REMOTE_URLS 1 -//#else -#define ALLOW_REMOTE_URLS 0 -//#endif - // KDE5FilePicker KDE5FilePicker::KDE5FilePicker(QObject* parent) @@ -53,16 +42,15 @@ KDE5FilePicker::KDE5FilePicker(QObject* parent) , _winId(0) , allowRemoteUrls(false) { -#if ALLOW_REMOTE_URLS - if (KFileWidget* fileWidget = dynamic_cast<KFileWidget*>(_dialog->fileWidget())) - { - allowRemoteUrls = true; - // Use finishedLoading signal rather than e.g. urlEntered, because if there's a problem - // such as the URL being mistyped, there's no way to prevent two message boxes about it, - // one from us and one from Qt code. - connect(fileWidget->dirOperator(), SIGNAL(finishedLoading()), SLOT(checkProtocol())); - } -#endif + _dialog->setSupportedSchemes({ + QStringLiteral("file"), + QStringLiteral("ftp"), + QStringLiteral("http"), + QStringLiteral("https"), + QStringLiteral("webdav"), + QStringLiteral("webdavs"), + QStringLiteral("smb"), + }); setMultiSelectionMode(false); @@ -245,21 +233,6 @@ void SAL_CALL KDE5FilePicker::initialize(bool saveDialog) } } -void KDE5FilePicker::checkProtocol() -{ - // There's no libreoffice.desktop :(, so find a matching one. - /* - KService::List services = KServiceTypeTrader::self()->query( "Application", "Exec =~ 'libreoffice %U'" ); - QStringList protocols; - if( !services.isEmpty()) - protocols = services[ 0 ]->property( "X-Qt-Protocols" ).toStringList(); - if( protocols.isEmpty()) // incorrect (developer?) installation ? - protocols << "file" << "http"; - if( !protocols.contains( _dialog->baseUrl().protocol()) && !protocols.contains( "KIO" )) - KMessageBox::error( _dialog, KIO::buildErrorString( KIO::ERR_UNSUPPORTED_PROTOCOL, _dialog->baseUrl().protocol())); -*/ -} - void KDE5FilePicker::setWinId(sal_uIntPtr winId) { _winId = winId; } bool KDE5FilePicker::eventFilter(QObject* o, QEvent* e) diff --git a/vcl/unx/gtk3_kde5/kde5_filepicker.hxx b/vcl/unx/gtk3_kde5/kde5_filepicker.hxx index 8b364832c6af..25c7454f86b5 100644 --- a/vcl/unx/gtk3_kde5/kde5_filepicker.hxx +++ b/vcl/unx/gtk3_kde5/kde5_filepicker.hxx @@ -102,9 +102,6 @@ private: protected: bool eventFilter(QObject* watched, QEvent* event) override; -private Q_SLOTS: - void checkProtocol(); - Q_SIGNALS: void filterChanged(); void selectionChanged(); diff --git a/vcl/unx/gtk3_kde5/kde5_filepicker_ipc.cxx b/vcl/unx/gtk3_kde5/kde5_filepicker_ipc.cxx index 9911219d010a..1ae6289677d6 100644 --- a/vcl/unx/gtk3_kde5/kde5_filepicker_ipc.cxx +++ b/vcl/unx/gtk3_kde5/kde5_filepicker_ipc.cxx @@ -44,12 +44,12 @@ void sendIpcArg(std::ostream& stream, const QString& string) sendIpcStringArg(stream, utf8.size(), utf8.data()); } -void sendIpcArg(std::ostream& stream, const QList<QUrl>& urls) +void sendIpcArg(std::ostream& stream, const QStringList& list) { - stream << static_cast<uint32_t>(urls.size()) << ' '; - for (const auto& url : urls) + stream << static_cast<uint32_t>(list.size()) << ' '; + for (const auto& entry : list) { - sendIpcArg(stream, url.toString()); + sendIpcArg(stream, entry); } } @@ -126,7 +126,24 @@ void FilePickerIpc::readCommand() } case Commands::GetSelectedFiles: { - sendIpcArgs(std::cout, messageId, m_filePicker->getSelectedFiles()); + QStringList files; + for (auto url : m_filePicker->getSelectedFiles()) + { + if (url.scheme() == QLatin1String("webdav") + || url.scheme() == QLatin1String("webdavs")) + { + // translate webdav and webdavs URLs into a format supported by LO + url.setScheme(QLatin1String("vnd.sun.star.") + url.scheme()); + } + else if (url.scheme() == QLatin1String("smb")) + { + // clear the user name - the GIO backend does not support this apparently + // when no username is available, it will ask for the password + url.setUserName({}); + } + files << url.toString(); + } + sendIpcArgs(std::cout, messageId, files); return; } case Commands::AppendFilter: |