diff options
| author | Rafał Lichwała <[email protected]> | 2025-10-30 16:11:43 +0100 |
|---|---|---|
| committer | Méven Car <[email protected]> | 2025-10-31 10:19:48 +0000 |
| commit | 8d44699fa48bc4028b2a7fab4af77ad91f899956 (patch) | |
| tree | 0df743ac01ee1df1c7337bc46f4c2ce7449d00cd /src | |
| parent | a2893a61c2802953c7aee61442be8eec820a2359 (diff) | |
dolphintabpage: save and restore splitter position
This commit changes version number for save/restore tab state,
because format has changed - m_splitterLastPosition is now also saved/restored
BUG: 430705
Diffstat (limited to 'src')
| -rw-r--r-- | src/dolphintabpage.cpp | 14 | ||||
| -rw-r--r-- | src/dolphintabpage.h | 7 |
2 files changed, 17 insertions, 4 deletions
diff --git a/src/dolphintabpage.cpp b/src/dolphintabpage.cpp index 9df1c77b3..f6ccff22e 100644 --- a/src/dolphintabpage.cpp +++ b/src/dolphintabpage.cpp @@ -25,6 +25,7 @@ void resetSplitterSizes(QSplitter *splitter) DolphinTabPage::DolphinTabPage(const QUrl &primaryUrl, const QUrl &secondaryUrl, QWidget *parent) : QWidget(parent) + , m_splitterLastPosition(0) , m_expandingContainer{nullptr} , m_primaryViewActive(true) , m_splitViewEnabled(false) @@ -72,6 +73,11 @@ bool DolphinTabPage::splitViewEnabled() const return m_splitViewEnabled; } +void DolphinTabPage::splitterMoved(int pos) +{ + m_splitterLastPosition = pos; +} + void DolphinTabPage::setSplitViewEnabled(bool enabled, Animated animated, const QUrl &secondaryUrl) { if (m_splitViewEnabled == enabled) { @@ -281,7 +287,7 @@ QByteArray DolphinTabPage::saveState() const QByteArray state; QDataStream stream(&state, QIODevice::WriteOnly); - stream << quint32(2); // Tab state version + stream << quint32(3); // Tab state version stream << m_splitViewEnabled; @@ -297,6 +303,7 @@ QByteArray DolphinTabPage::saveState() const stream << m_primaryViewActive; stream << m_splitter->saveState(); + stream << m_splitterLastPosition; if (!m_customLabel.isEmpty()) { stream << m_customLabel; @@ -317,7 +324,7 @@ void DolphinTabPage::restoreState(const QByteArray &state) // Read the version number of the tab state and check if the version is supported. quint32 version = 0; stream >> version; - if (version != 2) { + if (version != 3) { // The version of the tab state isn't supported, we can't restore it. return; } @@ -355,6 +362,7 @@ void DolphinTabPage::restoreState(const QByteArray &state) QByteArray splitterState; stream >> splitterState; m_splitter->restoreState(splitterState); + stream >> m_splitterLastPosition; if (!stream.atEnd()) { QString tabTitle; @@ -525,7 +533,7 @@ void DolphinTabPage::startExpandViewAnimation(DolphinViewContainer *expandingCon m_expandViewAnimation->setStartValue(expandingContainer->width()); if (m_splitViewEnabled) { // A new viewContainer is being opened. - m_expandViewAnimation->setEndValue(m_splitter->width() / 2); + m_expandViewAnimation->setEndValue(m_splitterLastPosition ? (m_splitter->width() - m_splitterLastPosition) : (m_splitter->width() / 2)); m_expandViewAnimation->setEasingCurve(QEasingCurve::OutCubic); } else { // A viewContainer is being closed. m_expandViewAnimation->setEndValue(m_splitter->width()); diff --git a/src/dolphintabpage.h b/src/dolphintabpage.h index 1abc05670..b6135d360 100644 --- a/src/dolphintabpage.h +++ b/src/dolphintabpage.h @@ -155,10 +155,14 @@ public: Q_SIGNALS: void activeViewChanged(DolphinViewContainer *viewContainer); void activeViewUrlChanged(const QUrl &url); - void splitterMoved(int pos, int index); private Q_SLOTS: /** + * Saves splitter position to be able to restore it on split mode OFF->ON + */ + void splitterMoved(int pos); + + /** * Deletes all zombie viewContainers that were used for the animation * and resets the minimum size of the others to a sane value. */ @@ -217,6 +221,7 @@ private: bool m_active; /** @see setCustomLabel(). */ QString m_customLabel; + int m_splitterLastPosition = 0; }; class DolphinTabPageSplitterHandle : public QSplitterHandle |
