--- a/trunk/CommandLineOut.h
+++ b/trunk/ConsoleManager.h
@@ -1,7 +1,7 @@
/* ----------------------------------------------------------------
SmillaEnlarger - resize, especially magnify bitmaps in high quality
- CommandLineOut.h: QObject for accepting signals from EnlargerThread for command line output
+ ConsoleManager.h: command line functionality
Copyright (C) 2009 Mischa Lusteck
@@ -20,31 +20,73 @@
along with this program; if not, see <http://www.gnu.org/licenses/>.
---------------------------------------------------------------------- */
-#ifndef COMMANDLINEOUT_H
-#define COMMANDLINEOUT_H
+#ifndef CONSOLEMANAGER_H
+#define CONSOLEMANAGER_H
#include <QString>
#include <QObject>
+#include <QImage>
#include <iostream>
+
+#include "ArgumentParser.h"
+#include "ImageEnlargerCode/EnlargeParam.h"
using namespace std;
+class EnlargerThread;
+class EnlargerDialog;
+
+// QObject for console output
class EnlargerOut : public QObject {
Q_OBJECT
QString dstName;
+ bool ended;
public:
- EnlargerOut( const QString & dstNam ) : QObject(), dstName(dstNam)
- { cout<<"Calculating "<<dstName.toStdString()<<": ["<<flush; }
+ EnlargerOut( void ) : QObject() { ended=false;}
~EnlargerOut( void ) {}
+ void SetName( const QString & name ) { dstName = name; }
+ void StartMessage( void ) { cout<<"Calculating '"<<dstName.toStdString()<<"' - "<<flush; }
public slots:
- void PrintProgress( int p ) { cout<<"."<<flush; if( p>=100 ) cout<<"]"<<flush; }
+ void PrintProgress( int p ) {
+ if( !ended ) { cout<<"\rCalculating '"<<dstName.toStdString()<<"' - [ "<<p<<"% ] "<<flush; } }
void badAlloc( void )
- { cout<<" ERROR ]\nCould not allocate enough memory for '"<<dstName.toStdString()<<"'./n"<<flush; }
+ { cout<<"\n[ ERROR ]\nCould not allocate enough memory for '"<<dstName.toStdString()<<"'.\n"<<flush; ended=true; }
void imageNotSaved( void )
- { cout<<" \n[ ERROR ] - Could not save image '"<<dstName.toStdString()<<"'./n"<<flush; }
- void imageSaved( void ) { }
+ { cout<<" \n[ ERROR ] - Could not save image '"<<dstName.toStdString()<<"'.\n"<<flush; ended=true; }
+ void imageSaved( void ) { cout<<" OK.\n"<<flush; ended=true; }
};
-#endif // COMMANDLINEOUT_H
+class ConsoleManager : public QObject {
+ Q_OBJECT
+
+ bool parseError;
+ ArgumentParser myParser;
+ IntegerOption oZoom;
+ IntegerOption oWidth, oHeight;
+
+ IntegerOption oSharp, oFlat;
+ IntegerOption oDeNoise, oPreSharp;
+ IntegerOption oDither, oFNoise;
+
+ StringOption oOutput;
+ BasicOption oHelp, oInteractive;
+
+ EnlargerOut myEnOut;
+
+ QString dstName;
+
+public:
+ ConsoleManager( int argc, char *argv[] );
+ ~ConsoleManager( void ) {}
+ bool UseGUI( void );
+ void SetupEnlargerDialog ( EnlargerDialog & theDialog );
+ bool StartConsoleEnlarge ( EnlargerThread & myThread );
+ bool TryOpenSource( QString filename, QImage & srcImage );
+ void PrintHelp( void );
+
+};
+
+
+#endif // CONSOLEMANAGER_H