1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "mcukitcreationdialog.h"
#include "../mcuabstractpackage.h"
#include "../mcusupportconstants.h"
#include "../mcusupporttr.h"
#include <utils/filepath.h>
#include <utils/icon.h>
#include <utils/layoutbuilder.h>
#include <coreplugin/icore.h>
#include <QApplication>
#include <QDesktopServices>
#include <QDialogButtonBox>
#include <QLabel>
#include <QPushButton>
#include <QStyle>
namespace McuSupport::Internal {
McuKitCreationDialog::McuKitCreationDialog(const MessagesList &messages,
const SettingsHandler::Ptr &settingsHandler,
McuPackagePtr qtMCUPackage,
QWidget *parent)
: QDialog(parent)
, m_messages(messages)
{
resize(500, 300);
setWindowTitle(Tr::tr("Qt for MCUs Kit Creation"));
m_iconLabel = new QLabel;
m_iconLabel->setAlignment(Qt::AlignTop);
m_textLabel = new QLabel;
m_informationLabel = new QLabel;
m_informationLabel->setWordWrap(true);
m_informationLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
m_informationLabel->setAlignment(Qt::AlignTop);
m_qtMCUsPathLabel = new QLabel;
auto line = new QFrame;
line->setFrameShape(QFrame::VLine);
line->setFrameShadow(QFrame::Sunken);
auto buttonBox = new QDialogButtonBox(Qt::Vertical);
buttonBox->setStandardButtons(QDialogButtonBox::Ignore);
m_messageCountLabel = new QLabel;
m_messageCountLabel->setAlignment(Qt::AlignCenter);
using namespace Layouting;
Row {
Column {
Row {
m_iconLabel,
Column {
m_textLabel,
m_informationLabel,
},
},
m_qtMCUsPathLabel,
},
line,
Column {
buttonBox,
m_messageCountLabel,
},
}.attachTo(this);
m_previousButton = buttonBox->addButton("<", QDialogButtonBox::ActionRole);
m_nextButton = buttonBox->addButton(">", QDialogButtonBox::ActionRole);
QPushButton *fixButton = buttonBox->addButton(Tr::tr("Fix"), QDialogButtonBox::ActionRole);
QPushButton *helpButton = buttonBox->addButton(Tr::tr("Help"), QDialogButtonBox::HelpRole);
if (messages.empty()) {
fixButton->setVisible(false);
m_informationLabel->setText(
QCoreApplication::translate("QtC::Autotest", "No errors detected."));
}
if (messages.size() < 2) {
m_nextButton->setVisible(false);
m_previousButton->setVisible(false);
}
//display first message
if (!messages.empty())
updateMessage(1);
if (qtMCUPackage->isValidStatus())
m_qtMCUsPathLabel->setText(
Tr::tr("Qt for MCUs path %1").arg(qtMCUPackage->path().toUserOutput()));
connect(m_nextButton, &QPushButton::clicked, this, [this] { updateMessage(1); });
connect(m_previousButton, &QPushButton::clicked, this, [this] { updateMessage(-1); });
connect(fixButton, &QPushButton::clicked, this, [this, settingsHandler] {
// Open the MCU Options widget on the current platform
settingsHandler->setInitialPlatformName(m_messages[m_currentIndex].platform);
Core::ICore::showOptionsDialog(Constants::SETTINGS_ID);
// reset the initial platform name
settingsHandler->setInitialPlatformName("");
});
connect(helpButton, &QPushButton::clicked, [] {
QDesktopServices::openUrl(QUrl("https://doc.qt.io/QtForMCUs/qtul-prerequisites.html"));
});
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
}
void McuKitCreationDialog::updateMessage(const int inc)
{
m_currentIndex += inc;
m_nextButton->setEnabled(m_currentIndex < (m_messages.size() - 1));
m_previousButton->setEnabled(m_currentIndex > 0);
m_textLabel->setText(QString("<b>%1 %2</b> : %3")
.arg(Tr::tr("Target"),
(m_messages[m_currentIndex].status == McuSupportMessage::Warning
? Tr::tr("Warning")
: Tr::tr("Error")),
m_messages[m_currentIndex].platform));
m_iconLabel->setPixmap(
QApplication::style()
->standardIcon(m_messages[m_currentIndex].status == McuSupportMessage::Warning
? QStyle::SP_MessageBoxWarning
: QStyle::SP_MessageBoxCritical)
.pixmap(64, 64));
m_informationLabel->setText(QString("<b>%1</b>: %2<br><br><b>%3</b>: %4")
.arg(Tr::tr("Package"),
m_messages[m_currentIndex].packageName,
Tr::tr("Status"),
m_messages.at(m_currentIndex).message));
m_messageCountLabel->setText(QString("%1 / %2").arg(QString::number(m_currentIndex + 1),
QString::number(m_messages.size())));
}
} // namespace McuSupport::Internal
|