diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-12-13 12:49:28 +0100 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-12-13 13:41:50 +0100 |
commit | 4eedf60d76a047f63b0991eee0b623e9be854c76 (patch) | |
tree | c8b335c8909a309c2bc2765e823bec5da74aa5aa /src/subwindow/subwindow.cpp | |
parent | Fix crash creating ConfigurationEditorPlugin widget (diff) | |
download | smolbote-4eedf60d76a047f63b0991eee0b623e9be854c76.tar.xz |
MainWindow: rework menu bar
Split off menu bar into its own class out of MainWindow
Menu bar now has a 'Find in menus' function
Diffstat (limited to 'src/subwindow/subwindow.cpp')
-rw-r--r-- | src/subwindow/subwindow.cpp | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/src/subwindow/subwindow.cpp b/src/subwindow/subwindow.cpp index 0844f1f..4beba49 100644 --- a/src/subwindow/subwindow.cpp +++ b/src/subwindow/subwindow.cpp @@ -61,18 +61,6 @@ SubWindow::SubWindow(const Configuration *config, QWidget *parent, Qt::WindowFla menu->insertSeparator(firstAction); } - // new tab button - auto *newTab_button = new QToolButton(this); - newTab_button->setIcon(style()->standardIcon(QStyle::SP_FileIcon)); - newTab_button->setToolTip(tr("Add tab")); - newTab_button->setShortcut(QKeySequence(config->value<QString>("subwindow.shortcuts.new").value())); - connect(newTab_button, &QToolButton::clicked, this, [=]() { - auto index = addTab(WebProfile::defaultProfile()->newtab()); - tabWidget->setCurrentIndex(index); - }); - newTab_button->setMenu(tabWidget->createTabMenu(newTab_button)); - tabWidget->setCornerWidget(newTab_button, Qt::TopRightCorner); - // general actions auto *closeTab_shortcut = new QShortcut(QKeySequence(config->value<QString>("subwindow.shortcuts.close").value()), this); connect(closeTab_shortcut, &QShortcut::activated, this, [=]() { @@ -159,8 +147,10 @@ int SubWindow::tabCount() const void SubWindow::setProfile(WebProfile *profile) { - if(profile == nullptr) + if(profile == nullptr) { + setProfile(WebProfile::defaultProfile()); return; + } this->m_profile = profile; for(int i = 0; i < tabWidget->count(); ++i) { @@ -178,13 +168,29 @@ int SubWindow::addTab(const QUrl &url, WebProfile *profile) { Q_CHECK_PTR(m_profile); - auto *view = new WebView((profile == nullptr) ? m_profile : profile, this); - if(!url.isEmpty()) + auto *_profile = (profile == nullptr) ? m_profile : profile; + + auto *view = new WebView(_profile, this); + if(url.isEmpty()) + view->load(_profile->newtab()); + else view->load(url); + return tabWidget->addTab(view); } void SubWindow::setCurrentTab(int index) { - tabWidget->setCurrentIndex(index); + if(index > 0) + tabWidget->setCurrentIndex(index); +} + +int SubWindow::restoreLastTab() +{ + return tabWidget->restoreLastTab(); +} + +void SubWindow::restoreTabMenu(QMenu *menu) +{ + tabWidget->restoreTabMenu(menu); } |