Add reddit frontend setting

remotes/1691844314220217825/master
tobtoht 3 years ago
parent 94a53abb00
commit 5cf37918e7
Signed by untrusted user: tobtoht
GPG Key ID: 1CADD27F41F45C3C

@ -468,7 +468,7 @@ void AppContext::onWSReddit(const QJsonArray& reddit_data) {
auto redditPost = new RedditPost( auto redditPost = new RedditPost(
obj.value("title").toString(), obj.value("title").toString(),
obj.value("author").toString(), obj.value("author").toString(),
obj.value("url").toString(), obj.value("permalink").toString(),
obj.value("comments").toInt()); obj.value("comments").toInt());
QSharedPointer<RedditPost> r = QSharedPointer<RedditPost>(redditPost); QSharedPointer<RedditPost> r = QSharedPointer<RedditPost>(redditPost);
l.append(r); l.append(r);

@ -45,6 +45,7 @@ Settings::Settings(QWidget *parent) :
connect(ui->comboBox_skin, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &Settings::comboBox_skinChanged); connect(ui->comboBox_skin, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &Settings::comboBox_skinChanged);
connect(ui->comboBox_blockExplorer, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &Settings::comboBox_blockExplorerChanged); connect(ui->comboBox_blockExplorer, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &Settings::comboBox_blockExplorerChanged);
connect(ui->comboBox_redditFrontend, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &Settings::comboBox_redditFrontendChanged);
// setup preferred fiat currency combobox // setup preferred fiat currency combobox
QStringList fiatCurrencies; QStringList fiatCurrencies;
@ -94,6 +95,11 @@ void Settings::comboBox_blockExplorerChanged(int pos) {
emit blockExplorerChanged(blockExplorer); emit blockExplorerChanged(blockExplorer);
} }
void Settings::comboBox_redditFrontendChanged(int pos) {
QString redditFrontend = ui->comboBox_redditFrontend->currentText();
config()->set(Config::redditFrontend, redditFrontend);
}
void Settings::copyToClipboard() { void Settings::copyToClipboard() {
ui->textLogs->copy(); ui->textLogs->copy();
} }

@ -36,7 +36,8 @@ public slots:
void checkboxExternalLinkWarn(); void checkboxExternalLinkWarn();
void fiatCurrencySelected(int index); void fiatCurrencySelected(int index);
void comboBox_skinChanged(int pos); void comboBox_skinChanged(int pos);
void comboBox_blockExplorerChanged(int post); void comboBox_blockExplorerChanged(int pos);
void comboBox_redditFrontendChanged(int pos);
private: private:
QStringList m_skins{"Native", "QDarkStyle", "Breeze/Dark", "Breeze/Light"}; QStringList m_skins{"Native", "QDarkStyle", "Breeze/Dark", "Breeze/Light"};

@ -161,20 +161,46 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="4" column="0">
<widget class="QCheckBox" name="checkBox_externalLink"> <widget class="QCheckBox" name="checkBox_externalLink">
<property name="text"> <property name="text">
<string>Warn before opening external link</string> <string>Warn before opening external link</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0"> <item row="5" column="0">
<widget class="QCheckBox" name="checkBox_hideBalance"> <widget class="QCheckBox" name="checkBox_hideBalance">
<property name="text"> <property name="text">
<string>Hide balance</string> <string>Hide balance</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Reddit frontend:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="comboBox_redditFrontend">
<item>
<property name="text">
<string>old.reddit.com</string>
</property>
</item>
<item>
<property name="text">
<string>reddit.com</string>
</property>
</item>
<item>
<property name="text">
<string>teddit.net</string>
</property>
</item>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_node"> <widget class="QWidget" name="tab_node">

@ -43,7 +43,8 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
{Config::geometry, {QS("geometry"), {}}}, {Config::geometry, {QS("geometry"), {}}},
{Config::windowState, {QS("windowState"), {}}}, {Config::windowState, {QS("windowState"), {}}},
{Config::firstRun,{QS("firstRun"), false}}, {Config::firstRun,{QS("firstRun"), false}},
{Config::hideBalance, {QS("hideBalance"), false}} {Config::hideBalance, {QS("hideBalance"), false}},
{Config::redditFrontend, {QS("redditFrontend"), "old.reddit.com"}}
}; };

@ -45,7 +45,8 @@ public:
geometry, geometry,
windowState, windowState,
firstRun, firstRun,
hideBalance hideBalance,
redditFrontend
}; };
~Config() override; ~Config() override;

@ -7,11 +7,12 @@
#include <QString> #include <QString>
struct RedditPost { struct RedditPost {
RedditPost(const QString &title, const QString &author, const QString &url, int comments) : title(title), author(author), url(url), comments(comments){}; RedditPost(const QString &title, const QString &author, const QString &permalink, int comments)
: title(title), author(author), permalink(permalink), comments(comments){};
QString title; QString title;
QString author; QString author;
QString url; QString permalink;
int comments; int comments;
}; };

@ -9,6 +9,7 @@
#include "redditwidget.h" #include "redditwidget.h"
#include "ui_redditwidget.h" #include "ui_redditwidget.h"
#include "utils/utils.h" #include "utils/utils.h"
#include "utils/config.h"
RedditWidget::RedditWidget(QWidget *parent) : RedditWidget::RedditWidget(QWidget *parent) :
QWidget(parent), QWidget(parent),
@ -36,8 +37,11 @@ void RedditWidget::linkClicked() {
QModelIndex index = ui->tableView->currentIndex(); QModelIndex index = ui->tableView->currentIndex();
auto post = m_model->post(index.row()); auto post = m_model->post(index.row());
if (post) { if (post != nullptr) {
Utils::externalLinkWarning(this, post->url); QString redditFrontend = config()->get(Config::redditFrontend).toString();
QString link = QString("https://%1%2").arg(redditFrontend, post->permalink);
Utils::externalLinkWarning(this, link);
} }
} }

Loading…
Cancel
Save