┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/dolphintabwidget.cpp
diff options
context:
space:
mode:
authorFelix Ernst <[email protected]>2020-09-20 18:53:59 +0200
committerElvis Angelaccio <[email protected]>2020-11-09 23:49:07 +0100
commit37327c9b0aae112c5890703cba1f0157043007e0 (patch)
tree5cda9876f310a258b95226bc0d9681acc665f98e /src/dolphintabwidget.cpp
parent6151a7aec0516570926cb1d15da48936e38e6765 (diff)
Make UrlNavigators in the toolbar the only option
The UrlNavigators will be automatically added to the toolbar. The Sort By action is removed from the default toolbar to make space. Remove all options to have UrlNavigators outside the toolbar and remove those code paths. Make it so the new NavigatorsWidgetAction contains two UrlNavigators when in split view mode. Spacing was also added to align these UrlNavigators with the ViewContainers when enough space is available. Force the toolbar to be either at the top or bottom of the window. Set a sane sizeHint for DolphinUrlNavigator. It would be better to do this in KUrlNavigator in the future. This commit also contains a changes which should be moved to a separate merge requests before this gets merged: - Add an expansion animation when split view is enabled by the user
Diffstat (limited to 'src/dolphintabwidget.cpp')
-rw-r--r--src/dolphintabwidget.cpp34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/dolphintabwidget.cpp b/src/dolphintabwidget.cpp
index 3ce8229f9..a09a769d3 100644
--- a/src/dolphintabwidget.cpp
+++ b/src/dolphintabwidget.cpp
@@ -20,9 +20,10 @@
#include <QApplication>
#include <QDropEvent>
-DolphinTabWidget::DolphinTabWidget(QWidget* parent) :
+DolphinTabWidget::DolphinTabWidget(DolphinNavigatorsWidgetAction *navigatorsWidget, QWidget* parent) :
QTabWidget(parent),
- m_lastViewedTab(0)
+ m_lastViewedTab(nullptr),
+ m_navigatorsWidget{navigatorsWidget}
{
KAcceleratorManager::setNoAccel(this);
@@ -126,11 +127,19 @@ bool DolphinTabWidget::isUrlOpen(const QUrl &url) const
void DolphinTabWidget::openNewActivatedTab()
{
+ std::unique_ptr<DolphinUrlNavigator::VisualState> oldNavigatorState;
+ if (currentTabPage()->primaryViewActive()) {
+ oldNavigatorState = m_navigatorsWidget->primaryUrlNavigator()->visualState();
+ } else {
+ if (!m_navigatorsWidget->secondaryUrlNavigator()) {
+ m_navigatorsWidget->createSecondaryUrlNavigator();
+ }
+ oldNavigatorState = m_navigatorsWidget->secondaryUrlNavigator()->visualState();
+ }
+
const DolphinViewContainer* oldActiveViewContainer = currentTabPage()->activeViewContainer();
Q_ASSERT(oldActiveViewContainer);
- const bool isUrlEditable = oldActiveViewContainer->urlNavigator()->isUrlEditable();
-
openNewActivatedTab(oldActiveViewContainer->url());
DolphinViewContainer* newActiveViewContainer = currentTabPage()->activeViewContainer();
@@ -138,7 +147,7 @@ void DolphinTabWidget::openNewActivatedTab()
// The URL navigator of the new tab should have the same editable state
// as the current tab
- newActiveViewContainer->urlNavigator()->setUrlEditable(isUrlEditable);
+ newActiveViewContainer->urlNavigator()->setVisualState(*oldNavigatorState.get());
// Always focus the new tab's view
newActiveViewContainer->view()->setFocus();
@@ -384,16 +393,21 @@ void DolphinTabWidget::tabUrlChanged(const QUrl& url)
void DolphinTabWidget::currentTabChanged(int index)
{
- // last-viewed tab deactivation
- if (DolphinTabPage* tabPage = tabPageAt(m_lastViewedTab)) {
- tabPage->setActive(false);
+ DolphinTabPage *tabPage = tabPageAt(index);
+ if (tabPage == m_lastViewedTab) {
+ return;
+ }
+ if (m_lastViewedTab) {
+ m_lastViewedTab->disconnectNavigators();
+ m_lastViewedTab->setActive(false);
}
- DolphinTabPage* tabPage = tabPageAt(index);
DolphinViewContainer* viewContainer = tabPage->activeViewContainer();
Q_EMIT activeViewChanged(viewContainer);
Q_EMIT currentUrlChanged(viewContainer->url());
tabPage->setActive(true);
- m_lastViewedTab = index;
+ tabPage->connectNavigators(m_navigatorsWidget);
+ m_navigatorsWidget->setSecondaryNavigatorVisible(tabPage->splitViewEnabled());
+ m_lastViewedTab = tabPageAt(index);
}
void DolphinTabWidget::tabInserted(int index)