diff --git a/src/plugins/VerticalTabs/verticaltabsplugin.cpp b/src/plugins/VerticalTabs/verticaltabsplugin.cpp index d1159db87..9bacfc9b0 100644 --- a/src/plugins/VerticalTabs/verticaltabsplugin.cpp +++ b/src/plugins/VerticalTabs/verticaltabsplugin.cpp @@ -56,11 +56,14 @@ void VerticalTabsPlugin::init(InitState state, const QString &settingsPath) settings.beginGroup(QSL("VerticalTabs")); m_viewType = static_cast(settings.value(QSL("ViewType"), TabListView).toInt()); m_replaceTabBar = settings.value(QSL("ReplaceTabBar"), false).toBool(); + m_addChildBehavior = static_cast(settings.value(QSL("AddChildBehavior"), AppendChild).toInt()); settings.endGroup(); m_controller = new VerticalTabsController(this); SideBarManager::addSidebar(QSL("VerticalTabs"), m_controller); + setWebTabBehavior(m_addChildBehavior); + connect(mApp->plugins(), &PluginProxy::mainWindowCreated, this, &VerticalTabsPlugin::mainWindowCreated); if (state == LateInitState) { @@ -135,6 +138,24 @@ void VerticalTabsPlugin::setReplaceTabBar(bool replace) settings.setValue(QSL("VerticalTabs/ReplaceTabBar"), m_replaceTabBar); } +VerticalTabsPlugin::AddChildBehavior VerticalTabsPlugin::addChildBehavior() const +{ + return m_addChildBehavior; +} + +void VerticalTabsPlugin::setAddChildBehavior(AddChildBehavior behavior) +{ + if (m_addChildBehavior == behavior) { + return; + } + + m_addChildBehavior = behavior; + setWebTabBehavior(m_addChildBehavior); + + QSettings settings(m_settingsPath, QSettings::IniFormat); + settings.setValue(QSL("VerticalTabs/AddChildBehavior"), m_addChildBehavior); +} + void VerticalTabsPlugin::mainWindowCreated(BrowserWindow *window) { if (window->sideBarManager()->activeSideBar().isEmpty()) { @@ -150,3 +171,8 @@ void VerticalTabsPlugin::setTabBarVisible(bool visible) window->tabWidget()->tabBar()->setForceHidden(!visible); } } + +void VerticalTabsPlugin::setWebTabBehavior(AddChildBehavior behavior) +{ + WebTab::setAddChildBehavior(behavior == AppendChild ? WebTab::AppendChild : WebTab::PrependChild); +} diff --git a/src/plugins/VerticalTabs/verticaltabsplugin.h b/src/plugins/VerticalTabs/verticaltabsplugin.h index a2a37309d..e72504513 100644 --- a/src/plugins/VerticalTabs/verticaltabsplugin.h +++ b/src/plugins/VerticalTabs/verticaltabsplugin.h @@ -50,15 +50,25 @@ public: bool replaceTabBar() const; void setReplaceTabBar(bool replace); + enum AddChildBehavior { + AppendChild, + PrependChild + }; + + AddChildBehavior addChildBehavior() const; + void setAddChildBehavior(AddChildBehavior behavior); + signals: void viewTypeChanged(ViewType type); private: void mainWindowCreated(BrowserWindow *window); void setTabBarVisible(bool visible); + void setWebTabBehavior(AddChildBehavior behavior); QString m_settingsPath; VerticalTabsController *m_controller = nullptr; ViewType m_viewType = TabListView; bool m_replaceTabBar = false; + AddChildBehavior m_addChildBehavior = AppendChild; }; diff --git a/src/plugins/VerticalTabs/verticaltabssettings.cpp b/src/plugins/VerticalTabs/verticaltabssettings.cpp index 282efbc37..653d0ce82 100644 --- a/src/plugins/VerticalTabs/verticaltabssettings.cpp +++ b/src/plugins/VerticalTabs/verticaltabssettings.cpp @@ -29,11 +29,14 @@ VerticalTabsSettings::VerticalTabsSettings(VerticalTabsPlugin *plugin, QWidget * ui->tabListView->setChecked(m_plugin->viewType() == VerticalTabsPlugin::TabListView); ui->tabTreeView->setChecked(m_plugin->viewType() == VerticalTabsPlugin::TabTreeView); + ui->appendChild->setChecked(m_plugin->addChildBehavior() == VerticalTabsPlugin::AppendChild); + ui->prependChild->setChecked(m_plugin->addChildBehavior() == VerticalTabsPlugin::PrependChild); ui->replaceTabBar->setChecked(m_plugin->replaceTabBar()); connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); connect(ui->buttonBox, &QDialogButtonBox::accepted, this, [this]() { m_plugin->setViewType(ui->tabListView->isChecked() ? VerticalTabsPlugin::TabListView : VerticalTabsPlugin::TabTreeView); + m_plugin->setAddChildBehavior(ui->appendChild->isChecked() ? VerticalTabsPlugin::AppendChild : VerticalTabsPlugin::PrependChild); m_plugin->setReplaceTabBar(ui->replaceTabBar->isChecked()); accept(); }); diff --git a/src/plugins/VerticalTabs/verticaltabssettings.ui b/src/plugins/VerticalTabs/verticaltabssettings.ui index 3b7ed0260..e31076c62 100644 --- a/src/plugins/VerticalTabs/verticaltabssettings.ui +++ b/src/plugins/VerticalTabs/verticaltabssettings.ui @@ -6,8 +6,8 @@ 0 0 - 415 - 231 + 460 + 317 @@ -20,13 +20,6 @@ View - - - - Please select view type: - - - @@ -44,6 +37,29 @@ + + + + Options + + + + + + Add new child tabs to the end of tab tree + + + + + + + Add new child tabs to the beginning of tab tree + + + + + +