mirror of
				https://git.wownero.com/wowlet/wowlet.git
				synced 2024-08-15 01:03:14 +00:00 
			
		
		
		
	Merge pull request 'Move MainWindow::getContext() to constructor' (#45) from tobtoht/feather:ctx_to_constructor into master
Reviewed-on: https://git.wownero.com/feather/feather/pulls/45
This commit is contained in:
		
						commit
						17c1526057
					
				
					 7 changed files with 12 additions and 16 deletions
				
			
		| 
						 | 
					@ -13,6 +13,7 @@ CalcWidget::CalcWidget(QWidget *parent) :
 | 
				
			||||||
        ui(new Ui::CalcWidget)
 | 
					        ui(new Ui::CalcWidget)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    ui->setupUi(this);
 | 
					    ui->setupUi(this);
 | 
				
			||||||
 | 
					    m_ctx = MainWindow::getContext();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ui->imageExchange->setBackgroundRole(QPalette::Base);
 | 
					    ui->imageExchange->setBackgroundRole(QPalette::Base);
 | 
				
			||||||
    QPixmap pm(":/assets/images/exchange.png");
 | 
					    QPixmap pm(":/assets/images/exchange.png");
 | 
				
			||||||
| 
						 | 
					@ -106,21 +107,15 @@ void CalcWidget::toComboChanged(const QString &data) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void CalcWidget::initCrypto() {
 | 
					void CalcWidget::initCrypto() {
 | 
				
			||||||
    if (this->m_ctx == nullptr)
 | 
					 | 
				
			||||||
        this->m_ctx = MainWindow::getContext();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    this->initComboBox();
 | 
					    this->initComboBox();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void CalcWidget::initFiat() {
 | 
					void CalcWidget::initFiat() {
 | 
				
			||||||
    if(this->m_ctx == nullptr)
 | 
					 | 
				
			||||||
        this->m_ctx = MainWindow::getContext();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    this->initComboBox();
 | 
					    this->initComboBox();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void CalcWidget::initComboBox() {
 | 
					void CalcWidget::initComboBox() {
 | 
				
			||||||
    if(m_comboBoxInit || this->m_ctx == nullptr) return;
 | 
					    if(m_comboBoxInit) return;
 | 
				
			||||||
    QList<QString> marketsKeys = AppContext::prices->markets.keys();
 | 
					    QList<QString> marketsKeys = AppContext::prices->markets.keys();
 | 
				
			||||||
    QList<QString> ratesKeys = AppContext::prices->rates.keys();
 | 
					    QList<QString> ratesKeys = AppContext::prices->rates.keys();
 | 
				
			||||||
    if(marketsKeys.count() <= 0 || ratesKeys.count() <= 0) return;
 | 
					    if(marketsKeys.count() <= 0 || ratesKeys.count() <= 0) return;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -31,7 +31,7 @@ public slots:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
    Ui::CalcWidget *ui;
 | 
					    Ui::CalcWidget *ui;
 | 
				
			||||||
    AppContext *m_ctx = nullptr;
 | 
					    AppContext *m_ctx;
 | 
				
			||||||
    bool m_comboBoxInit = false;
 | 
					    bool m_comboBoxInit = false;
 | 
				
			||||||
    void initComboBox();
 | 
					    void initComboBox();
 | 
				
			||||||
    bool m_changing = false;
 | 
					    bool m_changing = false;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -37,14 +37,14 @@ MainWindow * MainWindow::pMainWindow = nullptr;
 | 
				
			||||||
MainWindow::MainWindow(AppContext *ctx, QWidget *parent) :
 | 
					MainWindow::MainWindow(AppContext *ctx, QWidget *parent) :
 | 
				
			||||||
    QMainWindow(parent),
 | 
					    QMainWindow(parent),
 | 
				
			||||||
    ui(new Ui::MainWindow),
 | 
					    ui(new Ui::MainWindow),
 | 
				
			||||||
    m_ctx(ctx),
 | 
					    m_ctx(ctx)
 | 
				
			||||||
    m_aboutDialog(new AboutDialog(this)),
 | 
					 | 
				
			||||||
    m_windowCalc(new CalcWindow(this))
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    pMainWindow = this;
 | 
					    pMainWindow = this;
 | 
				
			||||||
    ui->setupUi(this);
 | 
					    ui->setupUi(this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    m_windowSettings = new Settings(this);
 | 
					    m_windowSettings = new Settings(this);
 | 
				
			||||||
 | 
					    m_aboutDialog = new AboutDialog(this);
 | 
				
			||||||
 | 
					    m_windowCalc = new CalcWindow(this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // light/dark theme
 | 
					    // light/dark theme
 | 
				
			||||||
    m_skins.insert("Native", "");
 | 
					    m_skins.insert("Native", "");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -12,10 +12,9 @@ Settings::Settings(QWidget *parent) :
 | 
				
			||||||
        ui(new Ui::Settings)
 | 
					        ui(new Ui::Settings)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    ui->setupUi(this);
 | 
					    ui->setupUi(this);
 | 
				
			||||||
    this->setWindowIcon(QIcon("://assets/images/appicons/64x64.png"));
 | 
					    m_ctx = MainWindow::getContext();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if(m_ctx == nullptr)
 | 
					    this->setWindowIcon(QIcon("://assets/images/appicons/64x64.png"));
 | 
				
			||||||
        m_ctx = MainWindow::getContext();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ui->tabWidget->setTabVisible(2, false);
 | 
					    ui->tabWidget->setTabVisible(2, false);
 | 
				
			||||||
    ui->tabWidget->setTabVisible(4, false);
 | 
					    ui->tabWidget->setTabVisible(4, false);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -47,7 +47,7 @@ private:
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
    void setupSkinCombobox();
 | 
					    void setupSkinCombobox();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    AppContext *m_ctx = nullptr;
 | 
					    AppContext *m_ctx;
 | 
				
			||||||
    Ui::Settings *ui;
 | 
					    Ui::Settings *ui;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -15,6 +15,7 @@ TickerWidget::TickerWidget(QWidget *parent, QString symbol, QString title, bool
 | 
				
			||||||
    m_convertBalance(convertBalance)
 | 
					    m_convertBalance(convertBalance)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    ui->setupUi(this);
 | 
					    ui->setupUi(this);
 | 
				
			||||||
 | 
					    m_ctx = MainWindow::getContext();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // default values before API data
 | 
					    // default values before API data
 | 
				
			||||||
    if (title == "") title = m_symbol;
 | 
					    if (title == "") title = m_symbol;
 | 
				
			||||||
| 
						 | 
					@ -29,7 +30,7 @@ TickerWidget::TickerWidget(QWidget *parent, QString symbol, QString title, bool
 | 
				
			||||||
    connect(AppContext::prices, &Prices::fiatPricesUpdated, this, &TickerWidget::init);
 | 
					    connect(AppContext::prices, &Prices::fiatPricesUpdated, this, &TickerWidget::init);
 | 
				
			||||||
    connect(AppContext::prices, &Prices::cryptoPricesUpdated, this, &TickerWidget::init);
 | 
					    connect(AppContext::prices, &Prices::cryptoPricesUpdated, this, &TickerWidget::init);
 | 
				
			||||||
    if (convertBalance)
 | 
					    if (convertBalance)
 | 
				
			||||||
        connect(MainWindow::getContext(), &AppContext::balanceUpdated, this, &TickerWidget::init);
 | 
					        connect(m_ctx, &AppContext::balanceUpdated, this, &TickerWidget::init);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TickerWidget::init() {
 | 
					void TickerWidget::init() {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -34,6 +34,7 @@ private:
 | 
				
			||||||
    Ui::TickerWidget *ui;
 | 
					    Ui::TickerWidget *ui;
 | 
				
			||||||
    QString m_symbol;
 | 
					    QString m_symbol;
 | 
				
			||||||
    bool m_convertBalance;
 | 
					    bool m_convertBalance;
 | 
				
			||||||
 | 
					    AppContext *m_ctx;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // TICKERWIDGET_H
 | 
					#endif // TICKERWIDGET_H
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue