2012-02-20 21:47:14 +00:00
|
|
|
/* This file is (c) 2008-2012 Konstantin Isakov <ikm@goldendict.org>
|
2009-01-28 20:55:45 +00:00
|
|
|
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
|
|
|
|
2018-04-10 15:44:43 +00:00
|
|
|
#include <QIcon>
|
2009-01-28 20:55:45 +00:00
|
|
|
#include "initializing.hh"
|
2009-02-08 20:55:28 +00:00
|
|
|
#include <QCloseEvent>
|
2009-01-28 20:55:45 +00:00
|
|
|
|
2021-11-26 09:24:59 +00:00
|
|
|
#if defined( Q_OS_WIN32 )
|
2013-09-27 13:04:57 +00:00
|
|
|
#include <qt_windows.h>
|
|
|
|
#include <uxtheme.h>
|
2022-01-08 14:02:29 +00:00
|
|
|
#include <QOperatingSystemVersion>
|
2019-03-20 14:49:39 +00:00
|
|
|
|
|
|
|
WindowsStyle::WindowsStyle()
|
|
|
|
{
|
|
|
|
style = QStyleFactory::create( "windows" );
|
|
|
|
}
|
|
|
|
|
|
|
|
WindowsStyle & WindowsStyle::instance()
|
|
|
|
{
|
|
|
|
static WindowsStyle ws;
|
|
|
|
return ws;
|
|
|
|
}
|
|
|
|
|
2013-09-27 13:04:57 +00:00
|
|
|
#endif
|
|
|
|
|
2009-03-29 13:34:39 +00:00
|
|
|
Initializing::Initializing( QWidget * parent, bool showOnStartup ): QDialog( parent )
|
2009-01-28 20:55:45 +00:00
|
|
|
{
|
|
|
|
ui.setupUi( this );
|
2009-02-08 21:03:36 +00:00
|
|
|
setWindowFlags( Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint |
|
|
|
|
Qt::WindowMinimizeButtonHint );
|
2011-08-06 18:39:16 +00:00
|
|
|
|
|
|
|
#ifndef Q_OS_MAC
|
|
|
|
setWindowIcon( QIcon( ":/icons/programicon.png" ) );
|
|
|
|
#else
|
|
|
|
setWindowIcon( QIcon( ":/icons/macicon.png" ) );
|
|
|
|
#endif
|
2009-03-29 13:34:39 +00:00
|
|
|
|
2021-11-26 09:24:59 +00:00
|
|
|
#if defined( Q_OS_WIN32 )
|
2013-09-27 13:04:57 +00:00
|
|
|
|
|
|
|
// Style "windowsvista" in Qt5 turn off progress bar animation for classic appearance
|
|
|
|
// We use simply "windows" style instead for this case
|
|
|
|
|
|
|
|
oldBarStyle = 0;
|
|
|
|
|
2022-01-08 14:02:29 +00:00
|
|
|
if( QOperatingSystemVersion::current () >= QOperatingSystemVersion::Windows7
|
2013-09-27 13:04:57 +00:00
|
|
|
&& !IsThemeActive() )
|
|
|
|
{
|
2019-03-20 14:49:39 +00:00
|
|
|
QStyle * barStyle = WindowsStyle::instance().getStyle();
|
2013-09-27 13:04:57 +00:00
|
|
|
|
|
|
|
if( barStyle )
|
|
|
|
{
|
|
|
|
oldBarStyle = ui.progressBar->style();
|
|
|
|
ui.progressBar->setStyle( barStyle );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2009-03-29 13:34:39 +00:00
|
|
|
if ( showOnStartup )
|
|
|
|
{
|
|
|
|
ui.operation->setText( tr( "Please wait..." ) );
|
|
|
|
ui.dictionary->hide();
|
|
|
|
ui.progressBar->hide();
|
|
|
|
show();
|
|
|
|
}
|
2009-01-28 20:55:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Initializing::indexing( QString const & dictionaryName )
|
|
|
|
{
|
|
|
|
ui.operation->setText( tr( "Please wait while indexing dictionary" ) );
|
|
|
|
ui.dictionary->setText( dictionaryName );
|
2009-03-29 13:34:39 +00:00
|
|
|
ui.dictionary->show();
|
|
|
|
ui.progressBar->show();
|
2013-05-22 13:09:43 +00:00
|
|
|
adjustSize();
|
2009-01-28 20:55:45 +00:00
|
|
|
show();
|
|
|
|
}
|
2009-02-08 20:55:28 +00:00
|
|
|
|
|
|
|
void Initializing::closeEvent( QCloseEvent * ev )
|
|
|
|
{
|
|
|
|
ev->ignore();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Initializing::reject()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-11-26 09:24:59 +00:00
|
|
|
#if defined( Q_OS_WIN32 )
|
2013-09-27 13:04:57 +00:00
|
|
|
|
|
|
|
Initializing::~Initializing()
|
|
|
|
{
|
2019-03-20 14:49:39 +00:00
|
|
|
if( oldBarStyle )
|
2013-09-27 13:04:57 +00:00
|
|
|
ui.progressBar->setStyle( oldBarStyle );
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|