Raw support in Qt wallet (#1675)
This commit is contained in:
		
					parent
					
						
							
								2aab2713c1
							
						
					
				
			
			
				commit
				
					
						c55ac6e809
					
				
			
		
					 3 changed files with 17 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -40,6 +40,7 @@ nano::uint128_t const kxrb_ratio = nano::uint128_t ("100000000000000000000000000
 | 
			
		|||
nano::uint128_t const xrb_ratio = nano::uint128_t ("1000000000000000000000000"); // 10^24
 | 
			
		||||
nano::uint128_t const mxrb_ratio = nano::uint128_t ("1000000000000000000000"); // 10^21
 | 
			
		||||
nano::uint128_t const uxrb_ratio = nano::uint128_t ("1000000000000000000"); // 10^18
 | 
			
		||||
nano::uint128_t const raw_ratio = nano::uint128_t ("1"); // 10^0
 | 
			
		||||
 | 
			
		||||
union uint128_union
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1466,6 +1466,10 @@ std::string nano_qt::wallet::format_balance (nano::uint128_t const & balance) co
 | 
			
		|||
	{
 | 
			
		||||
		unit = std::string ("nano");
 | 
			
		||||
	}
 | 
			
		||||
	else if (rendering_ratio == nano::raw_ratio)
 | 
			
		||||
	{
 | 
			
		||||
		unit = std::string ("raw");
 | 
			
		||||
	}
 | 
			
		||||
	return balance_str + " " + unit;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1749,6 +1753,7 @@ ratio_group (new QButtonGroup),
 | 
			
		|||
mnano_unit (new QRadioButton ("Mnano")),
 | 
			
		||||
knano_unit (new QRadioButton ("knano")),
 | 
			
		||||
nano_unit (new QRadioButton ("nano")),
 | 
			
		||||
raw_unit (new QRadioButton ("raw")),
 | 
			
		||||
back (new QPushButton ("Back")),
 | 
			
		||||
ledger_window (new QWidget),
 | 
			
		||||
ledger_layout (new QVBoxLayout),
 | 
			
		||||
| 
						 | 
				
			
			@ -1772,13 +1777,16 @@ wallet (wallet_a)
 | 
			
		|||
	ratio_group->addButton (mnano_unit);
 | 
			
		||||
	ratio_group->addButton (knano_unit);
 | 
			
		||||
	ratio_group->addButton (nano_unit);
 | 
			
		||||
	ratio_group->addButton (raw_unit);
 | 
			
		||||
	ratio_group->setId (mnano_unit, 0);
 | 
			
		||||
	ratio_group->setId (knano_unit, 1);
 | 
			
		||||
	ratio_group->setId (nano_unit, 2);
 | 
			
		||||
	ratio_group->setId (raw_unit, 3);
 | 
			
		||||
	scale_layout->addWidget (scale_label);
 | 
			
		||||
	scale_layout->addWidget (mnano_unit);
 | 
			
		||||
	scale_layout->addWidget (knano_unit);
 | 
			
		||||
	scale_layout->addWidget (nano_unit);
 | 
			
		||||
	scale_layout->addWidget (raw_unit);
 | 
			
		||||
	scale_window->setLayout (scale_layout);
 | 
			
		||||
 | 
			
		||||
	ledger_model->setHorizontalHeaderItem (0, new QStandardItem ("Account"));
 | 
			
		||||
| 
						 | 
				
			
			@ -1851,6 +1859,13 @@ wallet (wallet_a)
 | 
			
		|||
			this->wallet.change_rendering_ratio (nano::xrb_ratio);
 | 
			
		||||
		}
 | 
			
		||||
	});
 | 
			
		||||
	QObject::connect (raw_unit, &QRadioButton::toggled, [this]() {
 | 
			
		||||
		if (raw_unit->isChecked ())
 | 
			
		||||
		{
 | 
			
		||||
			QSettings ().setValue (saved_ratio_key, ratio_group->id (raw_unit));
 | 
			
		||||
			this->wallet.change_rendering_ratio (nano::raw_ratio);
 | 
			
		||||
		}
 | 
			
		||||
	});
 | 
			
		||||
	auto selected_ratio_id (QSettings ().value (saved_ratio_key, ratio_group->id (mnano_unit)).toInt ());
 | 
			
		||||
	auto selected_ratio_button = ratio_group->button (selected_ratio_id);
 | 
			
		||||
	assert (selected_ratio_button != nullptr);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -70,6 +70,7 @@ public:
 | 
			
		|||
	QRadioButton * mnano_unit;
 | 
			
		||||
	QRadioButton * knano_unit;
 | 
			
		||||
	QRadioButton * nano_unit;
 | 
			
		||||
	QRadioButton * raw_unit;
 | 
			
		||||
	QPushButton * back;
 | 
			
		||||
 | 
			
		||||
	QWidget * ledger_window;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue