Changeset View
Changeset View
Standalone View
Standalone View
src/kmainwindow.cpp
Show First 20 Lines • Show All 131 Lines • ▼ Show 20 Line(s) | |||||
132 | { | 132 | { | ||
133 | } | 133 | } | ||
134 | 134 | | |||
135 | void KMWSessionManager::saveState(QSessionManager &sm) | 135 | void KMWSessionManager::saveState(QSessionManager &sm) | ||
136 | { | 136 | { | ||
137 | KConfigGui::setSessionConfig(sm.sessionId(), sm.sessionKey()); | 137 | KConfigGui::setSessionConfig(sm.sessionId(), sm.sessionKey()); | ||
138 | 138 | | |||
139 | KConfig *config = KConfigGui::sessionConfig(); | 139 | KConfig *config = KConfigGui::sessionConfig(); | ||
140 | if (!KMainWindow::memberList().isEmpty()) { | 140 | const auto windows = KMainWindow::memberList(); | ||
141 | if (!windows.isEmpty()) { | ||||
141 | // According to Jochen Wilhelmy <digisnap@cs.tu-berlin.de>, this | 142 | // According to Jochen Wilhelmy <digisnap@cs.tu-berlin.de>, this | ||
142 | // hook is useful for better document orientation | 143 | // hook is useful for better document orientation | ||
143 | KMainWindow::memberList().at(0)->saveGlobalProperties(config); | 144 | windows.at(0)->saveGlobalProperties(config); | ||
144 | } | 145 | } | ||
145 | 146 | | |||
146 | int n = 0; | 147 | int n = 0; | ||
147 | foreach (KMainWindow *mw, KMainWindow::memberList()) { | 148 | for (KMainWindow *mw : windows) { | ||
148 | n++; | 149 | n++; | ||
149 | mw->savePropertiesInternal(config, n); | 150 | mw->savePropertiesInternal(config, n); | ||
150 | } | 151 | } | ||
151 | 152 | | |||
152 | KConfigGroup group(config, "Number"); | 153 | KConfigGroup group(config, "Number"); | ||
153 | group.writeEntry("NumberOfWindows", n); | 154 | group.writeEntry("NumberOfWindows", n); | ||
154 | 155 | | |||
155 | // store new status to disk | 156 | // store new status to disk | ||
Show All 27 Lines | 181 | - quitting the application and thus closing the session manager connection | |||
183 | in the description of the client's state machine: | 184 | in the description of the client's state machine: | ||
184 | 185 | | |||
185 | save-yourself-done: (changing state is forbidden) | 186 | save-yourself-done: (changing state is forbidden) | ||
186 | 187 | | |||
187 | Closing the session manager connection causes a state change. | 188 | Closing the session manager connection causes a state change. | ||
188 | Worst of all, that is a real problem with ksmserver - it will not save | 189 | Worst of all, that is a real problem with ksmserver - it will not save | ||
189 | applications that quit on their own in state save-yourself-done. | 190 | applications that quit on their own in state save-yourself-done. | ||
190 | */ | 191 | */ | ||
191 | foreach (KMainWindow *window, KMainWindow::memberList()) { | 192 | const auto windows = KMainWindow::memberList(); | ||
193 | for (KMainWindow *window : windows) { | ||||
192 | if (window->testAttribute(Qt::WA_WState_Hidden)) { | 194 | if (window->testAttribute(Qt::WA_WState_Hidden)) { | ||
193 | continue; | 195 | continue; | ||
194 | } | 196 | } | ||
195 | QCloseEvent e; | 197 | QCloseEvent e; | ||
196 | QApplication::sendEvent(window, &e); | 198 | QApplication::sendEvent(window, &e); | ||
197 | if (!e.isAccepted()) { | 199 | if (!e.isAccepted()) { | ||
198 | sm.cancel(); | 200 | sm.cancel(); | ||
199 | return; | 201 | return; | ||
▲ Show 20 Lines • Show All 412 Lines • ▼ Show 20 Line(s) | 612 | if (!autoSaveSettings() || cg.name() == autoSaveGroup()) { | |||
612 | if (!cg.hasDefault("ToolBarsMovable") && !KToolBar::toolBarsLocked()) { | 614 | if (!cg.hasDefault("ToolBarsMovable") && !KToolBar::toolBarsLocked()) { | ||
613 | cg.revertToDefault("ToolBarsMovable"); | 615 | cg.revertToDefault("ToolBarsMovable"); | ||
614 | } else { | 616 | } else { | ||
615 | cg.writeEntry("ToolBarsMovable", KToolBar::toolBarsLocked() ? "Disabled" : "Enabled"); | 617 | cg.writeEntry("ToolBarsMovable", KToolBar::toolBarsLocked() ? "Disabled" : "Enabled"); | ||
616 | } | 618 | } | ||
617 | } | 619 | } | ||
618 | 620 | | |||
619 | int n = 1; // Toolbar counter. toolbars are counted from 1, | 621 | int n = 1; // Toolbar counter. toolbars are counted from 1, | ||
620 | foreach (KToolBar *toolbar, toolBars()) { | 622 | const auto toolBars = this->toolBars(); | ||
623 | for (KToolBar *toolbar : toolBars) { | ||||
621 | QByteArray groupName("Toolbar"); | 624 | QByteArray groupName("Toolbar"); | ||
622 | // Give a number to the toolbar, but prefer a name if there is one, | 625 | // Give a number to the toolbar, but prefer a name if there is one, | ||
623 | // because there's no real guarantee on the ordering of toolbars | 626 | // because there's no real guarantee on the ordering of toolbars | ||
624 | groupName += (toolbar->objectName().isEmpty() ? QByteArray::number(n) : QByteArray(" ").append(toolbar->objectName().toUtf8())); | 627 | groupName += (toolbar->objectName().isEmpty() ? QByteArray::number(n) : QByteArray(" ").append(toolbar->objectName().toUtf8())); | ||
625 | 628 | | |||
626 | KConfigGroup toolbarGroup(&cg, groupName.constData()); | 629 | KConfigGroup toolbarGroup(&cg, groupName.constData()); | ||
627 | toolbar->saveSettings(toolbarGroup); | 630 | toolbar->saveSettings(toolbarGroup); | ||
628 | n++; | 631 | n++; | ||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Line(s) | 667 | { | |||
693 | } | 696 | } | ||
694 | 697 | | |||
695 | if (!autoSaveSettings() || cg.name() == autoSaveGroup()) { // TODO should be cg == d->autoSaveGroup, to compare both kconfig and group name | 698 | if (!autoSaveSettings() || cg.name() == autoSaveGroup()) { // TODO should be cg == d->autoSaveGroup, to compare both kconfig and group name | ||
696 | QString entry = cg.readEntry("ToolBarsMovable", "Disabled"); | 699 | QString entry = cg.readEntry("ToolBarsMovable", "Disabled"); | ||
697 | KToolBar::setToolBarsLocked(entry == QLatin1String("Disabled")); | 700 | KToolBar::setToolBarsLocked(entry == QLatin1String("Disabled")); | ||
698 | } | 701 | } | ||
699 | 702 | | |||
700 | int n = 1; // Toolbar counter. toolbars are counted from 1, | 703 | int n = 1; // Toolbar counter. toolbars are counted from 1, | ||
701 | foreach (KToolBar *toolbar, toolBars()) { | 704 | const auto toolBars = this->toolBars(); | ||
705 | for (KToolBar *toolbar : toolBars) { | ||||
702 | QByteArray groupName("Toolbar"); | 706 | QByteArray groupName("Toolbar"); | ||
703 | // Give a number to the toolbar, but prefer a name if there is one, | 707 | // Give a number to the toolbar, but prefer a name if there is one, | ||
704 | // because there's no real guarantee on the ordering of toolbars | 708 | // because there's no real guarantee on the ordering of toolbars | ||
705 | groupName += (toolbar->objectName().isEmpty() ? QByteArray::number(n) : QByteArray(" ").append(toolbar->objectName().toUtf8())); | 709 | groupName += (toolbar->objectName().isEmpty() ? QByteArray::number(n) : QByteArray(" ").append(toolbar->objectName().toUtf8())); | ||
706 | 710 | | |||
707 | KConfigGroup toolbarGroup(&cg, groupName.constData()); | 711 | KConfigGroup toolbarGroup(&cg, groupName.constData()); | ||
708 | toolbar->applySettings(toolbarGroup); | 712 | toolbar->applySettings(toolbarGroup); | ||
709 | n++; | 713 | n++; | ||
▲ Show 20 Lines • Show All 229 Lines • Show Last 20 Lines |