Ecnryptable note

This commit is contained in:
Aurélie Delhaie
2022-02-08 17:59:05 +01:00
parent d661cc7b42
commit 64d216fcf2
21 changed files with 294 additions and 91 deletions

View File

@@ -71,7 +71,7 @@
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Version 1.1.0.0</string>
<string>Version 1.2.0.0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>

View File

@@ -14,6 +14,7 @@ MainWindow::MainWindow(QWidget *parent)
connect(ui->noteList, &QListWidget::currentRowChanged, this, &MainWindow::selectionChanged);
connect(ui->titleEdit, &QLineEdit::textChanged, this, &MainWindow::titleChanged);
connect(ui->contentEdit, &QPlainTextEdit::textChanged, this, &MainWindow::contentChanged);
connect(ui->actionEncrypt, &QAction::triggered, this, &MainWindow::encryptNote);
const QFont fixedFont = QFontDatabase::systemFont(QFontDatabase::FixedFont);
ui->contentEdit->setFont(fixedFont);
this->savemng = new SaveManager();
@@ -55,8 +56,13 @@ void MainWindow::selectionChanged(int i)
ui->titleEdit->setDisabled(false);
ui->contentEdit->setDisabled(false);
ui->titleEdit->setText(n->getTitle());
ui->contentEdit->setPlainText(n->getContent());
ui->markdownViewer->setMarkdown(n->getContent());
if (n->isEncrypted())
{
ui->contentEdit->setPlainText(n->getEncryptedContent("azertyuiop"));
} else {
ui->contentEdit->setPlainText(n->getContent());
}
ui->markdownViewer->setMarkdown(ui->contentEdit->toPlainText());
}
void MainWindow::removeSelected()
@@ -71,6 +77,7 @@ void MainWindow::removeSelected()
void MainWindow::save()
{
ui->actionSave->setDisabled(true);
if (this->currentIndex > -1)
{
Note *n = this->savemng->getNoteByIndex(this->currentIndex);
@@ -89,6 +96,7 @@ void MainWindow::titleChanged()
n->setTitle(ui->titleEdit->text());
ui->noteList->item(this->currentIndex)->setText(ui->titleEdit->text());
}
ui->actionSave->setDisabled(false);
timer->start(1000);
}
@@ -99,6 +107,16 @@ void MainWindow::showAboutBox()
dialog.exec();
}
void MainWindow::encryptNote()
{
if (this->currentIndex > -1)
{
Note *n = this->savemng->getNoteByIndex(this->currentIndex);
n->encrypt("azertyuiop");
savemng->flushSave();
}
}
void MainWindow::contentChanged()
{
timer->stop();
@@ -108,6 +126,7 @@ void MainWindow::contentChanged()
n->setContent(ui->contentEdit->toPlainText());
ui->markdownViewer->setMarkdown(ui->contentEdit->toPlainText());
}
ui->actionSave->setDisabled(false);
timer->start(1000);
}

View File

@@ -30,6 +30,7 @@ private slots:
void contentChanged();
void titleChanged();
void showAboutBox();
void encryptNote();
private:
Ui::MainWindow *ui;

View File

@@ -120,15 +120,24 @@
</layout>
</widget>
<widget class="QToolBar" name="toolBar">
<property name="enabled">
<bool>true</bool>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>33</height>
<height>96</height>
</size>
</property>
<property name="windowTitle">
<string>toolBar</string>
</property>
<property name="movable">
<bool>false</bool>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextUnderIcon</enum>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
@@ -140,12 +149,16 @@
<addaction name="separator"/>
<addaction name="actionSave"/>
<addaction name="separator"/>
<addaction name="actionLock"/>
<addaction name="actionUnlock"/>
<addaction name="actionEncrypt"/>
<addaction name="separator"/>
<addaction name="actionAbout"/>
</widget>
<action name="actionAdd">
<property name="icon">
<iconset resource="../../icons.qrc">
<normaloff>:/icon/resources/outline_add_circle_outline_black_18dp.png</normaloff>:/icon/resources/outline_add_circle_outline_black_18dp.png</iconset>
<normaloff>:/icon/resources/outline_add_circle_outline_black_48dp.png</normaloff>:/icon/resources/outline_add_circle_outline_black_48dp.png</iconset>
</property>
<property name="text">
<string>Add</string>
@@ -157,16 +170,19 @@
</property>
<property name="icon">
<iconset resource="../../icons.qrc">
<normaloff>:/icon/resources/outline_delete_forever_black_18dp.png</normaloff>:/icon/resources/outline_delete_forever_black_18dp.png</iconset>
<normaloff>:/icon/resources/outline_delete_forever_black_48dp.png</normaloff>:/icon/resources/outline_delete_forever_black_48dp.png</iconset>
</property>
<property name="text">
<string>Remove</string>
</property>
</action>
<action name="actionSave">
<property name="enabled">
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="../../icons.qrc">
<normaloff>:/icon/resources/outline_save_black_18dp.png</normaloff>:/icon/resources/outline_save_black_18dp.png</iconset>
<normaloff>:/icon/resources/outline_save_black_48dp.png</normaloff>:/icon/resources/outline_save_black_48dp.png</iconset>
</property>
<property name="text">
<string>Save</string>
@@ -175,12 +191,45 @@
<action name="actionAbout">
<property name="icon">
<iconset resource="../../icons.qrc">
<normaloff>:/icon/resources/outline_help_outline_black_18dp.png</normaloff>:/icon/resources/outline_help_outline_black_18dp.png</iconset>
<normaloff>:/icon/resources/outline_help_outline_black_48dp.png</normaloff>:/icon/resources/outline_help_outline_black_48dp.png</iconset>
</property>
<property name="text">
<string>About</string>
</property>
</action>
<action name="actionLock">
<property name="icon">
<iconset resource="../../icons.qrc">
<normaloff>:/icon/resources/outline_lock_black_48dp.png</normaloff>:/icon/resources/outline_lock_black_48dp.png</iconset>
</property>
<property name="text">
<string>Lock</string>
</property>
<property name="visible">
<bool>false</bool>
</property>
</action>
<action name="actionUnlock">
<property name="icon">
<iconset resource="../../icons.qrc">
<normaloff>:/icon/resources/outline_lock_open_black_48dp.png</normaloff>:/icon/resources/outline_lock_open_black_48dp.png</iconset>
</property>
<property name="text">
<string>Unlock</string>
</property>
<property name="visible">
<bool>false</bool>
</property>
</action>
<action name="actionEncrypt">
<property name="icon">
<iconset resource="../../icons.qrc">
<normaloff>:/icon/resources/outline_shield_black_48dp.png</normaloff>:/icon/resources/outline_shield_black_48dp.png</iconset>
</property>
<property name="text">
<string>Encrypt</string>
</property>
</action>
</widget>
<resources>
<include location="../../icons.qrc"/>