~voidraven/cryptomonitor

ref: e42397d8030afd37479f9623e4902ef62048e20a cryptomonitor/CryptoMonitorGog/mainwindow.cpp -rw-r--r-- 1.6 KiB
e42397d8voidraven first commit, again 1 year, 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <QDebug>
#include <QHBoxLayout>
#include <QLabel>
#include <QWidget>
#include <QVector>

#include "./http/coinmarketcap.h"
#include "mainwindow.h"
#include "./ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}

// When the refresh button is clicked.
void MainWindow::on_pushButton_clicked()
{
    QVector<QString>* priceVec = new QVector<QString>();
    CoinMarketCap* pCmc = new CoinMarketCap();
    pCmc->Init(priceVec);
    generateTopTen(priceVec);
}

void MainWindow::on_addNewCoin_clicked()
{
    qDebug() << "on_addNewCoin_clicked\n";
}

void MainWindow::generateTopTen(QVector<QString>* priceVec) {
    if(priceVec->size() == 10) {
        ui->btcPrice->setText(priceVec->at(0));
        ui->ethPrice->setText(priceVec->at(1));
        ui->xrpPrice->setText(priceVec->at(2));
        ui->bchPrice->setText(priceVec->at(3));
        ui->bsvPrice->setText(priceVec->at(4));
        ui->ltcPrice->setText(priceVec->at(5));
        ui->usdtPrice->setText(priceVec->at(6));
        ui->eosPrice->setText(priceVec->at(7));
        ui->bnbPrice->setText(priceVec->at(8));
        ui->xtzPrice->setText(priceVec->at(9));
    }
    else {
        qDebug() << "priceVec was very very naughty";
    }
}

void MainWindow::on_settings_clicked()
{
    qDebug() << "on_settings_clicked() invoked";
    //close() // Can cause memory leak. Closes the window, but it doesn't destroy the process.
    SettingsWindow* settingsWindow = new SettingsWindow();
    settingsWindow->show();
}