From 69419171b797b0d2b243b919c6c5e31aec9a1e4b Mon Sep 17 00:00:00 2001 From: tobtoht Date: Wed, 26 Mar 2025 07:19:50 +0100 Subject: [PATCH] move contacts to separate tab --- src/ContactsWidget.cpp | 12 ++++----- src/ContactsWidget.ui | 58 ++++++++++++++++++++++++++++++++++-------- src/MainWindow.cpp | 23 +++++++++++------ src/MainWindow.ui | 57 ++++++++++++++++++++++++++--------------- 4 files changed, 105 insertions(+), 45 deletions(-) diff --git a/src/ContactsWidget.cpp b/src/ContactsWidget.cpp index 0e741057..c6389ca2 100644 --- a/src/ContactsWidget.cpp +++ b/src/ContactsWidget.cpp @@ -22,11 +22,6 @@ ContactsWidget::ContactsWidget(Wallet *wallet, QWidget *parent) { ui->setupUi(this); - m_btn_addContact = new QPushButton(this); - m_btn_addContact->setIcon(icons()->icon("register.svg")); - ui->searchLayout->addWidget(m_btn_addContact, 0, Qt::AlignRight); - connect(m_btn_addContact, &QPushButton::clicked, [this]{this->newContact();}); - m_model = m_wallet->addressBookModel(); m_proxyModel = new AddressBookProxyModel; m_proxyModel->setSourceModel(m_model); @@ -40,9 +35,14 @@ ContactsWidget::ContactsWidget(Wallet *wallet, QWidget *parent) // header context menu ui->contacts->header()->setContextMenuPolicy(Qt::CustomContextMenu); m_headerMenu = new QMenu(this); + m_headerMenu->addAction("New contact", [this] { + this->newContact(); + }); m_showFullAddressesAction = m_headerMenu->addAction("Show full addresses", this, &ContactsWidget::setShowFullAddresses); m_showFullAddressesAction->setCheckable(true); + ui->btn_options->setMenu(m_headerMenu); + connect(ui->contacts->header(), &QHeaderView::customContextMenuRequested, this, &ContactsWidget::showHeaderMenu); connect(ui->contacts, &QTreeView::doubleClicked, [this](QModelIndex index){ @@ -78,7 +78,7 @@ ContactsWidget::ContactsWidget(Wallet *wallet, QWidget *parent) } void ContactsWidget::setSearchbarVisible(bool visible) { - ui->search->setVisible(visible); + ui->frame_search->setVisible(visible); } void ContactsWidget::focusSearchbar() { diff --git a/src/ContactsWidget.ui b/src/ContactsWidget.ui index 8281279d..81c95b3e 100644 --- a/src/ContactsWidget.ui +++ b/src/ContactsWidget.ui @@ -7,7 +7,7 @@ 0 0 914 - 763 + 384 @@ -30,15 +30,49 @@ 0 - - - - - Search contacts... - - - - + + + QFrame::Shape::NoFrame + + + QFrame::Shadow::Plain + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Search... + + + + + + + + + + + :/assets/images/preferences.svg:/assets/images/preferences.svg + + + QToolButton::ToolButtonPopupMode::InstantPopup + + + + + @@ -58,6 +92,8 @@ - + + + diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 698f17b0..e9b03725 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -230,9 +230,6 @@ void MainWindow::initWidgets() { // [Send] m_sendWidget = new SendWidget(m_wallet, this); ui->sendWidgetLayout->addWidget(m_sendWidget); - // -------------- - m_contactsWidget = new ContactsWidget(m_wallet, this); - ui->contactsWidgetLayout->addWidget(m_contactsWidget); // [Receive] m_receiveWidget = new ReceiveWidget(m_wallet, this); @@ -241,14 +238,19 @@ void MainWindow::initWidgets() { m_historyWidget->setSearchText(text); ui->tabWidget->setCurrentIndex(this->findTab("History")); }); - connect(m_contactsWidget, &ContactsWidget::fill, [this](const QString &address, const QString &description){ - m_sendWidget->fill(address, description, 0, true); - }); // [Coins] m_coinsWidget = new CoinsWidget(m_wallet, this); ui->coinsWidgetLayout->addWidget(m_coinsWidget); + // [Contacts] + m_contactsWidget = new ContactsWidget(m_wallet, this); + ui->contactsWidgetLayout->addWidget(m_contactsWidget); + connect(m_contactsWidget, &ContactsWidget::fill, [this](const QString &address, const QString &description){ + m_sendWidget->fill(address, description, 0, true); + ui->tabWidget->setCurrentIndex(this->findTab("Send")); + }); + // [Plugins..] for (auto* plugin : m_plugins) { if (!plugin->hasParent()) { @@ -332,6 +334,11 @@ void MainWindow::initMenu() { m_tabShowHideMapper["Coins"] = new ToggleTab(ui->tabCoins, "Coins", "Coins", ui->actionShow_Coins, this); m_tabShowHideSignalMapper->setMapping(ui->actionShow_Coins, "Coins"); + // Show/Hide Contacts + connect(ui->actionShow_Contacts, &QAction::triggered, m_tabShowHideSignalMapper, QOverload<>::of(&QSignalMapper::map)); + m_tabShowHideMapper["Contacts"] = new ToggleTab(ui->tabContacts, "Contacts", "Contacts", ui->actionShow_Contacts, this); + m_tabShowHideSignalMapper->setMapping(ui->actionShow_Contacts, "Contacts"); + // Show/Hide Plugins.. for (const auto &plugin : m_plugins) { if (plugin->parent() != "") { @@ -1968,7 +1975,7 @@ void MainWindow::toggleSearchbar(bool visible) { int currentTab = ui->tabWidget->currentIndex(); if (currentTab == this->findTab("History")) m_historyWidget->focusSearchbar(); - else if (currentTab == this->findTab("Send")) + else if (currentTab == this->findTab("Contacts")) m_contactsWidget->focusSearchbar(); else if (currentTab == this->findTab("Receive")) m_receiveWidget->focusSearchbar(); @@ -1987,4 +1994,4 @@ int MainWindow::findTab(const QString &title) { MainWindow::~MainWindow() { qDebug() << "~MainWindow" << QThread::currentThreadId(); -} \ No newline at end of file +} diff --git a/src/MainWindow.ui b/src/MainWindow.ui index 1133416c..f7c27dc8 100644 --- a/src/MainWindow.ui +++ b/src/MainWindow.ui @@ -113,20 +113,17 @@ - - + + + Qt::Orientation::Vertical + + - 0 + 20 0 - - Qt::Horizontal - - - - - + @@ -158,15 +155,29 @@ + + + + :/assets/images/tab_contacts.png:/assets/images/tab_contacts.png + + + Contacts + + + + + + + - QFrame::StyledPanel + QFrame::Shape::StyledPanel - QFrame::Raised + QFrame::Shadow::Raised @@ -181,7 +192,7 @@ Coin control active: - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + Qt::TextInteractionFlag::LinksAccessibleByMouse|Qt::TextInteractionFlag::TextSelectableByMouse @@ -332,10 +343,10 @@ - Qt::Vertical + Qt::Orientation::Vertical - QSizePolicy::Fixed + QSizePolicy::Policy::Fixed @@ -368,10 +379,10 @@ - Qt::Vertical + Qt::Orientation::Vertical - QSizePolicy::Fixed + QSizePolicy::Policy::Fixed @@ -393,7 +404,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -429,7 +440,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -469,7 +480,7 @@ 0 0 977 - 27 + 23 @@ -575,6 +586,7 @@ + @@ -945,6 +957,11 @@ Import descriptions from CSV + + + Show Contacts + + -- 2.52.0