added sqlite3 file to project

This commit is contained in:
Daniel Jones 2023-09-19 10:33:33 -05:00
parent e343f2e819
commit 1807fafb06
7 changed files with 336 additions and 331 deletions

148
.gitignore vendored
View File

@ -1,74 +1,74 @@
# This file is used to ignore files which are generated # This file is used to ignore files which are generated
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
*~ *~
*.autosave *.autosave
*.a *.a
*.core *.core
*.moc *.moc
*.o *.o
*.obj *.obj
*.orig *.orig
*.rej *.rej
*.so *.so
*.so.* *.so.*
*_pch.h.cpp *_pch.h.cpp
*_resource.rc *_resource.rc
*.qm *.qm
.#* .#*
*.*# *.*#
core core
!core/ !core/
tags tags
.DS_Store .DS_Store
.directory .directory
*.debug *.debug
Makefile* Makefile*
*.prl *.prl
*.app *.app
moc_*.cpp moc_*.cpp
ui_*.h ui_*.h
qrc_*.cpp qrc_*.cpp
Thumbs.db Thumbs.db
*.res *.res
*.rc *.rc
/.qmake.cache /.qmake.cache
/.qmake.stash /.qmake.stash
# qtcreator generated files # qtcreator generated files
*.pro.user* *.pro.user*
CMakeLists.txt.user* CMakeLists.txt.user*
# xemacs temporary files # xemacs temporary files
*.flc *.flc
# Vim temporary files # Vim temporary files
.*.swp .*.swp
# Visual Studio generated files # Visual Studio generated files
*.ib_pdb_index *.ib_pdb_index
*.idb *.idb
*.ilk *.ilk
*.pdb *.pdb
*.sln *.sln
*.suo *.suo
*.vcproj *.vcproj
*vcproj.*.*.user *vcproj.*.*.user
*.ncb *.ncb
*.sdf *.sdf
*.opensdf *.opensdf
*.vcxproj *.vcxproj
*vcxproj.* *vcxproj.*
# MinGW generated files # MinGW generated files
*.Debug *.Debug
*.Release *.Release
# Python byte code # Python byte code
*.pyc *.pyc
# Binaries # Binaries
# -------- # --------
*.dll *.dll
*.exe *.exe

View File

@ -1,70 +1,70 @@
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.5)
project(Daily_Bread VERSION 0.1 LANGUAGES CXX) project(Daily_Bread VERSION 0.1 LANGUAGES CXX)
set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON) set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON) 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)
set(PROJECT_SOURCES set(PROJECT_SOURCES
main.cpp main.cpp
mainwindow.cpp mainwindow.cpp
mainwindow.h mainwindow.h
mainwindow.ui mainwindow.ui
) )
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(Daily_Bread qt_add_executable(Daily_Bread
MANUAL_FINALIZATION MANUAL_FINALIZATION
${PROJECT_SOURCES} ${PROJECT_SOURCES}
) )
# Define target properties for Android with Qt 6 as: # Define target properties for Android with Qt 6 as:
# set_property(TARGET Daily_Bread APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR # set_property(TARGET Daily_Bread APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
# ${CMAKE_CURRENT_SOURCE_DIR}/android) # ${CMAKE_CURRENT_SOURCE_DIR}/android)
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation # For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
else() else()
if(ANDROID) if(ANDROID)
add_library(Daily_Bread SHARED add_library(Daily_Bread SHARED
${PROJECT_SOURCES} ${PROJECT_SOURCES}
) )
# Define properties for Android with Qt 5 after find_package() calls as: # Define properties for Android with Qt 5 after find_package() calls as:
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android") # set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
else() else()
add_executable(Daily_Bread add_executable(Daily_Bread
${PROJECT_SOURCES} ${PROJECT_SOURCES}
) )
endif() endif()
endif() endif()
target_link_libraries(Daily_Bread PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) target_link_libraries(Daily_Bread PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
# 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.
if(${QT_VERSION} VERSION_LESS 6.1.0) if(${QT_VERSION} VERSION_LESS 6.1.0)
set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.Daily_Bread) set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.Daily_Bread)
endif() endif()
set_target_properties(Daily_Bread PROPERTIES set_target_properties(Daily_Bread PROPERTIES
${BUNDLE_ID_OPTION} ${BUNDLE_ID_OPTION}
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE WIN32_EXECUTABLE TRUE
) )
include(GNUInstallDirs) include(GNUInstallDirs)
install(TARGETS Daily_Bread install(TARGETS Daily_Bread
BUNDLE DESTINATION . BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
) )
if(QT_VERSION_MAJOR EQUAL 6) if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(Daily_Bread) qt_finalize_executable(Daily_Bread)
endif() endif()

View File

@ -1,12 +1,12 @@
#include "mainwindow.h" #include "mainwindow.h"
#include <QApplication> #include <QApplication>
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QApplication a(argc, argv); QApplication a(argc, argv);
MainWindow w; MainWindow w;
w.show(); w.show();
return a.exec(); return a.exec();
} }

View File

@ -1,66 +1,71 @@
/*Author: Daniel Jones /*Author: Daniel Jones
*IDE: QT Creator *IDE: QT Creator
*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: 9/1/2023
*/ */
#include "mainwindow.h" #include "mainwindow.h"
#include "./ui_mainwindow.h" #include "./ui_mainwindow.h"
#include <iostream> #include <iostream>
#include <random> #include <random>
QString verse_display();
std::string sqlite_func(int day);
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent) QString verse_display();
, ui(new Ui::MainWindow) std::string verse_grab(int day);
{
ui->setupUi(this);
ui->verse->setText(verse_display()); MainWindow::MainWindow(QWidget *parent)
} : QMainWindow(parent)
, ui(new Ui::MainWindow)
MainWindow::~MainWindow() {
{ ui->setupUi(this);
ui->verse->setText(verse_display());
delete ui; }
}
MainWindow::~MainWindow()
//As name implies, randomly chooses a number between 1 and 100. {
int random_verse(){
std::random_device rd; delete ui;
std:: uniform_int_distribution<int> dist(1, 100); }
return dist(rd);
} //As name implies, randomly chooses a number between 1 and 100.
int random_verse(){
//This is the function that will load the verse into the program. std::random_device rd;
QString verse_display() std:: uniform_int_distribution<int> dist(1, 100);
{ return dist(rd);
std::string verse_text; }
int verse_day = random_verse();
verse_text = sqlite_func(verse_day); //This is the function that will load the verse into the program.
QString verse_display()
{
std::string verse_text;
return "It is receiving text from verse_display()"; int verse_day = random_verse();
} verse_text = verse_grab(verse_day);
QString returned_string = QString::fromStdString(verse_text);
std::string sqlite_func(int day){
return returned_string;
std::string my_verse; }
return my_verse;
std::string verse_grab(int day){
}
std::string my_verse;
my_verse = "Hello, this is a verse!";
return my_verse;
void MainWindow::on_exitButton_clicked() }
{
QApplication::quit();
}
void MainWindow::on_exitButton_clicked()
{
QApplication::quit();
}

View File

@ -1,26 +1,26 @@
#ifndef MAINWINDOW_H #ifndef MAINWINDOW_H
#define MAINWINDOW_H #define MAINWINDOW_H
#include <QMainWindow> #include <QMainWindow>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; } namespace Ui { class MainWindow; }
QT_END_NAMESPACE QT_END_NAMESPACE
class MainWindow : public QMainWindow class MainWindow : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
public: public:
MainWindow(QWidget *parent = nullptr); MainWindow(QWidget *parent = nullptr);
~MainWindow(); ~MainWindow();
private slots: private slots:
void on_exitButton_clicked(); void on_exitButton_clicked();
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H

View File

@ -1,83 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>MainWindow</class> <class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow"> <widget class="QMainWindow" name="MainWindow">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>387</width> <width>387</width>
<height>600</height> <height>600</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Daily Bread</string> <string>Daily Bread</string>
</property> </property>
<property name="windowIcon"> <property name="windowIcon">
<iconset theme="accessories-dictionary"> <iconset theme="accessories-dictionary">
<normaloff>bread.png</normaloff>bread.png</iconset> <normaloff>bread.png</normaloff>bread.png</iconset>
</property> </property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<widget class="QPushButton" name="exitButton"> <widget class="QPushButton" name="exitButton">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>150</x> <x>150</x>
<y>490</y> <y>490</y>
<width>80</width> <width>80</width>
<height>24</height> <height>24</height>
</rect> </rect>
</property> </property>
<property name="text"> <property name="text">
<string>Go in Peace</string> <string>Go in Peace</string>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="verse"> <widget class="QLabel" name="verse">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>20</y> <y>20</y>
<width>361</width> <width>361</width>
<height>161</height> <height>161</height>
</rect> </rect>
</property> </property>
<property name="text"> <property name="text">
<string>TextLabel</string> <string>TextLabel</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
</property> </property>
</widget> </widget>
</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>387</width>
<height>21</height> <height>21</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuDaily_Bread"> <widget class="QMenu" name="menuDaily_Bread">
<property name="title"> <property name="title">
<string>File</string> <string>File</string>
</property> </property>
<addaction name="actionbookmark_verse"/> <addaction name="actionbookmark_verse"/>
<addaction name="actionexit"/> <addaction name="actionexit"/>
</widget> </widget>
<addaction name="menuDaily_Bread"/> <addaction name="menuDaily_Bread"/>
</widget> </widget>
<widget class="QStatusBar" name="statusbar"/> <widget class="QStatusBar" name="statusbar"/>
<action name="actionbookmark_verse"> <action name="actionbookmark_verse">
<property name="text"> <property name="text">
<string>bookmark verse</string> <string>bookmark verse</string>
</property> </property>
</action> </action>
<action name="actionexit"> <action name="actionexit">
<property name="text"> <property name="text">
<string>exit</string> <string>exit</string>
</property> </property>
</action> </action>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>

BIN
verses Normal file

Binary file not shown.