Skip to content

Commit

Permalink
Merge branch 'master' into ui_warning_messages
Browse files Browse the repository at this point in the history
  • Loading branch information
levonpetrosyan93 committed Jun 18, 2024
2 parents ba95af0 + fa6a50c commit 1717ced
Show file tree
Hide file tree
Showing 25 changed files with 714 additions and 24 deletions.
4 changes: 4 additions & 0 deletions src/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ class CBlockIndex
sigma::spend_info_container sigmaSpentSerials;
std::unordered_map<Scalar, int> lelantusSpentSerials;
std::unordered_map<GroupElement, int> spentLTags;
// linking tag hash mapped to tx hash
std::unordered_map<uint256, uint256> ltagTxhash;

//! list of disabling sporks active at this block height
//! std::map {feature name} -> {block number when feature is re-enabled again, parameter}
Expand Down Expand Up @@ -303,6 +305,7 @@ class CBlockIndex
sparkMintedCoins.clear();
sparkSetHash.clear();
spentLTags.clear();
ltagTxhash.clear();
sparkTxHashContext.clear();
sigmaSpentSerials.clear();
lelantusSpentSerials.clear();
Expand Down Expand Up @@ -563,6 +566,7 @@ class CDiskBlockIndex : public CBlockIndex

if (GetBoolArg("-mobile", false)) {
READWRITE(sparkTxHashContext);
READWRITE(ltagTxhash);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/policy/policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static const unsigned int DEFAULT_BLOCK_MIN_TX_FEE = 1000;
/** The maximum weight for transactions we're willing to relay/mine */
static const unsigned int MAX_STANDARD_TX_WEIGHT = 400000;
/** The new maximum weight for transactions we're willing to relay/mine */
static const unsigned int MAX_NEW_TX_WEIGHT = 520000;
static const unsigned int MAX_NEW_TX_WEIGHT = 1000000;
/** Maximum number of signature check operations in an IsStandard() P2SH script */
static const unsigned int MAX_P2SH_SIGOPS = 15;
/** The maximum number of sigops we're willing to relay/mine in a single tx */
Expand Down
27 changes: 25 additions & 2 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ void BitcoinGUI::createToolBars()
{
if(walletFrame)
{
QToolBar *toolbar = addToolBar(tr("Tabs toolbar"));
toolbar = addToolBar(tr("Tabs toolbar"));
toolbar->setContextMenuPolicy(Qt::PreventContextMenu);
toolbar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
toolbar->setToolButtonStyle(Qt::ToolButtonTextOnly);
Expand All @@ -523,7 +523,7 @@ void BitcoinGUI::createToolBars()
toolbar->addAction(lelantusAction);
toolbar->addAction(masternodeAction);

QLabel *logoLabel = new QLabel();
logoLabel = new QLabel();
logoLabel->setObjectName("lblToolbarLogo");
logoLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);

Expand Down Expand Up @@ -1474,3 +1474,26 @@ void UnitDisplayStatusBarControl::onMenuSelection(QAction* action)
optionsModel->setDisplayUnit(action->data());
}
}

// Handles resize events for the BitcoinGUI widget by adjusting internal component sizes.
void BitcoinGUI::resizeEvent(QResizeEvent* event) {
QMainWindow::resizeEvent(event);

// Retrieve new dimensions from the resize event
int newWidth = event->size().width();
int newHeight = event->size().height();
int actionWidth = newWidth / 6;

// 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);

overviewWidget->setMinimumWidth(actionWidth);
receiveWidget->setMinimumWidth(actionWidth);
historyWidget->setMinimumWidth(actionWidth);
sendCoinsWidget->setMinimumWidth(actionWidth);
masternodeWidget->setMinimumWidth(actionWidth);
}
6 changes: 5 additions & 1 deletion src/qt/bitcoingui.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <QMenu>
#include <QPoint>
#include <QSystemTrayIcon>
#include <QPushButton>
#include <QWidget>

class ClientModel;
class NetworkStyle;
Expand Down Expand Up @@ -121,7 +123,8 @@ class BitcoinGUI : public QMainWindow
QAction *lelantusAction;
QAction *masternodeAction;
QAction *logoAction;

QToolBar *toolbar;
QLabel *logoLabel;
QSystemTrayIcon *trayIcon;
QMenu *trayIconMenu;
Notificator *notificator;
Expand All @@ -141,6 +144,7 @@ class BitcoinGUI : public QMainWindow
void createMenuBar();
/** Create the toolbars */
void createToolBars();
void resizeEvent(QResizeEvent*);
/** Create system tray icon and notification */
void createTrayIcon(const NetworkStyle *networkStyle);
/** Create system tray menu (or setup the dock menu) */
Expand Down
45 changes: 45 additions & 0 deletions src/qt/masternodelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,3 +367,48 @@ void MasternodeList::copyCollateralOutpoint_clicked()

QApplication::clipboard()->setText(QString::fromStdString(dmn->collateralOutpoint.ToStringShort()));
}

void MasternodeList::resizeEvent(QResizeEvent* event)
{
QWidget::resizeEvent(event);

const int newWidth = event->size().width();
const int newHeight = event->size().height();

adjustTextSize(newWidth ,newHeight);

// Calculate new column widths based on the new window width
int newWidthOwner = static_cast<int>(newWidth * 0.19);
int newWidthMin = static_cast<int>(newWidth * 0.08);
int newWidthMid = static_cast<int>(newWidth * 0.12);
int newWidthStatus = static_cast<int>(newWidth * 0.11);

// Apply new column widths
ui->tableWidgetMasternodesDIP3->setColumnWidth(0, newWidthStatus);
ui->tableWidgetMasternodesDIP3->setColumnWidth(1, newWidthMin);
ui->tableWidgetMasternodesDIP3->setColumnWidth(2, newWidthMin);
ui->tableWidgetMasternodesDIP3->setColumnWidth(3, newWidthMid);
ui->tableWidgetMasternodesDIP3->setColumnWidth(4, newWidthMid);
ui->tableWidgetMasternodesDIP3->setColumnWidth(5, newWidthMid);
ui->tableWidgetMasternodesDIP3->setColumnWidth(6, newWidthMid);
ui->tableWidgetMasternodesDIP3->setColumnWidth(7, newWidthMid);
ui->tableWidgetMasternodesDIP3->setColumnWidth(8, newWidthMid);
ui->tableWidgetMasternodesDIP3->setColumnWidth(9, newWidthOwner);
}
void MasternodeList::adjustTextSize(int width,int height){

const double fontSizeScalingFactor = 70.0;
int baseFontSize = std::min(width, height) / fontSizeScalingFactor;
int fontSize = std::min(15, std::max(12, baseFontSize));
QFont font = this->font();
font.setPointSize(fontSize);

// Set font size for all labels
ui->label_filter_2->setFont(font);
ui->label_count_2->setFont(font);
ui->countLabelDIP3->setFont(font);
ui->checkBoxMyMasternodesOnly->setFont(font);
ui->tableWidgetMasternodesDIP3->setFont(font);
ui->tableWidgetMasternodesDIP3->horizontalHeader()->setFont(font);
ui->tableWidgetMasternodesDIP3->verticalHeader()->setFont(font);
}
4 changes: 3 additions & 1 deletion src/qt/masternodelist.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <QMenu>
#include <QTimer>
#include <QWidget>
#include <QResizeEvent>

#define MASTERNODELIST_UPDATE_SECONDS 3
#define MASTERNODELIST_FILTER_COOLDOWN_SECONDS 3
Expand Down Expand Up @@ -38,7 +39,8 @@ class MasternodeList : public QWidget

void setClientModel(ClientModel* clientModel);
void setWalletModel(WalletModel* walletModel);

void resizeEvent(QResizeEvent*) override;
void adjustTextSize(int width,int height);
private:
QMenu* contextMenuDIP3;
int64_t nTimeFilterUpdatedDIP3;
Expand Down
136 changes: 129 additions & 7 deletions src/qt/overviewpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include "transactiontablemodel.h"
#include "walletmodel.h"
#include "validation.h"
#include "askpassphrasedialog.h"


#ifdef WIN32
#include <string.h>
Expand Down Expand Up @@ -380,14 +382,18 @@ void OverviewPage::onRefreshClicked()
{
auto privateBalance = walletModel->getLelantusModel()->getPrivateBalance();
auto lGracefulPeriod = ::Params().GetConsensus().nLelantusGracefulPeriod;
int heightDifference = lGracefulPeriod - chainActive.Height();
const int approxBlocksPerDay = 570;
int daysUntilMigrationCloses = heightDifference / approxBlocksPerDay;

if(privateBalance.first > 0 && chainActive.Height() < lGracefulPeriod && spark::IsSparkAllowed()) {
ui->warningFrame->show();
lelantusGracefulPeriod = QString::fromStdString(std::to_string(lGracefulPeriod));
currentBlock = QString::fromStdString(std::to_string(chainActive.Height()));
migrationWindowClosesIn = QString::fromStdString(std::to_string(daysUntilMigrationCloses));
blocksRemaining = QString::fromStdString(std::to_string(heightDifference));
migrateAmount = "<b>" + BitcoinUnits::formatHtmlWithUnit(walletModel->getOptionsModel()->getDisplayUnit(), privateBalance.first);
migrateAmount.append("</b>");
ui->textWarning1->setText(tr("Firo is migrating to Spark. Redemption of coins in Lelantus will be disabled at block %1. <i>Current block is %2</i>.").arg(lelantusGracefulPeriod, currentBlock));
ui->textWarning2->setText(tr("to migrate %1 from Lelantus.").arg(migrateAmount));
ui->textWarning1->setText(tr("We have detected Lelantus coins that have not been migrated to Spark. Migration window will close in %1 blocks (~ %2 days).").arg(blocksRemaining , migrationWindowClosesIn));
ui->textWarning2->setText(tr("to migrate %1 ").arg(migrateAmount));
QFont qFont = ui->migrateButton->font();
qFont.setUnderline(true);
ui->migrateButton->setFont(qFont);
Expand All @@ -398,11 +404,27 @@ void OverviewPage::onRefreshClicked()

void OverviewPage::migrateClicked()
{
if(walletModel->getAvailableLelantusCoins() && spark::IsSparkAllowed() && chainActive.Height() < ::Params().GetConsensus().nLelantusGracefulPeriod){
MigrateLelantusToSparkDialog migrate(walletModel);
auto privateBalance = walletModel->getLelantusModel()->getPrivateBalance();
auto lGracefulPeriod = ::Params().GetConsensus().nLelantusGracefulPeriod;
migrateAmount = "<b>" + BitcoinUnits::formatHtmlWithUnit(walletModel->getOptionsModel()->getDisplayUnit(), privateBalance.first);
migrateAmount.append("</b>");
QString info = tr("Your wallet needs to be unlocked to migrate your funds to Spark.");

if(walletModel->getEncryptionStatus() == WalletModel::Locked) {

AskPassphraseDialog dlg(AskPassphraseDialog::Unlock, this, info);
dlg.setModel(walletModel);
dlg.exec();
}
if (walletModel->getEncryptionStatus() == WalletModel::Unlocked){
if(walletModel->getAvailableLelantusCoins() && spark::IsSparkAllowed() && chainActive.Height() < ::Params().GetConsensus().nLelantusGracefulPeriod){
MigrateLelantusToSparkDialog migrate(walletModel);
if(!migrate.getClickedButton()){
ui->warningFrame->hide();
}
}
}
}

MigrateLelantusToSparkDialog::MigrateLelantusToSparkDialog(WalletModel *_model):QMessageBox()
{
this->model = _model;
Expand Down Expand Up @@ -475,4 +497,104 @@ void MigrateLelantusToSparkDialog::onMigrateClicked()
bool MigrateLelantusToSparkDialog::getClickedButton()
{
return clickedButton;
}
void OverviewPage::resizeEvent(QResizeEvent* event)
{
QWidget::resizeEvent(event);

// Retrieve new dimensions from the resize event
const int newWidth = event->size().width();
const int newHeight = event->size().height();
adjustTextSize(newWidth, newHeight);

// Determine widths for specific widgets as percentages of total width
int labelWidth = static_cast<int>(newWidth * 0.5);
int labelMinWidth = static_cast<int>(newWidth * 0.15);
int labelMaxWidth = static_cast<int>(newWidth * 0.35);
const int labelHeight = 20;

// Configure the dimensions and constraints of each widget
ui->labelBalance->setFixedWidth(labelWidth);
ui->labelBalance->setMinimumWidth(labelMinWidth);
ui->labelBalance->setMaximumWidth(labelMaxWidth);
ui->labelBalance->setFixedHeight(labelHeight);

ui->labelUnconfirmed->setFixedWidth(labelWidth);
ui->labelUnconfirmed->setMinimumWidth(labelMinWidth);
ui->labelUnconfirmed->setMaximumWidth(labelMaxWidth);
ui->labelUnconfirmed->setFixedHeight(labelHeight);

int buttonWidth = static_cast<int>(newWidth * 0.15);
int buttonHeight = static_cast<int>(newHeight * 0.05);
int buttonMinHeight = static_cast<int>(20);
int buttonMaxHeight = static_cast<int>(45);

ui->anonymizeButton->setMinimumWidth(buttonWidth);
ui->anonymizeButton->setMaximumWidth(buttonWidth * 2);
ui->anonymizeButton->setMinimumHeight(buttonMinHeight);
ui->anonymizeButton->setMaximumHeight(buttonMaxHeight);

// Set the minimum width for all label widgets to ensure they maintain a consistent and readable size regardless of window resizing
ui->labelAnonymizable->setMinimumWidth(labelMinWidth);
ui->labelAlerts->setMinimumWidth(labelMinWidth);
ui->label->setMinimumWidth(labelMinWidth);
ui->labelWatchPending->setMinimumWidth(labelMinWidth);
ui->labelBalance->setMinimumWidth(labelMinWidth);
ui->labelSpendable->setMinimumWidth(labelMinWidth);
ui->labelWatchAvailable->setMinimumWidth(labelMinWidth);
ui->labelUnconfirmedPrivate->setMinimumWidth(labelMinWidth);
ui->labelWatchonly->setMinimumWidth(labelMinWidth);
ui->labelTotal->setMinimumWidth(labelMinWidth);
ui->labelWatchTotal->setMinimumWidth(labelMinWidth);
ui->labelUnconfirmed->setMinimumWidth(labelMinWidth);
ui->labelImmature->setMinimumWidth(labelMinWidth);
ui->labelPrivate->setMinimumWidth(labelMinWidth);
ui->label_4->setMinimumWidth(labelMinWidth);
}
void OverviewPage::adjustTextSize(int width, int height){

const double fontSizeScalingFactor = 133.0;
int baseFontSize = width / fontSizeScalingFactor;
int fontSize = std::min(15, std::max(12, baseFontSize));

// Font for regular text components(not bold)
QFont textFont = ui->labelBalance->font();
textFont.setPointSize(fontSize);
textFont.setBold(false);

// Font for text components that should be bold
QFont labelFont = textFont;
labelFont.setBold(true);

ui->textWarning1->setFont(textFont);
ui->textWarning2->setFont(textFont);
ui->labelWalletStatus->setFont(textFont);
ui->anonymizeButton->setFont(textFont);

// Apply label font to all label components
ui->labelAlerts->setFont(labelFont);
ui->label_5->setFont(labelFont);
ui->labelAnonymizableText->setFont(textFont);
ui->label->setFont(labelFont);
ui->labelAnonymizable->setFont(labelFont);
ui->labelWatchPending->setFont(labelFont);
ui->labelBalance->setFont(labelFont);
ui->labelSpendable->setFont(labelFont);
ui->labelWatchAvailable->setFont(labelFont);
ui->labelPendingText->setFont(textFont);
ui->labelUnconfirmedPrivate->setFont(labelFont);
ui->labelUnconfirmedPrivateText->setFont(textFont);
ui->labelTotalText->setFont(textFont);
ui->labelWatchonly->setFont(labelFont);
ui->labelBalanceText->setFont(textFont);
ui->labelTotal->setFont(labelFont);
ui->labelWatchTotal->setFont(labelFont);
ui->labelUnconfirmed->setFont(labelFont);
ui->labelImmatureText->setFont(textFont);
ui->labelImmature->setFont(labelFont);
ui->labelWatchImmature->setFont(labelFont);
ui->labelPrivateText->setFont(textFont);
ui->labelPrivate->setFont(labelFont);
ui->label_4->setFont(labelFont);

}
9 changes: 6 additions & 3 deletions src/qt/overviewpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include <QSettings>
#include <QMessageBox>
#include <QTimer>
#include <QResizeEvent>


class ClientModel;
class TransactionFilterProxy;
Expand Down Expand Up @@ -44,6 +46,7 @@ class OverviewPage : public QWidget
void setWalletModel(WalletModel *walletModel);
void showOutOfSyncWarning(bool fShow);
void UpdatePropertyBalance(unsigned int propertyId, uint64_t available, uint64_t reserved);
void resizeEvent(QResizeEvent* event) override;

public Q_SLOTS:
void on_anonymizeButton_clicked();
Expand Down Expand Up @@ -86,10 +89,10 @@ public Q_SLOTS:

QTimer countDownTimer;
int secDelay;
QString lelantusGracefulPeriod;
QString currentBlock;
QString migrationWindowClosesIn;
QString blocksRemaining;
QString migrateAmount;

void adjustTextSize(int width,int height);
private Q_SLOTS:
void updateDisplayUnit();
void handleTransactionClicked(const QModelIndex &index);
Expand Down
Loading

0 comments on commit 1717ced

Please sign in to comment.