KissCount/src/view/wxUI.hpp

131 lines
2.9 KiB
C++
Raw Normal View History

2010-07-10 16:34:30 +02:00
/*
2012-02-01 11:02:54 +01:00
Copyright 2010-2012 Grégory Soutadé
2010-07-10 16:34:30 +02:00
This file is part of KissCount.
2010-07-10 16:34:30 +02:00
KissCount is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
2010-07-10 16:34:30 +02:00
KissCount 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 General Public License for more details.
2010-07-10 16:34:30 +02:00
You should have received a copy of the GNU General Public License
along with KissCount. If not, see <http://www.gnu.org/licenses/>.
2010-07-10 16:34:30 +02:00
*/
#ifndef WXUI_H
#define WXUI_H
2011-03-13 19:15:21 +01:00
class ImportEngine;
2011-08-25 17:45:41 +02:00
#include <QFrame>
#include <QLocale>
2011-09-04 11:21:30 +02:00
#include <QHBoxLayout>
2011-08-25 17:45:41 +02:00
#include <QVBoxLayout>
#include <QScrollArea>
#include <QPushButton>
2011-09-04 19:25:53 +02:00
#include <QSignalMapper>
2011-08-25 17:45:41 +02:00
2011-08-20 14:02:47 +02:00
#include <controller/KissCount.hpp>
2011-08-20 11:43:12 +02:00
#include "view.hpp"
#include "SupportedLanguages.hpp"
2011-08-25 17:45:41 +02:00
#include <qtranslator.h>
#include <qtextcodec.h>
#define _(s) QApplication::translate("", s)
// #define _(s) QObject::trUtf8(s)
2011-02-05 21:02:03 +01:00
class KissCount;
2011-08-20 11:43:12 +02:00
class KissPanel;
class AccountPanel;
2010-05-17 18:03:21 +02:00
class PreferencesPanel;
2011-08-25 17:45:41 +02:00
class wxUI: public QFrame
{
2011-09-03 20:40:21 +02:00
Q_OBJECT;
public:
static const int MAX_CATEGORY = 12;
2011-08-27 18:35:36 +02:00
static QString months[MAX_CATEGORY];
2011-08-25 17:45:41 +02:00
static QColor categoryColors[MAX_CATEGORY];
2011-08-25 17:45:41 +02:00
wxUI(KissCount* kiss, const QString& title);
~wxUI();
2011-08-27 18:35:36 +02:00
bool SetLanguage(QString language);
void ChangeUser();
void LoadUser();
2010-05-16 10:35:34 +02:00
void ShowAccount();
void ShowSearch();
void ShowPreferences();
void GenerateMonth(int month, int year);
void UpdateStats();
2010-05-17 18:03:21 +02:00
void KillMe();
2010-06-27 21:39:49 +02:00
void ShowPanel(KissPanel* panel);
void NeedReload();
2010-06-27 21:39:49 +02:00
QLocale* GetLocale() {return _locale;}
QString GetDateFormat();
QString _language;
SupportedLanguages::language _curLanguage;
2011-09-03 20:40:21 +02:00
private slots:
2011-09-04 19:25:53 +02:00
void OnButtonClicked(int id);
2011-09-03 20:40:21 +02:00
void OnButtonChangeUser();
void OnButtonAbout();
void OnButtonQuit();
private:
KissCount *_kiss;
2011-09-04 19:25:53 +02:00
QSignalMapper _signalMapper;
2011-09-04 11:21:30 +02:00
QVBoxLayout *_vbox;
QHBoxLayout *_buttonsBox;
KissPanel *_curPanel;
std::vector<KissPanel*> _panels;
2011-08-25 17:45:41 +02:00
std::vector<QPushButton*> _buttons;
QLocale *_locale;
QTranslator _translator;
bool _needReload;
void InitPanels();
void LoadPanels();
2011-08-25 17:45:41 +02:00
};
class KissPanel: public QFrame
2011-08-25 17:45:41 +02:00
{
public:
KissPanel(KissCount* kiss, wxUI* parent) :
QFrame(static_cast<QWidget*>(parent)),
2011-08-25 17:45:41 +02:00
_kiss(kiss),
_wxUI(parent),
_KissButton(0)
{
DEFAULT_FONT(font);
hide();
setFont(font);
}
2011-08-25 17:45:41 +02:00
2011-09-04 19:25:53 +02:00
virtual void OnShow()=0;
2011-08-25 17:45:41 +02:00
virtual KissPanel* CreatePanel()=0;
2011-09-04 19:25:53 +02:00
virtual QPushButton* GetButton() {return 0;}
2011-08-27 18:35:36 +02:00
virtual QString GetToolTip() {return "";}
2011-08-25 17:45:41 +02:00
protected:
KissCount* _kiss;
wxUI* _wxUI;
QPushButton* _KissButton;
};
#endif