1 /***************************************************************************
2  *   Copyright (C) 2016 Christian Ehrlicher <ch.ehrlicher@gmx.de>          *
3  *                                                                         *
4  *   This program is free software; you can redistribute it and/or modify  *
5  *   it under the terms of the GNU General Public License as published by  *
6  *   the Free Software Foundation; either version 2 of the License, or     *
7  *   (at your option) any later version.                                   *
8  *                                                                         *
9  *   This program is distributed in the hope that it will be useful,       *
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12  *   GNU General Public License for more details.                          *
13  *                                                                         *
14  *   You should have received a copy of the GNU General Public License     *
15  *   along with this program; if not, write to the                         *
16  *   Free Software Foundation, Inc.,                                       *
17  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
18  ***************************************************************************/
19 #pragma once
20 
21 #include <QDialog>
22 
23 class QDialogButtonBox;
24 class QVBoxLayout;
25 
26 class KSvnDialog : public QDialog
27 {
28     Q_OBJECT
29 public:
30     explicit KSvnDialog(const QString &configGroupName, QWidget *parent = nullptr);
31     ~KSvnDialog();
32 
33 protected:
34     void setDefaultButton(QPushButton *defaultButton);
35     void showEvent(QShowEvent *e) override;
36 private:
37     QString m_configGroupName;
38 };
39 
40 class KSvnSimpleOkDialog : public KSvnDialog
41 {
42     Q_OBJECT
43 public:
44     explicit KSvnSimpleOkDialog(const QString &configGroupName, QWidget *parent = nullptr);
45 
46     /**
47      * @brief Add a cancel button to the button box
48      */
49     void setWithCancelButton();
50     /**
51      * @brief Add a new widget to the VBoxLayout
52      */
53     void addWidget(QWidget *widget);
54     /**
55      * @brief Add the button box to the vbox layout.
56      * only needed if exec() is not called
57      * --> if it is not treated as modal dialog
58      */
59     void addButtonBox();
60     /**
61      * @brief Set the appropriate help context
62      */
63     void setHelp(const QString &context);
64     int exec() override;
65 
buttonBox()66     QDialogButtonBox *buttonBox() { return m_bBox; }
67 
68 private Q_SLOTS:
69     void onHelpRequested();
70 private:
71     QVBoxLayout *m_layout;
72     QDialogButtonBox *m_bBox;
73     bool m_bBoxAdded;
74     QString m_helpContext;
75 };
76