Skip to content

Commit 26fb82e

Browse files
authored
new Welcome Page and firstrunWizard (#235)
Co-authored-by: Chris Rizzitello <crizzitello@ics.com>
1 parent 3e1ba34 commit 26fb82e

34 files changed

+1845
-7
lines changed

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ find_package(Qt6 6.5.0 REQUIRED COMPONENTS
6464
Network
6565
Sql
6666
Core
67+
Svg
6768
)
6869

6970
add_subdirectory(deploy)

src/appconfig.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ QString AppConfig::defaultValue(const QString &key)
104104
if (key == CONFIG::APIURL)
105105
return QStringLiteral("http://localhost:8080");
106106

107+
if (key == CONFIG::SHOW_WELCOME_SCREEN)
108+
return QStringLiteral("true");
109+
107110
if (key == CONFIG::SHORTCUT_CAPTURECLIPBOARD) {
108111
if(!get()->appSettings->value(key).isValid())
109112
return QStringLiteral("Meta+Alt+v");

src/appconfig.h

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ struct CONFIG {
2121
inline static const auto COMMAND_CAPTUREWINDOW = QStringLiteral("captureWindowExec");
2222
inline static const auto SHORTCUT_CAPTUREWINDOW = QStringLiteral("captureWindowShortcut");
2323
inline static const auto SHORTCUT_CAPTURECLIPBOARD = QStringLiteral("captureClipboardShortcut");
24+
inline static const auto SHOW_WELCOME_SCREEN = QStringLiteral("showWelcomeScreen");
2425
};
2526

2627
/// AppConfig is a singleton for accessing the application's configuration.
@@ -102,5 +103,6 @@ class AppConfig : public QObject
102103
CONFIG::COMMAND_CAPTUREWINDOW,
103104
CONFIG::SHORTCUT_CAPTUREWINDOW,
104105
CONFIG::SHORTCUT_CAPTURECLIPBOARD,
106+
CONFIG::SHOW_WELCOME_SCREEN,
105107
};
106108
};

src/forms/CMakeLists.txt

+14
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@ add_library (FORMS STATIC
99
getinfo/getinfo.cpp getinfo/getinfo.h
1010
porting/porting_dialog.cpp porting/porting_dialog.h
1111
settings/settings.cpp settings/settings.h
12+
firstRunWizard/firstTimeWizard.h firstRunWizard/firstTimeWizard.cpp
13+
firstRunWizard/welcomepage.h firstRunWizard/welcomepage.cpp
14+
firstRunWizard/wizardpage.h firstRunWizard/wizardpage.cpp
15+
firstRunWizard/requirementspage.h firstRunWizard/requirementspage.cpp
16+
firstRunWizard/evidencepage.h firstRunWizard/evidencepage.cpp
17+
firstRunWizard/apikeyspage.h firstRunWizard/apikeyspage.cpp
18+
firstRunWizard/hostpathpage.h firstRunWizard/hostpathpage.cpp
19+
firstRunWizard/hosttestpage.h firstRunWizard/hosttestpage.cpp
20+
firstRunWizard/captureareapage.h firstRunWizard/captureareapage.cpp
21+
firstRunWizard/capturewindowpage.h firstRunWizard/capturewindowpage.cpp
22+
firstRunWizard/captureclipboardpage.h firstRunWizard/captureclipboardpage.cpp
23+
firstRunWizard/opspage.h firstRunWizard/opspage.cpp
24+
firstRunWizard/finishedpage.h firstRunWizard/finishedpage.cpp
1225
)
1326

1427
add_library(ASHIRT::FORMS ALIAS FORMS)
@@ -26,6 +39,7 @@ target_link_libraries ( FORMS
2639
Qt::Gui
2740
Qt::Widgets
2841
Qt::Sql
42+
Qt::Svg
2943
ASHIRT::HELPERS
3044
ASHIRT::MODELS
3145
ASHIRT::COMPONENTS
+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
#include "apikeyspage.h"
2+
3+
#include <QFileDialog>
4+
#include <QLabel>
5+
#include <QLineEdit>
6+
#include <QPushButton>
7+
#include <QVBoxLayout>
8+
#include <appconfig.h>
9+
10+
bool ApiKeysPage::validatePage()
11+
{
12+
if (!field("host.accessKey").isValid())
13+
return false;
14+
15+
if (!field("host.secretKey").isValid())
16+
return false;
17+
18+
return true;
19+
}
20+
21+
void ApiKeysPage::initializePage()
22+
{
23+
QString accessKey = AppConfig::value(CONFIG::ACCESSKEY);
24+
setField("host.accessKey", accessKey);
25+
accessKeyLine->setText(accessKey);
26+
27+
QString secretKey = AppConfig::value(CONFIG::SECRETKEY);
28+
setField("host.secretKey", secretKey);
29+
secretKeyLine->setText(secretKey);
30+
}
31+
32+
ApiKeysPage::ApiKeysPage(QWidget *parent)
33+
: WizardPage{Page_Api, parent}
34+
{
35+
36+
auto f = font();
37+
auto _lblTitleLabel = new QLabel(this);
38+
f.setPointSize(titleFont.first);
39+
f.setWeight(titleFont.second);
40+
_lblTitleLabel->setFont(f);
41+
_lblTitleLabel->setText(tr("API Keys"));
42+
43+
auto _lblSubtitle = new QLabel(this);
44+
f.setPointSize(subTitleFont.first);
45+
f.setWeight(subTitleFont.second);
46+
_lblSubtitle->setFont(f);
47+
_lblSubtitle->setWordWrap(true);
48+
_lblSubtitle->setText(tr("Input Api keys for the server"));
49+
50+
auto _lblBody = new QLabel(this);
51+
f.setPointSize(bodyFont.first);
52+
f.setWeight(bodyFont.second);
53+
_lblBody->setFont(f);
54+
_lblBody->setWordWrap(true);
55+
_lblBody->setText(tr("• Login to the Ashirt server click the profile icon in the top right then select <i>Account Settings</i><br>"));
56+
57+
auto _lblBody2 = new QLabel(this);
58+
_lblBody2->setFont(f);
59+
_lblBody2->setWordWrap(true);
60+
_lblBody2->setText(tr("• Select <i>API Keys</i> on the left, select click <i>Generate New API Key</i><br>"));
61+
62+
auto _lblBody3 = new QLabel(this);
63+
_lblBody3->setFont(f);
64+
_lblBody3->setWordWrap(true);
65+
_lblBody3->setText(tr("• Enter your keys below"));
66+
67+
auto _lblAKey = new QLabel(this);
68+
f.setPointSize(smallFont.first);
69+
f.setWeight(smallFont.second);
70+
_lblAKey->setFont(f);
71+
_lblAKey->setText(tr("Access Key"));
72+
73+
accessKeyLine = new QLineEdit(this);
74+
accessKeyLine->setMaxLength(24);
75+
accessKeyLine->setTextMargins(3,0,3,0);
76+
accessKeyLine->setMaximumWidth(fontMetrics().averageCharWidth() * 27);
77+
registerField("host.accessKey*", accessKeyLine);
78+
79+
auto t1 = new QVBoxLayout();
80+
t1->setSpacing(1);
81+
t1->addWidget(_lblAKey);
82+
t1->addWidget(accessKeyLine);
83+
84+
auto _lblBKey = new QLabel(this);
85+
f.setPointSize(smallFont.first);
86+
f.setWeight(smallFont.second);
87+
_lblBKey->setFont(f);
88+
_lblBKey->setText(tr("Secret Key"));
89+
90+
secretKeyLine = new QLineEdit(this);
91+
secretKeyLine->setTextMargins(3,0,3,0);
92+
registerField("host.secretKey*", secretKeyLine);
93+
94+
auto t2 = new QVBoxLayout();
95+
t2->setSpacing(1);
96+
t2->addWidget(_lblBKey);
97+
t2->addWidget(secretKeyLine);
98+
99+
auto tLayout = new QHBoxLayout();
100+
tLayout->addLayout(t1);
101+
tLayout->addLayout(t2);
102+
103+
auto layout = new QVBoxLayout();
104+
layout->addWidget(_lblTitleLabel);
105+
layout->addWidget(_lblSubtitle);
106+
layout->addSpacerItem(new QSpacerItem(0,30,QSizePolicy::Minimum, QSizePolicy::Fixed));
107+
layout->addWidget(_lblBody);
108+
layout->addWidget(_lblBody2);
109+
layout->addWidget(_lblBody3);
110+
layout->addSpacerItem(new QSpacerItem(0,30,QSizePolicy::Minimum, QSizePolicy::Fixed));
111+
layout->addLayout(tLayout);
112+
layout->addSpacerItem(new QSpacerItem(0,0,QSizePolicy::Minimum, QSizePolicy::Expanding));
113+
setLayout(layout);
114+
}
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#pragma once
2+
3+
#include "wizardpage.h"
4+
#include <QObject>
5+
6+
class QLineEdit;
7+
class ApiKeysPage : public WizardPage
8+
{
9+
Q_OBJECT
10+
public:
11+
bool validatePage() override;
12+
void initializePage() override;
13+
ApiKeysPage(QWidget *parent = nullptr);
14+
private:
15+
QLineEdit * accessKeyLine = nullptr;
16+
QLineEdit * secretKeyLine = nullptr;
17+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#include "captureareapage.h"
2+
3+
#include <QFileDialog>
4+
#include <QLabel>
5+
#include <QLineEdit>
6+
#include <QPushButton>
7+
#include <QVBoxLayout>
8+
#include <appconfig.h>
9+
10+
#include "hotkeymanager.h"
11+
#include "components/custom_keyseq_edit/singlestrokekeysequenceedit.h"
12+
13+
bool CaptureAreaPage::validatePage()
14+
{
15+
if(!field("command.area").isValid())
16+
return false;
17+
AppConfig::setValue(CONFIG::COMMAND_SCREENSHOT, field("command.area").toString());
18+
19+
if(!field("keySequence.area").isValid())
20+
return false;
21+
auto keyCombo = QKeySequence::fromString(field("keySequence.area").toString(), QKeySequence::NativeText);
22+
AppConfig::setValue(CONFIG::SHORTCUT_SCREENSHOT, keyCombo.toString(QKeySequence::PortableText));
23+
HotkeyManager::updateHotkeys();
24+
return true;
25+
}
26+
27+
void CaptureAreaPage::initializePage()
28+
{
29+
HotkeyManager::unregisterKey(HotkeyManager::ACTION_CAPTURE_AREA);
30+
QString captureAreaCommand = AppConfig::value(CONFIG::COMMAND_SCREENSHOT);
31+
if(!captureAreaCommand.isEmpty()) {
32+
setField("command.area", captureAreaCommand);
33+
captureAreaLine->setText(captureAreaCommand);
34+
}
35+
36+
QString sequence = AppConfig::value(CONFIG::SHORTCUT_SCREENSHOT);
37+
if(!sequence.isEmpty()) {
38+
setField("keySequence.area", sequence);
39+
captureAreaKeySequenceEdit->setKeySequence(QKeySequence::fromString(sequence));
40+
}
41+
}
42+
43+
void CaptureAreaPage::cleanupPage()
44+
{
45+
HotkeyManager::updateHotkeys();
46+
}
47+
48+
CaptureAreaPage::CaptureAreaPage(QWidget *parent)
49+
: WizardPage{Page_CaptureArea, parent}
50+
{
51+
auto f = font();
52+
auto _lblTitleLabel = new QLabel(this);
53+
f.setPointSize(titleFont.first);
54+
f.setWeight(titleFont.second);
55+
_lblTitleLabel->setFont(f);
56+
_lblTitleLabel->setText(tr("Capture Area"));
57+
58+
auto _lblSubtitle = new QLabel(this);
59+
f.setPointSize(subTitleFont.first);
60+
f.setWeight(subTitleFont.second);
61+
_lblSubtitle->setFont(f);
62+
_lblSubtitle->setWordWrap(true);
63+
_lblSubtitle->setText(tr("Set the capture area command and shortcut."));
64+
65+
auto _lblB1 = new QLabel(this);
66+
f.setPointSize(bodyFont.first);
67+
f.setWeight(bodyFont.second);
68+
_lblB1->setFont(f);
69+
_lblB1->setText(tr("<html><br><br>• Enter the command ashirt will use to capture area screenshots<br><br>• Enter a key combination that will trigger the capture area command<html>"));
70+
71+
auto hLayout = new QHBoxLayout();
72+
hLayout->addWidget(_lblB1, 0, Qt::AlignHCenter);
73+
74+
auto _lblAKey = new QLabel(this);
75+
f.setPointSize(smallFont.first);
76+
f.setWeight(smallFont.second);
77+
_lblAKey->setFont(f);
78+
_lblAKey->setText(tr("Capture Area Command"));
79+
80+
captureAreaLine = new QLineEdit(this);
81+
captureAreaLine->setTextMargins(3,0,3,0);
82+
registerField("command.area*", captureAreaLine);
83+
84+
auto t1 = new QVBoxLayout();
85+
t1->setSpacing(1);
86+
t1->addWidget(_lblAKey);
87+
t1->addWidget(captureAreaLine);
88+
89+
auto _lblBKey = new QLabel(this);
90+
f.setPointSize(smallFont.first);
91+
f.setWeight(smallFont.second);
92+
_lblBKey->setFont(f);
93+
_lblBKey->setText(tr("Shortcut"));
94+
95+
captureAreaKeySequenceEdit = new SingleStrokeKeySequenceEdit(this);
96+
registerField("keySequence.area*", captureAreaKeySequenceEdit, "keySequence", SIGNAL(keySequenceChanged(const QKeySequence &)));
97+
98+
auto t2 = new QVBoxLayout();
99+
t2->setSpacing(1);
100+
t2->addWidget(_lblBKey);
101+
t2->addWidget(captureAreaKeySequenceEdit);
102+
103+
auto tLayout = new QHBoxLayout();
104+
tLayout->addLayout(t1, 8);
105+
tLayout->addLayout(t2, 2);
106+
107+
auto layout = new QVBoxLayout();
108+
layout->addWidget(_lblTitleLabel);
109+
layout->addWidget(_lblSubtitle);
110+
layout->addLayout(hLayout);
111+
layout->addSpacerItem(new QSpacerItem(0,60,QSizePolicy::Minimum, QSizePolicy::Fixed));
112+
layout->addLayout(tLayout);
113+
layout->addSpacerItem(new QSpacerItem(0,0,QSizePolicy::Minimum, QSizePolicy::Expanding));
114+
setLayout(layout);
115+
}
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#pragma once
2+
3+
#include "wizardpage.h"
4+
#include <QObject>
5+
6+
class QLineEdit;
7+
class SingleStrokeKeySequenceEdit;
8+
class CaptureAreaPage : public WizardPage
9+
{
10+
Q_OBJECT
11+
public:
12+
bool validatePage() override;
13+
void initializePage() override;
14+
void cleanupPage() override;
15+
CaptureAreaPage(QWidget *parent = nullptr);
16+
private:
17+
QLineEdit *captureAreaLine = nullptr;
18+
SingleStrokeKeySequenceEdit *captureAreaKeySequenceEdit = nullptr;
19+
};

0 commit comments

Comments
 (0)