Commit 31668247 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Allow to show where we exported mail as pdf

parent 66040aeb
......@@ -48,10 +48,10 @@ void ViewerTest::shouldHaveDefaultValuesOnCreation()
QVERIFY(scandetectionWidget);
QCOMPARE(scandetectionWidget->isVisible(), false);
QWidget *openattachementfolderwidget
= viewer->findChild<QWidget *>(QStringLiteral("openattachementfolderwidget"));
QVERIFY(openattachementfolderwidget);
QCOMPARE(openattachementfolderwidget->isVisible(), false);
QWidget *opensavefilefolderwidget
= viewer->findChild<QWidget *>(QStringLiteral("opensavefilefolderwidget"));
QVERIFY(opensavefilefolderwidget);
QCOMPARE(opensavefilefolderwidget->isVisible(), false);
QVERIFY(viewer->toggleFixFontAction());
QVERIFY(viewer->toggleMimePartTreeAction());
......
......@@ -144,7 +144,7 @@ set(libmessageviewer_widgets_SRCS
widgets/htmlstatusbar.cpp
widgets/vcardviewer.cpp
widgets/invitationsettings.cpp
widgets/openattachmentfolderwidget.cpp
widgets/opensavedfilefolderwidget.cpp
widgets/mailsourceviewtextbrowserwidget.cpp
widgets/submittedformwarningwidget.cpp
widgets/mailtrackingwarningwidget.cpp
......
......@@ -683,7 +683,7 @@ void Viewer::setPluginName(const QString &pluginName)
void Viewer::showOpenAttachmentFolderWidget(const QList<QUrl> &urls)
{
Q_D(Viewer);
d->showOpenAttachmentFolderWidget(urls);
d->showSavedFileFolderWidget(urls, MessageViewer::OpenSavedFileFolderWidget::FileType::Attachment);
}
QList<QAction *> Viewer::viewerPluginActionList(ViewerPluginInterface::SpecificFeatureTypes features)
......
......@@ -32,7 +32,7 @@
#include "scamdetection/scamdetectionwarningwidget.h"
#include "scamdetection/scamattribute.h"
#include "viewer/mimeparttree/mimeparttreeview.h"
#include "widgets/openattachmentfolderwidget.h"
#include "messageviewer/headerstyle.h"
#include "messageviewer/headerstrategy.h"
#include "widgets/developertooldialog.h"
......@@ -339,7 +339,7 @@ void ViewerPrivate::openAttachment(KMime::Content *node, const QUrl &url)
if (choice == AttachmentDialog::Save) {
QList<QUrl> urlList;
if (Util::saveContents(mMainWindow, KMime::Content::List() << node, urlList)) {
showOpenAttachmentFolderWidget(urlList);
showSavedFileFolderWidget(urlList, MessageViewer::OpenSavedFileFolderWidget::FileType::Attachment);
}
} else if (choice == AttachmentDialog::Open) { // Open
if (offer) {
......@@ -1216,7 +1216,7 @@ void ViewerPrivate::resetStateForNewMessage()
}
mViewerPluginToolManager->closeAllTools();
mScamDetectionWarning->setVisible(false);
mOpenAttachmentFolderWidget->setVisible(false);
mOpenSavedFileFolderWidget->setVisible(false);
mSubmittedFormWarning->setVisible(false);
mMailTrackingWarning->hideAndClear();
......@@ -1467,9 +1467,9 @@ void ViewerPrivate::createWidgets()
mScamDetectionWarning->setObjectName(QStringLiteral("scandetectionwarning"));
readerBoxVBoxLayout->addWidget(mScamDetectionWarning);
mOpenAttachmentFolderWidget = new OpenAttachmentFolderWidget(readerBox);
mOpenAttachmentFolderWidget->setObjectName(QStringLiteral("openattachementfolderwidget"));
readerBoxVBoxLayout->addWidget(mOpenAttachmentFolderWidget);
mOpenSavedFileFolderWidget = new OpenSavedFileFolderWidget(readerBox);
mOpenSavedFileFolderWidget->setObjectName(QStringLiteral("opensavefilefolderwidget"));
readerBoxVBoxLayout->addWidget(mOpenSavedFileFolderWidget);
mTextToSpeechWidget = new KPIMTextEdit::TextToSpeechWidget(readerBox);
mTextToSpeechWidget->setObjectName(QStringLiteral("texttospeechwidget"));
......@@ -2340,9 +2340,13 @@ void ViewerPrivate::exportToPdf(const QString &fileName)
{
WebEngineViewer::WebEngineExportPdfPageJob *job
= new WebEngineViewer::WebEngineExportPdfPageJob(this);
connect(job, &WebEngineViewer::WebEngineExportPdfPageJob::exportToPdfSuccess, this, [this, fileName]() {
showSavedFileFolderWidget({QUrl::fromLocalFile(fileName)}, MessageViewer::OpenSavedFileFolderWidget::FileType::Pdf);
});
job->setEngineView(mViewer);
job->setPdfPath(fileName);
job->start();
}
void ViewerPrivate::slotOpenInBrowser()
......@@ -2496,10 +2500,10 @@ void ViewerPrivate::slotAttachmentOpen()
#endif
}
void ViewerPrivate::showOpenAttachmentFolderWidget(const QList<QUrl> &urls)
void ViewerPrivate::showSavedFileFolderWidget(const QList<QUrl> &urls, OpenSavedFileFolderWidget::FileType fileType)
{
mOpenAttachmentFolderWidget->setUrls(urls);
mOpenAttachmentFolderWidget->slotShowWarning();
mOpenSavedFileFolderWidget->setUrls(urls, fileType);
mOpenSavedFileFolderWidget->slotShowWarning();
}
bool ViewerPrivate::mimePartTreeIsEmpty() const
......@@ -2543,7 +2547,7 @@ void ViewerPrivate::slotAttachmentSaveAs()
const auto contents = selectedContents();
QList<QUrl> urlList;
if (Util::saveAttachments(contents, mMainWindow, urlList)) {
showOpenAttachmentFolderWidget(urlList);
showSavedFileFolderWidget(urlList, MessageViewer::OpenSavedFileFolderWidget::FileType::Attachment);
}
}
......@@ -2552,7 +2556,7 @@ void ViewerPrivate::slotAttachmentSaveAll()
const auto contents = mMessage->attachments();
QList<QUrl> urlList;
if (Util::saveAttachments(contents, mMainWindow, urlList)) {
showOpenAttachmentFolderWidget(urlList);
showSavedFileFolderWidget(urlList, MessageViewer::OpenSavedFileFolderWidget::FileType::Attachment);
}
}
......@@ -2650,12 +2654,12 @@ void ViewerPrivate::slotHandleAttachment(int choice)
item.setMimeType(KMime::Message::mimeType());
QUrl url;
if (MessageViewer::Util::saveMessageInMboxAndGetUrl(url, Akonadi::Item::List() << item, mMainWindow)) {
showOpenAttachmentFolderWidget(QList<QUrl>() << url);
showSavedFileFolderWidget(QList<QUrl>() << url, MessageViewer::OpenSavedFileFolderWidget::FileType::Attachment);
}
} else {
QList<QUrl> urlList;
if (Util::saveContents(mMainWindow, KMime::Content::List() << mCurrentContent, urlList)) {
showOpenAttachmentFolderWidget(urlList);
showSavedFileFolderWidget(urlList, MessageViewer::OpenSavedFileFolderWidget::FileType::Attachment);
}
}
break;
......
......@@ -26,6 +26,7 @@
#include "viewer.h" //not so nice, it is actually for the enums from MailViewer
#include <PimCommon/ShareServiceUrlManager>
#include "messageviewer/viewerplugininterface.h"
#include "widgets/opensavedfilefolderwidget.h"
#include <WebEngineViewer/CheckPhishingUrlUtil>
#include <AkonadiCore/item.h>
......@@ -87,7 +88,6 @@ class WebEnginePartHtmlWriter;
class HtmlStatusBar;
class ScamDetectionWarningWidget;
class MimePartTreeView;
class OpenAttachmentFolderWidget;
class HeaderStyleMenuManager;
class ViewerPluginToolManager;
class SubmittedFormWarningWidget;
......@@ -418,7 +418,7 @@ public:
void goOnline();
void goResourceOnline();
void showOpenAttachmentFolderWidget(const QList<QUrl> &urls);
void showSavedFileFolderWidget(const QList<QUrl> &urls, MessageViewer::OpenSavedFileFolderWidget::FileType fileType);
Q_REQUIRED_RESULT bool mimePartTreeIsEmpty() const;
......@@ -682,7 +682,7 @@ public:
Akonadi::Item::Id mPreviouslyViewedItemId;
MessageViewer::ScamDetectionWarningWidget *mScamDetectionWarning = nullptr;
MessageViewer::OpenAttachmentFolderWidget *mOpenAttachmentFolderWidget = nullptr;
MessageViewer::OpenSavedFileFolderWidget *mOpenSavedFileFolderWidget = nullptr;
MessageViewer::SubmittedFormWarningWidget *mSubmittedFormWarning = nullptr;
MessageViewer::MailTrackingWarningWidget *mMailTrackingWarning = nullptr;
KPIMTextEdit::TextToSpeechWidget *mTextToSpeechWidget = nullptr;
......
......@@ -17,7 +17,7 @@
Boston, MA 02110-1301, USA.
*/
#include "openattachmentfolderwidget.h"
#include "opensavedfilefolderwidget.h"
#include <KLocalizedString>
#include <KIO/OpenFileManagerWindowJob>
......@@ -28,13 +28,13 @@
using namespace MessageViewer;
OpenAttachmentFolderWidget::OpenAttachmentFolderWidget(QWidget *parent)
OpenSavedFileFolderWidget::OpenSavedFileFolderWidget(QWidget *parent)
: KMessageWidget(parent)
{
mTimer = new QTimer(this);
mTimer->setSingleShot(true);
mTimer->setInterval(5000); // 5 seconds
connect(mTimer, &QTimer::timeout, this, &OpenAttachmentFolderWidget::slotTimeOut);
connect(mTimer, &QTimer::timeout, this, &OpenSavedFileFolderWidget::slotTimeOut);
setVisible(false);
setCloseButtonVisible(true);
setMessageType(Positive);
......@@ -42,32 +42,41 @@ OpenAttachmentFolderWidget::OpenAttachmentFolderWidget(QWidget *parent)
QAction *action = this->findChild<QAction *>(); // should give us the close action...
if (action) {
connect(action, &QAction::triggered, this,
&OpenAttachmentFolderWidget::slotExplicitlyClosed);
&OpenSavedFileFolderWidget::slotExplicitlyClosed);
}
action = new QAction(i18n("Open folder where attachment was saved"), this);
connect(action, &QAction::triggered, this,
&OpenAttachmentFolderWidget::slotOpenAttachmentFolder);
addAction(action);
mShowFolderAction = new QAction(i18n("Open folder where attachment was saved"), this);
connect(mShowFolderAction, &QAction::triggered, this,
&OpenSavedFileFolderWidget::slotOpenSavedFileFolder);
addAction(mShowFolderAction);
}
OpenAttachmentFolderWidget::~OpenAttachmentFolderWidget()
OpenSavedFileFolderWidget::~OpenSavedFileFolderWidget()
{
}
void OpenAttachmentFolderWidget::slotExplicitlyClosed()
void OpenSavedFileFolderWidget::slotExplicitlyClosed()
{
if (mTimer->isActive()) {
mTimer->stop();
}
}
void OpenAttachmentFolderWidget::setUrls(const QList<QUrl> &urls)
void OpenSavedFileFolderWidget::setUrls(const QList<QUrl> &urls, FileType fileType)
{
mUrls = urls;
switch(fileType) {
case FileType::Attachment:
mShowFolderAction->setText(i18np("Open folder where attachment was saved", "Open folder where attachments were saved", mUrls.count()));
break;
case FileType::Pdf:
mShowFolderAction->setText(i18n("Open folder where PDF file was saved"));
break;
}
}
void OpenAttachmentFolderWidget::slotOpenAttachmentFolder()
void OpenSavedFileFolderWidget::slotOpenSavedFileFolder()
{
if (!mUrls.isEmpty()) {
KIO::highlightInFileManager(mUrls);
......@@ -75,7 +84,7 @@ void OpenAttachmentFolderWidget::slotOpenAttachmentFolder()
}
}
void OpenAttachmentFolderWidget::slotHideWarning()
void OpenSavedFileFolderWidget::slotHideWarning()
{
if (mTimer->isActive()) {
mTimer->stop();
......@@ -83,7 +92,7 @@ void OpenAttachmentFolderWidget::slotHideWarning()
animatedHide();
}
void OpenAttachmentFolderWidget::slotShowWarning()
void OpenSavedFileFolderWidget::slotShowWarning()
{
if (mTimer->isActive()) {
mTimer->stop();
......@@ -92,7 +101,7 @@ void OpenAttachmentFolderWidget::slotShowWarning()
animatedShow();
}
void OpenAttachmentFolderWidget::slotTimeOut()
void OpenSavedFileFolderWidget::slotTimeOut()
{
animatedHide();
}
......@@ -24,25 +24,31 @@
#include <QUrl>
class QTimer;
namespace MessageViewer {
class OpenAttachmentFolderWidget : public KMessageWidget
class OpenSavedFileFolderWidget : public KMessageWidget
{
Q_OBJECT
public:
explicit OpenAttachmentFolderWidget(QWidget *parent = nullptr);
~OpenAttachmentFolderWidget();
enum class FileType {
Attachment,
Pdf
};
void setUrls(const QList<QUrl> &urls);
explicit OpenSavedFileFolderWidget(QWidget *parent = nullptr);
~OpenSavedFileFolderWidget();
void setUrls(const QList<QUrl> &urls, MessageViewer::OpenSavedFileFolderWidget::FileType fileType);
public Q_SLOTS:
void slotShowWarning();
void slotHideWarning();
private:
void slotOpenAttachmentFolder();
void slotOpenSavedFileFolder();
void slotTimeOut();
void slotExplicitlyClosed();
QList<QUrl> mUrls;
QTimer *mTimer = nullptr;
QAction *mShowFolderAction = 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