mirror of
https://git.wownero.com/wowlet/wowlet.git
synced 2024-08-15 01:03:14 +00:00
Add reddit frontend setting
This commit is contained in:
parent
94a53abb00
commit
5cf37918e7
8 changed files with 50 additions and 10 deletions
|
@ -468,7 +468,7 @@ void AppContext::onWSReddit(const QJsonArray& reddit_data) {
|
|||
auto redditPost = new RedditPost(
|
||||
obj.value("title").toString(),
|
||||
obj.value("author").toString(),
|
||||
obj.value("url").toString(),
|
||||
obj.value("permalink").toString(),
|
||||
obj.value("comments").toInt());
|
||||
QSharedPointer<RedditPost> r = QSharedPointer<RedditPost>(redditPost);
|
||||
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_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
|
||||
QStringList fiatCurrencies;
|
||||
|
@ -94,6 +95,11 @@ void Settings::comboBox_blockExplorerChanged(int pos) {
|
|||
emit blockExplorerChanged(blockExplorer);
|
||||
}
|
||||
|
||||
void Settings::comboBox_redditFrontendChanged(int pos) {
|
||||
QString redditFrontend = ui->comboBox_redditFrontend->currentText();
|
||||
config()->set(Config::redditFrontend, redditFrontend);
|
||||
}
|
||||
|
||||
void Settings::copyToClipboard() {
|
||||
ui->textLogs->copy();
|
||||
}
|
||||
|
|
|
@ -36,7 +36,8 @@ public slots:
|
|||
void checkboxExternalLinkWarn();
|
||||
void fiatCurrencySelected(int index);
|
||||
void comboBox_skinChanged(int pos);
|
||||
void comboBox_blockExplorerChanged(int post);
|
||||
void comboBox_blockExplorerChanged(int pos);
|
||||
void comboBox_redditFrontendChanged(int pos);
|
||||
|
||||
private:
|
||||
QStringList m_skins{"Native", "QDarkStyle", "Breeze/Dark", "Breeze/Light"};
|
||||
|
|
|
@ -161,20 +161,46 @@
|
|||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="checkBox_externalLink">
|
||||
<property name="text">
|
||||
<string>Warn before opening external link</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<item row="5" column="0">
|
||||
<widget class="QCheckBox" name="checkBox_hideBalance">
|
||||
<property name="text">
|
||||
<string>Hide balance</string>
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_node">
|
||||
|
|
|
@ -43,7 +43,8 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
|
|||
{Config::geometry, {QS("geometry"), {}}},
|
||||
{Config::windowState, {QS("windowState"), {}}},
|
||||
{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,
|
||||
windowState,
|
||||
firstRun,
|
||||
hideBalance
|
||||
hideBalance,
|
||||
redditFrontend
|
||||
};
|
||||
|
||||
~Config() override;
|
||||
|
|
|
@ -7,11 +7,12 @@
|
|||
#include <QString>
|
||||
|
||||
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 author;
|
||||
QString url;
|
||||
QString permalink;
|
||||
int comments;
|
||||
};
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "redditwidget.h"
|
||||
#include "ui_redditwidget.h"
|
||||
#include "utils/utils.h"
|
||||
#include "utils/config.h"
|
||||
|
||||
RedditWidget::RedditWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
|
@ -36,8 +37,11 @@ void RedditWidget::linkClicked() {
|
|||
QModelIndex index = ui->tableView->currentIndex();
|
||||
auto post = m_model->post(index.row());
|
||||
|
||||
if (post) {
|
||||
Utils::externalLinkWarning(this, post->url);
|
||||
if (post != nullptr) {
|
||||
QString redditFrontend = config()->get(Config::redditFrontend).toString();
|
||||
QString link = QString("https://%1%2").arg(redditFrontend, post->permalink);
|
||||
|
||||
Utils::externalLinkWarning(this, link);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue