DailyBread/mainwindow.cpp
2023-09-19 10:33:33 -05:00

72 lines
1.3 KiB
C++

/*Author: Daniel Jones
*IDE: QT Creator
*Compiler: MinGW
*OS: Windows 10
*Purpose: QT Widget that displays the verse of the day upon Windows 10 bootup.
* Last edited: 9/1/2023
*/
#include "mainwindow.h"
#include "./ui_mainwindow.h"
#include <iostream>
#include <random>
QString verse_display();
std::string verse_grab(int day);
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->verse->setText(verse_display());
}
MainWindow::~MainWindow()
{
delete ui;
}
//As name implies, randomly chooses a number between 1 and 100.
int random_verse(){
std::random_device rd;
std:: uniform_int_distribution<int> dist(1, 100);
return dist(rd);
}
//This is the function that will load the verse into the program.
QString verse_display()
{
std::string verse_text;
int verse_day = random_verse();
verse_text = verse_grab(verse_day);
QString returned_string = QString::fromStdString(verse_text);
return returned_string;
}
std::string verse_grab(int day){
std::string my_verse;
my_verse = "Hello, this is a verse!";
return my_verse;
}
void MainWindow::on_exitButton_clicked()
{
QApplication::quit();
}