mirror of
https://github.com/feather-wallet/feather.git
synced 2024-12-23 03:59:29 +00:00
Merge pull request 'Reddit: copy link' (#276) from tobtoht/feather:reddit_copy_link into master
Reviewed-on: https://git.wownero.com/feather/feather/pulls/276
This commit is contained in:
commit
1c088cc925
4 changed files with 40 additions and 8 deletions
|
@ -177,6 +177,8 @@ MainWindow::MainWindow(AppContext *ctx, QWidget *parent) :
|
|||
connect(m_ctx, &AppContext::ccsUpdated, ui->ccsWidget->model(), &CCSModel::updateEntries);
|
||||
connect(m_ctx, &AppContext::redditUpdated, ui->redditWidget->model(), &RedditModel::updatePosts);
|
||||
|
||||
connect(ui->redditWidget, &RedditWidget::setStatusText, this, &MainWindow::setStatusText);
|
||||
|
||||
connect(ui->tabHomeWidget, &QTabWidget::currentChanged, [](int index){
|
||||
config()->set(Config::homeWidget, TabsHome(index));
|
||||
});
|
||||
|
@ -675,10 +677,22 @@ void MainWindow::onBalanceUpdated(quint64 balance, quint64 spendable) {
|
|||
m_balanceWidget->setHidden(hide);
|
||||
}
|
||||
|
||||
void MainWindow::setStatusText(const QString &text) {
|
||||
m_statusText = text;
|
||||
if (!m_constructingTransaction)
|
||||
void MainWindow::setStatusText(const QString &text, bool override, int timeout) {
|
||||
if (override) {
|
||||
m_statusOverrideActive = true;
|
||||
m_statusLabelStatus->setText(text);
|
||||
QTimer::singleShot(timeout, [this]{
|
||||
m_statusOverrideActive = false;
|
||||
this->setStatusText(m_statusText);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
m_statusText = text;
|
||||
|
||||
if (!m_statusOverrideActive && !m_constructingTransaction) {
|
||||
m_statusLabelStatus->setText(text);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onSynchronized() {
|
||||
|
|
|
@ -169,7 +169,7 @@ private:
|
|||
void updatePasswordIcon();
|
||||
void updateNetStats();
|
||||
void rescanSpent();
|
||||
void setStatusText(const QString &text);
|
||||
void setStatusText(const QString &text, bool override = false, int timeout = 1000);
|
||||
void showBalanceDialog();
|
||||
QString statusDots();
|
||||
|
||||
|
@ -222,6 +222,7 @@ private:
|
|||
QString m_statusText;
|
||||
int m_statusDots;
|
||||
bool m_constructingTransaction = false;
|
||||
bool m_statusOverrideActive = false;
|
||||
QTimer m_txTimer;
|
||||
|
||||
private slots:
|
||||
|
|
|
@ -22,6 +22,7 @@ RedditWidget::RedditWidget(QWidget *parent) :
|
|||
this->setupTable();
|
||||
|
||||
m_contextMenu->addAction("View thread", this, &RedditWidget::linkClicked);
|
||||
m_contextMenu->addAction("Copy link", this, &RedditWidget::copyUrl);
|
||||
connect(ui->tableView, &QHeaderView::customContextMenuRequested, this, &RedditWidget::showContextMenu);
|
||||
|
||||
connect(ui->tableView, &QTableView::doubleClicked, this, &RedditWidget::linkClicked);
|
||||
|
@ -37,11 +38,17 @@ void RedditWidget::linkClicked() {
|
|||
QModelIndex index = ui->tableView->currentIndex();
|
||||
auto post = m_model->post(index.row());
|
||||
|
||||
if (post != nullptr) {
|
||||
QString redditFrontend = config()->get(Config::redditFrontend).toString();
|
||||
QString link = QString("https://%1%2").arg(redditFrontend, post->permalink);
|
||||
if (post)
|
||||
Utils::externalLinkWarning(this, this->getLink(post->permalink));
|
||||
}
|
||||
|
||||
Utils::externalLinkWarning(this, link);
|
||||
void RedditWidget::copyUrl() {
|
||||
QModelIndex index = ui->tableView->currentIndex();
|
||||
auto post = m_model->post(index.row());
|
||||
|
||||
if (post) {
|
||||
Utils::copyToClipboard(this->getLink(post->permalink));
|
||||
emit setStatusText("Link copied to clipboard", true, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,6 +69,11 @@ void RedditWidget::showContextMenu(const QPoint &pos) {
|
|||
m_contextMenu->exec(ui->tableView->viewport()->mapToGlobal(pos));
|
||||
}
|
||||
|
||||
QString RedditWidget::getLink(const QString &permaLink) {
|
||||
QString redditFrontend = config()->get(Config::redditFrontend).toString();
|
||||
return QString("https://%1%2").arg(redditFrontend, permaLink);
|
||||
}
|
||||
|
||||
RedditWidget::~RedditWidget() {
|
||||
delete ui;
|
||||
}
|
||||
|
|
|
@ -26,9 +26,14 @@ public:
|
|||
public slots:
|
||||
void linkClicked();
|
||||
|
||||
signals:
|
||||
void setStatusText(const QString &msg, bool override, int timeout);
|
||||
|
||||
private:
|
||||
void setupTable();
|
||||
void showContextMenu(const QPoint &pos);
|
||||
void copyUrl();
|
||||
QString getLink(const QString &permaLink);
|
||||
|
||||
Ui::RedditWidget *ui;
|
||||
RedditModel* const m_model;
|
||||
|
|
Loading…
Reference in a new issue