Remove double margin
[kdepim.git] / kaddressbook / mainwindow.cpp
blobb63e7eea78140970827e0ea4c9019746a07ad6e6
1 /*
2 This file is part of KAddressBook.
4 Copyright (c) 2007 Tobias Koenig <tokoe@kde.org>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU 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.
21 #include "mainwindow.h"
22 #include "mainwidget.h"
23 #include "xxport/xxportmanager.h"
25 #include <KConfigGroup>
26 #include <KToolBar>
27 #include <QAction>
28 #include <KActionCollection>
29 #include <KEditToolBar>
30 #include <KShortcutsDialog>
31 #include <KStandardAction>
32 #include <KLocalizedString>
33 #include <KSharedConfig>
35 MainWindow::MainWindow()
36 : KXmlGuiWindow(Q_NULLPTR)
38 mMainWidget = new MainWidget(this, this);
40 setCentralWidget(mMainWidget);
42 initActions();
44 setStandardToolBarMenuEnabled(true);
46 toolBar()->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
48 setupGUI(Save | Create, QStringLiteral("kaddressbookui.rc"));
50 setAutoSaveSettings();
53 MainWindow::~MainWindow()
57 MainWidget *MainWindow::mainWidget() const
59 return mMainWidget;
62 void MainWindow::initActions()
64 KStandardAction::quit(this, SLOT(close()), actionCollection());
66 QAction *action =
67 KStandardAction::keyBindings(this, SLOT(configureKeyBindings()), actionCollection());
68 action->setWhatsThis(
69 i18nc("@info:whatsthis",
70 "You will be presented with a dialog where you can configure "
71 "the application-wide shortcuts."));
72 KStandardAction::configureToolbars(this, SLOT(configureToolbars()), actionCollection());
73 KStandardAction::preferences(this, SLOT(configure()), actionCollection());
76 void MainWindow::configure()
78 mMainWidget->configure();
81 void MainWindow::configureKeyBindings()
83 if (KShortcutsDialog::configure(actionCollection(), KShortcutsEditor::LetterShortcutsAllowed, this)) {
84 mMainWidget->updateQuickSearchText();
88 void MainWindow::configureToolbars()
90 KConfigGroup grp = KSharedConfig::openConfig()->group("MainWindow");
91 saveMainWindowSettings(grp);
93 KEditToolBar dlg(factory());
94 connect(&dlg, &KEditToolBar::newToolBarConfig, this, &MainWindow::newToolbarConfig);
95 dlg.exec();
98 void MainWindow::newToolbarConfig()
100 createGUI(QStringLiteral("kaddressbookui.rc"));
102 applyMainWindowSettings(KSharedConfig::openConfig()->group("MainWindow"));