Compare commits

..

No commits in common. "master" and "linux_ver" have entirely different histories.

6 changed files with 22 additions and 155 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 <chrono>
#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,33 @@ 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(){
/* 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;
}

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

@ -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,9 +46,6 @@
<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">
@ -76,31 +73,11 @@
</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>

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```

Binary file not shown.