/*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 #include #include int current_day(); int current_month(); QString verse_display(); std::string verse_grab(); MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); ui->verse->setText(verse_display()); std::cout << current_day(); std::cout << current_month(); } MainWindow::~MainWindow() { delete ui; } //This is the function that will load the verse into the program. QString verse_display() { std::string verse_text; verse_text = verse_grab(); QString returned_string = QString::fromStdString(verse_text); return returned_string; } std::string verse_grab(){ std::string my_verse; int curmonth = current_month(); int curday = current_day(); std::string query = "select * from verses where day = " + std::to_string(curday) + " and month = " + std::to_string(curmonth); my_verse = "hello world!"; return query; } void MainWindow::on_exitButton_clicked() { QApplication::quit(); } //Everything below this grabs the day and month. typedef std::chrono::system_clock Clock; int current_day(){ auto now = Clock::now(); std::time_t now_c = Clock::to_time_t(now); struct tm *parts = std::localtime(&now_c); int day = parts->tm_mday; return day; } int current_month(){ auto now = Clock::now(); std::time_t now_c = Clock::to_time_t(now); struct tm *parts = std::localtime(&now_c); int month = 1 + parts->tm_mon; return month; }