Skip to content

Commit fe789a1

Browse files
authored
Merge pull request #2 from mxrcode/v1.3.0_qt_6.8
v1.3.0 Qt 6.8
2 parents ea86bef + a312d9e commit fe789a1

8 files changed

Lines changed: 62 additions & 87 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Makefile*
3131
*build-*
3232
*.qm
3333
*.prl
34+
build
3435

3536
# Qt unit tests
3637
target_wrapper.*

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.5)
22

3-
project(TaskGuard VERSION 1.2.1 LANGUAGES CXX)
3+
project(TaskGuard VERSION 1.3.0 LANGUAGES CXX)
44

55
set(CMAKE_AUTOUIC ON)
66
set(CMAKE_AUTOMOC ON)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ TaskGuard is a to-do list application that helps you manage your tasks in a simp
55

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

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

1010
## Features
1111
- **Task management**: Create, edit, and delete tasks with ease.

src/about_qt_window.ui

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ li.checked::marker { content: "\2612"; }
3030
</style></head><body style=" font-family:'Segoe UI'; font-size:9pt; font-weight:400; font-style:normal;">
3131
<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>
3232
<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>
33-
<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>
33+
<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>
3434
<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>
3535
<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>
3636
<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>
@@ -49,7 +49,7 @@ li.checked::marker { content: "\2612"; }
4949
<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>
5050
<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>
5151
<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>
52-
<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>
52+
<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>
5353
<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>
5454
<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>
5555
<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>
@@ -65,7 +65,7 @@ li.checked::marker { content: "\2612"; }
6565
<item>
6666
<spacer name="horizontalSpacer">
6767
<property name="orientation">
68-
<enum>Qt::Horizontal</enum>
68+
<enum>Qt::Orientation::Horizontal</enum>
6969
</property>
7070
<property name="sizeHint" stdset="0">
7171
<size>

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ void message_handler(QtMsgType type, const QMessageLogContext &context, const QS
66
QFile log_file("qInfo.log");
77
if (log_file.open(QIODevice::WriteOnly | QIODevice::Append)) {
88
QTextStream stream(&log_file);
9-
QString t_msg = QDateTime::currentDateTime().toString() + " : " + msg;
9+
QString t_msg = "[" + QDateTime::currentDateTime().toString() + "] : " + msg;
1010
stream << t_msg << Qt::endl;
1111
}
1212
}

src/mainwindow.cpp

Lines changed: 48 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,100 +1073,70 @@ void MainWindow::on_group_item_clicked(QListWidgetItem *item) {
10731073
}
10741074

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

1077-
unsigned int task_id;
1078-
1079-
if (item != 0x0) {
1080-
task_id = item->data(Qt::UserRole).toUInt();
1081-
} else {
1082-
task_id = 0;
1083-
}
1084-
1085-
if (task_id > 0) {
1086-
m_task_current_id = 0;
1079+
if (task_id > 0) {
1080+
m_task_current_id = 0;
10871081

1088-
if (db_show_task(task_id)) {
1089-
m_task_current_id = task_id;
1082+
if (db_show_task(task_id)) {
1083+
m_task_current_id = task_id;
10901084

1091-
if (auto_save_status == false) auto_save();
1085+
if (auto_save_status == false) {
1086+
setup_auto_save();
1087+
auto_save_status = true;
1088+
}
10921089

1093-
ui->task_title->setCursorPosition(0);
1094-
ui->task_view_frame->show();
1090+
ui->task_title->setCursorPosition(0);
1091+
ui->task_view_frame->show();
1092+
}
10951093
}
10961094
}
1097-
10981095
}
10991096

1100-
void MainWindow::auto_save() {
1101-
1102-
connect(ui->task_title, &QLineEdit::textChanged, [this]() {
1103-
1104-
if (m_task_current_id == 0) {
1105-
return;
1106-
}
1107-
1108-
QDateTime data_time = QDateTime::currentDateTime();
1109-
int timestamp = data_time.toSecsSinceEpoch();
1110-
1111-
// Auto save QTextEdit
1112-
QSqlQuery db_query;
1113-
1114-
db_query.prepare("UPDATE task_list SET title = :title, update_time = :update_time WHERE id = :id");
1115-
db_query.bindValue(":id", m_task_current_id);
1116-
db_query.bindValue(":title", ui->task_title->text());
1117-
db_query.bindValue(":update_time", timestamp);
1118-
1119-
if (!db_query.exec())
1120-
{
1121-
qInfo() << "An error occurred when executing the query related to autosave task title!";
1122-
} else {
1123-
window_update();
1124-
1125-
QDateTime t_update_time;
1126-
t_update_time.setSecsSinceEpoch(timestamp);
1127-
QString format_update_time = t_update_time.toString("dd/MM/yyyy hh:mm");
1128-
ui->updated_data->setText(format_update_time);
1129-
1130-
ui->updated_text->show();
1131-
ui->updated_data->show();
1132-
}
1133-
1134-
});
1135-
1136-
connect(ui->task_edit, &QTextEdit::textChanged, [this]() {
1137-
1138-
if (m_task_current_id == 0) {
1139-
return;
1140-
}
1097+
void MainWindow::setup_auto_save() {
1098+
connect(ui->task_title, &QLineEdit::textChanged, this, &MainWindow::save_task_title);
1099+
connect(ui->task_edit, &QTextEdit::textChanged, this, &MainWindow::save_task_text);
1100+
}
11411101

1142-
QDateTime data_time = QDateTime::currentDateTime();
1143-
int timestamp = data_time.toSecsSinceEpoch();
1102+
void MainWindow::save_task_title() {
1103+
if (m_task_current_id == 0) return;
1104+
save_task_data("title", ui->task_title->text());
1105+
}
11441106

1145-
// Auto save QTextEdit
1146-
QSqlQuery db_query;
1107+
void MainWindow::save_task_text() {
1108+
if (m_task_current_id == 0) return;
1109+
save_task_data("text", ui->task_edit->toPlainText());
1110+
}
11471111

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

1153-
if (!db_query.exec())
1154-
{
1155-
qInfo() << "An error occurred when executing the query related to autosave task text!";
1156-
} else {
1157-
QDateTime t_update_time;
1158-
t_update_time.setSecsSinceEpoch(timestamp);
1159-
QString format_update_time = t_update_time.toString("dd/MM/yyyy hh:mm");
1160-
ui->updated_data->setText(format_update_time);
1116+
QSqlQuery db_query;
1117+
QString queryStr = QString("UPDATE task_list SET %1 = :value, update_time = :update_time WHERE id = :id").arg(column);
1118+
db_query.prepare(queryStr);
1119+
db_query.bindValue(":id", m_task_current_id);
1120+
db_query.bindValue(":value", value);
1121+
db_query.bindValue(":update_time", timestamp);
11611122

1162-
ui->updated_text->show();
1163-
ui->updated_data->show();
1164-
}
1123+
if (db_query.exec()) {
1124+
update_task_ui_after_save(timestamp);
1125+
} else {
1126+
qWarning() << "An error occurred when executing the query related to autosave task" << column << "!";
1127+
}
1128+
}
11651129

1166-
});
1130+
void MainWindow::update_task_ui_after_save(int timestamp) {
1131+
window_update();
11671132

1168-
auto_save_status = true;
1133+
QDateTime t_update_time;
1134+
t_update_time.setSecsSinceEpoch(timestamp);
1135+
QString format_update_time = t_update_time.toString("dd/MM/yyyy hh:mm");
11691136

1137+
ui->updated_data->setText(format_update_time);
1138+
ui->updated_text->show();
1139+
ui->updated_data->show();
11701140
}
11711141

11721142
QVector<QMap<QString, QVariant>> MainWindow::get_task_data_by_id(unsigned int task_id) {

src/mainwindow.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ class MainWindow : public QMainWindow
106106
void on_group_item_clicked(QListWidgetItem *item);
107107
void on_task_item_clicked(QListWidgetItem *item);
108108

109-
void auto_save();
109+
void setup_auto_save();
110+
void save_task_title();
111+
void save_task_text();
112+
void save_task_data(const QString& column, const QString& value);
113+
void update_task_ui_after_save(int timestamp);
110114

111115
void groups_update();
112116
void tasks_update();

src/version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
#include <QCryptographicHash>
77

88
const QString SOFT_NAME = "TaskGuard";
9-
const QString SOFT_VERSION = "1.2.1";
9+
const QString SOFT_VERSION = "1.3.0";
1010

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

1414
// Settings
1515
void save_settings(QString name, QString data);

0 commit comments

Comments
 (0)