Work on #102.
This commit is contained in:
parent
43ce147750
commit
b0a416a96b
@ -767,7 +767,8 @@ void FeedsModel::loadFromDatabase() {
|
||||
query_feeds.setForwardOnly(true);
|
||||
|
||||
if (!query_feeds.exec("SELECT * FROM Feeds;") || query_feeds.lastError().isValid()) {
|
||||
qFatal("Query for obtaining feeds failed.");
|
||||
qFatal("Query for obtaining feeds failed. Error message: '%s'.",
|
||||
qPrintable(query_feeds.lastError().text()));
|
||||
}
|
||||
|
||||
while (query_feeds.next()) {
|
||||
|
@ -243,6 +243,8 @@ void FeedMessageViewer::createConnections() {
|
||||
SIGNAL(triggered()), m_messagesView, SLOT(openSelectedSourceMessagesInternally()));
|
||||
connect(form_main->m_ui->m_actionOpenSelectedMessagesInternally,
|
||||
SIGNAL(triggered()), m_messagesView, SLOT(openSelectedMessagesInternally()));
|
||||
connect(form_main->m_ui->m_actionSendMessageViaEmail,
|
||||
SIGNAL(triggered()), m_messagesView, SLOT(sendSelectedMessageViaEmail()));
|
||||
connect(form_main->m_ui->m_actionMarkAllFeedsRead,
|
||||
SIGNAL(triggered()), m_feedsView, SLOT(markAllFeedsRead()));
|
||||
connect(form_main->m_ui->m_actionMarkSelectedFeedsAsRead,
|
||||
|
@ -162,6 +162,7 @@
|
||||
<addaction name="m_actionOpenSelectedSourceArticlesExternally"/>
|
||||
<addaction name="m_actionOpenSelectedSourceArticlesInternally"/>
|
||||
<addaction name="m_actionOpenSelectedMessagesInternally"/>
|
||||
<addaction name="m_actionSendMessageViaEmail"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="m_actionSelectNextMessage"/>
|
||||
<addaction name="m_actionSelectPreviousMessage"/>
|
||||
@ -643,6 +644,11 @@
|
||||
<string>&Downloads</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_actionSendMessageViaEmail">
|
||||
<property name="text">
|
||||
<string>Send selected message via e-mail</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
@ -121,6 +121,8 @@ FormSettings::FormSettings(QWidget *parent) : QDialog(parent), m_ui(new Ui::Form
|
||||
connect(m_ui->m_treeSkins, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(onSkinSelected(QTreeWidgetItem*,QTreeWidgetItem*)));
|
||||
connect(m_ui->m_cmbExternalBrowserPreset, SIGNAL(currentIndexChanged(int)), this, SLOT(changeDefaultBrowserArguments(int)));
|
||||
connect(m_ui->m_btnExternalBrowserExecutable, SIGNAL(clicked()), this, SLOT(selectBrowserExecutable()));
|
||||
connect(m_ui->m_cmbExternalEmailPreset, SIGNAL(currentIndexChanged(int)), this, SLOT(changeDefaultEmailArguments(int)));
|
||||
connect(m_ui->m_btnExternalEmailExecutable, SIGNAL(clicked()), this, SLOT(selectEmailExecutable()));
|
||||
connect(m_ui->m_txtMysqlUsername->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(onMysqlUsernameChanged(QString)));
|
||||
connect(m_ui->m_txtMysqlHostname->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(onMysqlHostnameChanged(QString)));
|
||||
connect(m_ui->m_txtMysqlPassword->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(onMysqlPasswordChanged(QString)));
|
||||
@ -205,7 +207,30 @@ void FormSettings::selectBrowserExecutable() {
|
||||
);
|
||||
|
||||
if (!executable_file.isEmpty()) {
|
||||
m_ui->m_txtExternalBrowserExecutable->setText(executable_file);
|
||||
m_ui->m_txtExternalBrowserExecutable->setText(QDir::toNativeSeparators(executable_file));
|
||||
}
|
||||
}
|
||||
|
||||
void FormSettings::changeDefaultEmailArguments(int index) {
|
||||
if (index != 0) {
|
||||
m_ui->m_txtExternalEmailArguments->setText(m_ui->m_cmbExternalEmailPreset->itemData(index).toString());
|
||||
}
|
||||
}
|
||||
|
||||
void FormSettings::selectEmailExecutable() {
|
||||
QString executable_file = QFileDialog::getOpenFileName(this,
|
||||
tr("Select e-mail executable"),
|
||||
qApp->homeFolderPath(),
|
||||
//: File filter for external e-mail selection dialog.
|
||||
#if defined(Q_OS_LINUX)
|
||||
tr("Executables (*)")
|
||||
#else
|
||||
tr("Executables (*.*)")
|
||||
#endif
|
||||
);
|
||||
|
||||
if (!executable_file.isEmpty()) {
|
||||
m_ui->m_txtExternalEmailExecutable->setText(QDir::toNativeSeparators(executable_file));
|
||||
}
|
||||
}
|
||||
|
||||
@ -378,6 +403,12 @@ void FormSettings::loadBrowser() {
|
||||
m_ui->m_checkAutoLoadImages->setChecked(WebFactory::instance()->autoloadImages());
|
||||
m_ui->m_checkEnableJavascript->setChecked(WebFactory::instance()->javascriptEnabled());
|
||||
m_ui->m_checkEnablePlugins->setChecked(WebFactory::instance()->pluginsEnabled());
|
||||
|
||||
// Load settings of e-mail.
|
||||
m_ui->m_cmbExternalEmailPreset->addItem(tr("Mozilla Thunderbird"), "-compose \"subject='%1',body='%2'\"");
|
||||
m_ui->m_txtExternalEmailExecutable->setText(settings->value(GROUP(Browser), SETTING(Browser::CustomExternalEmailExecutable)).toString());
|
||||
m_ui->m_txtExternalEmailArguments->setText(settings->value(GROUP(Browser), SETTING(Browser::CustomExternalEmailArguments)).toString());
|
||||
m_ui->m_grpCustomExternalEmail->setChecked(settings->value(GROUP(Browser), SETTING(Browser::CustomExternalEmailEnabled)).toBool());
|
||||
}
|
||||
|
||||
void FormSettings::saveBrowser() {
|
||||
@ -390,6 +421,11 @@ void FormSettings::saveBrowser() {
|
||||
settings->setValue(GROUP(Browser), Browser::CustomExternalBrowserExecutable, m_ui->m_txtExternalBrowserExecutable->text());
|
||||
settings->setValue(GROUP(Browser), Browser::CustomExternalBrowserArguments, m_ui->m_txtExternalBrowserArguments->text());
|
||||
|
||||
// Save settings of e-mail.
|
||||
settings->setValue(GROUP(Browser), Browser::CustomExternalEmailExecutable, m_ui->m_txtExternalEmailExecutable->text());
|
||||
settings->setValue(GROUP(Browser), Browser::CustomExternalEmailArguments, m_ui->m_txtExternalEmailArguments->text());
|
||||
settings->setValue(GROUP(Browser), Browser::CustomExternalEmailEnabled, m_ui->m_grpCustomExternalEmail->isChecked());
|
||||
|
||||
WebFactory::instance()->switchImages(m_ui->m_checkAutoLoadImages->isChecked());
|
||||
WebFactory::instance()->switchJavascript(m_ui->m_checkEnableJavascript->isChecked());
|
||||
WebFactory::instance()->switchPlugins(m_ui->m_checkEnablePlugins->isChecked());
|
||||
|
@ -91,6 +91,9 @@ class FormSettings : public QDialog {
|
||||
void changeDefaultBrowserArguments(int index);
|
||||
void selectBrowserExecutable();
|
||||
|
||||
void changeDefaultEmailArguments(int index);
|
||||
void selectEmailExecutable();
|
||||
|
||||
void loadProxy();
|
||||
void saveProxy();
|
||||
void displayProxyPassword(int state);
|
||||
|
@ -70,7 +70,7 @@
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Web browser & proxy</string>
|
||||
<string>Web browser & e-mail & proxy</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
@ -88,7 +88,7 @@
|
||||
<item row="0" column="1">
|
||||
<widget class="QStackedWidget" name="m_stackedSettings">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>5</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="m_pageGeneral">
|
||||
<layout class="QFormLayout" name="formLayout_5">
|
||||
@ -414,8 +414,8 @@ MySQL backend will automatically use database with name "rssguard". Do
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>100</width>
|
||||
<height>30</height>
|
||||
<width>740</width>
|
||||
<height>451</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
@ -492,8 +492,8 @@ MySQL backend will automatically use database with name "rssguard". Do
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>208</width>
|
||||
<height>238</height>
|
||||
<width>734</width>
|
||||
<height>425</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
@ -898,15 +898,10 @@ MySQL backend will automatically use database with name "rssguard". Do
|
||||
<widget class="QLabel" name="m_lblMouseGestures">
|
||||
<property name="text">
|
||||
<string>Mouse gestures work with middle mouse button. Possible gestures are:
|
||||
<ul>
|
||||
<li>previous web page (drag mouse left),</li>
|
||||
<li>next web page (drag mouse right),</li>
|
||||
<li>reload current web page (drag mouse up),</li>
|
||||
<li>open new web browser tab (drag mouse down).</li>
|
||||
</ul></string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
• previous web page (drag mouse left),
|
||||
• next web page (drag mouse right),
|
||||
• reload current web page (drag mouse up),
|
||||
• open new web browser tab (drag mouse down).</string>
|
||||
</property>
|
||||
<property name="indent">
|
||||
<number>20</number>
|
||||
@ -926,7 +921,7 @@ MySQL backend will automatically use database with name "rssguard". Do
|
||||
<string><html><head/><body><p>If unchecked, then default system-wide web browser is used.</p></body></html></string>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Custom external web browser</string>
|
||||
<string>Use custom external web browser</string>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
@ -993,7 +988,7 @@ MySQL backend will automatically use database with name "rssguard". Do
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Note that "%1" (without quotation marks) is placeholder for URL of selected message.</string>
|
||||
@ -1008,6 +1003,104 @@ MySQL backend will automatically use database with name "rssguard". Do
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>External e-mail client</string>
|
||||
</attribute>
|
||||
<layout class="QFormLayout" name="formLayout_22">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="m_grpCustomExternalEmail">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>If unchecked, then default system-wide web browser is used.</p></body></html></string>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Use custom external e-mail client</string>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_21">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="m_lblExternalEmailExecutable">
|
||||
<property name="text">
|
||||
<string>E-mail client executable</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_15">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="m_txtExternalEmailExecutable">
|
||||
<property name="placeholderText">
|
||||
<string>Executable file of e-mail client</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="m_btnExternalEmailExecutable">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="m_lblExternalEmailArguments">
|
||||
<property name="text">
|
||||
<string>Executable parameters</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="m_txtExternalEmailArguments">
|
||||
<property name="placeholderText">
|
||||
<string>Parameters to executable</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="m_lblExternalEmailPreset">
|
||||
<property name="text">
|
||||
<string>Use sample arguments for</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="m_cmbExternalEmailPreset">
|
||||
<property name="currentText">
|
||||
<string>Select client</string>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToContents</enum>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Select client</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="m_lblExternalEmailInfo">
|
||||
<property name="text">
|
||||
<string>Placeholders:
|
||||
• %1 - title of selected message,
|
||||
• %2 - body of selected message.</string>
|
||||
</property>
|
||||
<property name="indent">
|
||||
<number>20</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="m_tabProxy">
|
||||
<attribute name="title">
|
||||
<string>Proxy</string>
|
||||
|
@ -161,6 +161,7 @@ void MessagesView::contextMenuEvent(QContextMenuEvent *event) {
|
||||
void MessagesView::initializeContextMenu() {
|
||||
m_contextMenu = new QMenu(tr("Context menu for messages"), this);
|
||||
m_contextMenu->addActions(QList<QAction*>() <<
|
||||
qApp->mainForm()->m_ui->m_actionSendMessageViaEmail <<
|
||||
qApp->mainForm()->m_ui->m_actionOpenSelectedSourceArticlesExternally <<
|
||||
qApp->mainForm()->m_ui->m_actionOpenSelectedSourceArticlesInternally <<
|
||||
qApp->mainForm()->m_ui->m_actionOpenSelectedMessagesInternally <<
|
||||
@ -299,6 +300,19 @@ void MessagesView::openSelectedMessagesInternally() {
|
||||
}
|
||||
}
|
||||
|
||||
void MessagesView::sendSelectedMessageViaEmail() {
|
||||
if (selectionModel()->selectedRows().size() == 1) {
|
||||
Message message = m_sourceModel->messageAt(m_proxyModel->mapToSource(selectionModel()->selectedRows().at(0)).row());
|
||||
|
||||
if (!WebFactory::instance()->sendMessageViaEmail(message)) {
|
||||
MessageBox::show(this,
|
||||
QMessageBox::Critical,
|
||||
tr("Problem with starting external e-mail client"),
|
||||
tr("External e-mail client could not be started."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MessagesView::markSelectedMessagesRead() {
|
||||
setSelectedMessagesReadStatus(1);
|
||||
}
|
||||
|
@ -66,6 +66,7 @@ class MessagesView : public QTreeView {
|
||||
void openSelectedSourceArticlesExternally();
|
||||
void openSelectedSourceMessagesInternally();
|
||||
void openSelectedMessagesInternally();
|
||||
void sendSelectedMessageViaEmail();
|
||||
|
||||
// Works with SELECTED messages only.
|
||||
void setSelectedMessagesReadStatus(int read);
|
||||
|
@ -238,6 +238,15 @@ DVALUE(char*) Browser::CustomExternalBrowserExecutableDef = "";
|
||||
DKEY Browser::CustomExternalBrowserArguments = "external_browser_arguments";
|
||||
DVALUE(char*) Browser::CustomExternalBrowserArgumentsDef = "%1";
|
||||
|
||||
DKEY Browser::CustomExternalEmailEnabled = "custom_external_email";
|
||||
DVALUE(bool) Browser::CustomExternalEmailEnabledDef = false;
|
||||
|
||||
DKEY Browser::CustomExternalEmailExecutable = "external_email_executable";
|
||||
DVALUE(char*) Browser::CustomExternalEmailExecutableDef = "";
|
||||
|
||||
DKEY Browser::CustomExternalEmailArguments = "external_email_arguments";
|
||||
DVALUE(char*) Browser::CustomExternalEmailArgumentsDef = "";
|
||||
|
||||
DKEY Browser::QueueTabs = "queue_tabs";
|
||||
DVALUE(bool) Browser::QueueTabsDef = true;
|
||||
|
||||
|
@ -261,6 +261,15 @@ namespace Browser {
|
||||
KEY CustomExternalBrowserArguments;
|
||||
VALUE(char*) CustomExternalBrowserArgumentsDef;
|
||||
|
||||
KEY CustomExternalEmailEnabled;
|
||||
VALUE(bool) CustomExternalEmailEnabledDef;
|
||||
|
||||
KEY CustomExternalEmailExecutable;
|
||||
VALUE(char*) CustomExternalEmailExecutableDef;
|
||||
|
||||
KEY CustomExternalEmailArguments;
|
||||
VALUE(char*) CustomExternalEmailArgumentsDef;
|
||||
|
||||
KEY QueueTabs;
|
||||
VALUE(bool) QueueTabsDef;
|
||||
}
|
||||
|
@ -28,6 +28,24 @@ void WebFactory::loadState() {
|
||||
switchPlugins(settings->value(GROUP(Browser), SETTING(Browser::PluginsEnabled)).toBool(), false);
|
||||
}
|
||||
|
||||
bool WebFactory::sendMessageViaEmail(const Message &message) {
|
||||
if (qApp->settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalEmailEnabled)).toBool()) {
|
||||
QString browser = qApp->settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalEmailExecutable)).toString();
|
||||
QString arguments = qApp->settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalEmailArguments)).toString();
|
||||
|
||||
return QProcess::startDetached(browser, QStringList() << arguments.arg(message.m_title,
|
||||
stripTags(message.m_contents)));
|
||||
}
|
||||
else {
|
||||
// TODO: Check encoding when using mailto and add icon for the action.
|
||||
|
||||
// Send it via mailto protocol.
|
||||
// NOTE: http://en.wikipedia.org/wiki/Mailto
|
||||
return QDesktopServices::openUrl(QString("mailto:?subject=%1&body=%2").arg(QString(QUrl::toPercentEncoding(message.m_title)),
|
||||
QString(QUrl::toPercentEncoding(stripTags(message.m_contents)))));
|
||||
}
|
||||
}
|
||||
|
||||
bool WebFactory::openUrlInExternalBrowser(const QString &url) {
|
||||
if (qApp->settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalBrowserEnabled)).toBool()) {
|
||||
QString browser = qApp->settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalBrowserExecutable)).toString();
|
||||
|
@ -2,6 +2,9 @@
|
||||
#define WEBFACTORY_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "core/messagesmodel.h"
|
||||
|
||||
#include <QPointer>
|
||||
#include <QMap>
|
||||
|
||||
@ -38,6 +41,7 @@ class WebFactory : public QObject {
|
||||
public slots:
|
||||
// Opens given string URL in external browser.
|
||||
bool openUrlInExternalBrowser(const QString &url);
|
||||
bool sendMessageViaEmail(const Message &message);
|
||||
|
||||
// Switchers.
|
||||
void switchJavascript(bool enable, bool save_settings = true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user