aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ui/function/VersionCheckThread.cpp16
-rw-r--r--src/ui/smtp/SendMailDialog.cpp2
-rw-r--r--src/ui/widgets/EditorPage.cpp30
-rw-r--r--src/ui/widgets/EditorPage.h8
-rw-r--r--src/ui/widgets/TextEdit.cpp30
-rw-r--r--src/ui/widgets/TextEdit.h2
6 files changed, 46 insertions, 42 deletions
diff --git a/src/ui/function/VersionCheckThread.cpp b/src/ui/function/VersionCheckThread.cpp
index 091f7cd2..52d1b22a 100644
--- a/src/ui/function/VersionCheckThread.cpp
+++ b/src/ui/function/VersionCheckThread.cpp
@@ -56,12 +56,13 @@ void VersionCheckThread::run() {
QNetworkRequest latest_request, current_request;
latest_request.setUrl(QUrl(latest_version_url.c_str()));
current_request.setUrl(QUrl(current_version_url.c_str()));
- auto reply = manager->get(latest_request);
- while (reply->isRunning()) QApplication::processEvents();
- if (reply->error() != QNetworkReply::NoError) {
+ auto _reply = manager->get(latest_request);
+ while (_reply->isRunning()) QApplication::processEvents();
+ if (_reply->error() != QNetworkReply::NoError) {
LOG(ERROR) << "network error";
version.latest_version = current_version;
} else {
+ latest_reply_bytes_ = _reply->readAll();
auto latest_reply_json =
nlohmann::json::parse(latest_reply_bytes_.toStdString());
@@ -90,11 +91,10 @@ void VersionCheckThread::run() {
version.release_note = release_note;
}
- latest_reply_bytes_ = reply->readAll();
- reply = manager->get(current_request);
- while (reply->isRunning()) QApplication::processEvents();
- current_reply_bytes_ = reply->readAll();
- if (reply->error() != QNetworkReply::NoError) {
+ _reply = manager->get(current_request);
+ while (_reply->isRunning()) QApplication::processEvents();
+ current_reply_bytes_ = _reply->readAll();
+ if (_reply->error() != QNetworkReply::NoError) {
LOG(ERROR) << "network error";
manager->deleteLater();
return;
diff --git a/src/ui/smtp/SendMailDialog.cpp b/src/ui/smtp/SendMailDialog.cpp
index 9db78608..a758a18c 100644
--- a/src/ui/smtp/SendMailDialog.cpp
+++ b/src/ui/smtp/SendMailDialog.cpp
@@ -45,7 +45,7 @@ SendMailDialog::SendMailDialog(const QString& text, QWidget* parent)
if (smtp_address_.isEmpty()) {
QMessageBox::critical(
- this, _("Incomplete configuration"),
+ this->parentWidget(), _("Incomplete configuration"),
_("The SMTP address is empty, please go to the setting interface to "
"complete the configuration."));
diff --git a/src/ui/widgets/EditorPage.cpp b/src/ui/widgets/EditorPage.cpp
index 94c98036..b73974a7 100644
--- a/src/ui/widgets/EditorPage.cpp
+++ b/src/ui/widgets/EditorPage.cpp
@@ -32,7 +32,7 @@
namespace GpgFrontend::UI {
EditorPage::EditorPage(QString filePath, QWidget* parent)
- : QWidget(parent), fullFilePath(std::move(filePath)) {
+ : QWidget(parent), full_file_path_(std::move(filePath)) {
// Set the Textedit properties
textPage = new QTextEdit();
textPage->setAcceptRichText(false);
@@ -51,12 +51,12 @@ EditorPage::EditorPage(QString filePath, QWidget* parent)
this->setAttribute(Qt::WA_DeleteOnClose);
}
-const QString& EditorPage::getFilePath() const { return fullFilePath; }
+const QString& EditorPage::getFilePath() const { return full_file_path_; }
QTextEdit* EditorPage::getTextPage() { return textPage; }
void EditorPage::setFilePath(const QString& filePath) {
- fullFilePath = filePath;
+ full_file_path_ = filePath;
}
void EditorPage::showNotificationWidget(QWidget* widget,
@@ -110,34 +110,34 @@ void EditorPage::slotFormatGpgHeader() {
void EditorPage::ReadFile() {
LOG(INFO) << "Called";
- readDone = false;
+ read_done_ = false;
auto text_page = this->getTextPage();
text_page->setReadOnly(true);
- auto thread = new FileReadThread(this->fullFilePath.toStdString());
+ auto thread = new FileReadThread(this->full_file_path_.toStdString());
connect(thread, &FileReadThread::sendReadBlock, this,
&EditorPage::slotInsertText);
connect(thread, &FileReadThread::readDone, this, [=]() {
- LOG(INFO) << "Thread read done";
+ LOG(INFO) << "thread read done";
text_page->document()->setModified(false);
text_page->setReadOnly(false);
});
connect(thread, &FileReadThread::finished, this, [=]() {
- LOG(INFO) << "Thread finished";
+ LOG(INFO) << "thread finished";
thread->deleteLater();
- readDone = true;
- readThread = nullptr;
+ read_done_ = true;
+ read_hread_ = nullptr;
});
connect(this, &EditorPage::destroyed, [=]() {
- LOG(INFO) << "RequestInterruption for readThread";
+ LOG(INFO) << "request interruption for read thread";
thread->requestInterruption();
- readThread = nullptr;
+ read_hread_ = nullptr;
});
- this->readThread = thread;
+ this->read_hread_ = thread;
thread->start();
}
@@ -145,9 +145,9 @@ void EditorPage::slotInsertText(const QString& text) {
this->getTextPage()->insertPlainText(text);
}
void EditorPage::PrepareToDestroy() {
- if (readThread) {
- readThread->requestInterruption();
- readThread = nullptr;
+ if (read_hread_) {
+ read_hread_->requestInterruption();
+ read_hread_ = nullptr;
}
}
diff --git a/src/ui/widgets/EditorPage.h b/src/ui/widgets/EditorPage.h
index a0a05dab..d1bc1ac2 100644
--- a/src/ui/widgets/EditorPage.h
+++ b/src/ui/widgets/EditorPage.h
@@ -86,17 +86,17 @@ class EditorPage : public QWidget {
void ReadFile();
- [[nodiscard]] bool ReadDone() const { return this->readDone; }
+ [[nodiscard]] bool ReadDone() const { return this->read_done_; }
void PrepareToDestroy();
private:
QTextEdit* textPage; /** The textedit of the tab */
QVBoxLayout* mainLayout; /** The layout for the tab */
- QString fullFilePath; /** The path to the file handled in the tab */
+ QString full_file_path_; /** The path to the file handled in the tab */
bool signMarked{}; /** true, if the signed header is marked, false if not */
- bool readDone = false;
- QThread* readThread = nullptr;
+ bool read_done_ = false;
+ QThread* read_hread_ = nullptr;
private slots:
diff --git a/src/ui/widgets/TextEdit.cpp b/src/ui/widgets/TextEdit.cpp
index 036c69d4..be6ec181 100644
--- a/src/ui/widgets/TextEdit.cpp
+++ b/src/ui/widgets/TextEdit.cpp
@@ -55,8 +55,8 @@ void TextEdit::slotNewTab() {
tabWidget->setTabIcon(index, QIcon(":file.png"));
tabWidget->setCurrentIndex(tabWidget->count() - 1);
page->getTextPage()->setFocus();
- connect(page->getTextPage()->document(), SIGNAL(modificationChanged(bool)),
- this, SLOT(slotShowModified()));
+ connect(page->getTextPage()->document(), &QTextDocument::modificationChanged,
+ this, &TextEdit::slotShowModified);
}
void TextEdit::slotNewHelpTab(const QString& title, const QString& path) const {
@@ -81,6 +81,10 @@ void TextEdit::slotOpenFile(QString& path) {
auto result = file.open(QIODevice::ReadOnly | QIODevice::Text);
if (result) {
auto* page = new EditorPage(path);
+ connect(page->getTextPage()->document(),
+ &QTextDocument::modificationChanged, this,
+ &TextEdit::slotShowModified);
+
QApplication::setOverrideCursor(Qt::WaitCursor);
auto index = tabWidget->addTab(page, strippedName(path));
tabWidget->setTabIcon(index, QIcon(":file.png"));
@@ -295,20 +299,20 @@ bool TextEdit::maybeSaveCurrentTab(bool askToSave) {
bool TextEdit::maybeSaveAnyTab() {
// get a list of all unsaved documents and their tabids
- QHash<int, QString> unsavedDocs = this->unsavedDocuments();
+ QHash<int, QString> unsaved_docs = this->unsavedDocuments();
/*
* no unsaved documents, so app can be closed
*/
- if (unsavedDocs.empty()) {
+ if (unsaved_docs.empty()) {
return true;
}
/*
* only 1 unsaved document -> set modified tab as current
* and show normal unsaved doc dialog
*/
- if (unsavedDocs.size() == 1) {
- int modifiedTab = unsavedDocs.keys().at(0);
+ if (unsaved_docs.size() == 1) {
+ int modifiedTab = unsaved_docs.keys().at(0);
tabWidget->setCurrentIndex(modifiedTab);
return maybeSaveCurrentTab(true);
}
@@ -316,11 +320,11 @@ bool TextEdit::maybeSaveAnyTab() {
/*
* more than one unsaved documents
*/
- if (unsavedDocs.size() > 1) {
- QHashIterator<int, QString> i(unsavedDocs);
+ if (unsaved_docs.size() > 1) {
+ QHashIterator<int, QString> i(unsaved_docs);
QuitDialog* dialog;
- dialog = new QuitDialog(this, unsavedDocs);
+ dialog = new QuitDialog(this, unsaved_docs);
int result = dialog->exec();
// if result is QDialog::Rejected, discard or cancel was clicked
@@ -429,8 +433,8 @@ void TextEdit::loadFile(const QString& fileName) {
// statusBar()->showMessage(_("File loaded"), 2000);
}
-QString TextEdit::strippedName(const QString& fullFileName) {
- return QFileInfo(fullFileName).fileName();
+QString TextEdit::strippedName(const QString& full_file_name) {
+ return QFileInfo(full_file_name).fileName();
}
void TextEdit::slotPrint() {
@@ -469,8 +473,8 @@ void TextEdit::slotShowModified() const {
void TextEdit::slotSwitchTabUp() const {
if (tabWidget->count() > 1) {
- int newindex = (tabWidget->currentIndex() + 1) % (tabWidget->count());
- tabWidget->setCurrentIndex(newindex);
+ int new_index = (tabWidget->currentIndex() + 1) % (tabWidget->count());
+ tabWidget->setCurrentIndex(new_index);
}
}
diff --git a/src/ui/widgets/TextEdit.h b/src/ui/widgets/TextEdit.h
index 3cff74e7..e877ccc1 100644
--- a/src/ui/widgets/TextEdit.h
+++ b/src/ui/widgets/TextEdit.h
@@ -185,7 +185,7 @@ class TextEdit : public QWidget {
* @param a filename path
* @return QString containing the filename
*/
- static QString strippedName(const QString& fullFileName);
+ static QString strippedName(const QString& full_file_name);
/**
* @brief