/*****************************************************************************
 *
 *  miniconsolewidget.h -- Mini console for command line task output.
 *
 *  Copyright (C) 2010 Starbuck <starbuck@labdv.com>
 *  All rights reserved.
 *
 *  This file is part of the Gui4 module of the DVDx 4 application.
 *
 *  GNU Lesser General Public License Usage
 *  This file may be used under the terms of the GNU Lesser General
 *  Public License version 2.1 as published by the Free Software
 *  Foundation and appearing in the file LICENSE.LGPL included in the
 *  packaging of this file.  Please review the following information to
 *  ensure the GNU Lesser General Public License version 2.1 requirements
 *  will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 *
 *  GNU General Public License Usage
 *  Alternatively, this file may be used under the terms of the GNU
 *  General Public License version 3.0 as published by the Free Software
 *  Foundation and appearing in the file LICENSE.GPL included in the
 *  packaging of this file.  Please review the following information to
 *  ensure the GNU General Public License version 3.0 requirements will be
 *  met: http://www.gnu.org/copyleft/gpl.html.
 *
 *****************************************************************************/

#ifndef MINICONSOLEWIDGET_H
#define MINICONSOLEWIDGET_H

#include "consoledialog.h"
#include "../job/task.h"
#include <QWidget>
#include <QString>
#include <QTextEdit>
#include <QLabel>
#include <QPushButton>
#include <QGroupBox>
#include <QProgressBar>
#include <QLayout>
#include <QCloseEvent>

class MiniConsoleWidget : public QWidget
{
	Q_OBJECT

public:
	MiniConsoleWidget(ConsoleDialog *, QWidget *parent=0);
	~MiniConsoleWidget();

	inline void deleteConsole() { delete(console); };

	void setNoStateDisplay(bool);
	void setNoConsoleButton(bool);
	inline void setTotalTime(const double t) { totalTime = t; };
	inline void setTotalFrame(const int t) { totalFrame = t; };
	inline void setTotalSize(const int kB) { totalSize = kB; };
	inline void setRemovable(const bool b) { removable = b; };

	inline ConsoleDialog *getConsole() { return console; };
	inline Task *getTask() { return task; };
	inline bool isRemovable() { return removable; };

signals:
	void requestToAbort(MiniConsoleWidget *);
	void requestToRemove(MiniConsoleWidget *);

protected slots:
	void clickProcess();
	void displayProgress(int, double, int, int);
	void displayProgress();
	void showConsole(bool);

protected:
	void changeStateDisplay();

protected:
	Task *task;
	ConsoleDialog *console;

	QWidget *miniConsoleGroup;
	QHBoxLayout *miniConsoleLayout;

	QPushButton *showConsoleButton;
	QPushButton *stateDisplay;
	bool noStateDisplay;

	QLabel *taskTitle;
	QProgressBar *progress;

	double totalTime;
	int totalFrame;
	int totalSize;		// total size in kBytes
	bool removable;
};

#endif
