]> Nutra Git (v1) - gamesguru/feather.git/commitdiff
move contacts to separate tab
authortobtoht <tob@featherwallet.org>
Wed, 26 Mar 2025 06:19:50 +0000 (07:19 +0100)
committertobtoht <tob@featherwallet.org>
Wed, 26 Mar 2025 06:21:01 +0000 (07:21 +0100)
src/ContactsWidget.cpp
src/ContactsWidget.ui
src/MainWindow.cpp
src/MainWindow.ui

index 0e74105725bfc0ebcbb6d2167bc9f37e6d92d6e0..c6389ca27590d2e3510483bc9928fa2815d8996f 100644 (file)
@@ -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() {
index 8281279d9d3af4ee0e6b8a21f696c671c9a767ec..81c95b3ec121cc27464eecdc26e0981cb7284da7 100644 (file)
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>914</width>
-    <height>763</height>
+    <height>384</height>
    </rect>
   </property>
   <property name="windowTitle">
     <number>0</number>
    </property>
    <item>
-    <layout class="QHBoxLayout" name="searchLayout">
-     <item>
-      <widget class="QLineEdit" name="search">
-       <property name="placeholderText">
-        <string>Search contacts...</string>
-       </property>
-      </widget>
-     </item>
-    </layout>
+    <widget class="QFrame" name="frame_search">
+     <property name="frameShape">
+      <enum>QFrame::Shape::NoFrame</enum>
+     </property>
+     <property name="frameShadow">
+      <enum>QFrame::Shadow::Plain</enum>
+     </property>
+     <layout class="QHBoxLayout" name="horizontalLayout">
+      <property name="leftMargin">
+       <number>0</number>
+      </property>
+      <property name="topMargin">
+       <number>0</number>
+      </property>
+      <property name="rightMargin">
+       <number>0</number>
+      </property>
+      <property name="bottomMargin">
+       <number>0</number>
+      </property>
+      <item>
+       <widget class="QLineEdit" name="search">
+        <property name="placeholderText">
+         <string>Search...</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QToolButton" name="btn_options">
+        <property name="text">
+         <string/>
+        </property>
+        <property name="icon">
+         <iconset resource="assets.qrc">
+          <normaloff>:/assets/images/preferences.svg</normaloff>:/assets/images/preferences.svg</iconset>
+        </property>
+        <property name="popupMode">
+         <enum>QToolButton::ToolButtonPopupMode::InstantPopup</enum>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
    </item>
    <item>
     <widget class="QTreeView" name="contacts">
@@ -58,6 +92,8 @@
    </item>
   </layout>
  </widget>
- <resources/>
+ <resources>
+  <include location="assets.qrc"/>
+ </resources>
  <connections/>
 </ui>
index 698f17b0e7c65df5f97898639811ad97a0752299..e9b03725b2098b8ccc3cb261b126a5859296f92e 100644 (file)
@@ -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
+}
index 1133416c74b1bbe925edc9efcd1394440fa080e7..f7c27dc825f44493c2f12c7d68997b2124f30ac9 100644 (file)
              </layout>
             </item>
             <item>
-             <widget class="Line" name="line_3">
-              <property name="minimumSize">
+             <spacer name="verticalSpacer">
+              <property name="orientation">
+               <enum>Qt::Orientation::Vertical</enum>
+              </property>
+              <property name="sizeHint" stdset="0">
                <size>
-                <width>0</width>
+                <width>20</width>
                 <height>0</height>
                </size>
               </property>
-              <property name="orientation">
-               <enum>Qt::Horizontal</enum>
-              </property>
-             </widget>
-            </item>
-            <item>
-             <layout class="QVBoxLayout" name="contactsWidgetLayout"/>
+             </spacer>
             </item>
            </layout>
           </widget>
             </item>
            </layout>
           </widget>
+          <widget class="QWidget" name="tabContacts">
+           <attribute name="icon">
+            <iconset resource="assets.qrc">
+             <normaloff>:/assets/images/tab_contacts.png</normaloff>:/assets/images/tab_contacts.png</iconset>
+           </attribute>
+           <attribute name="title">
+            <string>Contacts</string>
+           </attribute>
+           <layout class="QVBoxLayout" name="verticalLayout_4">
+            <item>
+             <layout class="QVBoxLayout" name="contactsWidgetLayout"/>
+            </item>
+           </layout>
+          </widget>
          </widget>
         </item>
         <item>
          <widget class="QFrame" name="frame_coinControl">
           <property name="frameShape">
-           <enum>QFrame::StyledPanel</enum>
+           <enum>QFrame::Shape::StyledPanel</enum>
           </property>
           <property name="frameShadow">
-           <enum>QFrame::Raised</enum>
+           <enum>QFrame::Shadow::Raised</enum>
           </property>
           <layout class="QHBoxLayout" name="horizontalLayout_3">
            <property name="topMargin">
               <string>Coin control active: </string>
              </property>
              <property name="textInteractionFlags">
-              <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
+              <set>Qt::TextInteractionFlag::LinksAccessibleByMouse|Qt::TextInteractionFlag::TextSelectableByMouse</set>
              </property>
             </widget>
            </item>
             <item>
              <spacer name="verticalSpacer_3">
               <property name="orientation">
-               <enum>Qt::Vertical</enum>
+               <enum>Qt::Orientation::Vertical</enum>
               </property>
               <property name="sizeType">
-               <enum>QSizePolicy::Fixed</enum>
+               <enum>QSizePolicy::Policy::Fixed</enum>
               </property>
               <property name="sizeHint" stdset="0">
                <size>
             <item>
              <spacer name="verticalSpacer_4">
               <property name="orientation">
-               <enum>Qt::Vertical</enum>
+               <enum>Qt::Orientation::Vertical</enum>
               </property>
               <property name="sizeType">
-               <enum>QSizePolicy::Fixed</enum>
+               <enum>QSizePolicy::Policy::Fixed</enum>
               </property>
               <property name="sizeHint" stdset="0">
                <size>
               <item>
                <spacer name="horizontalSpacer_2">
                 <property name="orientation">
-                 <enum>Qt::Horizontal</enum>
+                 <enum>Qt::Orientation::Horizontal</enum>
                 </property>
                 <property name="sizeHint" stdset="0">
                  <size>
             <item>
              <spacer name="verticalSpacer_2">
               <property name="orientation">
-               <enum>Qt::Vertical</enum>
+               <enum>Qt::Orientation::Vertical</enum>
               </property>
               <property name="sizeHint" stdset="0">
                <size>
      <x>0</x>
      <y>0</y>
      <width>977</width>
-     <height>27</height>
+     <height>23</height>
     </rect>
    </property>
    <widget class="QMenu" name="menuFile">
     </property>
     <addaction name="actionPlaceholderBegin"/>
     <addaction name="actionShow_Coins"/>
+    <addaction name="actionShow_Contacts"/>
     <addaction name="actionPlaceholderEnd"/>
     <addaction name="separator"/>
     <addaction name="actionShow_Searchbar"/>
     <string>Import descriptions from CSV</string>
    </property>
   </action>
+  <action name="actionShow_Contacts">
+   <property name="text">
+    <string>Show Contacts</string>
+   </property>
+  </action>
  </widget>
  <layoutdefault spacing="6" margin="11"/>
  <customwidgets>