File indexing completed on 2024-05-12 05:20:46
0001 /* 0002 secondarywindow.cpp 0003 0004 This file is part of KMail, the KDE mail client. 0005 SPDX-FileCopyrightText: 2003 Ingo Kloecker <kloecker@kde.org> 0006 0007 SPDX-License-Identifier: GPL-2.0-only 0008 */ 0009 0010 #include "secondarywindow.h" 0011 #include "kmkernel.h" 0012 0013 #include <KLocalizedString> 0014 0015 #include <QCloseEvent> 0016 0017 using namespace KMail; 0018 //--------------------------------------------------------------------------- 0019 SecondaryWindow::SecondaryWindow(const QString &name) 0020 : KXmlGuiWindow(nullptr) 0021 { 0022 setObjectName(name); 0023 } 0024 0025 //--------------------------------------------------------------------------- 0026 SecondaryWindow::~SecondaryWindow() = default; 0027 0028 //--------------------------------------------------------------------------- 0029 void SecondaryWindow::closeEvent(QCloseEvent *e) 0030 { 0031 // if there's a system tray applet then just do what needs to be done if a 0032 // window is closed. 0033 if (kmkernel->haveSystemTrayApplet()) { 0034 // BEGIN of code borrowed from KMainWindow::closeEvent 0035 // Save settings if auto-save is enabled, and settings have changed 0036 if (settingsDirty() && autoSaveSettings()) { 0037 saveAutoSaveSettings(); 0038 } 0039 0040 if (!queryClose()) { 0041 e->ignore(); 0042 } 0043 // END of code borrowed from KMainWindow::closeEvent 0044 } else { 0045 KMainWindow::closeEvent(e); 0046 } 0047 } 0048 0049 void SecondaryWindow::setCaption(const QString &userCaption) 0050 { 0051 const QString caption = QGuiApplication::applicationDisplayName(); 0052 QString captionString = userCaption.isEmpty() ? caption : userCaption; 0053 if (!userCaption.isEmpty()) { 0054 // Add the application name if: 0055 // User asked for it, it's not a duplication and the app name (caption()) is not empty 0056 if (!caption.isEmpty()) { 0057 captionString += i18nc("Document/application separator in titlebar", " – ") + caption; 0058 } 0059 } 0060 0061 setWindowTitle(captionString); 0062 } 0063 0064 #include "moc_secondarywindow.cpp"