Verified Commit 8d4a5128 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

Small improvements to the 'Export to PDF' feature

Summary:
* Capitalize "PDF"
* Add the action to the KMReaderMainWin too
* Set default filename to <subject>.pdf

Reviewers: mlaurent

Reviewed By: mlaurent

Subscribers: yurchor, kde-pim

Tags: #kde_pim

Differential Revision: https://phabricator.kde.org/D27793
parent aeddfdcb
......@@ -3592,11 +3592,6 @@ void KMMainWidget::setupActions()
mRestartAccountSettings = new QAction(QIcon::fromTheme(QStringLiteral("view-refresh")), i18n("Restart Account"), this);
actionCollection()->addAction(QStringLiteral("resource_restart"), mRestartAccountSettings);
connect(mRestartAccountSettings, &QAction::triggered, this, &KMMainWidget::slotRestartAccount);
mExportToPdfAction = new QAction(QIcon::fromTheme(QStringLiteral("application-pdf")), i18n("Export to Pdf..."), this);
actionCollection()->addAction(QStringLiteral("file_export_pdf"), mExportToPdfAction);
connect(mExportToPdfAction, &QAction::triggered, this, &KMMainWidget::slotExportToPdf);
}
void KMMainWidget::slotAddFavoriteFolder()
......@@ -4368,16 +4363,6 @@ KActionMenu *KMMainWidget::mailingListActionMenu() const
return mMsgActions->mailingListActionMenu();
}
void KMMainWidget::slotExportToPdf()
{
if (mMsgView) {
const QString fileName = QFileDialog::getSaveFileName(this, i18n("Export to Pdf"));
if (!fileName.isEmpty()) {
mMsgView->viewer()->exportToPdf(fileName);
}
}
}
QAction *KMMainWidget::sendQueuedAction() const
{
return mSendQueued;
......
......@@ -227,9 +227,6 @@ private:
KActionMenu *mailingListActionMenu() const;
void slotExportToPdf();
// Moving messages around
/**
* This will ask for a destination folder and move the currently selected
......@@ -597,7 +594,6 @@ private:
QAction *mShowFolderShortcutDialogAction = nullptr;
QAction *mArchiveFolderAction = nullptr;
QAction *mMessageNewList = nullptr;
QAction *mExportToPdfAction = nullptr;
KToggleAction *mPreferHtmlLoadExtAction = nullptr;
QTimer *menutimer = nullptr;
......
......@@ -813,3 +813,4 @@ void KMReaderMainWin::slotUpdateToolbars()
createGUI(QStringLiteral("kmreadermainwin.rc"));
applyMainWindowSettings(KConfigGroup(KMKernel::self()->config(), "ReaderWindow"));
}
<!DOCTYPE gui>
<gui version="528" name="kmreadermainwin" translationDomain="kmail">
<gui version="529" name="kmreadermainwin" translationDomain="kmail">
<MenuBar>
<Menu noMerge="1" name="file" >
<text>&amp;File</text>
<Action name="save_message" />
<Action name="file_export_pdf" />
<Action name="file_print_preview"/>
<Action name="file_print" />
<Separator/>
......
......@@ -54,6 +54,7 @@
#include <KUriFilter>
#include <KStringHandler>
#include <QIcon>
#include <QFileDialog>
#include <QVariant>
#include <QWidget>
......@@ -203,6 +204,10 @@ MessageActions::MessageActions(KActionCollection *ac, QWidget *parent)
connect(mNewMessageFromTemplateAction, &QAction::triggered, this, &MessageActions::slotUseTemplate);
ac->setDefaultShortcut(mNewMessageFromTemplateAction, QKeySequence(Qt::SHIFT + Qt::Key_N));
mExportToPdfAction = new QAction(QIcon::fromTheme(QStringLiteral("application-pdf")), i18n("Export to PDF..."), this);
ac->addAction(QStringLiteral("file_export_pdf"), mExportToPdfAction);
connect(mExportToPdfAction, &QAction::triggered, this, &MessageActions::slotExportToPdf);
updateActions();
}
......@@ -760,3 +765,18 @@ void MessageActions::slotAddFollowupReminder()
}
delete dlg;
}
void MessageActions::slotExportToPdf()
{
if (!mCurrentItem.isValid()) {
return;
}
auto email = mCurrentItem.payload<KMime::Message::Ptr>();
const QString fileName = QFileDialog::getSaveFileName(mParent, i18n("Export to PDF"),
QDir::homePath() + QLatin1Char('/') + email->subject()->asUnicodeString() + QStringLiteral(".pdf"),
i18n("PDF document (*.pdf"));
if (!fileName.isEmpty()) {
mMessageView->viewer()->exportToPdf(fileName);
}
}
......@@ -141,6 +141,8 @@ private Q_SLOTS:
void slotResendMessage();
void slotUseTemplate();
void slotExportToPdf();
private:
QList<QAction *> mMailListActionList;
Akonadi::Item mCurrentItem;
......@@ -171,6 +173,7 @@ private:
QAction *mSendAgainAction = nullptr;
QAction *mNewMessageFromTemplateAction = nullptr;
KIO::KUriFilterSearchProviderActions *mWebShortcutMenuManager = nullptr;
QAction *mExportToPdfAction = 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