Entropy Piano Tuner  1.1.3 (documentation not yet complete)
An open-source experimental software for piano tuning by entropy minimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
initializedialog.cpp
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright 2015 Haye Hinrichsen, Christoph Wick
3  *
4  * This file is part of Entropy Piano Tuner.
5  *
6  * Entropy Piano Tuner is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * Entropy Piano Tuner is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * Entropy Piano Tuner. If not, see http://www.gnu.org/licenses/.
18  *****************************************************************************/
19 
20 #include "initializedialog.h"
21 #include <QApplication>
22 #include <QStyle>
23 #include "../core/messages/messagehandler.h"
24 
26  mParent(parent),
27  mInitializeDialog(nullptr) {
28 }
29 
31  if (mInitializeDialog) {
32  delete mInitializeDialog;
33  mInitializeDialog = nullptr;
34  }
35 }
36 
38 {
39  mInitializeDialog->updateProgress(percentage);
40 
41  // process the message loop
43  // process the events loop
44  QCoreApplication::processEvents();
45 }
46 
47 
49 {
50  EptAssert(!mInitializeDialog, "init dialog already created");
52 }
53 
54 
56 {
57  EptAssert(mInitializeDialog, "init dialog already destroyed");
58  delete mInitializeDialog;
59  mInitializeDialog = nullptr;
60 }
61 
62 
64  QProgressDialog(QString(), QString(), 0, 100, parent),
65  mOnceDrawn(false)
66 {
67  //ui->setupUi(this);
68  this->setModal(true);
69  this->setWindowTitle(tr("Initializing the core component"));
70  setWindowModality(Qt::WindowModal);
71 
72  // center on screen
73  this->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, this->size(), parent->geometry()));
74 
75  // no cancel button
76  setCancelButton(nullptr);
77 
78  setMinimumDuration(0);
79  setValue(0);
80 
81  show();
82 
83  // wait maximum of 1sec that this windows is drawn once
84  QEventLoop loop;
85  while (!mOnceDrawn) {
86  loop.processEvents(QEventLoop::AllEvents, 1000);
87  }
88 }
89 
91 {
92 }
93 
94 void InitializeDialog::updateProgress (int percentage)
95 {
96  // update values
97  setValue(percentage);
98  setLabelText(tr("Initializing, please wait"));
99 }
100 
101 void InitializeDialog::paintEvent(QPaintEvent *p) {
102  QProgressDialog::paintEvent(p);
103  mOnceDrawn = true;
104 }
static MessageHandler & getSingleton()
get a reference to the singleton class
InitializeDialog(QWidget *parent=0)
QtCoreInitialisation(QWidget *parent=0)
void process()
Main task, processing the events in the queue.
virtual void paintEvent(QPaintEvent *p) override
#define EptAssert(a, b)
Definition: eptexception.h:47
void updateProgress(int percentage)
virtual void destroy() override
Destroy the initialization dialog box.
virtual void create() override
Create the initialization dialog box.
virtual void updateProgress(int percentage) override
Show the current progress as a progress bar in the initialization message box.
InitializeDialog * mInitializeDialog