Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spats admin gui #1497

Open
wants to merge 4 commits into
base: libspats-refactor
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ QT_FORMS_UI = \
qt/forms/editaddressdialog.ui \
qt/forms/helpmessagedialog.ui \
qt/forms/masternodelist.ui \
qt/forms/myownspats.ui \
qt/forms/intro.ui \
qt/forms/modaloverlay.ui \
qt/forms/recover.ui \
Expand Down Expand Up @@ -146,6 +147,7 @@ QT_MOC_CPP = \
qt/moc_macdockiconhandler.cpp \
qt/moc_macnotificationhandler.cpp \
qt/moc_masternodelist.cpp \
qt/moc_myownspats.cpp \
qt/moc_modaloverlay.cpp \
qt/moc_notificator.cpp \
qt/moc_openuridialog.cpp \
Expand Down Expand Up @@ -225,6 +227,7 @@ BITCOIN_QT_H = \
qt/macdockiconhandler.h \
qt/macnotificationhandler.h \
qt/masternodelist.h \
qt/myownspats.h \
qt/modaloverlay.h \
qt/networkstyle.h \
qt/notificator.h \
Expand Down Expand Up @@ -403,6 +406,7 @@ BITCOIN_QT_BASE_CPP = \
qt/recover.cpp \
qt/notifymnemonic.cpp \
qt/masternodelist.cpp \
qt/myownspats.cpp \
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove duplicate source file inclusion.

The source file qt/myownspats.cpp is included in both BITCOIN_QT_BASE_CPP and BITCOIN_QT_WALLET_CPP variables. This could lead to duplicate symbol errors during linking. It should only be included in one of these variables based on its functionality.

If this is a wallet-related feature (which seems likely given it's a "My Own Spats" page), keep it only in BITCOIN_QT_WALLET_CPP. Apply this diff:

 BITCOIN_QT_BASE_CPP = \
   qt/bantablemodel.cpp \
   qt/bitcoinaddressvalidator.cpp \
   ...
-  qt/myownspats.cpp \
   qt/networkstyle.cpp \
   ...

Also applies to: 456-456

qt/networkstyle.cpp \
qt/notificator.cpp \
qt/optionsdialog.cpp \
Expand Down Expand Up @@ -449,6 +453,7 @@ BITCOIN_QT_WALLET_CPP = \
qt/walletmodel.cpp \
qt/walletmodeltransaction.cpp \
qt/masternodelist.cpp \
qt/myownspats.cpp \
qt/walletview.cpp \
qt/lelantusmodel.cpp \
qt/lelantusdialog.cpp \
Expand Down
26 changes: 24 additions & 2 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "evo/deterministicmns.h"
#include "masternode-sync.h"
#include "masternodelist.h"
#include "myownspats.h"
#include <iostream>

#include <QAction>
Expand Down Expand Up @@ -122,6 +123,7 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle *
showHelpMessageAction(0),
lelantusAction(0),
masternodeAction(0),
myownspatsAction(nullptr),
logoAction(0),
trayIcon(0),
trayIconMenu(0),
Expand Down Expand Up @@ -365,9 +367,18 @@ void BitcoinGUI::createActions()
tabGroup->addAction(masternodeAction);
#endif

myownspatsAction = new QAction(tr("M&y Own Spats"), this);
myownspatsAction->setStatusTip(tr("Browse My Own Spats"));
myownspatsAction->setToolTip(myownspatsAction->statusTip());
myownspatsAction->setCheckable(true);
myownspatsAction->setShortcut(QKeySequence(Qt::ALT + key++));
tabGroup->addAction(myownspatsAction);

#ifdef ENABLE_WALLET
connect(masternodeAction, &QAction::triggered, [this]{ showNormalIfMinimized(); });
connect(masternodeAction, &QAction::triggered, this, &BitcoinGUI::gotoMasternodePage);
connect(myownspatsAction, &QAction::triggered, [this]{ showNormalIfMinimized(); });
connect(myownspatsAction, &QAction::triggered, this, &BitcoinGUI::gotoMyOwnSpatsPage);
connect(overviewAction, &QAction::triggered, [this]{ showNormalIfMinimized(); });
connect(overviewAction, &QAction::triggered, this, &BitcoinGUI::gotoOverviewPage);
connect(sendCoinsAction, &QAction::triggered, [this]{ showNormalIfMinimized(); });
Expand Down Expand Up @@ -522,6 +533,7 @@ void BitcoinGUI::createToolBars()
toolbar->addAction(historyAction);
toolbar->addAction(lelantusAction);
toolbar->addAction(masternodeAction);
toolbar->addAction(myownspatsAction);

logoLabel = new QLabel();
logoLabel->setObjectName("lblToolbarLogo");
Expand Down Expand Up @@ -648,6 +660,7 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled)
historyAction->setEnabled(enabled);
lelantusAction->setEnabled(enabled);
masternodeAction->setEnabled(enabled);
myownspatsAction->setEnabled(enabled);
encryptWalletAction->setEnabled(enabled);
backupWalletAction->setEnabled(enabled);
changePassphraseAction->setEnabled(enabled);
Expand Down Expand Up @@ -790,6 +803,13 @@ void BitcoinGUI::gotoMasternodePage()
if (walletFrame) walletFrame->gotoMasternodePage();
}

void BitcoinGUI::gotoMyOwnSpatsPage()
{
QSettings settings;
myownspatsAction->setChecked(true);
if (walletFrame) walletFrame->gotoMyOwnSpatsPage();
}

void BitcoinGUI::gotoReceiveCoinsPage()
{
receiveCoinsAction->setChecked(true);
Expand Down Expand Up @@ -1482,18 +1502,20 @@ void BitcoinGUI::resizeEvent(QResizeEvent* event) {
// Retrieve new dimensions from the resize event
int newWidth = event->size().width();
int newHeight = event->size().height();
int actionWidth = newWidth / 6;
int actionWidth = newWidth / 7;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider adjusting the action width calculation.

The current calculation actionWidth = newWidth / 7 might need to be updated since we're adding another action to the toolbar. This could lead to cramped UI elements as the same width is divided among more actions.

Consider updating the width calculation to account for the new action:

-    int actionWidth = newWidth / 7;
+    int actionWidth = newWidth / 8;  // Updated to account for the new action

Also applies to: 1513-1513, 1520-1521


// Set widths for each action dynamically
QWidget* overviewWidget = toolbar->widgetForAction(overviewAction);
QWidget* receiveWidget = toolbar->widgetForAction(receiveCoinsAction);
QWidget* historyWidget = toolbar->widgetForAction(historyAction);
QWidget* sendCoinsWidget = toolbar->widgetForAction(sendCoinsAction);
QWidget* masternodeWidget = toolbar->widgetForAction(masternodeAction);
QWidget* myownspatsWidget = toolbar->widgetForAction(myownspatsAction);

overviewWidget->setMinimumWidth(actionWidth);
receiveWidget->setMinimumWidth(actionWidth);
historyWidget->setMinimumWidth(actionWidth);
sendCoinsWidget->setMinimumWidth(actionWidth);
masternodeWidget->setMinimumWidth(actionWidth);
}
myownspatsWidget->setMinimumWidth(actionWidth);
}
3 changes: 3 additions & 0 deletions src/qt/bitcoingui.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class BitcoinGUI : public QMainWindow
QAction *showHelpMessageAction;
QAction *lelantusAction;
QAction *masternodeAction;
QAction *myownspatsAction;
QAction *logoAction;
QToolBar *toolbar;
QLabel *logoLabel;
Expand Down Expand Up @@ -219,6 +220,8 @@ public Q_SLOTS:
void gotoBitcoinHistoryTab();
/** Switch to masternode page */
void gotoMasternodePage();
/** Switch to myownspats page */
void gotoMyOwnSpatsPage();
/** Switch to receive coins page */
void gotoReceiveCoinsPage();
/** Switch to send coins page */
Expand Down
251 changes: 251 additions & 0 deletions src/qt/forms/myownspats.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MyOwnSpats</class>
<widget class="QWidget" name="MyOwnSpats">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>762</width>
<height>535</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>190</width>
<height>65</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="topLayout">
<property name="leftMargin">
<number>20</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>20</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer0">
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="0">
<widget class="QTableWidget" name="tableWidgetMyOwnSpats">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::NoSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectItems</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<column>
<property name="text">
<string>Asset Type</string>
</property>
</column>
<column>
<property name="text">
<string>Identifier</string>
</property>
</column>
<column>
<property name="text">
<string>Symbol</string>
</property>
</column>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Description</string>
</property>
</column>
<column>
<property name="text">
<string>Total Supply</string>
</property>
</column>
<column>
<property name="text">
<string>Fungible</string>
</property>
</column>
<column>
<property name="text">
<string>Resuppliable</string>
</property>
</column>
<column>
<property name="text">
<string>Precision</string>
</property>
</column>
<column>
<property name="text">
<string>Metadata</string>
</property>
</column>
</widget>
</item>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_filter_2">
<property name="text">
<string>Filter List:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="filterLineEdit">
<property name="toolTip">
<string>Filter assets list</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_count_2">
<property name="text">
<string>Asset Count:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="countLabel">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="bottomMargin">
<number>20</number>
</property>
<item>
<widget class="QPushButton" name="create_spark_asset">
<property name="text">
<string>Create</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="mint_spark_asset">
<property name="text">
<string>Mint</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="modify_spark_asset">
<property name="text">
<string>Modify</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="unregister_spark_asset">
<property name="text">
<string>Unregister</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
Loading