Merge lp:~a-volkov/qpdfview/send_by_email_1 into lp:qpdfview

Proposed by Alexander Volkov
Status: Merged
Approved by: Adam Reichold
Approved revision: 2132
Merged at revision: 2133
Proposed branch: lp:~a-volkov/qpdfview/send_by_email_1
Merge into: lp:qpdfview
Diff against target: 68 lines (+18/-1)
2 files modified
sources/mainwindow.cpp (+16/-1)
sources/mainwindow.h (+2/-0)
To merge this branch: bzr merge lp:~a-volkov/qpdfview/send_by_email_1
Reviewer Review Type Date Requested Status
Adam Reichold Approve
Review via email: mp+407076@code.launchpad.net

This proposal supersedes a proposal from 2021-08-13.

Commit message

Add "Send by Email" action

To post a comment you must log in.
Revision history for this message
Adam Reichold (adamreichold) wrote : Posted in a previous version of this proposal

Thank you for your contribution! The change looks good to me, except for the minor nits detailed inline with the diff.

review: Needs Fixing
Revision history for this message
Adam Reichold (adamreichold) :
review: Approve
Revision history for this message
Adam Reichold (adamreichold) wrote :

I merged this into trunk revision 2133. It did not work for me using Thunderbird though: While an URL like "mailto:?attach=/absolute/path/to/file.pdf" was generated, this did not make Thunderbird actually attach the file.

Revision history for this message
Alexander Volkov (a-volkov) wrote :

xdg-email treats thunderbird as a special case: https://gitlab.freedesktop.org/xdg/xdg-utils/-/blob/master/scripts/xdg-email.in#L33
It should run thunderbird by the command line "thunderbird -compose attachment='path/to/file.pdf'"
Probably in your case xdg-email decided that thunderbird is not thunderbird.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'sources/mainwindow.cpp'
2--- sources/mainwindow.cpp 2021-04-23 08:00:48 +0000
3+++ sources/mainwindow.cpp 2021-08-13 12:54:39 +0000
4@@ -596,6 +596,7 @@
5
6 m_refreshAction->setEnabled(hasCurrent);
7 m_printAction->setEnabled(hasCurrent);
8+ m_emailAction->setEnabled(hasCurrent);
9
10 m_previousPageAction->setEnabled(hasCurrent);
11 m_nextPageAction->setEnabled(hasCurrent);
12@@ -1579,6 +1580,11 @@
13 }
14 }
15
16+void MainWindow::on_email_triggered()
17+{
18+ QProcess::startDetached(QLatin1String("xdg-email"), QStringList() << QLatin1String("--attach") << currentTab()->fileInfo().absoluteFilePath());
19+}
20+
21 void MainWindow::on_recentlyUsed_openTriggered(const QString& filePath)
22 {
23 if(!jumpToPageOrOpenInNewTab(filePath, -1, true))
24@@ -3188,6 +3194,15 @@
25 m_saveAsAction = createAction(tr("Save &as..."), QLatin1String("saveAs"), QLatin1String("document-save-as"), QKeySequence::SaveAs, SLOT(on_saveAs_triggered()));
26 m_saveCopyAction = createAction(tr("Save &copy..."), QLatin1String("saveCopy"), QIcon(), QKeySequence(), SLOT(on_saveCopy_triggered()));
27 m_printAction = createAction(tr("&Print..."), QLatin1String("print"), QLatin1String("document-print"), QKeySequence::Print, SLOT(on_print_triggered()));
28+ m_emailAction = createAction(tr("Send by &e-mail..."), QLatin1String("email"), QLatin1String("mail-send"), QList<QKeySequence>(), SLOT(on_email_triggered()));
29+
30+ m_emailAction->setVisible(
31+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
32+ !QStandardPaths::findExecutable(QLatin1String("xdg-email")).isEmpty()
33+#else
34+ false
35+#endif
36+ );
37 m_exitAction = createAction(tr("E&xit"), QLatin1String("exit"), QIcon::fromTheme("application-exit"), QKeySequence::Quit, SLOT(close()));
38 m_exitAction->setMenuRole(QAction::QuitRole);
39
40@@ -3539,7 +3554,7 @@
41 setToolButtonMenu(m_fileToolBar, m_openInNewTabAction, m_recentlyUsedMenu);
42 }
43
44- m_fileMenu->addActions(QList< QAction* >() << m_refreshAction << m_saveAction << m_saveAsAction << m_saveCopyAction << m_printAction);
45+ m_fileMenu->addActions(QList< QAction* >() << m_refreshAction << m_saveAction << m_saveAsAction << m_saveCopyAction << m_printAction << m_emailAction);
46 m_fileMenu->addSeparator();
47 m_fileMenu->addAction(m_exitAction);
48
49
50=== modified file 'sources/mainwindow.h'
51--- sources/mainwindow.h 2021-04-23 08:00:48 +0000
52+++ sources/mainwindow.h 2021-08-13 12:54:39 +0000
53@@ -166,6 +166,7 @@
54 void on_saveAs_triggered();
55 void on_saveCopy_triggered();
56 void on_print_triggered();
57+ void on_email_triggered();
58
59 void on_recentlyUsed_openTriggered(const QString& filePath);
60
61@@ -369,6 +370,7 @@
62 QAction* m_saveAsAction;
63 QAction* m_saveCopyAction;
64 QAction* m_printAction;
65+ QAction* m_emailAction;
66 QAction* m_exitAction;
67
68 QAction* m_previousPageAction;

Subscribers

People subscribed via source and target branches