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