aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2025-03-16 15:28:00 +0530
committerAkshay Nair <phenax5@gmail.com>2025-03-16 15:29:59 +0530
commit041f8933be28d0fcff1196792f30c5ca3176c155 (patch)
tree5fceaf5844f3312e8db63425c5c25825df594861 /src
parent350d2bd7ccf80b91abdff154344f0ce88080a195 (diff)
downloadnull-browser-041f8933be28d0fcff1196792f30c5ca3176c155.tar.gz
null-browser-041f8933be28d0fcff1196792f30c5ca3176c155.zip
Add configuration class
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp13
-rw-r--r--src/widgets/MainWindow.cpp6
-rw-r--r--src/widgets/WebViewStack.cpp10
3 files changed, 9 insertions, 20 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 3e2e2eb..c6c9a29 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -4,7 +4,6 @@
#include "widgets/MainWindow.hpp"
int main(int argc, char *argv[]) {
- // QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
QApplication app(argc, argv);
MainWindow mainWindow;
@@ -13,15 +12,3 @@ int main(int argc, char *argv[]) {
return app.exec();
}
-
-// auto L = luaL_newstate();
-//
-// luaL_openlibs(L);
-//
-// auto status = luaL_dostring(L, "print(500 + 10 * 3)");
-// if (status) {
-// fprintf(stderr, "Couldn't load file: %s\n", lua_tostring(L, -1));
-// exit(1);
-// }
-// lua_close(L);
-// exit(0);
diff --git a/src/widgets/MainWindow.cpp b/src/widgets/MainWindow.cpp
index e2e54da..289e629 100644
--- a/src/widgets/MainWindow.cpp
+++ b/src/widgets/MainWindow.cpp
@@ -21,7 +21,8 @@ MainWindow::MainWindow() {
centralWidget()->setLayout(layout);
// Web engine
- auto webViewStack = new WebViewStack(new QWebEngineProfile("web-browser"));
+ auto webViewStack = new WebViewStack((const Configuration *)&configuration,
+ new QWebEngineProfile("web-browser"));
layout->addWidget(webViewStack);
// Command input
@@ -44,8 +45,7 @@ void MainWindow::keyPressEvent(QKeyEvent *event) {
inputMediator->showCommandInput("");
} else if (combo.key() == Qt::Key_T &&
combo.keyboardModifiers().testFlag(Qt::ControlModifier)) {
- inputMediator->openUrl(QUrl("https://lite.duckduckgo.com"),
- OpenType::OpenUrlInTab);
+ inputMediator->showTabsInput();
} else if (combo.key() == Qt::Key_J &&
combo.keyboardModifiers().testFlag(Qt::ControlModifier)) {
inputMediator->nextWebView();
diff --git a/src/widgets/WebViewStack.cpp b/src/widgets/WebViewStack.cpp
index b825623..d89db6e 100644
--- a/src/widgets/WebViewStack.cpp
+++ b/src/widgets/WebViewStack.cpp
@@ -4,13 +4,14 @@
#include "widgets/WebViewStack.hpp"
-WebViewStack::WebViewStack(QWebEngineProfile *profile, QWidget *parent)
- : QWidget(parent), profile(profile) {
+WebViewStack::WebViewStack(const Configuration *configuration,
+ QWebEngineProfile *profile, QWidget *parent)
+ : QWidget(parent), profile(profile), configuration(configuration) {
layout = new QStackedLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->setStackingMode(QStackedLayout::StackOne);
- createNewWebView(WebViewStack::NewtabURL, true);
+ createNewWebView(configuration->newTabUrl, true);
}
void WebViewStack::openUrl(QUrl url, OpenType openType) {
@@ -104,7 +105,7 @@ void WebViewStack::close(long index) {
focusWebView(currentWebViewIndex());
if (webViewList.isEmpty()) {
- createNewWebView(WebViewStack::NewtabURL, true);
+ createNewWebView(configuration->newTabUrl, true);
}
}
@@ -116,6 +117,7 @@ std::vector<QUrl> WebViewStack::urls() {
}
u_int32_t WebViewStack::currentWebViewIndex() { return layout->currentIndex(); }
+
u_int32_t WebViewStack::count() { return webViewList.length(); }
void WebViewStack::focusWebView(long index) {