mirror of
https://github.com/martravi/wiiqt.git
synced 2025-02-16 17:29:13 +01:00
* nandChecker: don't use bundle crap on OSx. add color stuff for win32
This commit is contained in:
parent
b45b4dfd83
commit
14f32c8fd6
@ -22,7 +22,29 @@ bool tryToKeepGoing = false;
|
||||
bool color = true;
|
||||
QByteArray sysMenuResource;
|
||||
|
||||
#ifndef Q_WS_WIN
|
||||
#ifdef Q_WS_WIN
|
||||
#include <windows.h> // WinApi header
|
||||
#define C_STICKY 31
|
||||
#define C_CAP 192
|
||||
|
||||
int origColor;
|
||||
HANDLE hConsole;
|
||||
|
||||
int GetColor()
|
||||
{
|
||||
WORD wColor = 0;
|
||||
|
||||
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
//We use csbi for the wAttributes word.
|
||||
if( GetConsoleScreenBufferInfo(hStdOut, &csbi ) )
|
||||
{
|
||||
wColor = csbi.wAttributes;
|
||||
}
|
||||
return wColor;
|
||||
}
|
||||
|
||||
#else
|
||||
#define LEN_STR_PAIR(s) sizeof (s) - 1, s
|
||||
enum indicator_no
|
||||
{
|
||||
@ -71,7 +93,7 @@ static void put_indicator( const struct bin_str *ind )
|
||||
{
|
||||
fwrite( ind->string, ind->len, 1, stdout );
|
||||
}
|
||||
|
||||
#endif
|
||||
void PrintColoredString( const char *msg, int highlite )
|
||||
{
|
||||
if( !color )
|
||||
@ -84,13 +106,21 @@ void PrintColoredString( const char *msg, int highlite )
|
||||
QString m2 = m.trimmed();
|
||||
m.resize( m.indexOf( m2 ) );
|
||||
printf( "%s", m.toLatin1().data() ); //print all leading whitespace
|
||||
#ifdef Q_WS_WIN
|
||||
SetConsoleTextAttribute( hConsole, highlite );
|
||||
#else
|
||||
put_indicator( &color_indicator[ C_LEFT ] );
|
||||
put_indicator( &color_indicator[ highlite ] ); //change color
|
||||
put_indicator( &color_indicator[ C_RIGHT ] );
|
||||
#endif
|
||||
printf( "%s", m2.toLatin1().data() ); //print text
|
||||
#ifdef Q_WS_WIN
|
||||
SetConsoleTextAttribute( hConsole, origColor );
|
||||
#else
|
||||
put_indicator( &color_indicator[ C_LEFT ] );
|
||||
put_indicator( &color_indicator[ C_NORM ] ); //reset color
|
||||
put_indicator( &color_indicator[ C_RIGHT ] );
|
||||
#endif
|
||||
printf( "\n" );
|
||||
}
|
||||
fflush( stdout );
|
||||
@ -103,7 +133,6 @@ void DebugHandler( QtMsgType type, const char *msg )
|
||||
{
|
||||
case QtDebugMsg:
|
||||
printf( "%s\n", msg );
|
||||
fflush( stdout );
|
||||
break;
|
||||
case QtWarningMsg:
|
||||
PrintColoredString( msg, C_STICKY );
|
||||
@ -117,7 +146,6 @@ void DebugHandler( QtMsgType type, const char *msg )
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
bool CheckTitleIntegrity( quint64 tid );
|
||||
|
||||
@ -146,10 +174,8 @@ void Usage()
|
||||
qDebug() << " -v increase verbosity";
|
||||
qDebug() << "";
|
||||
qDebug() << " -continue try to keep going as fas as possible on errors that should be fatal";
|
||||
#ifndef Q_WS_WIN
|
||||
qDebug() << "";
|
||||
qDebug() << " -nocolor don\'t use terminal color trickery";
|
||||
#endif
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
@ -295,8 +321,8 @@ QTreeWidgetItem *ItemFromPath( const QString &path )
|
||||
item = FindItem( lookingFor, item );
|
||||
if( !item )
|
||||
{
|
||||
// if( verbose )
|
||||
// qWarning() << "ItemFromPath ->item not found" << path;
|
||||
// if( verbose )
|
||||
// qWarning() << "ItemFromPath ->item not found" << path;
|
||||
return NULL;
|
||||
}
|
||||
slash = nextSlash + 1;
|
||||
@ -1093,7 +1119,7 @@ void CheckSettingTxt()
|
||||
qDebug() << qPrintable( str );
|
||||
}
|
||||
return;
|
||||
error:
|
||||
error:
|
||||
qCritical() << "Something is wrong with this setting.txt";
|
||||
if( !shownSetting )
|
||||
{
|
||||
@ -1105,9 +1131,11 @@ error:
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
QCoreApplication a( argc, argv );
|
||||
#ifndef Q_WS_WIN
|
||||
qInstallMsgHandler( DebugHandler );
|
||||
#ifdef Q_WS_WIN
|
||||
origColor = GetColor();
|
||||
hConsole = GetStdHandle( STD_OUTPUT_HANDLE );
|
||||
#endif
|
||||
qInstallMsgHandler( DebugHandler );
|
||||
args = QCoreApplication::arguments();
|
||||
|
||||
if( args.contains( "-nocolor", Qt::CaseInsensitive ) )
|
||||
|
@ -8,8 +8,8 @@
|
||||
# gui
|
||||
|
||||
TARGET = nandBinCheck
|
||||
#CONFIG += console
|
||||
#CONFIG -= app_bundle
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user