Compare commits

..

10 Commits

Author SHA1 Message Date
Daniel Jones
d85a8791b8 exit menu action working 2024-01-05 14:53:15 -06:00
Daniel Jones
f798593240 trying to add actions to the menu bar 2024-01-05 13:59:51 -06:00
Daniel Jones
29e0b1068b Merge branch 'master' of https://git.whoisthisjoker.com/Daniel/DailyBread 2024-01-04 16:35:17 -06:00
Daniel Jones
302980f890 Database connection working, displaying verses. 2024-01-04 16:32:53 -06:00
Daniel Jones
bdd60877a7 Added readme.md
This is a simple description describing how to install. I will provide an install script for Linux and Windows in the future, but for now this is just so that there will be some documentation provided.
2024-01-03 22:26:21 +00:00
Daniel Jones
47e9e8e7a8 added better documentation so that when I return to this I will remember where I left off 2024-01-03 15:40:47 -06:00
Daniel Jones
309b1c7085 added new way to get time, should not need seperate versions of Daily Bread now. Same method works for both Linux and Windows. 2024-01-03 14:33:07 -06:00
Daniel Jones
d645996ab6 fixed cmake by pulling from master branch, uploading sqlite to master branch 2024-01-03 13:26:53 -06:00
19cf0fbc00 synced the verses database with master branch 2023-11-25 23:11:44 +00:00
Daniel Jones
fe486d770b saving current work. 2023-09-19 14:11:06 -05:00
5 changed files with 160 additions and 41 deletions

View File

@ -12,6 +12,10 @@ 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
@ -43,7 +47,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,18 +3,21 @@
*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: 9/1/2023 * Last edited: 1/5/2024
*/ */
#include "mainwindow.h" #include "mainwindow.h"
#include "./ui_mainwindow.h" #include "./ui_mainwindow.h"
#include <windows.h> #include <chrono>
#include <iostream> #include <ctime>
#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)
@ -22,7 +25,8 @@ MainWindow::MainWindow(QWidget *parent)
, ui(new Ui::MainWindow) , ui(new Ui::MainWindow)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->verse->setText(verse_display()); ui->verse->setText(verse_grab());
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
@ -32,39 +36,109 @@ MainWindow::~MainWindow()
} }
void bookmarked_verse_func(){
//This is the function that will load the verse into the program. qDebug("test");
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. /*
SYSTEMTIME st = {0}; * Function: verse_grab
GetLocalTime(&st); * description: selects the verse based on the current day and returns the result
int cur_day = st.wDay; * Return type: string
int cur_month = st.wMonth; * Param: none
*/
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,6 +1,5 @@
#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>404</width> <width>387</width>
<height>614</height> <height>600</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>160</x> <x>150</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>161</height> <height>271</height>
</rect> </rect>
</property> </property>
<property name="text"> <property name="text">
@ -46,16 +46,17 @@
<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>404</width> <width>387</width>
<height>21</height> <height>21</height>
</rect> </rect>
</property> </property>
@ -64,7 +65,6 @@
<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,16 +76,31 @@
</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>

27
readme.md Normal file
View File

@ -0,0 +1,27 @@
# 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```