/*
    QAD - Qt ADvanced

    Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef ABOUTWINDOW_H
#define ABOUTWINDOW_H

#include "qad_application_export.h"

#include <QDialog>


#define ADD_ABOUT_VERSION(lib)                                                                                         \
	{                                                                                                                  \
		if (lib##_VERSION_BUILD > 0)                                                                                   \
			AboutWindow::addVersion(#lib, lib##_VERSION_NAME " (build " + QString::number(lib##_VERSION_BUILD) + ")"); \
		else                                                                                                           \
			AboutWindow::addVersion(#lib, lib##_VERSION_NAME);                                                         \
	}
#define ADD_ABOUT_VERSION_NAMED(lib, label)                                                                             \
	{                                                                                                                   \
		if (lib##_VERSION_BUILD > 0)                                                                                    \
			AboutWindow::addVersion(label, lib##_VERSION_NAME " (build " + QString::number(lib##_VERSION_BUILD) + ")"); \
		else                                                                                                            \
			AboutWindow::addVersion(label, lib##_VERSION_NAME);                                                         \
	}
#define ADD_ABOUT_BUILD_INFO(lib)                              \
	AboutWindow::addBuildInfo("Arch", lib##_ARCH);             \
	AboutWindow::addBuildInfo("Compiler", lib##_CXX_COMPILER); \
	AboutWindow::addBuildInfo("CMake", lib##_CMAKE_VERSION);   \
	AboutWindow::addBuildInfo("Date", lib##_BUILD_DATE);

namespace Ui {
class AboutWindow;
}

class QAD_APPLICATION_EXPORT AboutWindow: public QDialog {
	Q_OBJECT
	typedef QPair<QString, QString> SSPair;
	explicit AboutWindow(QWidget * parent = 0);
	~AboutWindow();

public:
	static void setLogo(QImage im);
	static void setLogo(QString path);
	static void addVersion(QString name, QString version);
	static void addBuildInfo(QString name, QString value);
	static void setComment(QString text);
	static void setStyleSheet(QString ss);

	static void show();

protected:
	virtual void changeEvent(QEvent * e);
	virtual int exec();

	QString authors();

private:
	Ui::AboutWindow * ui;

	static QImage logo;
	static QVector<SSPair> versions, builds;
	static QString stylesheet, comment;
};

#endif // ABOUTWINDOW_H
