Skip to content

Commit f4e8945

Browse files
committed
chore: code tidy
replaced emit with Q_EMIT replaced signals: & slots: in class definitions, each function definition now has either a Q_SIGNAL or Q_SLOT prefix started work on Cloner, embeds nodejs into the application to allow easy grabbing and parsing of html/css/javascript files
1 parent 3b486bb commit f4e8945

17 files changed

+203
-29
lines changed

.github/semantic.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
titleOnly: true
2+
allowMergeCommits: false
3+
allowRevertCommits: false
4+
types:
5+
- feat
6+
- fix
7+
- docs
8+
- style
9+
- refactor
10+
- perf
11+
- test
12+
- build
13+
- ci
14+
- chore
15+
- revert
16+
- repo
17+
- wip
18+
- merge

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ deployment
55
tools
66
assets/dmg_background.tiff
77
*.autosave
8+
9+
libnode/

CMakeLists.txt

+10
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ set(APPLICATION_SOURCES
132132
GeneralSettingsPage.cpp
133133
GeneralSettingsPage.h
134134
GeneralSettingsPage.ui
135+
Cloner.cpp
136+
Cloner.h
135137
)
136138

137139
# List of Qt libraries used by the application
@@ -231,6 +233,14 @@ if(APPLE)
231233
set(APPLICATION_BUNDLE_SCHEME "${APPLICATION_SHORT_NAME}")
232234
endif()
233235

236+
# nodejs static libration
237+
238+
if(EXISTS ${APPLICATON_SOURCE_ROOT}/libnode)
239+
target_include_directories(${APPLICATION_SHORT_NAME} PRIVATE "${APPLICATON_SOURCE_ROOT}/libnode/include")
240+
list(APPEND APPLICATION_QT_LINK_LIBRARIES "-L${APPLICATON_SOURCE_ROOT}/libnode/lib")
241+
list(APPEND APPLICATION_QT_LINK_LIBRARIES "node")
242+
endif()
243+
234244
# cocoa frameworks
235245

236246
if(APPLE)

Cloner.cpp

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright (C) 2020 Adrian Carpenter
3+
*
4+
* This file is part of a regex101.com offline application.
5+
*
6+
* https://github.com/fizzyade/regex101
7+
*
8+
* =====================================================================
9+
* The regex101 web content is owned and used with permission from
10+
* Firas Dib at regex101.com. This application is an unofficial
11+
* tool to provide an offline application version of the website.
12+
* =====================================================================
13+
*
14+
* This program is free software: you can redistribute it and/or modify
15+
* it under the terms of the GNU General Public License as published by
16+
* the Free Software Foundation, either version 3 of the License, or
17+
* (at your option) any later version.
18+
*
19+
* This program is distributed in the hope that it will be useful,
20+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
* GNU General Public License for more details.
23+
*
24+
* You should have received a copy of the GNU General Public License
25+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
26+
*/
27+
28+
#include "Cloner.h"
29+
/*#include "node.h"
30+
31+
#include <QDebug>
32+
33+
using node::ArrayBufferAllocator;
34+
using node::Environment;
35+
using node::IsolateData;
36+
using node::MultiIsolatePlatform;
37+
using v8::Context;
38+
using v8::HandleScope;
39+
using v8::Isolate;
40+
using v8::Local;
41+
using v8::Locker;
42+
using v8::MaybeLocal;
43+
using v8::SealHandleScope;
44+
using v8::V8;
45+
using v8::Value;
46+
*/
47+
Nedrysoft::Cloner::Cloner()
48+
{
49+
/* argv = uv_setup_args(0, 0);
50+
51+
std::vector<std::string> args(argv, argv + argc);
52+
std::vector<std::string> exec_args;
53+
std::vector<std::string> errors;
54+
55+
int exit_code = node::InitializeNodeWithArgs(&args, &exec_args, &errors);
56+
57+
for (const std::string& error : errors) {
58+
qDebug() << error.c_str());
59+
}
60+
61+
if (exit_code != 0) {
62+
qDebug() << "error:" << exit_code;
63+
}
64+
65+
std::unique_ptr<MultiIsolatePlatform> platform = MultiIsolatePlatform::Create(4);
66+
67+
V8::InitializePlatform(platform.get());
68+
V8::Initialize();*/
69+
}

Cloner.h

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright (C) 2020 Adrian Carpenter
3+
*
4+
* This file is part of a regex101.com offline application.
5+
*
6+
* https://github.com/fizzyade/regex101
7+
*
8+
* =====================================================================
9+
* The regex101 web content is owned and used with permission from
10+
* Firas Dib at regex101.com. This application is an unofficial
11+
* tool to provide an offline application version of the website.
12+
* =====================================================================
13+
*
14+
* This program is free software: you can redistribute it and/or modify
15+
* it under the terms of the GNU General Public License as published by
16+
* the Free Software Foundation, either version 3 of the License, or
17+
* (at your option) any later version.
18+
*
19+
* This program is distributed in the hope that it will be useful,
20+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
* GNU General Public License for more details.
23+
*
24+
* You should have received a copy of the GNU General Public License
25+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
26+
*/
27+
28+
#ifndef CLONER_H
29+
#define CLONER_H
30+
31+
namespace Nedrysoft {
32+
/**
33+
* @brief Clones the regex101.com
34+
*
35+
* @details Downloads all the required files from the regex101.com site,
36+
* this involves searching through each file that is downloaded to find any
37+
* other dependencies that are required.
38+
*
39+
* The purpose of this is to allow users to update to a later verison of the
40+
* regex101.com application, although they do this at their own risk as newer version
41+
* may have changes that break the url handler.
42+
*/
43+
class Cloner
44+
{
45+
public:
46+
/**
47+
* @brief Constructor
48+
*
49+
* @details Constructs a Cloner instance
50+
*/
51+
Cloner();
52+
};
53+
}
54+
55+
#endif // CLONER_H

MainWindow.h

+9-8
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ namespace Nedrysoft {
4444
*
4545
* @details Provides the main window for the application.
4646
*/
47-
class MainWindow : public QMainWindow {
47+
class MainWindow :
48+
public QMainWindow
49+
{
4850
private:
4951
Q_OBJECT
5052

@@ -83,9 +85,9 @@ namespace Nedrysoft {
8385
*
8486
* @param[in] closeEvent contains the information about the event including accpt/regect functions
8587
*/
86-
virtual void closeEvent(QCloseEvent *closeEvent);
88+
virtual void closeEvent(QCloseEvent *closeEvent) override;
8789

88-
private slots:
90+
private:
8991
/**
9092
* @brief Event filter mathod
9193
*
@@ -98,29 +100,28 @@ namespace Nedrysoft {
98100
*
99101
* @returns true if the event is handled; otherwise false.
100102
*/
101-
bool eventFilter(QObject *obj, QEvent *event);
103+
Q_SLOT bool eventFilter(QObject *obj, QEvent *event);
102104

103-
private slots:
104105
/**
105106
* @brief About slot function.
106107
*
107108
* @details This slot is called when the About action is triggered, the about dialog is displayed.
108109
*/
109-
void on_actionAbout_triggered();
110+
Q_SLOT void on_actionAbout_triggered();
110111

111112
/**
112113
* @brief Exit slot function.
113114
*
114115
* @details This slot is called when the Exit action is triggered, the application is closed.
115116
*/
116-
void on_actionExit_triggered();
117+
Q_SLOT void on_actionExit_triggered();
117118

118119
/**
119120
* @brief Preferences action triggered function
120121
*
121122
* @details This slot is called when the preferences action is triggered
122123
*/
123-
void on_actionPreferences_triggered();
124+
Q_SLOT void on_actionPreferences_triggered();
124125

125126
private:
126127
Ui::MainWindow *ui; //! ui class for the main window

RegExAboutDialog.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ namespace Nedrysoft {
3737
*
3838
* @details A dialog box that shows details about the application.
3939
*/
40-
class RegExAboutDialog : public QDialog {
40+
class RegExAboutDialog :
41+
public QDialog
42+
{
4143
private:
4244
Q_OBJECT
4345

RegExApiEndpoint.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ namespace Nedrysoft {
4242
*
4343
* @details Provides functions that can be called from javascript in the web browser.
4444
*/
45-
class RegExApiEndpoint : public QObject {
45+
class RegExApiEndpoint :
46+
public QObject
47+
{
4648
private:
4749
Q_OBJECT
4850

@@ -147,8 +149,8 @@ namespace Nedrysoft {
147149
* @param[in] message contains the message received.
148150
*/
149151
Q_INVOKABLE void notifyApplication(QVariant message) const;
150-
private:
151152

153+
private:
152154
/**
153155
* @brief Creates a random string of characters
154156
*

RegExNullWebEnginePage.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ namespace Nedrysoft {
3939
* link target. This class denies the navigation request, but uses the qt desktop services
4040
* to open the link in the system default web browser.
4141
*/
42-
class RegExNullWebEnginePage : public QWebEnginePage {
42+
class RegExNullWebEnginePage :
43+
public QWebEnginePage
44+
{
4345
private:
4446
Q_OBJECT
4547

@@ -61,7 +63,7 @@ namespace Nedrysoft {
6163
*
6264
* @returns true if the navigation is allowed; otherwise false.
6365
*/
64-
bool acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame);
66+
bool acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame) override;
6567
};
6668
}
6769
#endif // REGEXNULLWEBENGINEPAGE_H

RegExSplashScreen.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ namespace Nedrysoft {
3838
*
3939
* @details A dialog box that provides a custom splash screen.
4040
*/
41-
class RegExSplashScreen : public QSplashScreen {
41+
class RegExSplashScreen :
42+
public QSplashScreen
43+
{
4244
private:
4345
Q_OBJECT
4446

@@ -62,7 +64,7 @@ namespace Nedrysoft {
6264
*
6365
* @param[in] painter is the painter to draw to.
6466
*/
65-
virtual void drawContents(QPainter *painter);
67+
virtual void drawContents(QPainter *painter) override;
6668
};
6769
}
6870

RegExUrlRequestInterceptor.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ namespace Nedrysoft {
3838
* blocks all requests that are not aimed at the custom scheme so ensure that the
3939
* application is completely standalone.
4040
*/
41-
class RegExUrlRequestInterceptor : public QWebEngineUrlRequestInterceptor {
41+
class RegExUrlRequestInterceptor :
42+
public QWebEngineUrlRequestInterceptor
43+
{
4244
private:
4345
Q_OBJECT
4446

@@ -50,7 +52,7 @@ namespace Nedrysoft {
5052
*
5153
* @param[in] info is an object that contains HTTP request parameters.
5254
*/
53-
void interceptRequest(QWebEngineUrlRequestInfo &info);
55+
void interceptRequest(QWebEngineUrlRequestInfo &info) override;
5456
};
5557
}
5658

RegExUrlSchemeHandler.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ namespace Nedrysoft {
4040
* with the RefExUrlRequestInterceptor and RegExApiEndpoint classes to provide
4141
* a full implementation.
4242
*/
43-
class RegExUrlSchemeHandler : public QWebEngineUrlSchemeHandler {
43+
class RegExUrlSchemeHandler :
44+
public QWebEngineUrlSchemeHandler
45+
{
4446
private:
4547
Q_OBJECT
4648

@@ -100,7 +102,6 @@ namespace Nedrysoft {
100102
static QString root();
101103

102104
protected:
103-
104105
/**
105106
* @brief setInitialState
106107
*

RegExWebEnginePage.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ namespace Nedrysoft {
4242
* @details This subclass provides a web page that is set up to use the handlers,
4343
* interceptors and web channels.
4444
*/
45-
class RegExWebEnginePage : public QWebEnginePage {
45+
class RegExWebEnginePage :
46+
public QWebEnginePage
47+
{
4648
private:
4749
Q_OBJECT
4850

RegExWebEngineProfile.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ namespace Nedrysoft {
3838
* @details Provides a profile which is set up to handle the custom scheme with
3939
* appropriate security levels.
4040
*/
41-
class RegExWebEngineProfile : public QWebEngineProfile {
41+
class RegExWebEngineProfile :
42+
public QWebEngineProfile
43+
{
4244
private:
4345
Q_OBJECT
4446

SettingsDialog.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ bool Nedrysoft::SettingsDialog::close()
246246
page->m_pageSettings->acceptSettings();
247247
}
248248
#endif
249-
emit closed();
249+
Q_EMIT closed();
250250

251251
return QWidget::close();
252252
}

0 commit comments

Comments
 (0)