aboutsummaryrefslogtreecommitdiff
path: root/src/subwindow/subwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/subwindow/subwindow.cpp')
-rw-r--r--src/subwindow/subwindow.cpp38
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);
}