Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Makefile*
*build-*
*.qm
*.prl
build

# Qt unit tests
target_wrapper.*
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.5)

project(TaskGuard VERSION 1.2.1 LANGUAGES CXX)
project(TaskGuard VERSION 1.3.0 LANGUAGES CXX)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ TaskGuard is a to-do list application that helps you manage your tasks in a simp

![image](https://user-images.githubusercontent.com/123785508/234422735-0a73b366-f11b-410c-828f-7b2de99d8683.png)

****To encrypt the database, we use the [QtCipherSqlitePlugin(v1.3, LGPL-2.1)](https://github.com/devbean/QtCipherSqlitePlugin).***
**To encrypt the database, we use the [QtCipherSqlitePlugin](https://github.com/mxrcode/QtCipherSqlitePlugin).*

## Features
- **Task management**: Create, edit, and delete tasks with ease.
Expand Down
6 changes: 3 additions & 3 deletions src/about_qt_window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ li.checked::marker { content: "\2612"; }
</style></head><body style=" font-family:'Segoe UI'; font-size:9pt; font-weight:400; font-style:normal;">
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt; font-weight:700;">About Qt</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This program uses Qt version 6.5.</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This program uses Qt version 6.8.</p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Qt is a C++ toolkit for cross-platform application development.</p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p>
Expand All @@ -49,7 +49,7 @@ li.checked::marker { content: "\2612"; }
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Please see <a href="qt.io/licensing"><span style=" text-decoration: underline; color:#007af4;">qt.io/licensing</span></a> for an overview of Qt licensing.</p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Copyright (C) 2023 The Qt Company Ltd and other contributors.</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Copyright (C) 2024 The Qt Company Ltd and other contributors.</p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Qt and the Qt logo are trademarks of The Qt Company Ltd.</p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p>
Expand All @@ -65,7 +65,7 @@ li.checked::marker { content: "\2612"; }
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ void message_handler(QtMsgType type, const QMessageLogContext &context, const QS
QFile log_file("qInfo.log");
if (log_file.open(QIODevice::WriteOnly | QIODevice::Append)) {
QTextStream stream(&log_file);
QString t_msg = QDateTime::currentDateTime().toString() + " : " + msg;
QString t_msg = "[" + QDateTime::currentDateTime().toString() + "] : " + msg;
stream << t_msg << Qt::endl;
}
}
Expand Down
126 changes: 48 additions & 78 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1073,100 +1073,70 @@ void MainWindow::on_group_item_clicked(QListWidgetItem *item) {
}

void MainWindow::on_task_item_clicked(QListWidgetItem *item) {
if (item != nullptr) {
unsigned int task_id = item->data(Qt::UserRole).toUInt();

unsigned int task_id;

if (item != 0x0) {
task_id = item->data(Qt::UserRole).toUInt();
} else {
task_id = 0;
}

if (task_id > 0) {
m_task_current_id = 0;
if (task_id > 0) {
m_task_current_id = 0;

if (db_show_task(task_id)) {
m_task_current_id = task_id;
if (db_show_task(task_id)) {
m_task_current_id = task_id;

if (auto_save_status == false) auto_save();
if (auto_save_status == false) {
setup_auto_save();
auto_save_status = true;
}

ui->task_title->setCursorPosition(0);
ui->task_view_frame->show();
ui->task_title->setCursorPosition(0);
ui->task_view_frame->show();
}
}
}

}

void MainWindow::auto_save() {

connect(ui->task_title, &QLineEdit::textChanged, [this]() {

if (m_task_current_id == 0) {
return;
}

QDateTime data_time = QDateTime::currentDateTime();
int timestamp = data_time.toSecsSinceEpoch();

// Auto save QTextEdit
QSqlQuery db_query;

db_query.prepare("UPDATE task_list SET title = :title, update_time = :update_time WHERE id = :id");
db_query.bindValue(":id", m_task_current_id);
db_query.bindValue(":title", ui->task_title->text());
db_query.bindValue(":update_time", timestamp);

if (!db_query.exec())
{
qInfo() << "An error occurred when executing the query related to autosave task title!";
} else {
window_update();

QDateTime t_update_time;
t_update_time.setSecsSinceEpoch(timestamp);
QString format_update_time = t_update_time.toString("dd/MM/yyyy hh:mm");
ui->updated_data->setText(format_update_time);

ui->updated_text->show();
ui->updated_data->show();
}

});

connect(ui->task_edit, &QTextEdit::textChanged, [this]() {

if (m_task_current_id == 0) {
return;
}
void MainWindow::setup_auto_save() {
connect(ui->task_title, &QLineEdit::textChanged, this, &MainWindow::save_task_title);
connect(ui->task_edit, &QTextEdit::textChanged, this, &MainWindow::save_task_text);
}

QDateTime data_time = QDateTime::currentDateTime();
int timestamp = data_time.toSecsSinceEpoch();
void MainWindow::save_task_title() {
if (m_task_current_id == 0) return;
save_task_data("title", ui->task_title->text());
}

// Auto save QTextEdit
QSqlQuery db_query;
void MainWindow::save_task_text() {
if (m_task_current_id == 0) return;
save_task_data("text", ui->task_edit->toPlainText());
}

db_query.prepare("UPDATE task_list SET text = :text, update_time = :update_time WHERE id = :id");
db_query.bindValue(":id", m_task_current_id);
db_query.bindValue(":text", ui->task_edit->toPlainText());
db_query.bindValue(":update_time", timestamp);
void MainWindow::save_task_data(const QString& column, const QString& value) {
QDateTime data_time = QDateTime::currentDateTime();
int timestamp = data_time.toSecsSinceEpoch();

if (!db_query.exec())
{
qInfo() << "An error occurred when executing the query related to autosave task text!";
} else {
QDateTime t_update_time;
t_update_time.setSecsSinceEpoch(timestamp);
QString format_update_time = t_update_time.toString("dd/MM/yyyy hh:mm");
ui->updated_data->setText(format_update_time);
QSqlQuery db_query;
QString queryStr = QString("UPDATE task_list SET %1 = :value, update_time = :update_time WHERE id = :id").arg(column);
db_query.prepare(queryStr);
db_query.bindValue(":id", m_task_current_id);
db_query.bindValue(":value", value);
db_query.bindValue(":update_time", timestamp);

ui->updated_text->show();
ui->updated_data->show();
}
if (db_query.exec()) {
update_task_ui_after_save(timestamp);
} else {
qWarning() << "An error occurred when executing the query related to autosave task" << column << "!";
}
}

});
void MainWindow::update_task_ui_after_save(int timestamp) {
window_update();

auto_save_status = true;
QDateTime t_update_time;
t_update_time.setSecsSinceEpoch(timestamp);
QString format_update_time = t_update_time.toString("dd/MM/yyyy hh:mm");

ui->updated_data->setText(format_update_time);
ui->updated_text->show();
ui->updated_data->show();
}

QVector<QMap<QString, QVariant>> MainWindow::get_task_data_by_id(unsigned int task_id) {
Expand Down
6 changes: 5 additions & 1 deletion src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ class MainWindow : public QMainWindow
void on_group_item_clicked(QListWidgetItem *item);
void on_task_item_clicked(QListWidgetItem *item);

void auto_save();
void setup_auto_save();
void save_task_title();
void save_task_text();
void save_task_data(const QString& column, const QString& value);
void update_task_ui_after_save(int timestamp);

void groups_update();
void tasks_update();
Expand Down
4 changes: 2 additions & 2 deletions src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
#include <QCryptographicHash>

const QString SOFT_NAME = "TaskGuard";
const QString SOFT_VERSION = "1.2.1";
const QString SOFT_VERSION = "1.3.0";

// Used to encrypt various data in the application, we recommend that you change this value "QString(value)" for private use.
const QString MAGIC = QCryptographicHash::hash(QString("e@txAaCLhYnlmwFSuG3#ADJaGdF3HElOWr1bC8FOlxD1lS25HjgDHS5oQL8BNDUuHKr&WTfEfRh#zzsd6jid9vEFEEVAwurqI2zy1dKed35uswIqhn7WmHCN4BGpo2lg").toUtf8() + QSysInfo::machineUniqueId(), QCryptographicHash::Blake2b_512).toHex();
const QString MAGIC = QCryptographicHash::hash(QString("NfxjiNNSCy2ZIgQUT5V8ZF5qKchadALUpeE5NvFHSlJAbW2t9nqzhF%tToP11bWQODaakdGRRQckcmmPzy1cbWVd7N6ZMVH1Tyq4G#TcdzOmS249oS9eo8YNa6dTWLz3").toUtf8() + QSysInfo::machineUniqueId(), QCryptographicHash::Blake2b_512).toHex();

// Settings
void save_settings(QString name, QString data);
Expand Down