Clazy fix++
[kdepim.git] / kmail / secondarywindow.cpp
blob24442dc2eaef71953eece223e9104b484449a9f4
1 /*
2 secondarywindow.cpp
4 This file is part of KMail, the KDE mail client.
5 Copyright (c) 2003 Ingo Kloecker <kloecker@kde.org>
7 KMail is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License, version 2, as
9 published by the Free Software Foundation.
11 KMail is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 In addition, as a special exception, the copyright holders give
21 permission to link the code of this program with any edition of
22 the Qt library by Trolltech AS, Norway (or with modified versions
23 of Qt that use the same license as Qt), and distribute linked
24 combinations including the two. You must obey the GNU General
25 Public License in all respects for all of the code used other than
26 Qt. If you modify this file, you may extend this exception to
27 your version of the file, but you are not obligated to do so. If
28 you do not wish to do so, delete this exception statement from
29 your version.
32 #include "secondarywindow.h"
33 #include "kmkernel.h"
35 #include <QApplication>
36 #include <KLocalizedString>
38 #include <QCloseEvent>
40 namespace KMail
43 //---------------------------------------------------------------------------
44 SecondaryWindow::SecondaryWindow(const char *name)
45 : KXmlGuiWindow(Q_NULLPTR)
47 setObjectName(QLatin1String(name));
48 // Set this to be the group leader for all subdialogs - this means
49 // modal subdialogs will only affect this window, not the other windows
50 setAttribute(Qt::WA_GroupLeader);
53 //---------------------------------------------------------------------------
54 SecondaryWindow::~SecondaryWindow()
58 //---------------------------------------------------------------------------
59 void SecondaryWindow::closeEvent(QCloseEvent *e)
61 // if there's a system tray applet then just do what needs to be done if a
62 // window is closed.
63 if (kmkernel->haveSystemTrayApplet()) {
64 // BEGIN of code borrowed from KMainWindow::closeEvent
65 // Save settings if auto-save is enabled, and settings have changed
66 if (settingsDirty() && autoSaveSettings()) {
67 saveAutoSaveSettings();
70 if (!queryClose()) {
71 e->ignore();
73 // END of code borrowed from KMainWindow::closeEvent
74 } else {
75 KMainWindow::closeEvent(e);
79 void SecondaryWindow::setCaption(const QString &userCaption)
81 const QString caption = QGuiApplication::applicationDisplayName();
82 QString captionString = userCaption.isEmpty() ? caption : userCaption;
83 if (!userCaption.isEmpty()) {
84 // Add the application name if:
85 // User asked for it, it's not a duplication and the app name (caption()) is not empty
86 if (!caption.isEmpty()) {
87 captionString += i18nc("Document/application separator in titlebar", " – ") + caption;
91 setWindowTitle(captionString);
94 } // namespace KMail