mirror of
https://github.com/feather-wallet/feather.git
synced 2024-12-22 11:39:25 +00:00
AccountSwitcherDialog: don't select #0 account on opening
This commit is contained in:
parent
117c6b9763
commit
147e8c04f6
2 changed files with 16 additions and 13 deletions
|
@ -39,7 +39,7 @@ AccountSwitcherDialog::AccountSwitcherDialog(Wallet *wallet, QWidget *parent)
|
||||||
ui->accounts->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
ui->accounts->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||||
ui->accounts->header()->setSectionResizeMode(SubaddressAccountModel::Label, QHeaderView::Stretch);
|
ui->accounts->header()->setSectionResizeMode(SubaddressAccountModel::Label, QHeaderView::Stretch);
|
||||||
|
|
||||||
connect(ui->accounts->selectionModel(), &QItemSelectionModel::currentChanged, this, &AccountSwitcherDialog::switchAccount);
|
connect(ui->accounts, &QTreeView::clicked, this, &AccountSwitcherDialog::switchAccount);
|
||||||
connect(ui->accounts, &QTreeView::customContextMenuRequested, this, &AccountSwitcherDialog::showContextMenu);
|
connect(ui->accounts, &QTreeView::customContextMenuRequested, this, &AccountSwitcherDialog::showContextMenu);
|
||||||
|
|
||||||
connect(ui->btn_newAccount, &QPushButton::clicked, [this]{
|
connect(ui->btn_newAccount, &QPushButton::clicked, [this]{
|
||||||
|
@ -47,11 +47,14 @@ AccountSwitcherDialog::AccountSwitcherDialog(Wallet *wallet, QWidget *parent)
|
||||||
m_wallet->subaddressAccount()->refresh();
|
m_wallet->subaddressAccount()->refresh();
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(m_wallet, &Wallet::currentSubaddressAccountChanged, this, &AccountSwitcherDialog::updateSelection);
|
|
||||||
connect(m_wallet->subaddressAccount(), &SubaddressAccount::refreshFinished, this, &AccountSwitcherDialog::updateSelection);
|
connect(m_wallet->subaddressAccount(), &SubaddressAccount::refreshFinished, this, &AccountSwitcherDialog::updateSelection);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AccountSwitcherDialog::showEvent(QShowEvent *event) {
|
||||||
|
QDialog::showEvent(event);
|
||||||
|
|
||||||
this->update();
|
this->update();
|
||||||
this->updateSelection();
|
m_wallet->switchSubaddressAccount(m_wallet->currentSubaddressAccount());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountSwitcherDialog::update() {
|
void AccountSwitcherDialog::update() {
|
||||||
|
@ -59,13 +62,8 @@ void AccountSwitcherDialog::update() {
|
||||||
m_wallet->subaddressAccount()->refresh();
|
m_wallet->subaddressAccount()->refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountSwitcherDialog::switchAccount() {
|
void AccountSwitcherDialog::switchAccount(const QModelIndex &index) {
|
||||||
auto row = this->currentEntry();
|
m_wallet->switchSubaddressAccount(m_proxyModel->mapToSource(index).row());
|
||||||
if (!row) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_wallet->switchSubaddressAccount(row->getRow());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountSwitcherDialog::copyLabel() {
|
void AccountSwitcherDialog::copyLabel() {
|
||||||
|
@ -93,11 +91,13 @@ void AccountSwitcherDialog::editLabel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountSwitcherDialog::updateSelection() {
|
void AccountSwitcherDialog::updateSelection() {
|
||||||
QModelIndex index = m_model->index(m_wallet->currentSubaddressAccount(), 0);
|
QModelIndex index = m_proxyModel->index(m_wallet->currentSubaddressAccount(), 0);
|
||||||
if (!index.isValid()) {
|
if (!index.isValid()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ui->accounts->selectionModel()->select(index, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
|
|
||||||
|
ui->accounts->setCurrentIndex(index);
|
||||||
|
ui->accounts->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountSwitcherDialog::showContextMenu(const QPoint &point) {
|
void AccountSwitcherDialog::showContextMenu(const QPoint &point) {
|
||||||
|
|
|
@ -22,12 +22,15 @@ public:
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void showEvent(QShowEvent *event) override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void showContextMenu(const QPoint& point);
|
void showContextMenu(const QPoint& point);
|
||||||
void updateSelection();
|
void updateSelection();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void switchAccount();
|
void switchAccount(const QModelIndex &index);
|
||||||
void copyLabel();
|
void copyLabel();
|
||||||
void copyBalance();
|
void copyBalance();
|
||||||
void editLabel();
|
void editLabel();
|
||||||
|
|
Loading…
Reference in a new issue