aboutsummaryrefslogtreecommitdiff
path: root/src/mainwindow/mainwindow.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-04-17 16:37:25 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2018-04-17 16:37:25 +0200
commit5152fc15d128821b842ade2c8fa7e2fcb16c0e94 (patch)
tree446658345a873ede716006bfe10d0470b8181aa8 /src/mainwindow/mainwindow.cpp
parentClear navigation bar and address bar when last subwindow is closed (diff)
downloadsmolbote-5152fc15d128821b842ade2c8fa7e2fcb16c0e94.tar.xz
Search box works again
Diffstat (limited to 'src/mainwindow/mainwindow.cpp')
-rw-r--r--src/mainwindow/mainwindow.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp
index b68ddbe..9b1db30 100644
--- a/src/mainwindow/mainwindow.cpp
+++ b/src/mainwindow/mainwindow.cpp
@@ -24,6 +24,8 @@
#include <about/aboutdialog.h>
#include <configuration/configuration.h>
#include "addressbar/addressbar.h"
+#include <QStatusBar>
+#include "widgets/searchform.h"
MainWindow::MainWindow(std::shared_ptr<Configuration> &config, QWidget *parent)
: QMainWindow(parent)
@@ -54,10 +56,17 @@ MainWindow::MainWindow(std::shared_ptr<Configuration> &config, QWidget *parent)
setCentralWidget(mdiArea);
mdiArea->setFocus();
+ // status bar
+ searchBox = new SearchForm(this);
+ statusBar()->addPermanentWidget(searchBox);
+ searchBox->setVisible(false);
+
+ // connect signlas
connect(mdiArea, &QMdiArea::subWindowActivated, this, [this, navigationToolBar](QMdiSubWindow *window) {
disconnect(titleChangedConnection);
disconnect(addressBarConnection);
disconnect(navigationBarConnection);
+ disconnect(searchBoxConnection);
auto *w = qobject_cast<Window *>(window);
if(w == nullptr) {
@@ -65,6 +74,7 @@ MainWindow::MainWindow(std::shared_ptr<Configuration> &config, QWidget *parent)
setWindowTitle(tr("smolbote"));
addressBar->connectWebView(nullptr);
navigationToolBar->connectWebView(nullptr);
+ searchBox->setView(nullptr);
} else {
setWindowTitle(w->windowTitle() + titleSuffix);
titleChangedConnection = connect(w, &Window::windowTitleChanged, this, [this](const QString &title) {
@@ -75,13 +85,20 @@ MainWindow::MainWindow(std::shared_ptr<Configuration> &config, QWidget *parent)
addressBarConnection = connect(w, &Window::currentViewChanged, addressBar, &AddressBar::connectWebView);
navigationToolBar->connectWebView(w->currentView());
navigationBarConnection = connect(w, &Window::currentViewChanged, navigationToolBar, &NavigationBar::connectWebView);
+ searchBox->setView(w->currentView());
+ searchBoxConnection = connect(w, &Window::currentViewChanged, searchBox, &SearchForm::setView);
}
});
auto *tileShortcut = new QShortcut(QKeySequence(config->value<std::string>("mainwindow.shortcuts.tileWindows").value().c_str()), this);
- connect(tileShortcut, &QShortcut::activated, this, [this]() {
+ connect(tileShortcut, &QShortcut::activated, this, [=]() {
mdiArea->tileSubWindows();
});
+
+ auto *searchShortcut = new QShortcut(QKeySequence(config->value<std::string>("mainwindow.shortcuts.search").value().c_str()), this);
+ connect(searchShortcut, &QShortcut::activated, this, [=]() {
+ searchBox->setVisible(!searchBox->isVisible());
+ });
}
MainWindow::~MainWindow()
@@ -89,6 +106,7 @@ MainWindow::~MainWindow()
disconnect(titleChangedConnection);
disconnect(addressBarConnection);
disconnect(navigationBarConnection);
+ disconnect(searchBoxConnection);
}
void MainWindow::createMenuBar()