From 12d4538a9740e82f4a4f7f58fb01c35bb0d7829d Mon Sep 17 00:00:00 2001 From: Joel Smith Date: Fri, 25 Sep 2020 17:19:24 -0700 Subject: [PATCH] Fixes to avoid runtime warnings (#55) --- src/components/code_editor/codeeditor.cpp | 4 +++- src/components/tagging/tageditor.cpp | 4 +++- src/components/tagging/tagwidget.cpp | 4 +++- src/forms/evidence/evidencemanager.cpp | 2 +- src/helpers/constants.h | 8 ++++++++ src/helpers/netman.h | 6 ++++-- src/traymanager.cpp | 12 +++++++++--- 7 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/components/code_editor/codeeditor.cpp b/src/components/code_editor/codeeditor.cpp index 757d58d..d1910a0 100644 --- a/src/components/code_editor/codeeditor.cpp +++ b/src/components/code_editor/codeeditor.cpp @@ -58,6 +58,8 @@ #include #include +#include "helpers/constants.h" + QColor currentLineHighlightColor = QColor(115, 191, 255); CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent) { @@ -70,7 +72,7 @@ CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent) { // customize for text/code editing setLineWrapMode(LineWrapMode::NoWrap); setTabChangesFocus(false); - QFont font("source code pro"); + QFont font(Constants::codeFont()); font.setStyleHint(QFont::TypeWriter); setFont(font); diff --git a/src/components/tagging/tageditor.cpp b/src/components/tagging/tageditor.cpp index 245fa98..46c89bf 100644 --- a/src/components/tagging/tageditor.cpp +++ b/src/components/tagging/tageditor.cpp @@ -16,7 +16,9 @@ TagEditor::TagEditor(QWidget *parent) : QWidget(parent) { } TagEditor::~TagEditor() { - disconnect(getTagsReply, &QNetworkReply::finished, this, &TagEditor::onGetTagsComplete); + if (getTagsReply != nullptr ) { + disconnect(getTagsReply, &QNetworkReply::finished, this, &TagEditor::onGetTagsComplete); + } delete couldNotCreateTagMsg; delete loading; delete tagCompleteTextBox; diff --git a/src/components/tagging/tagwidget.cpp b/src/components/tagging/tagwidget.cpp index b8ad915..50df2c8 100644 --- a/src/components/tagging/tagwidget.cpp +++ b/src/components/tagging/tagwidget.cpp @@ -38,7 +38,9 @@ void TagWidget::mouseReleaseEvent(QMouseEvent* evt) { void TagWidget::buildTag() { QFont labelFont; #ifdef Q_OS_MACOS - labelFont = QFont("Sans", 14); + labelFont = QFont("Arial", 14); +#elif defined(Q_OS_LINUX) + labelFont = QFont("Liberation Sans", 12); #else labelFont = QFont("Sans", 12); #endif diff --git a/src/forms/evidence/evidencemanager.cpp b/src/forms/evidence/evidencemanager.cpp index 9c9b7d4..40370d7 100644 --- a/src/forms/evidence/evidencemanager.cpp +++ b/src/forms/evidence/evidencemanager.cpp @@ -35,7 +35,6 @@ enum ColumnIndexes { static QStringList columnNames() { static QStringList names; if (names.count() == 0) { - names.insert(COL_ERROR_MSG, "Error"); names.insert(COL_DATE_CAPTURED, "Date Captured"); names.insert(COL_OPERATION, "Operation"); names.insert(COL_PATH, "Path"); @@ -44,6 +43,7 @@ static QStringList columnNames() { names.insert(COL_SUBMITTED, "Submitted"); names.insert(COL_DATE_SUBMITTED, "Date Submitted"); names.insert(COL_FAILED, "Failed"); + names.insert(COL_ERROR_MSG, "Error"); } return names; } diff --git a/src/helpers/constants.h b/src/helpers/constants.h index 87a7360..8ae543c 100644 --- a/src/helpers/constants.h +++ b/src/helpers/constants.h @@ -69,6 +69,14 @@ class Constants { return "https://github.com/theparanoids/ashirt/releases"; } + static QString codeFont() { + #ifdef Q_OS_MACX + return "monaco"; + #endif + + return "source code pro"; + } + private: enum RepoField { owner = 0, diff --git a/src/helpers/netman.h b/src/helpers/netman.h index e2883b7..ecb3f20 100644 --- a/src/helpers/netman.h +++ b/src/helpers/netman.h @@ -214,8 +214,10 @@ class NetMan : public QObject { /// refreshOperationsList retrieves the operations currently visible to the user. Results should be /// retrieved by listening for the operationListUpdated signal void refreshOperationsList() { - allOpsReply = getAllOperations(); - connect(allOpsReply, &QNetworkReply::finished, this, &NetMan::onGetOpsComplete); + if (allOpsReply == nullptr) { + allOpsReply = getAllOperations(); + connect(allOpsReply, &QNetworkReply::finished, this, &NetMan::onGetOpsComplete); + } } /// getOperationTags retrieves the tags for specified operation from the ASHIRT API server diff --git a/src/traymanager.cpp b/src/traymanager.cpp index 81f8ec2..7312196 100644 --- a/src/traymanager.cpp +++ b/src/traymanager.cpp @@ -152,11 +152,17 @@ void TrayManager::closeEvent(QCloseEvent* event) { } void TrayManager::createActions() { + auto toTop = [](QDialog* window) { + window->show(); // display the window + window->raise(); // bring to the top (mac) + window->activateWindow(); // alternate bring to the top (windows) + }; + quitAction = new QAction(tr("Quit"), this); connect(quitAction, &QAction::triggered, qApp, &QCoreApplication::quit); showSettingsAction = new QAction(tr("Settings"), this); - connect(showSettingsAction, &QAction::triggered, settingsWindow, &QWidget::show); + connect(showSettingsAction, &QAction::triggered, [this, toTop](){toTop(settingsWindow);}); currentOperationMenuAction = new QAction(this); currentOperationMenuAction->setEnabled(false); @@ -168,10 +174,10 @@ void TrayManager::createActions() { connect(captureWindowAction, &QAction::triggered, this, &TrayManager::captureWindowActionTriggered); showEvidenceManagerAction = new QAction(tr("View Accumulated Evidence"), this); - connect(showEvidenceManagerAction, &QAction::triggered, evidenceManagerWindow, &QWidget::show); + connect(showEvidenceManagerAction, &QAction::triggered, [this, toTop](){toTop(evidenceManagerWindow);}); showCreditsAction = new QAction(tr("About"), this); - connect(showCreditsAction, &QAction::triggered, creditsWindow, &QWidget::show); + connect(showCreditsAction, &QAction::triggered, [this, toTop](){toTop(creditsWindow);}); addCodeblockAction = new QAction(tr("Add Codeblock from Clipboard"), this); connect(addCodeblockAction, &QAction::triggered, this, &TrayManager::captureCodeblockActionTriggered);