File indexing completed on 2024-10-06 04:26:02

0001 /*
0002     SPDX-FileCopyrightText: 1998-2008 Sebastian Trueg <trueg@k3b.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "k3bsplash.h"
0008 #include "k3bthememanager.h"
0009 #include "k3bapplication.h"
0010 
0011 #include <KAboutData>
0012 
0013 #include <QEvent>
0014 #include <QString>
0015 #include <QFontMetrics>
0016 #include <QPainter>
0017 #include <QPixmap>
0018 #include <QApplication>
0019 #include <QLabel>
0020 #include <QScreen>
0021 #include <QVBoxLayout>
0022 
0023 K3b::Splash::Splash( QWidget* parent )
0024     : QWidget( parent)
0025 {
0026     setAttribute( Qt::WA_DeleteOnClose );
0027     setWindowFlags(Qt::FramelessWindowHint|
0028                    Qt::SplashScreen|
0029                    Qt::WindowStaysOnTopHint|
0030                    Qt::X11BypassWindowManagerHint);
0031 
0032     QPalette pal( palette() );
0033     pal.setColor( QPalette::Window, Qt::black );
0034     pal.setColor( QPalette::WindowText, Qt::white );
0035     setPalette( pal );
0036 
0037     QLabel* copyrightLabel = new QLabel( KAboutData::applicationData().copyrightStatement(), this );
0038     copyrightLabel->setContentsMargins( 5, 5, 5, 5 );
0039     copyrightLabel->setAlignment( Qt::AlignRight );
0040 
0041     QLabel* picLabel = new QLabel( this );
0042     if( K3b::Theme* theme = k3bappcore->themeManager()->currentTheme() ) {
0043         picLabel->setPalette( theme->palette() );
0044         picLabel->setPixmap( theme->pixmap( K3b::Theme::SPLASH ) );
0045     }
0046 
0047     m_infoBox = new QLabel( this );
0048     m_infoBox->setContentsMargins( 5, 5, 5, 5 );
0049 
0050     QVBoxLayout* layout = new QVBoxLayout( this );
0051     layout->setContentsMargins( 0, 0, 0, 0 );
0052     layout->setSpacing( 0 );
0053     layout->addWidget( copyrightLabel );
0054     layout->addWidget( picLabel );
0055     layout->addWidget( m_infoBox );
0056 
0057     // Set geometry, with support for Xinerama systems
0058     QRect r;
0059     r.setSize(sizeHint());
0060     const QScreen *ps = QGuiApplication::primaryScreen();
0061     r.moveCenter( ps->geometry().center() );
0062     setGeometry(r);
0063 }
0064 
0065 
0066 K3b::Splash::~Splash()
0067 {
0068 }
0069 
0070 
0071 void K3b::Splash::mousePressEvent( QMouseEvent* )
0072 {
0073     close();
0074 }
0075 
0076 
0077 void K3b::Splash::show()
0078 {
0079     QWidget::show();
0080     // make sure the splash screen is shown immediately
0081     qApp->processEvents();
0082 }
0083 
0084 
0085 void K3b::Splash::addInfo( const QString& s )
0086 {
0087     m_infoBox->setText( s );
0088 
0089     qApp->processEvents();
0090 }
0091 
0092 
0093 void K3b::Splash::hide()
0094 {
0095     QWidget::hide();
0096     qApp->processEvents();
0097 }
0098 
0099 #include "moc_k3bsplash.cpp"