/*
 *  Copyright (C) 2007-2008 CMM Sigma Andrzej Chmielowiec <cmmsigma@cmmsigma.eu>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 3
 *  as published by the Free Software Foundation.
 *
 *  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 General Public License for more details.
 */

#ifndef MAIN_WINDOW_H
#define MAIN_WINDOW_H

#include <QWidget>
#include <QSystemTrayIcon>
#include <QProcess>
#include <QActionGroup>

#include "AboutBox.h"

class QAction;
class QCheckBox;
class QComboBox;
class QGroupBox;
class QLabel;
class QLineEdit;
class QMenu;
class QPushButton;
class QSpinBox;
class QTextEdit;
class QListWidget;
class QListWidgetItem;
class VpnItem;
class QProcess;
class ConnectAction;

class MainWindow: public QWidget
{
	Q_OBJECT;
	
public:
	MainWindow(QWidget *parent = 0);
	
protected:
	void closeEvent(QCloseEvent *event);
	
private slots:
	void vpnConnectSlot();
	void vpnDisConnectSlot();
	void vpnFinishSlot(int exitCode, QProcess::ExitStatus exitStatus);
	void vpnOutputSlot();
	void vpnItemActiveSlot(QListWidgetItem *item);
	void vpnNewSlot();
	void vpnInfoSlot();
	void vpnEditSlot();
	void vpnDeleteSlot();
	void aboutSlot();
	void trayIconActive(QSystemTrayIcon::ActivationReason reason);
	void exit();
	void langEnSlot();
	void langPlSlot();
	
private:
	QGroupBox *createVpnSessions();
	QGroupBox *createVpnInfo();
	void readConfFiles();
	void langExclamation();
	
	void createActions();
	void createTrayIcon();
	void createAboutBox();
	
	bool mIsConnected;
	bool mIsInitialized;
	QProcess *mVpn;
	VpnItem *mVpnActiveItem;
	VpnItem *mVpnConnectItem;
	
	QListWidget *mVpnList;
	QPushButton *mVpnConnect;
	QPushButton *mVpnDisConnect;
	QPushButton *mVpnNew;
	QPushButton *mVpnInfo;
	QPushButton *mVpnEdit;
	QPushButton *mVpnDelete;
	
	QTextEdit *mVpnOutput;
	
	QAction *mOpenAction;
	QMenu *mConnectMenu;
	QList<ConnectAction*> mConnectActions;
	QAction *mDisConnectAction;
	QAction *mConnectInfoAction;
	QAction *mAboutAction;
	QAction *mExitAction;
	QActionGroup *mLang;
	QAction *mLangEn;
	QAction *mLangPl;
	
	QSystemTrayIcon *mTrayIcon;
	QMenu *mTrayIconMenu;
	
	AboutBox *mAboutBox;
};

#endif
