diff --git a/GUI/coregui/Views/SplashScreen.cpp b/GUI/coregui/Views/SplashScreen.cpp deleted file mode 100644 index 356d923e322de0eb19d8b216c58943f970263907..0000000000000000000000000000000000000000 --- a/GUI/coregui/Views/SplashScreen.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "SplashScreen.h" -#include <QStyleOptionProgressBarV2> - -SplashScreen::SplashScreen(QWidget *parent) : - QSplashScreen(parent),m_progress(0) - -{ - m_width = 500; - m_height = 500; - - this->setPixmap(QPixmap(":/images/BornAgain.ico").scaled(m_width, m_height, Qt::KeepAspectRatio)); - this->setCursor(Qt::BusyCursor); - - QFont font; - font.setPointSize(10); - font.setBold(false); - this->setFont(font); - - //this->showMessage("\t\t\t\t\t\tLoading application...", Qt::AlignBottom); -} - -void SplashScreen::drawContents(QPainter *painter) -{ - QSplashScreen::drawContents(painter); - - int width = 150; - int height = 8; - - // Set style for progressbar... - QStyleOptionProgressBarV2 pbstyle; - pbstyle.initFrom(this); - pbstyle.state = QStyle::State_Enabled; - pbstyle.textVisible = false; - pbstyle.minimum = 0; - pbstyle.maximum = 100; - pbstyle.progress = m_progress; - pbstyle.invertedAppearance = false; - pbstyle.rect = QRect(m_width-width-35, m_height-height-12, width, height); - - style()->drawControl(QStyle::CE_ProgressBar, &pbstyle, painter, this); - - style()->drawItemText(painter,QRect(30, m_height-25, 200, 20),0, this->palette(), true, "Loading application..."); -} diff --git a/GUI/coregui/coregui.qrc b/GUI/coregui/coregui.qrc index df3a4e30ce03f667cb7f9a65a7231c82f26d488c..38033f9ab23ba020d534d95a72785469c4983b3b 100644 --- a/GUI/coregui/coregui.qrc +++ b/GUI/coregui/coregui.qrc @@ -40,5 +40,6 @@ <file>images/BornAgain.ico</file> <file>images/collapse_arrow.png</file> <file>images/expand_arrow.png</file> + <file>images/splashscreen.png</file> </qresource> </RCC> diff --git a/GUI/coregui/images/splashscreen.png b/GUI/coregui/images/splashscreen.png new file mode 100644 index 0000000000000000000000000000000000000000..aedec654fd407f1aed8f4b3d357932d8f2afc899 Binary files /dev/null and b/GUI/coregui/images/splashscreen.png differ diff --git a/GUI/coregui/mainwindow/SplashScreen.cpp b/GUI/coregui/mainwindow/SplashScreen.cpp new file mode 100644 index 0000000000000000000000000000000000000000..25916561e02de9c2f1b17f626538806ec24fba09 --- /dev/null +++ b/GUI/coregui/mainwindow/SplashScreen.cpp @@ -0,0 +1,76 @@ +#include "SplashScreen.h" +#include "DesignerHelper.h" +#include "BAVersion.h" +#include <QStyleOptionProgressBarV2> +#include <QFont> +#include <QPainter> +#include <QDebug> + +SplashScreen::SplashScreen(QWidget *parent) : + QSplashScreen(parent),m_progress(0) + +{ + m_width = 480; + m_height = 380; + + this->setPixmap(QPixmap(":/images/splashscreen.png")); + this->setCursor(Qt::BusyCursor); + + QFont font; + font.setPointSize(10); + font.setBold(false); + this->setFont(font); + + //this->showMessage("\t\t\t\t\t\tLoading application...", Qt::AlignBottom); +} + +void SplashScreen::setProgress(int value) +{ + m_progress = value; + if (m_progress > 100) + m_progress = 100; + if (m_progress < 0) + m_progress = 0; + update(); +} + +void SplashScreen::drawContents(QPainter *painter) +{ + QSplashScreen::drawContents(painter); + + // int width = 150; + // int height = 8; + // // Set style for progressbar... + // QStyleOptionProgressBarV2 pbstyle; +// pbstyle.initFrom(this); +// pbstyle.state = QStyle::State_Enabled; +// pbstyle.textVisible = false; +// pbstyle.minimum = 0; +// pbstyle.maximum = 100; +// pbstyle.progress = m_progress; +// pbstyle.invertedAppearance = false; +// pbstyle.rect = QRect(m_width-width-35, m_height-height-12, width, height); +// style()->drawControl(QStyle::CE_ProgressBar, &pbstyle, painter, this); + +// style()->drawItemText(painter,QRect(30, m_height-25, 200, 20), 0, this->palette(), true, "Loading application..."); + + +// QFont serifFont("Monospace", DesignerHelper::getLabelFontSize(), QFont::Normal); +// painter->setFont(serifFont); + QRect textRect( 15.0, m_height-40, 100, 30); +// painter->drawText(textRect, Qt::AlignCenter, "ver 0.9.9"); + + QString versionText = QString::fromStdString("version ").append(QString::fromStdString(BornAgain::GetVersionNumber())); + style()->drawItemText(painter, textRect, 0, this->palette(), true, versionText); + + QString loadingText("loading . "); + for(size_t i=0; i<size_t(m_progress/20); ++i) { + loadingText.append(". "); + } + + qDebug() << loadingText; + + QRect loadingRect( 380.0, m_height-40, 100, 30); + style()->drawItemText(painter, loadingRect, 0, this->palette(), true, loadingText); + +} diff --git a/GUI/coregui/Views/SplashScreen.h b/GUI/coregui/mainwindow/SplashScreen.h similarity index 65% rename from GUI/coregui/Views/SplashScreen.h rename to GUI/coregui/mainwindow/SplashScreen.h index f0c91fc8dbd8142a915b326cddcf8dea098576cb..a900bcb4a9522ec9acdee13a658216542279708a 100644 --- a/GUI/coregui/Views/SplashScreen.h +++ b/GUI/coregui/mainwindow/SplashScreen.h @@ -12,15 +12,7 @@ public: public slots: - void setProgress(int value) - { - m_progress = value; - if (m_progress > 100) - m_progress = 100; - if (m_progress < 0) - m_progress = 0; - update(); - } + void setProgress(int value); protected: void drawContents(QPainter *painter); diff --git a/GUI/coregui/mainwindow/aboutapplicationdialog.cpp b/GUI/coregui/mainwindow/aboutapplicationdialog.cpp index 41355d267fb26bd2cce879b8ad9a337b897e72a6..c49053960c4a6ed73d59d7f935cce085124a4bf7 100644 --- a/GUI/coregui/mainwindow/aboutapplicationdialog.cpp +++ b/GUI/coregui/mainwindow/aboutapplicationdialog.cpp @@ -38,17 +38,17 @@ AboutApplicationDialog::AboutApplicationDialog(QWidget *parent) logoLabel->setPixmap(logo.scaled(120,120,Qt::KeepAspectRatio)); - QLabel *aboutTitleLabel = new QLabel(QString::fromStdString(BornAgain::GetName()).append(" ").append(QString::fromStdString(BornAgain::GetVersionNumber()))); + QLabel *aboutTitleLabel = new QLabel(QString::fromStdString(BornAgain::GetName()).append(" ver. ").append(QString::fromStdString(BornAgain::GetVersionNumber()))); aboutTitleLabel->setFont(titleFont); aboutTitleLabel->setContentsMargins(0,0,0,15); - QString copyright = "Copyright 2010-2014 MLZ Garching. All rights reserved."; + QString copyright = "Copyright: Forschungszentrum Jülich GmbH 2014."; QLabel *copyrightLabel = new QLabel(copyright); copyrightLabel->setFont(normalFont); //copyrightLabel->setWordWrap(true); copyrightLabel->setContentsMargins(0,0,0,15); - QString description = "A software to simulate and fit grazing-incidence small-angle scattering (GISAS), using distorted-wave Born approximation (DWBA). The software equally supports neutron and x-ray scattering (GISANS and GISAXS)."; + QString description = "A software to simulate and fit grazing-incidence small-angle scattering (GISAS) using distorted-wave Born approximation (DWBA)."; QLabel *descriptionLabel = new QLabel(description); descriptionLabel->setFont(normalFont); descriptionLabel->setWordWrap(true); @@ -60,8 +60,8 @@ AboutApplicationDialog::AboutApplicationDialog(QWidget *parent) QVBoxLayout *textLayout = new QVBoxLayout; textLayout->addWidget(aboutTitleLabel); - textLayout->addWidget(copyrightLabel); textLayout->addWidget(descriptionLabel); + textLayout->addWidget(copyrightLabel); textLayout->addStretch(1); textLayout->setContentsMargins(0,5,5,5); diff --git a/GUI/main/main.cpp b/GUI/main/main.cpp index 150e7192d912cfe966a8b350ecb830164cdbe752..b4f63cb87b005b9052adb3d3fcb1d9fd7b99384e 100644 --- a/GUI/main/main.cpp +++ b/GUI/main/main.cpp @@ -1,4 +1,3 @@ - #include "mainwindow.h" #include "SplashScreen.h" @@ -22,37 +21,36 @@ int main(int argc, char *argv[]) qInstallMessageHandler(messageHandler); } - SplashScreen *splash = new SplashScreen(); - splash->show(); - + if(a.arguments().contains(QLatin1String("--help")) || a.arguments().contains(QLatin1String("-h"))) { + std::cout << "Available options:" << std::endl; + std::cout << "--help print available options" << std::endl; + std::cout << "--with-debug print debug information" << std::endl; + std::cout << "--no-splash do not use splash screen" << std::endl; + return 0; + } - int time = 1000; - QTime dieTime = QTime::currentTime().addMSecs(1000); - QTime timer; - timer.start(); - while( QTime::currentTime() < dieTime ) - { - splash->setProgress(timer.elapsed()/(time/100)); - QCoreApplication::processEvents( QEventLoop::AllEvents, 100 ); + SplashScreen *splash(0); + if(!a.arguments().contains(QLatin1String("--no-splash"))) { + splash = new SplashScreen(); + splash->show(); + + int time(1500); + QTime dieTime = QTime::currentTime().addMSecs(time); + QTime timer; + timer.start(); + while( QTime::currentTime() < dieTime ) + { + splash->setProgress(timer.elapsed()/(time/100)); + QCoreApplication::processEvents( QEventLoop::AllEvents, 100 ); + } } + MainWindow w; w.show(); - splash->finish(&w); - -//#ifdef BORNAGAIN_CRASHHANDLER -// std::cout << "BORNAGAIN_CRASHHANDLER" << std::endl; -// StackTraceSetup s; -//#endif - -// QVector<double> vector; -// double d = vector[0]+0.1; -// qDebug() << "main double:" << d; - - -// return a.exec(); - const int r = a.exec(); + if(splash) + splash->finish(&w); - return r; + return a.exec(); }