File indexing completed on 2024-04-14 15:17:40

0001 /******************************************************************************
0002   Copyright (C) 2003 by Jeroen Wijnhout (Jeroen.Wijnhout@kdemail.net)
0003         2017 by Michel Ludwig (michel.ludwig@kdemail.net)
0004  ******************************************************************************/
0005 
0006 /***************************************************************************
0007  *                                                                         *
0008  *   This program is free software; you can redistribute it and/or modify  *
0009  *   it under the terms of the GNU General Public License as published by  *
0010  *   the Free Software Foundation; either version 2 of the License, or     *
0011  *   (at your option) any later version.                                   *
0012  *                                                                         *
0013  ***************************************************************************/
0014 
0015 #include "kilewizard.h"
0016 
0017 #include <QDialogButtonBox>
0018 #include <QPushButton>
0019 #include <QShowEvent>
0020 
0021 #include "utilities.h"
0022 
0023 namespace KileDialog
0024 {
0025 Wizard::Wizard(KConfig *config, QWidget *parent, const char *name, const QString &caption)
0026     : QDialog(parent)
0027     , m_td(QString(), QString(), QString(), 0, 0, QString())
0028     , m_config(config)
0029     , m_buttonBox(new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel))
0030 {
0031     setObjectName(name);
0032     setWindowTitle(caption);
0033     setModal(true);
0034 
0035     // add buttons
0036     QPushButton *okButton = m_buttonBox->button(QDialogButtonBox::Ok);
0037     okButton->setDefault(true);
0038     okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
0039     okButton->setDefault(true);
0040     connect(m_buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
0041     connect(m_buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
0042 }
0043 
0044 Wizard::~Wizard()
0045 {}
0046 
0047 KConfig* Wizard::config() const
0048 {
0049     return m_config;
0050 }
0051 
0052 QDialogButtonBox * Wizard::buttonBox() const
0053 {
0054     return m_buttonBox;
0055 }
0056 
0057 void Wizard::showEvent(QShowEvent *event)
0058 {
0059     // even with 'showEvent' the dialog might not be shown yet, only about to be shown
0060     // so we have to 'schedule' a centering (still does not work all the time)
0061     KileUtilities::scheduleCenteringOfWidget(this);
0062     QDialog::showEvent(event);
0063 }
0064 
0065 }