mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +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"));
|
||||
m_viewType = static_cast<ViewType>(settings.value(QSL("ViewType"), TabListView).toInt());
|
||||
m_replaceTabBar = settings.value(QSL("ReplaceTabBar"), false).toBool();
|
||||
m_addChildBehavior = static_cast<AddChildBehavior>(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);
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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();
|
||||
});
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>415</width>
|
||||
<height>231</height>
|
||||
<width>460</width>
|
||||
<height>317</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -20,13 +20,6 @@
|
||||
<string>View</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Please select view type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="tabListView">
|
||||
<property name="text">
|
||||
@ -44,6 +37,29 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</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>
|
||||
<widget class="QCheckBox" name="replaceTabBar">
|
||||
<property name="text">
|
||||
|
Loading…
Reference in New Issue
Block a user