1 /* vi: set sw=4 ts=4:
2  *
3  * Copyright (C) 2001 - 2015 Christian Hohnstaedt.
4  *
5  * All rights reserved.
6  */
7 
8 #ifndef __XCAAPPLICATION_H
9 #define __XCAAPPLICATION_H
10 
11 #include <QApplication>
12 #include <QTranslator>
13 #include <QLocale>
14 
15 class MainWindow;
16 class QAction;
17 
18 class XcaTranslator : public QTranslator
19 {
20 	Q_OBJECT
21 public:
QTranslator(p)22 	XcaTranslator(QObject *p = NULL) : QTranslator(p) { }
load(const QLocale & locale,const QString & filename,const QString & dir)23 	bool load(const QLocale &locale, const QString &filename,
24 		const QString &dir)
25 	{
26 		return QTranslator::load(QString("%1_%2").arg(filename)
27 						.arg(locale.name()), dir);
28 	}
29 };
30 
31 class XcaApplication : public QApplication
32 {
33 	Q_OBJECT
34 
35 private:
36 	MainWindow *mainw;
37 	XcaTranslator *qtTr;
38 	XcaTranslator *xcaTr;
39 	static QLocale lang;
40 	static QList<QLocale> langAvail;
41 
42 public:
43 	XcaApplication(int &argc, char *argv[]);
44 	virtual ~XcaApplication();
45 	void setMainwin(MainWindow *m);
46 	void setupLanguage(QLocale lang);
language()47 	static QLocale language() { return lang; }
48 	static QFont tableFont;
49 	static bool languageAvailable(QLocale l);
50 	bool eventFilter(QObject *watched, QEvent *ev);
51 	bool notify(QObject* receiver, QEvent* event);
52 
53 public slots:
54 	void switchLanguage(QAction* a);
55 	void quit();
56 };
57 #endif
58