Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
d85a8791b8 | ||
|
f798593240 | ||
|
29e0b1068b | ||
|
302980f890 | ||
|
bdd60877a7 | ||
|
47e9e8e7a8 | ||
|
309b1c7085 | ||
|
d645996ab6 | ||
19cf0fbc00 |
@ -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.
|
||||||
|
116
mainwindow.cpp
116
mainwindow.cpp
@ -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 <chrono>
|
#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,33 +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(){
|
|
||||||
|
|
||||||
std::string my_verse;
|
/*
|
||||||
|
* Function: verse_grab
|
||||||
|
* description: selects the verse based on the current day and returns the result
|
||||||
|
* Return type: string
|
||||||
|
* Param: none
|
||||||
|
*/
|
||||||
|
QString verse_grab(){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//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;
|
||||||
|
}
|
||||||
|
@ -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
|
||||||
|
@ -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,6 +46,9 @@
|
|||||||
<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>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenuBar" name="menubar">
|
<widget class="QMenuBar" name="menubar">
|
||||||
@ -73,11 +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>
|
||||||
</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
27
readme.md
Normal 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```
|
BIN
verses.sqlite
BIN
verses.sqlite
Binary file not shown.
Loading…
Reference in New Issue
Block a user