Merge pull request #104 from mamarley/disconnectdesyncfix
[quassel.git] / src / uisupport / aboutdata.h
1 /***************************************************************************
2  *   Copyright (C) 2005-2015 by the Quassel Project                        *
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  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
19  ***************************************************************************/
20
21 #pragma once
22
23 #include <QLocale>
24
25 #ifdef HAVE_KF5
26 #  include <KCoreAddons/KAboutData>
27 #endif
28
29
30 /**
31  * Represents a contributor or author for Quassel.
32  *
33  * This is used to show a list of contributors in the About Quassel dialog.
34  */
35 class AboutPerson
36 {
37 public:
38     /**
39      * Constructor.
40      *
41      * @param[in] name The person's name (in the form "Firstname Surname")
42      * @param[in] nick The person's nickname, if applicable
43      * @param[in] task Things the person does or has done for the project
44      * @param[in] emailAddress The person's email address, if applicable
45      * @param[in] translatedLanguage The language the person helped translate (only applicable for translators)
46      */
47     AboutPerson(const QString &name, const QString &nick, const QString &task, const QString &emailAddress = QString(), QLocale::Language translatedLanguage = QLocale::C);
48
49     /**
50      * Gets the person's name.
51      *
52      * @returns The person's name
53      */
54     QString name() const;
55
56     /**
57      * Gets the person's nick.
58      *
59      * @returns The person's nick
60      */
61     QString nick() const;
62
63     /**
64      * Gets the person's task.
65      *
66      * @returns The person's task
67      */
68     QString task() const;
69
70     /**
71      * Gets the person's e-mail address.
72      *
73      * @returns The person's e-mail address
74      */
75     QString emailAddress() const;
76
77     /**
78      * Gets the language this person helped translate.
79      *
80      * @returns The language this person helped translate
81      */
82     QLocale::Language translatedLanguage() const;
83
84     /**
85      * Gets the person's formatted name and nick.
86      *
87      * @returns The person's name and nick formatted for combined output
88      */
89     QString prettyName() const;
90
91 private:
92     QString _name;               ///< The person's name
93     QString _nick;               ///< The person's nick
94     QString _task;               ///< The person's task
95     QString _emailAddress;       ///< The person's email address
96     QLocale::Language _language; ///< The language the person helps translate
97 };
98
99
100 /**
101  * Holds a list of authors, contributors and translators.
102  *
103  * This class is meant to hold the list of people who contributed to Quassel, used for displaying
104  * the About Quassel dialog. Additionally, this class can provide a KAboutData object to be shown
105  * if KDE integration is enabled.
106  */
107 class AboutData : public QObject
108 {
109     Q_OBJECT
110 public:
111     /**
112      * Default constructor.
113      *
114      * @param[in] parent The parent object, if applicable
115      */
116     AboutData(QObject *parent = nullptr);
117
118     /**
119      * Adds an author to the list of contributors.
120      *
121      * Authors are people who contributed a significant amount of code to Quassel.
122      *
123      * @param[in] author The author to add
124      * @returns A reference to this AboutData instance
125      */
126     AboutData &addAuthor(const AboutPerson &author);
127
128     /**
129      * Adds a list of authors to the list of contributors.
130      *
131      * This method allows the use of a brace initializer in order to easily add a long list of
132      * people.
133      *
134      * @param[in] authors A list of authors to add
135      * @returns A reference to this AboutData instance
136      */
137     AboutData &addAuthors(std::initializer_list<AboutPerson> authors);
138
139     /**
140      * Adds a contributor.
141      *
142      * @param[in] author The contributor to add
143      * @returns A reference to this AboutData instance
144      */
145     AboutData &addCredit(const AboutPerson &credit);
146
147     /**
148      * Adds a list of contributors.
149      *
150      * This method allows the use of brace initializers in order to easily add a long list of
151      * people.
152      *
153      * @param[in] authors A list of contributors to add
154      * @returns A reference to this AboutData instance
155      */
156     AboutData &addCredits(std::initializer_list<AboutPerson> credits);
157
158     /**
159      * Gets the list of authors stored in this AboutData instance.
160      *
161      * @returns A list of authors
162      */
163     QList<AboutPerson> authors() const;
164
165     /**
166      * Gets the list of non-author contributors stored in this AboutData instance.
167      *
168      * @returns A list of contributors
169      */
170     QList<AboutPerson> credits() const;
171
172 #ifdef HAVE_KF5
173     /**
174      * Creates a KAboutData instance based on the contents of this AboutData instance.
175      *
176      * @returns A KAboutData instance holding the list of contributors as well as any additional
177      *          data required for KAboutDialog and friends
178      */
179     KAboutData kAboutData() const;
180 #endif
181
182     /**
183      * Fills the given AboutData instance with data relevant for Quassel itself.
184      *
185      * This method adds a (hardcoded) list of contributors to the given AboutData instance.
186      *
187      * @param[in,out] aboutData An existing AboutData instance to add Quassel's contributors to
188      */
189     static void setQuasselPersons(AboutData *aboutData);
190
191 private:
192     QList<AboutPerson> _authors;  ///< The list of authors
193     QList<AboutPerson> _credits;  ///< The list of other contributors
194 };