// From the class definition...
MainWin* m_pMainWin;
// Show Log file dialog ctor
{
m_pMainWin = static_cast<MainWin*>( pParent );
QDir::setCurrent( QDir::currentPath() );
m_logFile.setFileName( LOG_FILENAME );
if ( !m_logFile.exists() )
reject();
if ( !m_logFile.open( nOpenMode ) )
reject();
QPixmap pMap
( SHOWLOG_SPLASH_IMG
);
// Make the corners fully transparent (rounded-corner bitmap)
if ( !pMap.mask().isNull() )
{
QImage img
( SHOWLOG_SPLASH_IMG
);
if ( img.hasAlphaChannel() )
pMap.
setMask( QBitmap::fromImage( img.
createAlphaMask() ) );
else
pMap.
setMask( QBitmap::fromImage( img.
createHeuristicMask() ) );
}
ui.setupUi( this );
QPalette palette
= ui.
centralWidget->palette
();
palette.setColor( ui.centralWidget->backgroundRole(), COLOR_ManageBkg );
ui.centralWidget->setPalette( palette );
// Layout the Show Logfile dialog
.
.
.
// Initialize the text stream
QString sLine, sSrc, sType, sTime, sMsg;
QString sMsgText
( " Reading %1: line %2" );
Qt::ItemFlags flags;
int start, end, nRow = 0;
// Skip the header
while ( (sLine = logStream.readLine())[0] == '*' );
// Set up the splash screen
m_pSplash->setWindowOpacity( 0.8 ); // make the image semi-transparent
palette = m_pSplash->palette();
m_pSplash->setPalette( palette );
m_pSplash->setFixedSize( pMap.size() );
m_pSplash->setMask( pMap.mask() );
QFont font
= m_pSplash
->font
();
font.setBold( true );
m_pSplash->setFont( font ); // Set the m_pSplash font to bold
// Center the splash screen in the main application window
m_pSplash->move( m_pMainWin->pos().x() +
(m_pMainWin->frameGeometry().width() / 2) -
(m_pSplash->frameGeometry().width() / 2),
m_pMainWin->pos().y() +
(m_pMainWin->frameGeometry().height() / 2) -
(m_pSplash->frameGeometry().height() / 2) );
m_pSplash->show();
// Load the text
while ( !logStream.atEnd() || !sLine.isEmpty() )
{
if ( sLine.isEmpty() ) // skip any empty lines
{
sLine = logStream.readLine();
continue;
}
// Parse the Source
.
.
.
// Fill a table row
m_logTable->insertRow( nRow );
.
.
.
nRow++;
sLine = logStream.readLine();
// Incremental splash message
m_pSplash->showMessage( sMsgText.arg( LOG_FILENAME ).arg( nRow ),
nMsgAlignment, textColor );
}
// Close the QFile
if ( m_logFile.isOpen() )
m_logFile.close();
// Set sort indicator in column headers
m_logTable->horizontalHeader()->setSortIndicatorShown( true );
m_logTable->setSortingEnabled( true );
m_pSplash->finish( this );
}
// From the class definition...
QTableWidget* m_logTable;
MainWin* m_pMainWin;
QSplashScreen* m_pSplash;
QFile m_logFile;
// Show Log file dialog ctor
ShowLog::ShowLog( QWidget *pParent ) : QDialog( pParent )
{
m_pMainWin = static_cast<MainWin*>( pParent );
QDir::setCurrent( QDir::currentPath() );
m_logFile.setFileName( LOG_FILENAME );
QIODevice::OpenMode nOpenMode = QIODevice::ReadOnly | QIODevice::Text;
if ( !m_logFile.exists() )
reject();
if ( !m_logFile.open( nOpenMode ) )
reject();
QPixmap pMap( SHOWLOG_SPLASH_IMG );
// Make the corners fully transparent (rounded-corner bitmap)
if ( !pMap.mask().isNull() )
{
QImage img( SHOWLOG_SPLASH_IMG );
if ( img.hasAlphaChannel() )
pMap.setMask( QBitmap::fromImage( img.createAlphaMask() ) );
else
pMap.setMask( QBitmap::fromImage( img.createHeuristicMask() ) );
}
ui.setupUi( this );
QPalette palette = ui.centralWidget->palette();
palette.setColor( ui.centralWidget->backgroundRole(), COLOR_ManageBkg );
ui.centralWidget->setPalette( palette );
m_logTable = new QTableWidget( 0, 4, this );
// Layout the Show Logfile dialog
.
.
.
// Initialize the text stream
QTextStream logStream( &m_logFile );
QString sLine, sSrc, sType, sTime, sMsg;
QString sMsgText( " Reading %1: line %2" );
Qt::ItemFlags flags;
int start, end, nRow = 0;
// Skip the header
while ( (sLine = logStream.readLine())[0] == '*' );
// Set up the splash screen
m_pSplash = new QSplashScreen( pParent, pMap );
m_pSplash->setWindowOpacity( 0.8 ); // make the image semi-transparent
palette = m_pSplash->palette();
palette.setBrush( QPalette::Window, QBrush( pMap ) );
m_pSplash->setPalette( palette );
m_pSplash->setFixedSize( pMap.size() );
m_pSplash->setMask( pMap.mask() );
QFont font = m_pSplash->font();
font.setBold( true );
m_pSplash->setFont( font ); // Set the m_pSplash font to bold
// Center the splash screen in the main application window
m_pSplash->move( m_pMainWin->pos().x() +
(m_pMainWin->frameGeometry().width() / 2) -
(m_pSplash->frameGeometry().width() / 2),
m_pMainWin->pos().y() +
(m_pMainWin->frameGeometry().height() / 2) -
(m_pSplash->frameGeometry().height() / 2) );
m_pSplash->show();
// Load the text
while ( !logStream.atEnd() || !sLine.isEmpty() )
{
if ( sLine.isEmpty() ) // skip any empty lines
{
sLine = logStream.readLine();
continue;
}
// Parse the Source
.
.
.
// Fill a table row
m_logTable->insertRow( nRow );
.
.
.
nRow++;
sLine = logStream.readLine();
// Incremental splash message
m_pSplash->showMessage( sMsgText.arg( LOG_FILENAME ).arg( nRow ),
nMsgAlignment, textColor );
}
// Close the QFile
if ( m_logFile.isOpen() )
m_logFile.close();
// Set sort indicator in column headers
m_logTable->horizontalHeader()->setSortIndicatorShown( true );
m_logTable->setSortingEnabled( true );
m_pSplash->finish( this );
}
To copy to clipboard, switch view to plain text mode
Bookmarks