summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFiliph Sandström <filiph.sandstrom@filfatstudios.com>2022-07-14 06:08:30 +0200
committerAndrew Kaster <andrewdkaster@gmail.com>2022-12-25 07:58:58 -0700
commit91e5b6d4f5508d5c752bb8a54a72884fa9285400 (patch)
tree2f3248a75e39cd1cb639a0aa1f2e402422b0e55f
parenta8380047257cb19885bf23ead9a0a92075d4cbce (diff)
downloadserenity-91e5b6d4f5508d5c752bb8a54a72884fa9285400.zip
Ladybird: Add SettingsDialog stub
-rw-r--r--Ladybird/BrowserWindow.cpp12
-rw-r--r--Ladybird/CMakeLists.txt1
-rw-r--r--Ladybird/SettingsDialog.cpp19
-rw-r--r--Ladybird/SettingsDialog.h21
4 files changed, 53 insertions, 0 deletions
diff --git a/Ladybird/BrowserWindow.cpp b/Ladybird/BrowserWindow.cpp
index 0da3447251..aabdc6cbff 100644
--- a/Ladybird/BrowserWindow.cpp
+++ b/Ladybird/BrowserWindow.cpp
@@ -1,17 +1,22 @@
/*
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2022, Matthew Costa <ucosty@gmail.com>
+ * Copyright (c) 2022, Filiph Sandström <filiph.sandstrom@filfatstudios.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "BrowserWindow.h"
+#include "Settings.h"
+#include "SettingsDialog.h"
#include "WebView.h"
#include <LibCore/EventLoop.h>
#include <QAction>
+#include <QDialog>
#include <QPlainTextEdit>
extern String s_serenity_resource_root;
+extern Browser::Settings* s_settings;
BrowserWindow::BrowserWindow(Core::EventLoop& event_loop)
: m_event_loop(event_loop)
@@ -30,6 +35,10 @@ BrowserWindow::BrowserWindow(Core::EventLoop& event_loop)
new_tab_action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_T));
menu->addAction(new_tab_action);
+ auto* settings_action = new QAction("&Settings");
+ settings_action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Comma));
+ menu->addAction(settings_action);
+
auto* close_current_tab_action = new QAction("Close Current Tab");
close_current_tab_action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_W));
menu->addAction(close_current_tab_action);
@@ -163,6 +172,9 @@ BrowserWindow::BrowserWindow(Core::EventLoop& event_loop)
});
QObject::connect(new_tab_action, &QAction::triggered, this, &BrowserWindow::new_tab);
+ QObject::connect(settings_action, &QAction::triggered, this, [this] {
+ new SettingsDialog(this);
+ });
QObject::connect(quit_action, &QAction::triggered, this, &QMainWindow::close);
QObject::connect(m_tabs_container, &QTabWidget::currentChanged, [this](int index) {
setWindowTitle(QString("%1 - Ladybird").arg(m_tabs_container->tabText(index)));
diff --git a/Ladybird/CMakeLists.txt b/Ladybird/CMakeLists.txt
index aac6c8e19d..e907626c57 100644
--- a/Ladybird/CMakeLists.txt
+++ b/Ladybird/CMakeLists.txt
@@ -54,6 +54,7 @@ set(SOURCES
WebView.cpp
History.cpp
Settings.cpp
+ SettingsDialog.cpp
Tab.cpp
)
diff --git a/Ladybird/SettingsDialog.cpp b/Ladybird/SettingsDialog.cpp
new file mode 100644
index 0000000000..8ffae27c04
--- /dev/null
+++ b/Ladybird/SettingsDialog.cpp
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2022, Filiph Sandström <filiph.sandstrom@filfatstudios.com>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include "SettingsDialog.h"
+
+SettingsDialog::SettingsDialog(QMainWindow* window)
+ : m_window(window)
+{
+ m_layout = new QBoxLayout(QBoxLayout::Direction::TopToBottom, this);
+
+ setWindowTitle("Settings");
+ resize(340, 400);
+ setLayout(m_layout);
+ show();
+ setFocus();
+}
diff --git a/Ladybird/SettingsDialog.h b/Ladybird/SettingsDialog.h
new file mode 100644
index 0000000000..d303202d06
--- /dev/null
+++ b/Ladybird/SettingsDialog.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2022, Filiph Sandström <filiph.sandstrom@filfatstudios.com>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <QBoxLayout>
+#include <QDialog>
+#include <QMainWindow>
+
+#pragma once
+
+class SettingsDialog : public QDialog {
+ Q_OBJECT
+public:
+ explicit SettingsDialog(QMainWindow* window);
+
+private:
+ QBoxLayout* m_layout;
+ QMainWindow* m_window { nullptr };
+};