26 #include <QHBoxLayout>
27 #include <QVBoxLayout>
28 #include <QFormLayout>
29 #include <QMessageBox>
30 #include <QDialogButtonBox>
31 #include <QDoubleSpinBox>
32 #include <QScrollArea>
34 #include <QFontMetrics>
35 #include "../core/system/log.h"
36 #include "../core/calculation/calculationmanager.h"
37 #include "../core/calculation/algorithmfactorydescription.h"
38 #include "../core/messages/messagecaluclationprogress.h"
62 mCalculationInProgress(false)
65 QHBoxLayout *statusTextLayout =
new QHBoxLayout;
66 mainLayout->addLayout(statusTextLayout);
68 statusTextLayout->addWidget(
new QLabel(tr(
"Status:")));
70 mStatusLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
72 statusTextLayout->addStretch();
74 QHBoxLayout *progressLayout =
new QHBoxLayout;
75 mainLayout->addLayout(progressLayout);
78 class MinSizePushButton :
public QPushButton
81 MinSizePushButton(QString text = QString()) :
84 setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
88 virtual QSize minimumSizeHint()
const override
90 QFontMetrics f(fontMetrics());
92 return f.size(Qt::TextSingleLine, text() +
"xx");
94 virtual QSize sizeHint()
const override
96 QSize sh(QPushButton::sizeHint());
97 sh.setWidth(std::max(minimumSizeHint().width(), sh.width()));
103 class MinSizeProgressBar :
public QProgressBar
106 virtual QSize sizeHint()
const override {
return QSize(0, 0);}
116 progressLayout->addWidget(showAlgorithmInfo);
117 QObject::connect(showAlgorithmInfo, SIGNAL(clicked()),
this, SLOT(
showAlgorithmInfo()));
119 mainLayout->addStretch();
159 auto mcp(std::static_pointer_cast<MessageCaluclationProgress>(m));
160 switch (mcp->getCalculationType())
171 QMessageBox::information(
this, tr(
"Calculation finished"), tr(
"The calculation finished successfully! Now you can switch to the tuning mode and tune your piano."));
182 switch (mcp->getErrorCode())
185 LogW(
"Calculation error message was sent but no error code was set");
186 errorText = tr(
"An unknown error occured during the calculation.");
189 errorText = tr(
"No data available.");
192 errorText = tr(
"Not all keys recorded");
195 errorText = tr(
"Key data inconsistent.");
198 errorText = tr(
"Not enough keys recorded in left section.");
201 errorText = tr(
"Not enough keys recorded in right section.");
204 errorText = tr(
"Undefined error message.");
205 LogI(
"Undefined error message");
209 QMessageBox::critical(
this, tr(
"Calculation error"),
210 QString(
"%1<br><br><b>%2: %3</b>").arg(errorText, tr(
"Error code"),
211 QString(
"%1").arg(mcp->getErrorCode())));
299 mStatusLabel->setText(tr(
"Press the button to start the calculation"));
std::shared_ptr< const AlgorithmInformation > mAlgorithmSelection
Pointer to the algorithm selector.
std::shared_ptr< Message > MessagePtr
Global type of a shared message pointer.
virtual void startCalculation(const std::string &algorithmName)
Function called by the GUI to start the calculation of the tuning curve.
static CalculationManager & getSingleton()
static Settings & getSingleton()
Get a pointer to the singleton instance.
void onStartCalculation()
Function called to start the calculation.
void updateTitle()
Function to update the title of the algorithm in use.
bool mCalculationInProgress
Flag: calculation is in progress.
Adapter for starting and stopping the calculation process.
QPushButton * mStartCancelButton
Pointer to the start and cancel button.
QProgressBar * mCalculationProgressBar
Pointer to the progress bar.
void showAlgorithmInfo()
Show information about the algorithm.
QWidget * mMainWidgetContainer
Mode where the entropy optimization is carried out.
void onCancelCalculation()
Function called to cancel the calculation.
CalculationProgressGroup(Core *core, QWidget *parent=nullptr)
CalculationProgressGroup::CalculationProgressGroup.
void onResetCalculation()
Function called to reset the calculation.
QLabel * mStatusLabel
Pointer to the status label.
void activateMessageListener()
int toFlag(OperationMode mode)
virtual void setLastUsedAlgorithm(const std::string &name)
Set the name of the last used algorithm.
Message that progress of any kind was made by the calculator.
CORE : Class managing the core.
std::shared_ptr< const AlgorithmInformation > loadAlgorithmInformation(const std::string &algorithmName) const
virtual void cancelCalculation()
Function called by the GUI to interrupt or stop the calculation thread.
std::shared_ptr< const AlgorithmInformation > getAlgorithmInformation() const
void deactivateMessageListener()
void startCancelPressed()
Slot called when the start and stop button was pressed.
std::string getDefaultAlgorithmId() const
virtual void handleMessage(MessagePtr m) overridefinal
Message handling.
static const std::unique_ptr< DisplaySizeDefines > & getSingleton()
static SettingsForQt & getSingleton()
Getter function for the singleton.