example/DemoGUI/main.cpp
author cgandhi
Thu, 05 Aug 2010 16:35:33 +0530
changeset 16 b78fa4cdbf2b
child 27 b3e1347ac96a
permissions -rw-r--r--
pushing the demo application
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
     1
#include <QtGui/QApplication>
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
     2
#include "mainwindow.h"
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
     3
#include<qfile.h>
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
     4
#include<qtextstream.h>
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
     5
#ifdef Q_OS_SYMBIAN
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
     6
#include <eikenv.h>
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
     7
#include <eikappui.h>
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
     8
#include <aknenv.h>
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
     9
#include <aknappui.h>
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    10
#endif
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    11
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    12
void debugOutput(QtMsgType type, const char *msg)
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    13
	{
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    14
	QFile logFile("c://data//SmfLog.txt");
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    15
	Q_ASSERT(logFile.open( QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append ));
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    16
	QTextStream stream(&logFile);
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    17
	
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    18
	switch (type)
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    19
		{
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    20
		case QtDebugMsg:
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    21
			stream<<msg<<"\n";
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    22
			break;
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    23
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    24
		case QtWarningMsg:
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    25
			stream<<"Warning: ";
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    26
			stream<<msg<<"\n";
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    27
			break;
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    28
			
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    29
		case QtCriticalMsg:
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    30
			stream<<"Critical: ";
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    31
			stream<<msg<<"\n";
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    32
			break;
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    33
			
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    34
		case QtFatalMsg:
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    35
			stream<<"Fatal: ";
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    36
			stream<<msg<<"\n";
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    37
			break;
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    38
			
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    39
		default:;
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    40
		}
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    41
	}
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    42
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    43
int main(int argc, char *argv[])
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    44
{
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    45
    qInstallMsgHandler(debugOutput);
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    46
    QApplication a(argc, argv);
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    47
    MainWindow w;
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    48
#ifdef Q_OS_SYMBIAN    
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    49
CAknAppUi* appUi = dynamic_cast<CAknAppUi*> (CEikonEnv::Static()->AppUi()); 
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    50
TRAPD(error,     
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    51
if (appUi) {        // Lock application orientation into landscape        
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    52
appUi->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait);    
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    53
}    
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    54
);    
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    55
#endif
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    56
  
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    57
    
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    58
    w.showFullScreen();
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    59
    return a.exec();
b78fa4cdbf2b pushing the demo application
cgandhi
parents:
diff changeset
    60
}