External web browsers support for multiple arguments.

This commit is contained in:
Martin Rotter 2014-01-17 19:23:34 +01:00
parent e1e8f134e0
commit 222d33ed59
2 changed files with 42 additions and 45 deletions

View File

@ -17,7 +17,7 @@
<item row="0" column="1"> <item row="0" column="1">
<widget class="QStackedWidget" name="m_stackedSettings"> <widget class="QStackedWidget" name="m_stackedSettings">
<property name="currentIndex"> <property name="currentIndex">
<number>2</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="m_pageGeneral"> <widget class="QWidget" name="m_pageGeneral">
<layout class="QFormLayout" name="formLayout_5"> <layout class="QFormLayout" name="formLayout_5">
@ -51,8 +51,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>100</width> <width>576</width>
<height>30</height> <height>373</height>
</rect> </rect>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_4">
@ -102,8 +102,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>568</width> <width>177</width>
<height>344</height> <height>213</height>
</rect> </rect>
</property> </property>
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
@ -565,7 +565,7 @@
<item> <item>
<widget class="QTabWidget" name="m_tabFeedsMessages"> <widget class="QTabWidget" name="m_tabFeedsMessages">
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="m_tabFeeds"> <widget class="QWidget" name="m_tabFeeds">
<attribute name="title"> <attribute name="title">
@ -576,16 +576,13 @@
<attribute name="title"> <attribute name="title">
<string>Messages</string> <string>Messages</string>
</attribute> </attribute>
<layout class="QFormLayout" name="formLayout_10"> <layout class="QFormLayout" name="formLayout_11">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0" colspan="2"> <item row="0" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_3"> <widget class="QGroupBox" name="groupBox_3">
<property name="title"> <property name="title">
<string>External web browser for message viewing</string> <string>External web browser for message viewing</string>
</property> </property>
<layout class="QFormLayout" name="formLayout_11"> <layout class="QFormLayout" name="formLayout_10">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="m_lblExternalBrowserExecutable"> <widget class="QLabel" name="m_lblExternalBrowserExecutable">
<property name="text"> <property name="text">
@ -619,36 +616,32 @@
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_11"> <widget class="QLineEdit" name="m_txtExternalBrowserArguments">
<item> <property name="placeholderText">
<widget class="QLineEdit" name="m_txtExternalBrowserArguments"> <string>Parameters to executable</string>
<property name="placeholderText"> </property>
<string>Parameters to executable</string> </widget>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="m_lblExternalBrowserPreset">
<property name="text">
<string>use sample arguments for</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="m_cmbExternalBrowserPreset">
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
<item>
<property name="text">
<string>select browser</string>
</property>
</item>
</widget>
</item>
</layout>
</item> </item>
<item row="2" column="0" colspan="2"> <item row="2" column="0">
<widget class="QLabel" name="m_lblExternalBrowserPreset">
<property name="text">
<string>use sample arguments for</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="m_cmbExternalBrowserPreset">
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
<item>
<property name="text">
<string>select browser</string>
</property>
</item>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>Note that &quot;%1&quot; (without quotation marks) is placeholder for URL of selected message.</string> <string>Note that &quot;%1&quot; (without quotation marks) is placeholder for URL of selected message.</string>
@ -662,6 +655,8 @@
</widget> </widget>
</item> </item>
</layout> </layout>
<zorder>groupBox_3</zorder>
<zorder>label</zorder>
</widget> </widget>
</widget> </widget>
</item> </item>

View File

@ -214,10 +214,10 @@ void MessagesView::loadFeeds(const QList<int> &feed_ids) {
void MessagesView::openSelectedSourceArticlesExternally() { void MessagesView::openSelectedSourceArticlesExternally() {
QString browser = Settings::instance()->value(APP_CFG_MESSAGES, QString browser = Settings::instance()->value(APP_CFG_MESSAGES,
"external_browser_executable").toString(); "external_browser_executable").toString();
QString arguments = Settings::instance()->value(APP_CFG_MESSAGES, QStringList arguments = Settings::instance()->value(APP_CFG_MESSAGES,
"external_browser_arguments", "external_browser_arguments",
"%1").toString(); "%1").toString().split(' ');
if (browser.isEmpty() || arguments.isEmpty()) { if (browser.isEmpty() || arguments.isEmpty()) {
QMessageBox::critical(this, QMessageBox::critical(this,
@ -229,12 +229,14 @@ void MessagesView::openSelectedSourceArticlesExternally() {
foreach (const QModelIndex &index, selectionModel()->selectedRows()) { foreach (const QModelIndex &index, selectionModel()->selectedRows()) {
QString link = m_sourceModel->messageAt(m_proxyModel->mapToSource(index).row()).m_url; QString link = m_sourceModel->messageAt(m_proxyModel->mapToSource(index).row()).m_url;
QStringList real_arguments = arguments.replaceInStrings("%1", link);
if (!QProcess::startDetached(browser, QStringList() << arguments.arg(link))) { if (!QProcess::startDetached(browser, real_arguments)) {
QMessageBox::critical(this, QMessageBox::critical(this,
tr("Problem with starting external web browser"), tr("Problem with starting external web browser"),
tr("External web browser could not be started."), tr("External web browser could not be started."),
QMessageBox::Ok); QMessageBox::Ok);
return;
} }
} }
} }