Commit 578b6328 authored by Laurent Montel's avatar Laurent Montel

Fix Bug 388141 - Use KIO::highlightInFileManager in attachment saved confirmation

FIXED-IN: 5.8.0
BUG: 388141
parent 13156403
cmake_minimum_required(VERSION 3.0)
set(PIM_VERSION "5.7.43")
set(PIM_VERSION "5.7.44")
if (POLICY CMP0053)
cmake_policy(SET CMP0053 NEW)
......
......@@ -128,7 +128,7 @@ KMime::Content::List Util::allContents(const KMime::Content *message)
return result;
}
bool Util::saveContents(QWidget *parent, const KMime::Content::List &contents, QUrl &currentFolder)
bool Util::saveContents(QWidget *parent, const KMime::Content::List &contents, QUrl &currentFolder, QList<QUrl> &urlList)
{
QUrl url, dirUrl;
QString recentDirClass;
......@@ -268,6 +268,8 @@ bool Util::saveContents(QWidget *parent, const KMime::Content::List &contents, Q
const bool result = saveContent(parent, content, curUrl);
if (!result) {
globalResult = result;
} else {
urlList.append(curUrl);
}
}
}
......@@ -422,14 +424,14 @@ bool Util::saveContent(QWidget *parent, KMime::Content *content, const QUrl &url
return true;
}
bool Util::saveAttachments(const KMime::Content::List &contents, QWidget *parent, QUrl &currentFolder)
bool Util::saveAttachments(const KMime::Content::List &contents, QWidget *parent, QUrl &currentFolder, QList<QUrl> &urlList)
{
if (contents.isEmpty()) {
KMessageBox::information(parent, i18n("Found no attachments to save."));
return false;
}
return Util::saveContents(parent, contents, currentFolder);
return Util::saveContents(parent, contents, currentFolder, urlList);
}
bool Util::saveMessageInMbox(const Akonadi::Item::List &retrievedMsgs, QWidget *parent, bool appendMessages)
......
......@@ -61,7 +61,7 @@ namespace Util {
bool MESSAGEVIEWER_EXPORT checkOverwrite(const QUrl &url, QWidget *w);
MESSAGEVIEWER_EXPORT bool saveMessageInMbox(const Akonadi::Item::List &retrievedMsgs, QWidget *parent, bool appendMessages = false);
MESSAGEVIEWER_EXPORT bool saveAttachments(const KMime::Content::List &contents, QWidget *parent, QUrl &currentFolder);
MESSAGEVIEWER_EXPORT bool saveAttachments(const KMime::Content::List &contents, QWidget *parent, QUrl &currentFolder, QList<QUrl> &saveUrl);
MESSAGEVIEWER_EXPORT QAction *createAppAction(const KService::Ptr &service, bool singleOffer, QActionGroup *actionGroup, QObject *parent);
}
......
......@@ -52,7 +52,7 @@ bool handleUrlWithQDesktopServices(const QUrl &url);
KMime::Content::List allContents(const KMime::Content *message);
bool saveContents(QWidget *parent, const KMime::Content::List &contents, QUrl &currentFolder);
bool saveContents(QWidget *parent, const KMime::Content::List &contents, QUrl &currentFolder, QList<QUrl> &urlList);
bool saveContent(QWidget *parent, KMime::Content *content, const QUrl &url);
}
}
......
......@@ -731,8 +731,9 @@ bool AttachmentURLHandler::handleShiftClick(const QUrl &url, ViewerPrivate *wind
return false;
}
QUrl currentUrl;
if (Util::saveContents(window->viewer(), KMime::Content::List() << node, currentUrl)) {
window->viewer()->showOpenAttachmentFolderWidget(currentUrl);
QList<QUrl> urlList;
if (Util::saveContents(window->viewer(), KMime::Content::List() << node, currentUrl, urlList)) {
window->viewer()->showOpenAttachmentFolderWidget(urlList);
}
return true;
......
......@@ -655,10 +655,10 @@ void Viewer::setPluginName(const QString &pluginName)
return d->setPluginName(pluginName);
}
void Viewer::showOpenAttachmentFolderWidget(const QUrl &url)
void Viewer::showOpenAttachmentFolderWidget(const QList<QUrl> &urls)
{
Q_D(Viewer);
d->showOpenAttachmentFolderWidget(url);
d->showOpenAttachmentFolderWidget(urls);
}
QList<QAction *> Viewer::viewerPluginActionList(ViewerPluginInterface::SpecificFeatureTypes features)
......
......@@ -314,7 +314,7 @@ public:
void saveMainFrameScreenshotInFile(const QString &filename);
bool mimePartTreeIsEmpty() const;
void showOpenAttachmentFolderWidget(const QUrl &url);
void showOpenAttachmentFolderWidget(const QList<QUrl> &urls);
QList<QAction *> viewerPluginActionList(
MessageViewer::ViewerPluginInterface::SpecificFeatureTypes features);
QList<QAction *> interceptorUrlActions(const WebEngineViewer::WebHitTestResult &result) const;
......
......@@ -377,8 +377,9 @@ void ViewerPrivate::openAttachment(KMime::Content *node, const QUrl &url)
delete dialog;
if (choice == AttachmentDialog::Save) {
QUrl currentUrl;
if (Util::saveContents(mMainWindow, KMime::Content::List() << node, currentUrl)) {
showOpenAttachmentFolderWidget(currentUrl);
QList<QUrl> urlList;
if (Util::saveContents(mMainWindow, KMime::Content::List() << node, currentUrl, urlList)) {
showOpenAttachmentFolderWidget(urlList);
}
} else if (choice == AttachmentDialog::Open) { // Open
if (offer) {
......@@ -2540,9 +2541,9 @@ void ViewerPrivate::slotAttachmentOpen()
#endif
}
void ViewerPrivate::showOpenAttachmentFolderWidget(const QUrl &url)
void ViewerPrivate::showOpenAttachmentFolderWidget(const QList<QUrl> &urls)
{
mOpenAttachmentFolderWidget->setFolder(url);
mOpenAttachmentFolderWidget->setUrls(urls);
mOpenAttachmentFolderWidget->slotShowWarning();
}
......@@ -2586,8 +2587,9 @@ void ViewerPrivate::slotAttachmentSaveAs()
{
const auto contents = selectedContents();
QUrl currentUrl;
if (Util::saveAttachments(contents, mMainWindow, currentUrl)) {
showOpenAttachmentFolderWidget(currentUrl);
QList<QUrl> urlList;
if (Util::saveAttachments(contents, mMainWindow, currentUrl, urlList)) {
showOpenAttachmentFolderWidget(urlList);
}
}
......@@ -2595,8 +2597,9 @@ void ViewerPrivate::slotAttachmentSaveAll()
{
const auto contents = mMessage->attachments();
QUrl currentUrl;
if (Util::saveAttachments(contents, mMainWindow, currentUrl)) {
showOpenAttachmentFolderWidget(currentUrl);
QList<QUrl> urlList;
if (Util::saveAttachments(contents, mMainWindow, currentUrl, urlList)) {
showOpenAttachmentFolderWidget(urlList);
}
}
......@@ -2729,9 +2732,10 @@ void ViewerPrivate::slotHandleAttachment(int choice)
case Viewer::Save:
{
QUrl currentUrl;
QList<QUrl> urlList;
if (Util::saveContents(mMainWindow, KMime::Content::List() << mCurrentContent,
currentUrl)) {
showOpenAttachmentFolderWidget(currentUrl);
currentUrl, urlList)) {
showOpenAttachmentFolderWidget(urlList);
}
break;
}
......
......@@ -413,7 +413,7 @@ public:
void goOnline();
void goResourceOnline();
void showOpenAttachmentFolderWidget(const QUrl &url);
void showOpenAttachmentFolderWidget(const QList<QUrl> &urls);
bool mimePartTreeIsEmpty() const;
......
......@@ -20,8 +20,7 @@
#include "openattachmentfolderwidget.h"
#include <KLocalizedString>
#include <KRun>
#include <KIO/OpenFileManagerWindowJob>
#include <QTimer>
......@@ -63,15 +62,15 @@ void OpenAttachmentFolderWidget::slotExplicitlyClosed()
}
}
void OpenAttachmentFolderWidget::setFolder(const QUrl &url)
void OpenAttachmentFolderWidget::setUrls(const QList<QUrl> &urls)
{
mUrl = url;
mUrls = urls;
}
void OpenAttachmentFolderWidget::slotOpenAttachmentFolder()
{
if (!mUrl.isEmpty()) {
new KRun(mUrl, this);
if (!mUrls.isEmpty()) {
KIO::highlightInFileManager(mUrls);
slotHideWarning();
}
}
......
......@@ -31,7 +31,7 @@ public:
explicit OpenAttachmentFolderWidget(QWidget *parent = nullptr);
~OpenAttachmentFolderWidget();
void setFolder(const QUrl &url);
void setUrls(const QList<QUrl> &urls);
public Q_SLOTS:
void slotShowWarning();
......@@ -41,7 +41,7 @@ private:
void slotOpenAttachmentFolder();
void slotTimeOut();
void slotExplicitlyClosed();
QUrl mUrl;
QList<QUrl> mUrls;
QTimer *mTimer = nullptr;
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment