/*======================================================================================

	Program:		Range Imaging Toolkit (RITK)
	Module:			ritkMainWindow.h
	Version:		$Revision: 2476 $
	Date:			$Date: 2012-01-25 09:35:30 +0100 (Mi, 25 Jan 2012) $

	Copyright (c) 2010-2011
	Pattern Recognition Lab, 
    University Erlangen-Nuremberg, Germany
    All rights reserved.

	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 RITKCopyright.txt for more information.

	http://www5.informatik.uni-erlangen.de/research/software/ritk

========================================================================================*/

#ifndef MAINWINDOW_H__
#define MAINWINDOW_H__

#include "ui_ritkMainWindow.h"

#include <QMainWindow>
#include <QList>
#include <QDir>
#include <QActionGroup>
#include <QTextEdit>
#include <QShortcut>

#include "ritkSourcePlugin.h"
#include "ritkAboutDialog.h"
#include "ritkHotkeysDialog.h"
#include "ritkPluginManager.h"
#include "ritkPluginCreator.h"


namespace ritk
{

/**	@ingroup	Core
 *	@class		MainWindow
 *	@author		Jakob Wasza / Sebastian Bauer
 *	@brief		Main window of the RITK
 *
 *	@details
 *	The mainwindow of the RITK framework. The GUIs of player-, filter-, and
 *	application plugins will be arranged within the mainwindow. Additionally,
 *	the mainwindow provides a menu bar with the following items: \n
 *		-	Select the player	\n
 *		-	Options				\n
 *		-	Tools				\n
 *		-	Help				\n
 *	Adding and removing players from the corresponding is supported (@sa SourcePlugin).
 *	@todo	A detailed description of the process of adding/removing source plugins:  PlayerActionStruct, m_Players, AddPlayer, and RemovePlayer
 */
class CORE_EXPORT MainWindow : public QMainWindow, public Ui_MainWindow
{
	Q_OBJECT

public:
	/// Constructor
	MainWindow(QWidget* parent = 0, Qt::WindowFlags flags = 0);
	/// Destructor
	virtual ~MainWindow();

	/// Add player menu action	@todo 
	void AddPlayer(SourcePlugin *Player, QString Name);
	/// Remove a players menu action
	void RemovePlayer(SourcePlugin *Player);

signals:
	///	Emitted when the user triggers the plugin creator @todo Is this signal mandatory? If not, remove it!
	void ShowPluginCreatorDialog();
	///	Emitted when the user triggers the plugin manager dialog @todo Is this signal mandatory? If not, remove it!
	void ShowPluginManagerDialog();
	///	Emitted when the user triggers the plugin config dialog @todo Is this signal mandatory? If not, remove it!
	void ShowPluginConfigDialog();
	/// Signal that is emitted when the mainwindow is shut down
	void ShutDown();

	/// Signal that is emitted if a plugin is to be unregistered
	void ClosePlugin(int TabId, PluginManager::PluginTypes);
	
protected:
     void closeEvent(QCloseEvent *event);

protected slots:	
	/// Show the plugin creator
	void ShowPluginCreator();
	/// Show the plugin manager dialog
	void ShowPluginManager();
	/// Show the plugin config dialog
	void ShowPluginConfig();
	/// Show the about ritk dialog
	void AboutRITK();
	/// Show the hotkeys list
	void ShowHotkeys();

	/// Connected to the filter plugins close buttons
	void FilterPluginTabCloseRequested(int TabId);
	/// Connected to the application plugins close buttons
	void ApplicationPluginTabCloseRequested(int TabId);


protected:
	/// Pointer to the about dialog
	AboutDialog *m_AboutDialog;
	/// Pointer to the hotkeys list dialog
	HotkeysDialog *m_HotkeysDialog;
	/// Action group for the players
	QActionGroup *m_PlayerActionGroup;

	/// Struct that is used for dynamic management of source plugins.
	typedef struct 
	{
		/// The actual plugin
		SourcePlugin *Player;
		/// The corresponding action in the menu bar
		QAction *Action;
	} PlayerActionStruct;
	/// Holds all players that can be selected
	QList<PlayerActionStruct> m_Players;

	/// The shortcut to open the PluginManager
	QShortcut * m_PluginManagerShortcut;
};


} // end namespace ritk

#endif // MAINWINDOW_H__
