fixing a bug where quit messages from different networks were shown if the user has...
[quassel.git] / src / qtui / coreconfigwizard.h
1 /***************************************************************************
2  *   Copyright (C) 2005-08 by the Quassel IRC Team                         *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) version 3.                                           *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20
21 #ifndef _CORECONFIGWIZARD_H_
22 #define _CORECONFIGWIZARD_H_
23
24 #include <QHash>
25 #include <QWizard>
26 #include <QVariantMap>
27
28 #include "ui_coreconfigwizardintropage.h"
29 #include "ui_coreconfigwizardadminuserpage.h"
30 #include "ui_coreconfigwizardstorageselectionpage.h"
31 #include "ui_coreconfigwizardsyncpage.h"
32
33 namespace CoreConfigWizardPages {
34   class SyncPage;
35   class SyncRelayPage;
36 };
37
38 class CoreConfigWizard : public QWizard {
39   Q_OBJECT
40
41   public:
42     enum {
43       IntroPage,
44       AdminUserPage,
45       StorageSelectionPage,
46       SyncPage,
47       SyncRelayPage,
48       StorageDetailsPage,
49       ConclusionPage
50     };
51
52     CoreConfigWizard(const QList<QVariant> &backends, QWidget *parent = 0);
53     QHash<QString, QVariant> backends() const;
54
55   signals:
56     void setupCore(const QVariant &setupData);
57     void loginToCore(const QVariantMap &loginData);
58
59   public slots:
60     void loginSuccess();
61     void syncFinished();
62
63   private slots:
64     void prepareCoreSetup(const QString &backend);
65     void coreSetupSuccess();
66     void coreSetupFailed(const QString &);
67     void startOver();
68
69   private:
70     QHash<QString, QVariant> _backends;
71     CoreConfigWizardPages::SyncPage *syncPage;
72     CoreConfigWizardPages::SyncRelayPage *syncRelayPage;
73 };
74
75 namespace CoreConfigWizardPages {
76
77   class IntroPage : public QWizardPage {
78     Q_OBJECT
79
80     public:
81       IntroPage(QWidget *parent = 0);
82       int nextId() const;
83     private:
84       Ui::CoreConfigWizardIntroPage ui;
85   };
86
87   class AdminUserPage : public QWizardPage {
88     Q_OBJECT
89
90     public:
91       AdminUserPage(QWidget *parent = 0);
92       int nextId() const;
93       bool isComplete() const;
94     private:
95       Ui::CoreConfigWizardAdminUserPage ui;
96   };
97
98   class StorageSelectionPage : public QWizardPage {
99     Q_OBJECT
100
101     public:
102       StorageSelectionPage(const QHash<QString, QVariant> &backends, QWidget *parent = 0);
103       int nextId() const;
104       QString selectedBackend() const;
105     private slots:
106       void on_backendList_currentIndexChanged();
107     private:
108       Ui::CoreConfigWizardStorageSelectionPage ui;
109       QHash<QString, QVariant> _backends;
110   };
111
112   class SyncPage : public QWizardPage {
113     Q_OBJECT
114
115     public:
116       SyncPage(QWidget *parent = 0);
117       void initializePage();
118       int nextId() const;
119       bool isComplete() const;
120
121     public slots:
122       void setStatus(const QString &status);
123       void setError(bool);
124       void setComplete(bool);
125
126     signals:
127       void setupCore(const QString &backend);
128
129     private:
130       Ui::CoreConfigWizardSyncPage ui;
131       bool complete;
132       bool hasError;
133   };
134
135   class SyncRelayPage : public QWizardPage {
136     Q_OBJECT
137
138     public:
139       SyncRelayPage(QWidget *parent = 0);
140       int nextId() const;
141       enum Mode { Success, Error };
142
143     public slots:
144       void setMode(Mode);
145
146     signals:
147       void startOver() const;
148
149     private:
150       Mode mode;
151   };
152
153 }
154
155 #endif