Compare commits

..

9 Commits

Author SHA1 Message Date
Daniel Jones
bb97304508 added verses for October November and December. Finished with database. 2024-01-03 09:10:17 -06:00
Daniel Jones
25badb424d Added July, August, and September verses 2024-01-03 08:30:32 -06:00
Daniel Jones
8a283a1034 added June verses 2024-01-02 16:24:53 -06:00
Daniel Jones
7b1359c1e7 added May verses 2024-01-02 15:24:45 -06:00
Daniel Jones
2d2c59a2f1 added April verses 2024-01-02 15:06:52 -06:00
Daniel Jones
5668857327 added March verses 2024-01-02 14:44:23 -06:00
Daniel Jones
5f10105990 added verses for February. Will add March later today. 2024-01-02 11:05:23 -06:00
Daniel Jones
89778cea08 added Bible verses for most of December. Will finish tonight and start work on February next. 2023-09-29 14:07:35 -05:00
Daniel Jones
08d97563fb checks day and month to reference database now 2023-09-19 14:39:25 -05:00
5 changed files with 41 additions and 160 deletions

View File

@ -12,10 +12,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
find_package(Qt6 REQUIRED COMPONENTS Sql)
set(PROJECT_SOURCES set(PROJECT_SOURCES
main.cpp main.cpp
mainwindow.cpp mainwindow.cpp
@ -47,7 +43,7 @@ else()
endif() endif()
target_link_libraries(Daily_Bread PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) target_link_libraries(Daily_Bread PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
target_link_libraries(Daily_Bread PRIVATE Qt6::Sql)
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1. # Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an # If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though. # explicit, fixed bundle identifier manually though.

View File

@ -3,21 +3,18 @@
*Compiler: MinGW *Compiler: MinGW
*OS: Windows 10 *OS: Windows 10
*Purpose: QT Widget that displays the verse of the day upon Windows 10 bootup. *Purpose: QT Widget that displays the verse of the day upon Windows 10 bootup.
* Last edited: 1/5/2024 * Last edited: 9/1/2023
*/ */
#include "mainwindow.h" #include "mainwindow.h"
#include "./ui_mainwindow.h" #include "./ui_mainwindow.h"
#include <chrono> #include <windows.h>
#include <ctime> #include <iostream>
#include <QSqlDatabase>
#include <QSqlQuery>
//Function declarations
int current_day();
int current_month();
QString verse_grab();
QString verse_display();
std::string verse_grab();
MainWindow::MainWindow(QWidget *parent) MainWindow::MainWindow(QWidget *parent)
@ -25,8 +22,7 @@ MainWindow::MainWindow(QWidget *parent)
, ui(new Ui::MainWindow) , ui(new Ui::MainWindow)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->verse->setText(verse_grab()); ui->verse->setText(verse_display());
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
@ -36,109 +32,39 @@ MainWindow::~MainWindow()
} }
void bookmarked_verse_func(){
qDebug("test"); //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(){
/* //Windows way of getting current month and time.
* Function: verse_grab SYSTEMTIME st = {0};
* description: selects the verse based on the current day and returns the result GetLocalTime(&st);
* Return type: string int cur_day = st.wDay;
* Param: none int cur_month = st.wMonth;
*/
QString verse_grab(){
std::string my_query = "select ";
std::string my_verse;
//gets current month and day and returns the result
int curmonth = current_month();
int curday = current_day();
std::string query_string = "select * from verse_list where day = " + std::to_string(curday) + " and month = " + std::to_string(curmonth);
QString q_query = QString::fromStdString(query_string);
QString my_verse;
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("./verses.sqlite");
if(db.open()){
QSqlQuery query(db);
if (query.exec(q_query)){
query.next();
my_verse = query.value(1).toString();
db.close();
}
return my_verse; return my_verse;
}
return "error: sqlite database missing";
} }
//UI function that exits when the "go in peace" button is pressed.
void MainWindow::on_exitButton_clicked() void MainWindow::on_exitButton_clicked()
{ {
QApplication::quit(); QApplication::quit();
} }
//Everything below this grabs the day and month.
typedef std::chrono::system_clock Clock;
/*
* Function: current_day
* description: queries the operating system for the current day
* Return type: integer
* Param: none
*/
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;
}
/*
* Function: current_month
* description: queries the operating system for the current month
* Return type: integer
* Param: none
*/
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;
}

View File

@ -1,5 +1,6 @@
#ifndef MAINWINDOW_H #ifndef MAINWINDOW_H
#define MAINWINDOW_H #define MAINWINDOW_H
#include <QMainWindow> #include <QMainWindow>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>387</width> <width>404</width>
<height>600</height> <height>614</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -21,7 +21,7 @@
<widget class="QPushButton" name="exitButton"> <widget class="QPushButton" name="exitButton">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>150</x> <x>160</x>
<y>490</y> <y>490</y>
<width>80</width> <width>80</width>
<height>24</height> <height>24</height>
@ -37,7 +37,7 @@
<x>10</x> <x>10</x>
<y>20</y> <y>20</y>
<width>361</width> <width>361</width>
<height>271</height> <height>161</height>
</rect> </rect>
</property> </property>
<property name="text"> <property name="text">
@ -46,17 +46,16 @@
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
</property> </property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget> </widget>
<zorder>verse</zorder>
<zorder>exitButton</zorder>
</widget> </widget>
<widget class="QMenuBar" name="menubar"> <widget class="QMenuBar" name="menubar">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>387</width> <width>404</width>
<height>21</height> <height>21</height>
</rect> </rect>
</property> </property>
@ -65,6 +64,7 @@
<string>File</string> <string>File</string>
</property> </property>
<addaction name="actionbookmark_verse"/> <addaction name="actionbookmark_verse"/>
<addaction name="actionGo_to_bookmarked_verse"/>
<addaction name="actionexit"/> <addaction name="actionexit"/>
</widget> </widget>
<addaction name="menuDaily_Bread"/> <addaction name="menuDaily_Bread"/>
@ -76,31 +76,16 @@
</property> </property>
</action> </action>
<action name="actionexit"> <action name="actionexit">
<property name="checkable">
<bool>false</bool>
</property>
<property name="text"> <property name="text">
<string>exit</string> <string>exit</string>
</property> </property>
</action> </action>
<action name="actionGo_to_bookmarked_verse">
<property name="text">
<string>Go to bookmarked verse</string>
</property>
</action>
</widget> </widget>
<resources/> <resources/>
<connections> <connections/>
<connection>
<sender>actionexit</sender>
<signal>triggered()</signal>
<receiver>MainWindow</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>189</x>
<y>522</y>
</hint>
<hint type="destinationlabel">
<x>193</x>
<y>299</y>
</hint>
</hints>
</connection>
</connections>
</ui> </ui>

View File

@ -1,27 +0,0 @@
# Daily Bread
## Get your daily bread with this program for Windows and Linux systems!
## Introduction
Daily Bread is a QT6 program designed to give you a new Bible verse every morning when you log into your computer!
## Installation
### Windows:
Double click the .bat file that comes with the Binary release to install.
Once it is finished running, Daily Bread should be included with your startup programs.
You can check your startup programs by pressing ctrl + alt + delete, clicking "show details" on the task manager, and then clicking "startup" tab.
### Linux:
These instructions will work for most Linux distrobutions
Download the Linux binary, and unzip it into a directory that you like. Run the following command:
```chmod +x install.sh```
Once you have run that command, install Daily Bread by typing in
```./install.sh```