Changeset View
Standalone View
src/dolphinmainwindow.cpp
Show First 20 Lines • Show All 191 Lines • ▼ Show 20 Line(s) | 122 | #endif | |||
---|---|---|---|---|---|
192 | } | 192 | } | ||
193 | 193 | | |||
194 | // enable middle-click on back/forward/up to open in a new tab | 194 | // enable middle-click on back/forward/up to open in a new tab | ||
195 | auto *middleClickEventFilter = new MiddleClickActionEventFilter(this); | 195 | auto *middleClickEventFilter = new MiddleClickActionEventFilter(this); | ||
196 | connect(middleClickEventFilter, &MiddleClickActionEventFilter::actionMiddleClicked, this, &DolphinMainWindow::slotToolBarActionMiddleClicked); | 196 | connect(middleClickEventFilter, &MiddleClickActionEventFilter::actionMiddleClicked, this, &DolphinMainWindow::slotToolBarActionMiddleClicked); | ||
197 | toolBar()->installEventFilter(middleClickEventFilter); | 197 | toolBar()->installEventFilter(middleClickEventFilter); | ||
198 | 198 | | |||
199 | setupWhatsThis(); | 199 | setupWhatsThis(); | ||
200 | | ||||
201 | // Restore window state if the setting is turned on and there are no | ||||
202 | // other Dolphin windows open | ||||
203 | if (GeneralSettings::rememberOpenedTabs()) { | ||||
broulik: Instead of hardcoding those settings everywhere, please use KConfigXt (the `kcfg` files you can… | |||||
you need to check you're not being loaded as part of a session restore otherwise you'll have two paths call readProperties qApp->isSessionRestored() davidedmundson: you need to check you're not being loaded as part of a session restore otherwise you'll have… | |||||
204 | // Check for existing Dolphin windows in a separate nested if() to | ||||
205 | // save a DBus call if the user isn't using the feature | ||||
206 | if (Dolphin::dolphinInstanceData(QStringLiteral("org.kde.dolphin-%1").arg(QCoreApplication::applicationPid())).isEmpty()) { | ||||
207 | // Wait for the initialization ending | ||||
I'm surprised this works at all. AFAICTL it'll never be empty as the instance will find itself and hence won't be empty, unless our DBus interface isn't initialised yet (tbf I don't know when it would be). Either way I don't see why this instance is preferred so I think the code would be clearer if it was simply QString() instead. feverfew: I'm surprised this works at all. AFAICTL it'll never be empty as the instance will find itself… | |||||
It doesn't find itself because Dolphin::dolphinInstanceData() filters out the currently running instance by excludinv entries that match its PID. ngraham: It doesn't find itself because `Dolphin::dolphinInstanceData()` filters out the currently… | |||||
The reason why preferredService was a parameter was for when ShowFolders/ShowItems was called via DBus. It specifically bypasses excluding the running instance as in that case you wanted the running instance to accept those URLs, i.e. marking a sevice as preferred means it is exempt from the check that filters out the currently running instance. In this case you want to see if any other instances (apart from this one) exist, and hence you should be passing QString(). The only reason I can think of why the patch works in this current state is that Q_CLASSINFO macro only initialises the DBus object for the main window after the constructor finishes... feverfew: The reason why `preferredService` was a parameter was for when `ShowFolders`/`ShowItems` was… | |||||
208 | QTimer::singleShot(0, [this]() { | ||||
209 | KConfigGroup windowState{KSharedConfig::openConfig(QStringLiteral("dolphinrc")), "WindowState"}; | ||||
210 | readProperties(windowState); | ||||
211 | }); | ||||
212 | } | ||||
213 | } | ||||
200 | } | 214 | } | ||
201 | 215 | | |||
202 | DolphinMainWindow::~DolphinMainWindow() | 216 | DolphinMainWindow::~DolphinMainWindow() | ||
203 | { | 217 | { | ||
204 | } | 218 | } | ||
205 | 219 | | |||
206 | QVector<DolphinViewContainer*> DolphinMainWindow::viewContainers() const | 220 | QVector<DolphinViewContainer*> DolphinMainWindow::viewContainers() const | ||
207 | { | 221 | { | ||
208 | QVector<DolphinViewContainer*> viewContainers; | 222 | QVector<DolphinViewContainer*> viewContainers; | ||
209 | viewContainers.reserve(m_tabWidget->count()); | 223 | viewContainers.reserve(m_tabWidget->count()); | ||
210 | for (int i = 0; i < m_tabWidget->count(); ++i) { | 224 | for (int i = 0; i < m_tabWidget->count(); ++i) { | ||
elvisangelaccio: Please move this logic in `DolphinMainWindow::closeEvent()`. | |||||
211 | viewContainers << m_tabWidget->tabPageAt(i)->activeViewContainer(); | 225 | viewContainers << m_tabWidget->tabPageAt(i)->activeViewContainer(); | ||
212 | } | 226 | } | ||
213 | return viewContainers; | 227 | return viewContainers; | ||
214 | } | 228 | } | ||
215 | 229 | | |||
216 | void DolphinMainWindow::openDirectories(const QList<QUrl>& dirs, bool splitView) | 230 | void DolphinMainWindow::openDirectories(const QList<QUrl>& dirs, bool splitView) | ||
217 | { | 231 | { | ||
218 | m_tabWidget->openDirectories(dirs, splitView); | 232 | m_tabWidget->openDirectories(dirs, splitView); | ||
▲ Show 20 Lines • Show All 347 Lines • ▼ Show 20 Line(s) | 578 | case QDialogButtonBox::No: | |||
566 | // Do not quit, ignore quit event | 580 | // Do not quit, ignore quit event | ||
567 | Q_FALLTHROUGH(); | 581 | Q_FALLTHROUGH(); | ||
568 | default: | 582 | default: | ||
569 | event->ignore(); | 583 | event->ignore(); | ||
570 | return; | 584 | return; | ||
571 | } | 585 | } | ||
572 | } | 586 | } | ||
573 | 587 | | |||
588 | // TODO: clear the last window state when opening a new window | ||||
589 | if (GeneralSettings::rememberOpenedTabs()) { | ||||
590 | KConfigGroup windowState{KSharedConfig::openConfig(QStringLiteral("dolphinrc")), "WindowState"}; | ||||
591 | saveProperties(windowState); | ||||
592 | } | ||||
593 | | ||||
574 | GeneralSettings::setVersion(CurrentDolphinVersion); | 594 | GeneralSettings::setVersion(CurrentDolphinVersion); | ||
575 | GeneralSettings::self()->save(); | 595 | GeneralSettings::self()->save(); | ||
576 | 596 | | |||
577 | KXmlGuiWindow::closeEvent(event); | 597 | KXmlGuiWindow::closeEvent(event); | ||
578 | } | 598 | } | ||
579 | 599 | | |||
580 | void DolphinMainWindow::saveProperties(KConfigGroup& group) | 600 | void DolphinMainWindow::saveProperties(KConfigGroup& group) | ||
581 | { | 601 | { | ||
▲ Show 20 Lines • Show All 1668 Lines • Show Last 20 Lines |
Instead of hardcoding those settings everywhere, please use KConfigXt (the kcfg files you can see for other places in Dolphin), like GeneralSettings