diff options
author | Sune Vuorela <sune@vuorela.dk> | 2023-08-21 15:39:44 +0200 |
---|---|---|
committer | Sune Vuorela <sune@vuorela.dk> | 2023-08-21 16:22:06 +0200 |
commit | bd1f363d72c71324232e11b2029000fb3bd5876a (patch) | |
tree | 58c2944e5237cf0f8a4c6bcd7b309e952495ab71 /src/qtpass.cpp | |
parent | 1e5a217d6a14f06d699e2af52ef4ec4114bbdba2 (diff) |
Clazy cleanup and other minor fixes
- Code is now clazy clean with
CLAZY_CHECKS="no-connect-by-name,no-overloaded-signal"
- Given the minimum Qt version is 5.10, remove ifdef's for older
versions
- Some more range based for and related cleanups.
- Some include cleanups
Diffstat (limited to 'src/qtpass.cpp')
-rw-r--r-- | src/qtpass.cpp | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/src/qtpass.cpp b/src/qtpass.cpp index a18bd090..f9991e55 100644 --- a/src/qtpass.cpp +++ b/src/qtpass.cpp @@ -1,6 +1,7 @@ #include "qtpass.h" #include "mainwindow.h" #include "qtpasssettings.h" +#include "util.h" #include <QApplication> #include <QClipboard> #include <QDialog> @@ -135,11 +136,12 @@ void QtPass::setMainWindow(void) { QtPassSettings::getPass()->GitInit(); }); - connect( - m_mainWindow, &MainWindow::generateGPGKeyPair, [=](const QString &batch) { - QtPassSettings::getPass()->GenerateGPGKeys(batch); - m_mainWindow->showStatusMessage(tr("Generating GPG key pair"), 60000); - }); + connect(m_mainWindow, &MainWindow::generateGPGKeyPair, m_mainWindow, + [=](const QString &batch) { + QtPassSettings::getPass()->GenerateGPGKeys(batch); + m_mainWindow->showStatusMessage(tr("Generating GPG key pair"), + 60000); + }); } void QtPass::connectPassSignalHandlers(Pass *pass) { @@ -266,10 +268,7 @@ void QtPass::processError(QProcess::ProcessError error) { void QtPass::processErrorExit(int exitCode, const QString &p_error) { if (!p_error.isEmpty()) { QString output; - QString error = p_error; - error.replace(QRegularExpression("<"), "<"); - error.replace(QRegularExpression(">"), ">"); - error.replace(QRegularExpression(" "), " "); + QString error = p_error.toHtmlEscaped(); if (exitCode == 0) { // https://github.com/IJHack/qtpass/issues/111 output = "<span style=\"color: darkgray;\">" + error + "</span><br />"; @@ -277,10 +276,8 @@ void QtPass::processErrorExit(int exitCode, const QString &p_error) { output = "<span style=\"color: red;\">" + error + "</span><br />"; } - output.replace(QRegularExpression( - "((?:https?|ftp|ssh|sftp|ftps|webdav|webdavs)://\\S+)"), - R"(<a href="\1">\1</a>)"); - output.replace(QRegularExpression("\n"), "<br />"); + output.replace(Util::protocolRegex(), R"(<a href="\1">\1</a>)"); + output.replace(QStringLiteral("\n"), "<br />"); m_mainWindow->flashText(output, false, true); } @@ -335,14 +332,10 @@ void QtPass::passShowHandlerFinished(QString output) { void QtPass::showInTextBrowser(QString output, QString prefix, QString postfix) { - output.replace(QRegularExpression("<"), "<"); - output.replace(QRegularExpression(">"), ">"); - output.replace(QRegularExpression(" "), " "); - - output.replace(QRegularExpression( - "((?:https?|ftp|ssh|sftp|ftps|webdav|webdavs)://\\S+)"), - R"(<a href="\1">\1</a>)"); - output.replace(QRegularExpression("\n"), "<br />"); + output = output.toHtmlEscaped(); + + output.replace(Util::protocolRegex(), R"(<a href="\1">\1</a>)"); + output.replace(QStringLiteral("\n"), "<br />"); output = prefix + output + postfix; m_mainWindow->flashText(output, false, true); |