diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -186,6 +186,15 @@ toolBar()->installEventFilter(middleClickEventFilter); setupWhatsThis(); + + // Restore window state + if (GeneralSettings::rememberOpenedTabs() /*&& Dolphin not already running */) { + // Wait for the initialization ending + QTimer::singleShot(0, [this]() { + KConfigGroup windowState{KSharedConfig::openConfig(QStringLiteral("dolphinrc")), "WindowState"}; + readProperties(windowState); + }); + } } DolphinMainWindow::~DolphinMainWindow() @@ -534,6 +543,11 @@ } } + if (GeneralSettings::rememberOpenedTabs()) { + KConfigGroup windowState{KSharedConfig::openConfig(QStringLiteral("dolphinrc")), "WindowState"}; + saveProperties(windowState); + } + GeneralSettings::setVersion(CurrentDolphinVersion); GeneralSettings::self()->save(); diff --git a/src/settings/dolphin_generalsettings.kcfg b/src/settings/dolphin_generalsettings.kcfg --- a/src/settings/dolphin_generalsettings.kcfg +++ b/src/settings/dolphin_generalsettings.kcfg @@ -42,6 +42,10 @@ QUrl::fromLocalFile(QDir::homePath()).toDisplayString(QUrl::PreferLocalFile) + + + false + false diff --git a/src/settings/startup/startupsettingspage.h b/src/settings/startup/startupsettingspage.h --- a/src/settings/startup/startupsettingspage.h +++ b/src/settings/startup/startupsettingspage.h @@ -59,6 +59,7 @@ QUrl m_url; QLineEdit* m_homeUrl; + QCheckBox* m_rememberOpenedTabs; QCheckBox* m_splitView; QCheckBox* m_editableUrl; QCheckBox* m_showFullPath; diff --git a/src/settings/startup/startupsettingspage.cpp b/src/settings/startup/startupsettingspage.cpp --- a/src/settings/startup/startupsettingspage.cpp +++ b/src/settings/startup/startupsettingspage.cpp @@ -84,36 +84,38 @@ homeBoxLayout->addLayout(homeUrlBoxLayout); homeBoxLayout->addLayout(buttonBoxLayout); - topLayout->addRow(i18nc("@label:textbox", "Start in:"), homeBoxLayout); + topLayout->addRow(i18nc("@label:textbox", "For new windows, show:"), homeBoxLayout); + + m_splitView = new QCheckBox(i18nc("@option:check Startup Settings", "Split view mode")); + topLayout->addRow(QString(), m_splitView); + m_editableUrl = new QCheckBox(i18nc("@option:check Startup Settings", "Editable location bar")); + topLayout->addRow(QString(), m_editableUrl); + m_filterBar = new QCheckBox(i18nc("@option:check Startup Settings", "Filter bar")); + topLayout->addRow(QString(), m_filterBar); topLayout->addItem(new QSpacerItem(0, Dolphin::VERTICAL_SPACER_HEIGHT, QSizePolicy::Fixed, QSizePolicy::Fixed)); - // create 'Split view', 'Show full path', 'Editable location' and 'Filter bar' checkboxes - m_splitView = new QCheckBox(i18nc("@option:check Startup Settings", "Split view mode")); - topLayout->addRow(i18nc("@label:checkbox", "Window options:"), m_splitView); - m_editableUrl = new QCheckBox(i18nc("@option:check Startup Settings", "Editable location bar")); - topLayout->addRow(QString(), m_editableUrl); + m_rememberOpenedTabs = new QCheckBox(i18nc("@option:check Startup Settings", "Remember open folders and tabs")); + topLayout->addRow(i18nc("@label:checkbox", "General settings:"), m_rememberOpenedTabs); + m_openExternallyCalledFolderInNewTab = new QCheckBox(i18nc("@option:check Startup Settings", "Open new folders in tabs")); + topLayout->addRow(QString(), m_openExternallyCalledFolderInNewTab); m_showFullPath = new QCheckBox(i18nc("@option:check Startup Settings", "Show full path inside location bar")); topLayout->addRow(QString(), m_showFullPath); - m_filterBar = new QCheckBox(i18nc("@option:check Startup Settings", "Show filter bar")); - topLayout->addRow(QString(), m_filterBar); m_showFullPathInTitlebar = new QCheckBox(i18nc("@option:check Startup Settings", "Show full path in title bar")); topLayout->addRow(QString(), m_showFullPathInTitlebar); - m_openExternallyCalledFolderInNewTab = new QCheckBox(i18nc("@option:check Startup Settings", "Open new folders in tabs")); - topLayout->addRow(QString(), m_openExternallyCalledFolderInNewTab); - loadSettings(); connect(m_homeUrl, &QLineEdit::textChanged, this, &StartupSettingsPage::slotSettingsChanged); connect(m_splitView, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); connect(m_editableUrl, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); - connect(m_showFullPath, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); connect(m_filterBar, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); - connect(m_showFullPathInTitlebar, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); + connect(m_rememberOpenedTabs, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); connect(m_openExternallyCalledFolderInNewTab, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); + connect(m_showFullPath, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); + connect(m_showFullPathInTitlebar, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); } StartupSettingsPage::~StartupSettingsPage() @@ -132,6 +134,7 @@ KMessageBox::error(this, i18nc("@info", "The location for the home folder is invalid or does not exist, it will not be applied.")); } + settings->setRememberOpenedTabs(m_rememberOpenedTabs->isChecked()); settings->setSplitView(m_splitView->isChecked()); settings->setEditableUrl(m_editableUrl->isChecked()); settings->setShowFullPath(m_showFullPath->isChecked()); @@ -182,6 +185,7 @@ { const QUrl url(Dolphin::homeUrl()); m_homeUrl->setText(url.toDisplayString(QUrl::PreferLocalFile)); + m_rememberOpenedTabs->setChecked(GeneralSettings::rememberOpenedTabs()); m_splitView->setChecked(GeneralSettings::splitView()); m_editableUrl->setChecked(GeneralSettings::editableUrl()); m_showFullPath->setChecked(GeneralSettings::showFullPath());