aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/AsyncEventLoop.cpp6
-rw-r--r--src/AsyncEventLoop.hpp1
-rw-r--r--src/LuaRuntime.cpp16
-rw-r--r--src/LuaRuntime.hpp2
-rw-r--r--src/keymap/KeySeqParser.hpp4
-rw-r--r--src/keymap/KeymapEvaluator.cpp4
-rw-r--r--src/widgets/MainWindow.cpp2
-rw-r--r--src/widgets/WebViewStack.cpp20
-rw-r--r--src/widgets/WebViewStack.hpp8
9 files changed, 33 insertions, 30 deletions
diff --git a/src/AsyncEventLoop.cpp b/src/AsyncEventLoop.cpp
index 360a45e..31be89c 100644
--- a/src/AsyncEventLoop.cpp
+++ b/src/AsyncEventLoop.cpp
@@ -1,7 +1,9 @@
#include <QtCore>
#include <functional>
#include <mutex>
+#include <queue>
#include <thread>
+#include <utility>
#include <uv.h>
#include "AsyncEventLoop.hpp"
@@ -63,7 +65,7 @@ AsyncEventLoop::~AsyncEventLoop() {
uv_stop(loop);
// Close all handles
- AsyncEventLoop::closeHandle((uv_handle_t *)&asyncHandle);
+ AsyncEventLoop::closeHandle(reinterpret_cast<uv_handle_t *>(&asyncHandle));
uv_walk(loop, AsyncEventLoop::closeHandle, nullptr);
while (uv_run(loop, UV_RUN_ONCE) != 0)
;
@@ -87,7 +89,7 @@ void AsyncEventLoop::asyncHandleCallback(uv_async_t *handle) {
runtime->processTasks();
}
-void AsyncEventLoop::closeHandle(uv_handle_t *handle, void *arg) {
+void AsyncEventLoop::closeHandle(uv_handle_t *handle, void *) {
if (!uv_is_closing(handle)) {
uv_close(handle, [](uv_handle_t *h) { h->data = nullptr; });
}
diff --git a/src/AsyncEventLoop.hpp b/src/AsyncEventLoop.hpp
index ebe2cad..29c2958 100644
--- a/src/AsyncEventLoop.hpp
+++ b/src/AsyncEventLoop.hpp
@@ -5,6 +5,7 @@
#include <mutex>
#include <queue>
#include <thread>
+#include <utility>
#include <uv.h>
#include "utils.hpp"
diff --git a/src/LuaRuntime.cpp b/src/LuaRuntime.cpp
index f83ee48..cdf95b0 100644
--- a/src/LuaRuntime.cpp
+++ b/src/LuaRuntime.cpp
@@ -18,7 +18,7 @@ LuaRuntime::LuaRuntime() {
luaL_Reg weblib[] = {
{"open", &LuaRuntime::lua_onUrlOpen},
{"tabopen", &LuaRuntime::lua_onUrlTabOpen},
- {NULL, NULL},
+ {nullptr, nullptr},
};
luaL_newlib(state, weblib);
lua_setglobal(state, web_global_name);
@@ -60,13 +60,13 @@ void LuaRuntime::stopEventLoop() {
void LuaRuntime::evaluate(QString code) {
eventLoop->queueTask([this, code]() {
if (luaL_dostring(state, code.toStdString().c_str()) != LUA_OK) {
- auto value = lua_tostring(state, -1);
+ const char *value = lua_tostring(state, -1);
lua_pop(state, 1);
qDebug() << "Lua Error: " << value;
emit evaluationFailed(value);
} else {
- auto value = getValue(-1);
+ QVariant value = getValue(-1);
lua_pop(state, 1);
qDebug() << "result: " << value;
@@ -76,7 +76,7 @@ void LuaRuntime::evaluate(QString code) {
}
QVariant LuaRuntime::evaluateSync(QString code) {
- auto result = luaL_dostring(state, code.toStdString().c_str());
+ luaL_dostring(state, code.toStdString().c_str());
return getValue(-1); // TODO: error handling
}
@@ -113,25 +113,21 @@ int LuaRuntime::lua_onUrlTabOpen(lua_State *state) {
int LuaRuntime::lua_addKeymap(lua_State *state) {
const char *mode = lua_tostring(state, 1);
const char *keyseq = lua_tostring(state, 2);
- qDebug() << "Adduing" << mode << keyseq;
-
- qDebug() << "---" << lua_isfunction(state, 3);
lua_pushvalue(state, 3);
int functionRef = luaL_ref(state, LUA_REGISTRYINDEX);
auto action = [state, functionRef]() {
- qDebug() << "Hello";
+ qDebug() << "key action";
lua_rawgeti(state, LUA_REGISTRYINDEX, functionRef);
if (lua_pcall(state, 0, 0, 0) != LUA_OK) {
const char *error = lua_tostring(state, -1);
qDebug() << "Error calling Lua function:" << error;
lua_pop(state, 1);
- } else {
- qDebug() << "Done";
}
lua_pop(state, 1);
};
+ // TODO: Cleanup function ref on after keymap clear
auto runtime = LuaRuntime::instance();
emit runtime->keymapAddRequested(mode, keyseq, action);
diff --git a/src/LuaRuntime.hpp b/src/LuaRuntime.hpp
index 6c45ca5..9f672e9 100644
--- a/src/LuaRuntime.hpp
+++ b/src/LuaRuntime.hpp
@@ -19,7 +19,7 @@ public:
void evaluate(QString code);
QVariant evaluateSync(QString code);
- void loadFile(QString code);
+ void loadFile(QString path);
void stopEventLoop();
void startEventLoop();
diff --git a/src/keymap/KeySeqParser.hpp b/src/keymap/KeySeqParser.hpp
index fac2546..2dad0c7 100644
--- a/src/keymap/KeySeqParser.hpp
+++ b/src/keymap/KeySeqParser.hpp
@@ -20,8 +20,8 @@ enum KeyMatchType {
class KeySeqParser {
public:
- static const KeyMatchType keySequenceMatch(const KeySequence target,
- const KeySequence current) {
+ static KeyMatchType keySequenceMatch(const KeySequence target,
+ const KeySequence current) {
for (int i = 0; i < target.length(); i++) {
if (current.length() <= i)
return KeyMatchType::Pending;
diff --git a/src/keymap/KeymapEvaluator.cpp b/src/keymap/KeymapEvaluator.cpp
index b20aeda..692317b 100644
--- a/src/keymap/KeymapEvaluator.cpp
+++ b/src/keymap/KeymapEvaluator.cpp
@@ -14,7 +14,7 @@ void KeymapEvaluator::addKeymap(KeyMode mode, QString key, KeyAction action) {
qDebug() << " " << mode << key;
auto keySeq = keySeqParser.parse(key);
- modalKeys[mode].append((KeyMap){.keySequence = keySeq, .action = action});
+ modalKeys[mode].append(KeyMap{.keySequence = keySeq, .action = action});
}
bool KeymapEvaluator::evaluate(Qt::KeyboardModifiers modifiers, Qt::Key key) {
@@ -25,7 +25,7 @@ bool KeymapEvaluator::evaluate(Qt::KeyboardModifiers modifiers, Qt::Key key) {
auto keymaps = currentModeKeys();
auto foundPendingMatches = false;
- activeKeySequence.append((KeyChord){.mod = modifiers, .key = key});
+ activeKeySequence.append(KeyChord{.mod = modifiers, .key = key});
for (auto &keymap : *keymaps) {
auto matchType =
diff --git a/src/widgets/MainWindow.cpp b/src/widgets/MainWindow.cpp
index ca572e7..ce03bce 100644
--- a/src/widgets/MainWindow.cpp
+++ b/src/widgets/MainWindow.cpp
@@ -73,7 +73,7 @@ void MainWindow::keyPressEvent(QKeyEvent *event) {
}
}
-bool MainWindow::eventFilter(QObject *object, QEvent *event) {
+bool MainWindow::eventFilter(QObject *, QEvent *event) {
if (event->type() != QEvent::KeyPress)
return false;
diff --git a/src/widgets/WebViewStack.cpp b/src/widgets/WebViewStack.cpp
index f915d9e..fa5d3ab 100644
--- a/src/widgets/WebViewStack.cpp
+++ b/src/widgets/WebViewStack.cpp
@@ -1,11 +1,13 @@
#include <QStackedLayout>
#include <QWebEngineNewWindowRequest>
+#include <algorithm>
+#include <vector>
#include "widgets/WebViewStack.hpp"
WebViewStack::WebViewStack(const Configuration *configuration,
QWebEngineProfile *profile, QWidget *parent)
- : QWidget(parent), profile(profile), configuration(configuration) {
+ : QWidget(parent), configuration(configuration), profile(profile) {
layout = new QStackedLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->setStackingMode(QStackedLayout::StackOne);
@@ -48,11 +50,12 @@ WebView *WebViewStack::createNewWebView(QUrl url, bool focus) {
QList<Tab> WebViewStack::getTabList() {
QList<Tab> urls;
for (auto &view : webViewList)
- urls.append((Tab){.url = view->url().toString(), .title = view->title()});
+ urls.append(Tab{.url = view->url().toString(), .title = view->title()});
return urls;
}
-void WebViewStack::onNewWebViewRequest(QWebEngineNewWindowRequest &request) {
+void WebViewStack::onNewWebViewRequest(
+ const QWebEngineNewWindowRequest &request) {
switch (request.destination()) {
case QWebEngineNewWindowRequest::InNewTab:
createNewWebView(request.requestedUrl(), true);
@@ -83,15 +86,15 @@ void WebViewStack::next() {
void WebViewStack::previous() {
if (webViewList.isEmpty())
return;
- auto index = currentWebViewIndex() - 1;
- auto total = webViewList.length();
+ int index = ((int)currentWebViewIndex()) - 1;
+ qsizetype total = webViewList.length();
index = index < 0 ? total + index : index;
focusWebView(index);
}
void WebViewStack::closeCurrent() { close(currentWebViewIndex()); }
-void WebViewStack::close(long index) {
+void WebViewStack::close(int32_t index) {
if (index < 0 || index >= webViewList.length())
return;
@@ -119,11 +122,12 @@ u_int32_t WebViewStack::currentWebViewIndex() { return layout->currentIndex(); }
u_int32_t WebViewStack::count() { return webViewList.length(); }
-void WebViewStack::focusWebView(long index) {
+void WebViewStack::focusWebView(int32_t index) {
if (webViewList.isEmpty())
return;
- index = std::max((long)0, std::min(index, (long)webViewList.length() - 1));
+ index = std::max((long long)0,
+ std::min((long long)index, webViewList.length() - 1));
layout->setCurrentIndex(index);
}
diff --git a/src/widgets/WebViewStack.hpp b/src/widgets/WebViewStack.hpp
index e5b7ecc..473f699 100644
--- a/src/widgets/WebViewStack.hpp
+++ b/src/widgets/WebViewStack.hpp
@@ -2,7 +2,7 @@
#include <QStackedLayout>
#include <QWebEngineProfile>
-#include <sys/types.h>
+#include <vector>
#include "Configuration.hpp"
#include "widgets/WebView.hpp"
@@ -33,11 +33,11 @@ public:
u_int32_t count();
QUrl currentUrl();
- void focusWebView(long index);
+ void focusWebView(int32_t index);
void next();
void previous();
- void close(long index);
+ void close(int32_t index);
void closeCurrent();
private:
@@ -45,7 +45,7 @@ private:
WebView *createNewWebView(QUrl url, bool focus = false);
private slots:
- void onNewWebViewRequest(QWebEngineNewWindowRequest &request);
+ void onNewWebViewRequest(const QWebEngineNewWindowRequest &request);
private:
const Configuration *configuration;