[komposerwin] Save configuration on window close

Diffrential Revision: https://phabricator.kde.org/D7569

Signed-off-by: Anthony Fieroni <bvbfan@abv.bg>
wilder-work
Anthony Fieroni 8 years ago committed by Sandro Knauß
parent 806599dc4d
commit 8b4c6f90b4
  1. 3
      src/editor/attachment/attachmentview.cpp
  2. 1
      src/editor/attachment/attachmentview.h
  3. 11
      src/editor/kmcomposerwin.cpp
  4. 19
      src/kmkernel.cpp

@ -51,6 +51,7 @@ using namespace KMail;
AttachmentView::AttachmentView(MessageComposer::AttachmentModel *model, QWidget *parent)
: QTreeView(parent)
, grp(KMKernel::self()->config()->group("AttachmentView"))
{
mWidget = new QWidget();
QHBoxLayout *lay = new QHBoxLayout(mWidget);
@ -100,13 +101,11 @@ AttachmentView::~AttachmentView()
void AttachmentView::restoreHeaderState()
{
KConfigGroup grp(KMKernel::self()->config(), "AttachmentView");
header()->restoreState(grp.readEntry("State", QByteArray()));
}
void AttachmentView::saveHeaderState()
{
KConfigGroup grp(KMKernel::self()->config(), "AttachmentView");
grp.writeEntry("State", header()->saveState());
grp.sync();
}

@ -77,6 +77,7 @@ private:
QToolButton *mToolButton = nullptr;
QLabel *mInfoAttachment = nullptr;
QWidget *mWidget = nullptr;
KConfigGroup grp;
};
} // namespace KMail

@ -520,12 +520,13 @@ KMComposerWin::KMComposerWin(const KMime::Message::Ptr &aMsg, bool lastSignState
mDummyComposer = new MessageComposer::Composer(this);
mDummyComposer->globalPart()->setParentWidgetForGui(this);
KConfigGroup grp(KMKernel::self()->config()->group("Composer"));
setAutoSaveSettings(grp, true);
}
KMComposerWin::~KMComposerWin()
{
writeConfig();
// When we have a collection set, store the message back to that collection.
// Note that when we save the message or sent it, mFolder is set back to 0.
// So this for example kicks in when opening a draft and then closing the window.
@ -665,8 +666,6 @@ void KMComposerWin::writeConfig(void)
KMailSettings::self()->setComposerSize(size());
KMailSettings::self()->setShowSnippetManager(mSnippetAction->isChecked());
KConfigGroup grp(KMKernel::self()->config()->group("Composer"));
saveMainWindowSettings(grp);
if (mSnippetAction->isChecked()) {
KMailSettings::setSnippetSplitterPosition(mSnippetSplitter->sizes());
}
@ -1731,6 +1730,7 @@ bool KMComposerWin::queryClose()
return false;
}
if (kmkernel->shuttingDown() || qApp->isSavingSession()) {
writeConfig();
return true;
}
@ -1770,6 +1770,7 @@ bool KMComposerWin::queryClose()
qCWarning(KMAIL_LOG) << "Tried to close while composer was active";
return false;
}
writeConfig();
return true;
}
@ -3049,8 +3050,6 @@ void KMComposerWin::slotSpellcheckConfig()
void KMComposerWin::slotEditToolbars()
{
KConfigGroup grp(KMKernel::self()->config()->group("Composer"));
saveMainWindowSettings(grp);
QPointer<KEditToolBar> dlg = new KEditToolBar(guiFactory(), this);
connect(dlg.data(), &KEditToolBar::newToolBarConfig, this, &KMComposerWin::slotUpdateToolbars);

@ -1063,33 +1063,14 @@ void KMKernel::setFirstInstance(bool value)
void KMKernel::closeAllKMailWindows()
{
QList<KMainWindow *> windowsToDelete;
foreach (KMainWindow *window, KMainWindow::memberList()) {
if (::qobject_cast<KMMainWin *>(window)
|| ::qobject_cast<KMail::SecondaryWindow *>(window)) {
// close and delete the window
window->setAttribute(Qt::WA_DeleteOnClose);
window->close();
windowsToDelete.append(window);
}
}
// We delete all main windows here. Above we called close(), but that calls
// deleteLater() internally, therefore does not delete it immediately.
// This would lead to problems when closing Kontact when a composer window
// is open, because the destruction order is:
//
// 1. destructor of the Kontact mainwinow
// 2. delete all parts
// 3. the KMail part destructor calls KMKernel::cleanup(), which calls
// this function
// 4. delete all other mainwindows
//
// Deleting the composer windows here will make sure that step 4 will not delete
// any composer window, which would fail because the kernel is already deleted.
qDeleteAll(windowsToDelete);
windowsToDelete.clear();
}
void KMKernel::cleanup(void)

Loading…
Cancel
Save