mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
VerticalTabs: Add option to append/prepend new child tabs
This commit is contained in:
parent
e981f638de
commit
2c60d8bcfb
@ -56,11 +56,14 @@ void VerticalTabsPlugin::init(InitState state, const QString &settingsPath)
|
|||||||
settings.beginGroup(QSL("VerticalTabs"));
|
settings.beginGroup(QSL("VerticalTabs"));
|
||||||
m_viewType = static_cast<ViewType>(settings.value(QSL("ViewType"), TabListView).toInt());
|
m_viewType = static_cast<ViewType>(settings.value(QSL("ViewType"), TabListView).toInt());
|
||||||
m_replaceTabBar = settings.value(QSL("ReplaceTabBar"), false).toBool();
|
m_replaceTabBar = settings.value(QSL("ReplaceTabBar"), false).toBool();
|
||||||
|
m_addChildBehavior = static_cast<AddChildBehavior>(settings.value(QSL("AddChildBehavior"), AppendChild).toInt());
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
m_controller = new VerticalTabsController(this);
|
m_controller = new VerticalTabsController(this);
|
||||||
SideBarManager::addSidebar(QSL("VerticalTabs"), m_controller);
|
SideBarManager::addSidebar(QSL("VerticalTabs"), m_controller);
|
||||||
|
|
||||||
|
setWebTabBehavior(m_addChildBehavior);
|
||||||
|
|
||||||
connect(mApp->plugins(), &PluginProxy::mainWindowCreated, this, &VerticalTabsPlugin::mainWindowCreated);
|
connect(mApp->plugins(), &PluginProxy::mainWindowCreated, this, &VerticalTabsPlugin::mainWindowCreated);
|
||||||
|
|
||||||
if (state == LateInitState) {
|
if (state == LateInitState) {
|
||||||
@ -135,6 +138,24 @@ void VerticalTabsPlugin::setReplaceTabBar(bool replace)
|
|||||||
settings.setValue(QSL("VerticalTabs/ReplaceTabBar"), m_replaceTabBar);
|
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)
|
void VerticalTabsPlugin::mainWindowCreated(BrowserWindow *window)
|
||||||
{
|
{
|
||||||
if (window->sideBarManager()->activeSideBar().isEmpty()) {
|
if (window->sideBarManager()->activeSideBar().isEmpty()) {
|
||||||
@ -150,3 +171,8 @@ void VerticalTabsPlugin::setTabBarVisible(bool visible)
|
|||||||
window->tabWidget()->tabBar()->setForceHidden(!visible);
|
window->tabWidget()->tabBar()->setForceHidden(!visible);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VerticalTabsPlugin::setWebTabBehavior(AddChildBehavior behavior)
|
||||||
|
{
|
||||||
|
WebTab::setAddChildBehavior(behavior == AppendChild ? WebTab::AppendChild : WebTab::PrependChild);
|
||||||
|
}
|
||||||
|
@ -50,15 +50,25 @@ public:
|
|||||||
bool replaceTabBar() const;
|
bool replaceTabBar() const;
|
||||||
void setReplaceTabBar(bool replace);
|
void setReplaceTabBar(bool replace);
|
||||||
|
|
||||||
|
enum AddChildBehavior {
|
||||||
|
AppendChild,
|
||||||
|
PrependChild
|
||||||
|
};
|
||||||
|
|
||||||
|
AddChildBehavior addChildBehavior() const;
|
||||||
|
void setAddChildBehavior(AddChildBehavior behavior);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void viewTypeChanged(ViewType type);
|
void viewTypeChanged(ViewType type);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void mainWindowCreated(BrowserWindow *window);
|
void mainWindowCreated(BrowserWindow *window);
|
||||||
void setTabBarVisible(bool visible);
|
void setTabBarVisible(bool visible);
|
||||||
|
void setWebTabBehavior(AddChildBehavior behavior);
|
||||||
|
|
||||||
QString m_settingsPath;
|
QString m_settingsPath;
|
||||||
VerticalTabsController *m_controller = nullptr;
|
VerticalTabsController *m_controller = nullptr;
|
||||||
ViewType m_viewType = TabListView;
|
ViewType m_viewType = TabListView;
|
||||||
bool m_replaceTabBar = false;
|
bool m_replaceTabBar = false;
|
||||||
|
AddChildBehavior m_addChildBehavior = AppendChild;
|
||||||
};
|
};
|
||||||
|
@ -29,11 +29,14 @@ VerticalTabsSettings::VerticalTabsSettings(VerticalTabsPlugin *plugin, QWidget *
|
|||||||
|
|
||||||
ui->tabListView->setChecked(m_plugin->viewType() == VerticalTabsPlugin::TabListView);
|
ui->tabListView->setChecked(m_plugin->viewType() == VerticalTabsPlugin::TabListView);
|
||||||
ui->tabTreeView->setChecked(m_plugin->viewType() == VerticalTabsPlugin::TabTreeView);
|
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());
|
ui->replaceTabBar->setChecked(m_plugin->replaceTabBar());
|
||||||
|
|
||||||
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||||
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, [this]() {
|
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, [this]() {
|
||||||
m_plugin->setViewType(ui->tabListView->isChecked() ? VerticalTabsPlugin::TabListView : VerticalTabsPlugin::TabTreeView);
|
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());
|
m_plugin->setReplaceTabBar(ui->replaceTabBar->isChecked());
|
||||||
accept();
|
accept();
|
||||||
});
|
});
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>415</width>
|
<width>460</width>
|
||||||
<height>231</height>
|
<height>317</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -20,13 +20,6 @@
|
|||||||
<string>View</string>
|
<string>View</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>Please select view type:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QRadioButton" name="tabListView">
|
<widget class="QRadioButton" name="tabListView">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -44,6 +37,29 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBox_2">
|
||||||
|
<property name="title">
|
||||||
|
<string>Options</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QFormLayout" name="formLayout">
|
||||||
|
<item row="0" column="0" colspan="2">
|
||||||
|
<widget class="QRadioButton" name="appendChild">
|
||||||
|
<property name="text">
|
||||||
|
<string>Add new child tabs to the end of tab tree</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0" colspan="2">
|
||||||
|
<widget class="QRadioButton" name="prependChild">
|
||||||
|
<property name="text">
|
||||||
|
<string>Add new child tabs to the beginning of tab tree</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="replaceTabBar">
|
<widget class="QCheckBox" name="replaceTabBar">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
Loading…
Reference in New Issue
Block a user