LibWebView+UI/Qt: Move the vertical tab width to LibWebView settings
Let's store this alongside all other vertical tab settings.
This commit is contained in:
parent
ff13ac2b79
commit
80554dc914
6 changed files with 17 additions and 20 deletions
|
|
@ -26,6 +26,7 @@ static constexpr auto TAB_SETTINGS_KEY = "tabs"sv;
|
|||
static constexpr auto VERTICAL_TABS_ENABLED_KEY = "verticalTabsEnabled"sv;
|
||||
static constexpr auto VERTICAL_TABS_EXPANDED_KEY = "verticalTabsExpanded"sv;
|
||||
static constexpr auto VERTICAL_TABS_EXPAND_ON_HOVER_KEY = "verticalTabsExpandOnHover"sv;
|
||||
static constexpr auto VERTICAL_TABS_EXPANDED_WIDTH_KEY = "verticalTabsExpandedWidth"sv;
|
||||
|
||||
static constexpr auto SHOW_BOOKMARKS_BAR_KEY = "showBookmarksBar"sv;
|
||||
static constexpr auto DEFAULT_SHOW_BOOKMARKS_BAR = true;
|
||||
|
|
@ -296,6 +297,8 @@ JsonValue Settings::serialize_json() const
|
|||
tab_settings.set(VERTICAL_TABS_ENABLED_KEY, m_tab_settings.vertical_tabs_enabled);
|
||||
tab_settings.set(VERTICAL_TABS_EXPANDED_KEY, m_tab_settings.vertical_tabs_expanded);
|
||||
tab_settings.set(VERTICAL_TABS_EXPAND_ON_HOVER_KEY, m_tab_settings.vertical_tabs_expand_on_hover);
|
||||
if (m_tab_settings.vertical_tabs_expanded_width.has_value())
|
||||
tab_settings.set(VERTICAL_TABS_EXPANDED_WIDTH_KEY, *m_tab_settings.vertical_tabs_expanded_width);
|
||||
settings.set(TAB_SETTINGS_KEY, move(tab_settings));
|
||||
|
||||
settings.set(SHOW_BOOKMARKS_BAR_KEY, m_show_bookmarks_bar);
|
||||
|
|
@ -427,6 +430,8 @@ TabSettings Settings::parse_tab_settings(JsonValue const& settings)
|
|||
tab_settings.vertical_tabs_expanded = *vertical_tabs_expanded;
|
||||
if (auto vertical_tabs_expand_on_hover = settings.as_object().get_bool(VERTICAL_TABS_EXPAND_ON_HOVER_KEY); vertical_tabs_expand_on_hover.has_value())
|
||||
tab_settings.vertical_tabs_expand_on_hover = *vertical_tabs_expand_on_hover;
|
||||
if (auto vertical_tabs_expanded_width = settings.as_object().get_integer<u16>(VERTICAL_TABS_EXPANDED_WIDTH_KEY); vertical_tabs_expanded_width.has_value())
|
||||
tab_settings.vertical_tabs_expanded_width = *vertical_tabs_expanded_width;
|
||||
|
||||
return tab_settings;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ struct TabSettings {
|
|||
bool vertical_tabs_enabled { false };
|
||||
bool vertical_tabs_expanded { true };
|
||||
bool vertical_tabs_expand_on_hover { false };
|
||||
Optional<u16> vertical_tabs_expanded_width;
|
||||
};
|
||||
|
||||
struct BrowsingBehavior {
|
||||
|
|
|
|||
|
|
@ -176,9 +176,11 @@ void SettingsUI::set_tab_settings(JsonValue const& tab_settings)
|
|||
{
|
||||
auto& settings = WebView::Application::settings();
|
||||
auto parsed_tab_settings = Settings::parse_tab_settings(tab_settings);
|
||||
auto const& current_tab_settings = settings.tab_settings();
|
||||
|
||||
// Collapsed/expanded vertical tabs are not controlled by the settings UI. Don't overwrite it.
|
||||
parsed_tab_settings.vertical_tabs_expanded = settings.tab_settings().vertical_tabs_expanded;
|
||||
// Collapsed/expanded vertical tabs and their width are not controlled by the settings UI. Don't overwrite them.
|
||||
parsed_tab_settings.vertical_tabs_expanded = current_tab_settings.vertical_tabs_expanded;
|
||||
parsed_tab_settings.vertical_tabs_expanded_width = current_tab_settings.vertical_tabs_expanded_width;
|
||||
|
||||
settings.set_tab_settings(parsed_tab_settings);
|
||||
load_current_settings();
|
||||
|
|
|
|||
|
|
@ -73,16 +73,4 @@ void Settings::set_show_menubar(bool show_menubar)
|
|||
emit show_menubar_changed(show_menubar);
|
||||
}
|
||||
|
||||
Optional<int> Settings::vertical_tabs_expanded_width()
|
||||
{
|
||||
if (m_qsettings->contains("vertical_tabs_expanded_width"))
|
||||
return m_qsettings->value("vertical_tabs_expanded_width").toInt();
|
||||
return {};
|
||||
}
|
||||
|
||||
void Settings::set_vertical_tabs_expanded_width(int width)
|
||||
{
|
||||
m_qsettings->setValue("vertical_tabs_expanded_width", width);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,9 +45,6 @@ public:
|
|||
bool show_menubar();
|
||||
void set_show_menubar(bool show_menubar);
|
||||
|
||||
Optional<int> vertical_tabs_expanded_width();
|
||||
void set_vertical_tabs_expanded_width(int);
|
||||
|
||||
signals:
|
||||
void show_menubar_changed(bool show_menubar);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
# include <UI/Qt/MacWindow.h>
|
||||
#endif
|
||||
#include <UI/Qt/Menu.h>
|
||||
#include <UI/Qt/Settings.h>
|
||||
#include <UI/Qt/Tab.h>
|
||||
#include <UI/Qt/TabBar.h>
|
||||
#include <UI/Qt/WindowControlButton.h>
|
||||
|
|
@ -1116,7 +1115,7 @@ TabWidget::TabWidget(QWidget* parent)
|
|||
if (auto* top_level_window = window(); top_level_window != this)
|
||||
top_level_window->installEventFilter(this);
|
||||
|
||||
m_vertical_tabs_expanded_width = Settings::the()->vertical_tabs_expanded_width().value_or(VERTICAL_TABS_DEFAULT_EXPANDED_WIDTH);
|
||||
m_vertical_tabs_expanded_width = Application::settings().tab_settings().vertical_tabs_expanded_width.value_or(VERTICAL_TABS_DEFAULT_EXPANDED_WIDTH);
|
||||
m_vertical_tabs_expanded_width = clamp_vertical_tabs_expanded_width(m_vertical_tabs_expanded_width);
|
||||
|
||||
m_tab_bar = new TabBar(this);
|
||||
|
|
@ -1717,7 +1716,12 @@ void TabWidget::apply_vertical_tabs_expanded_width(int width)
|
|||
|
||||
void TabWidget::persist_vertical_tabs_expanded_width()
|
||||
{
|
||||
Settings::the()->set_vertical_tabs_expanded_width(m_vertical_tabs_expanded_width);
|
||||
auto tab_settings = Application::settings().tab_settings();
|
||||
|
||||
using ValueType = decltype(tab_settings.vertical_tabs_expanded_width)::ValueType;
|
||||
tab_settings.vertical_tabs_expanded_width = clamp(m_vertical_tabs_expanded_width, 0, NumericLimits<ValueType>::max());
|
||||
|
||||
Application::settings().set_tab_settings(tab_settings);
|
||||
}
|
||||
|
||||
void TabWidget::set_resize_handle_property(char const* property, bool enabled)
|
||||
|
|
|
|||
Loading…
Reference in a new issue