mirror of
https://github.com/MoreTore/openpilot.git
synced 2026-08-05 16:26:14 +08:00
Qt: use new signal slot syntax (#20783)
* new signal slot syntax continue * continue
This commit is contained in:
@@ -79,7 +79,7 @@ HttpRequest::HttpRequest(QObject *parent, const QString &requestURL, const QStri
|
||||
networkTimer = new QTimer(this);
|
||||
networkTimer->setSingleShot(true);
|
||||
networkTimer->setInterval(20000);
|
||||
connect(networkTimer, SIGNAL(timeout()), this, SLOT(requestTimeout()));
|
||||
connect(networkTimer, &QTimer::timeout, this, &HttpRequest::requestTimeout);
|
||||
|
||||
sendRequest(requestURL);
|
||||
|
||||
@@ -114,7 +114,7 @@ void HttpRequest::sendRequest(const QString &requestURL){
|
||||
reply = networkAccessManager->get(request);
|
||||
|
||||
networkTimer->start();
|
||||
connect(reply, SIGNAL(finished()), this, SLOT(requestFinished()));
|
||||
connect(reply, &QNetworkReply::finished, this, &HttpRequest::requestFinished);
|
||||
}
|
||||
|
||||
void HttpRequest::requestTimeout(){
|
||||
|
||||
@@ -77,7 +77,7 @@ OffroadHome::OffroadHome(QWidget* parent) : QFrame(parent) {
|
||||
|
||||
alert_notification = new QPushButton();
|
||||
alert_notification->setVisible(false);
|
||||
QObject::connect(alert_notification, SIGNAL(released()), this, SLOT(openAlerts()));
|
||||
QObject::connect(alert_notification, &QPushButton::released, this, &OffroadHome::openAlerts);
|
||||
header_layout->addWidget(alert_notification, 0, Qt::AlignHCenter | Qt::AlignRight);
|
||||
|
||||
std::string brand = Params().getBool("Passive") ? "dashcam" : "openpilot";
|
||||
@@ -108,7 +108,7 @@ OffroadHome::OffroadHome(QWidget* parent) : QFrame(parent) {
|
||||
center_layout->addWidget(statsAndSetupWidget);
|
||||
|
||||
alerts_widget = new OffroadAlert();
|
||||
QObject::connect(alerts_widget, SIGNAL(closeAlerts()), this, SLOT(closeAlerts()));
|
||||
QObject::connect(alerts_widget, &OffroadAlert::closeAlerts, this, &OffroadHome::closeAlerts);
|
||||
center_layout->addWidget(alerts_widget);
|
||||
center_layout->setAlignment(alerts_widget, Qt::AlignCenter);
|
||||
|
||||
@@ -116,7 +116,7 @@ OffroadHome::OffroadHome(QWidget* parent) : QFrame(parent) {
|
||||
|
||||
// set up refresh timer
|
||||
timer = new QTimer(this);
|
||||
QObject::connect(timer, SIGNAL(timeout()), this, SLOT(refresh()));
|
||||
QObject::connect(timer, &QTimer::timeout, this, &OffroadHome::refresh);
|
||||
refresh();
|
||||
timer->start(10 * 1000);
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ Networking::Networking(QWidget* parent, bool show_advanced) : QWidget(parent), s
|
||||
setLayout(s);
|
||||
|
||||
QTimer* timer = new QTimer(this);
|
||||
QObject::connect(timer, SIGNAL(timeout()), this, SLOT(refresh()));
|
||||
QObject::connect(timer, &QTimer::timeout, this, &Networking::refresh);
|
||||
timer->start(5000);
|
||||
attemptInitialization();
|
||||
}
|
||||
@@ -44,7 +44,7 @@ void Networking::attemptInitialization(){
|
||||
return;
|
||||
}
|
||||
|
||||
connect(wifi, SIGNAL(wrongPassword(QString)), this, SLOT(wrongPassword(QString)));
|
||||
connect(wifi, &WifiManager::wrongPassword, this, &Networking::wrongPassword);
|
||||
|
||||
QVBoxLayout* vlayout = new QVBoxLayout;
|
||||
|
||||
@@ -59,7 +59,7 @@ void Networking::attemptInitialization(){
|
||||
}
|
||||
|
||||
wifiWidget = new WifiUI(this, wifi);
|
||||
connect(wifiWidget, SIGNAL(connectToNetwork(Network)), this, SLOT(connectToNetwork(Network)));
|
||||
connect(wifiWidget, &WifiUI::connectToNetwork, this, &Networking::connectToNetwork);
|
||||
vlayout->addWidget(new ScrollView(wifiWidget, this), 1);
|
||||
|
||||
QWidget* wifiScreen = new QWidget(this);
|
||||
@@ -139,7 +139,7 @@ AdvancedNetworking::AdvancedNetworking(QWidget* parent, WifiManager* wifi): QWid
|
||||
// Enable tethering layout
|
||||
ToggleControl *tetheringToggle = new ToggleControl("Enable Tethering", "", "", wifi->tetheringEnabled());
|
||||
vlayout->addWidget(tetheringToggle);
|
||||
QObject::connect(tetheringToggle, SIGNAL(toggleFlipped(bool)), this, SLOT(toggleTethering(bool)));
|
||||
QObject::connect(tetheringToggle, &ToggleControl::toggleFlipped, this, &AdvancedNetworking::toggleTethering);
|
||||
vlayout->addWidget(horizontal_line(), 0);
|
||||
|
||||
// Change tethering password
|
||||
@@ -201,7 +201,7 @@ void WifiUI::refresh() {
|
||||
clearLayout(vlayout);
|
||||
|
||||
connectButtons = new QButtonGroup(this); // TODO check if this is a leak
|
||||
QObject::connect(connectButtons, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(handleButton(QAbstractButton*)));
|
||||
QObject::connect(connectButtons, qOverload<QAbstractButton*>(&QButtonGroup::buttonClicked), this, &WifiUI::handleButton);
|
||||
|
||||
int i = 0;
|
||||
for (Network &network : wifi->seen_networks) {
|
||||
|
||||
@@ -80,9 +80,7 @@ TermsPage::TermsPage(QWidget *parent) : QFrame(parent){
|
||||
accept_btn = new QPushButton("Scroll to accept");
|
||||
accept_btn->setEnabled(false);
|
||||
buttons->addWidget(accept_btn);
|
||||
QObject::connect(accept_btn, &QPushButton::released, [=]() {
|
||||
emit acceptedTerms();
|
||||
});
|
||||
QObject::connect(accept_btn, &QPushButton::released, this, &TermsPage::acceptedTerms);
|
||||
|
||||
QObject *obj = (QObject*)text->rootObject();
|
||||
QObject::connect(obj, SIGNAL(qmlSignal()), SLOT(enableAccept()));
|
||||
|
||||
@@ -285,11 +285,11 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QFrame(parent) {
|
||||
close_btn->setFixedSize(200, 200);
|
||||
sidebar_layout->addSpacing(45);
|
||||
sidebar_layout->addWidget(close_btn, 0, Qt::AlignCenter);
|
||||
QObject::connect(close_btn, SIGNAL(released()), this, SIGNAL(closeSettings()));
|
||||
QObject::connect(close_btn, &QPushButton::released, this, &SettingsWindow::closeSettings);
|
||||
|
||||
// setup panels
|
||||
DevicePanel *device = new DevicePanel(this);
|
||||
QObject::connect(device, SIGNAL(reviewTrainingGuide()), this, SIGNAL(reviewTrainingGuide()));
|
||||
QObject::connect(device, &DevicePanel::reviewTrainingGuide, this, &SettingsWindow::reviewTrainingGuide);
|
||||
|
||||
QPair<QString, QWidget *> panels[] = {
|
||||
{"Device", device},
|
||||
|
||||
@@ -52,7 +52,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
QPushButton *cancel_btn = new QPushButton("Cancel");
|
||||
btn_layout->addWidget(cancel_btn, 0, Qt::AlignLeft);
|
||||
QObject::connect(cancel_btn, SIGNAL(released()), &a, SLOT(quit()));
|
||||
QObject::connect(cancel_btn, &QPushButton::released, &a, &QApplication::quit);
|
||||
|
||||
QPushButton *confirm_btn = new QPushButton("Confirm");
|
||||
btn_layout->addWidget(confirm_btn, 0, Qt::AlignRight);
|
||||
|
||||
@@ -63,13 +63,13 @@ QWidget * Setup::build_page(QString title, QWidget *content, bool next, bool pre
|
||||
if (prev) {
|
||||
QPushButton *back_btn = new QPushButton("Back");
|
||||
nav_layout->addWidget(back_btn, 1, Qt::AlignBottom | Qt::AlignLeft);
|
||||
QObject::connect(back_btn, SIGNAL(released()), this, SLOT(prevPage()));
|
||||
QObject::connect(back_btn, &QPushButton::released, this, &Setup::prevPage);
|
||||
}
|
||||
|
||||
if (next) {
|
||||
QPushButton *continue_btn = new QPushButton("Continue");
|
||||
nav_layout->addWidget(continue_btn, 0, Qt::AlignBottom | Qt::AlignRight);
|
||||
QObject::connect(continue_btn, SIGNAL(released()), this, SLOT(nextPage()));
|
||||
QObject::connect(continue_btn, &QPushButton::released, this, &Setup:nextPage);
|
||||
}
|
||||
|
||||
main_layout->addLayout(nav_layout, 0);
|
||||
@@ -174,7 +174,7 @@ Setup::Setup(QWidget *parent) {
|
||||
addWidget(downloading());
|
||||
addWidget(download_failed());
|
||||
|
||||
QObject::connect(this, SIGNAL(downloadFailed()), this, SLOT(nextPage()));
|
||||
QObject::connect(this, &Setup::downloadFailed, this, &Setup::nextPage);
|
||||
|
||||
setStyleSheet(R"(
|
||||
* {
|
||||
|
||||
@@ -22,7 +22,7 @@ WifiSetup::WifiSetup(QWidget *parent) {
|
||||
finish_btn->setFixedSize(400, 200);
|
||||
main_layout->addWidget(finish_btn, 0, Qt::AlignTop | Qt::AlignLeft);
|
||||
|
||||
QObject::connect(finish_btn, SIGNAL(released()), this, SLOT(finish()));
|
||||
QObject::connect(finish_btn, &QPushButton::released, this, &WifiSetup::finish);
|
||||
|
||||
QWidget* n = new Networking(this, true);
|
||||
|
||||
@@ -40,7 +40,7 @@ WifiSetup::WifiSetup(QWidget *parent) {
|
||||
|
||||
setLayout(main_layout);
|
||||
|
||||
QObject::connect(this, SIGNAL(downloadFailed()), this, SLOT(nextPage()));
|
||||
QObject::connect(this, &WifiSetup::downloadFailed, this, &WifiSetup::nextPage);
|
||||
|
||||
setStyleSheet(R"(
|
||||
* {
|
||||
|
||||
@@ -94,7 +94,7 @@ Spinner::Spinner(QWidget *parent) {
|
||||
)");
|
||||
|
||||
notifier = new QSocketNotifier(fileno(stdin), QSocketNotifier::Read);
|
||||
QObject::connect(notifier, SIGNAL(activated(int)), this, SLOT(update(int)));
|
||||
QObject::connect(notifier, &QSocketNotifier::activated, this, &Spinner::update);
|
||||
};
|
||||
|
||||
void Spinner::update(int n) {
|
||||
|
||||
@@ -40,7 +40,7 @@ int main(int argc, char *argv[]) {
|
||||
});
|
||||
#else
|
||||
btn->setText("Exit");
|
||||
QObject::connect(btn, SIGNAL(released()), &a, SLOT(quit()));
|
||||
QObject::connect(btn, &QPushButton::released, &a, &QApplication::quit);
|
||||
#endif
|
||||
layout->addWidget(btn, 0, 0, Qt::AlignRight | Qt::AlignBottom);
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@ InputDialog::InputDialog(const QString &prompt_text, QWidget *parent) : QDialog(
|
||||
background-color: #444444;
|
||||
)");
|
||||
header_layout->addWidget(cancel_btn, 0, Qt::AlignRight);
|
||||
QObject::connect(cancel_btn, SIGNAL(released()), this, SLOT(reject()));
|
||||
QObject::connect(cancel_btn, SIGNAL(released()), this, SIGNAL(cancel()));
|
||||
QObject::connect(cancel_btn, &QPushButton::released, this, &InputDialog::reject);
|
||||
QObject::connect(cancel_btn, &QPushButton::released, this, &InputDialog::cancel);
|
||||
|
||||
layout->addLayout(header_layout);
|
||||
|
||||
@@ -43,7 +43,7 @@ InputDialog::InputDialog(const QString &prompt_text, QWidget *parent) : QDialog(
|
||||
layout->addWidget(line, 1, Qt::AlignTop);
|
||||
|
||||
k = new Keyboard(this);
|
||||
QObject::connect(k, SIGNAL(emitButton(const QString&)), this, SLOT(handleInput(const QString&)));
|
||||
QObject::connect(k, &Keyboard::emitButton, this, &InputDialog::handleInput);
|
||||
layout->addWidget(k, 2, Qt::AlignBottom);
|
||||
|
||||
setStyleSheet(R"(
|
||||
@@ -132,13 +132,13 @@ ConfirmationDialog::ConfirmationDialog(const QString &prompt_text, const QString
|
||||
if (cancel_text.length()) {
|
||||
QPushButton* cancel_btn = new QPushButton(cancel_text);
|
||||
btn_layout->addWidget(cancel_btn, 0, Qt::AlignRight);
|
||||
QObject::connect(cancel_btn, SIGNAL(released()), this, SLOT(reject()));
|
||||
QObject::connect(cancel_btn, &QPushButton::released, this, &ConfirmationDialog::reject);
|
||||
}
|
||||
|
||||
if (confirm_text.length()) {
|
||||
QPushButton* confirm_btn = new QPushButton(confirm_text);
|
||||
btn_layout->addWidget(confirm_btn, 0, Qt::AlignRight);
|
||||
QObject::connect(confirm_btn, SIGNAL(released()), this, SLOT(accept()));
|
||||
QObject::connect(confirm_btn, &QPushButton::released, this, &ConfirmationDialog::accept);
|
||||
}
|
||||
|
||||
setFixedSize(900, 350);
|
||||
|
||||
@@ -55,7 +55,7 @@ OffroadAlert::OffroadAlert(QWidget* parent) : QFrame(parent) {
|
||||
QPushButton *dismiss_btn = new QPushButton("Dismiss");
|
||||
dismiss_btn->setFixedSize(400, 125);
|
||||
footer_layout->addWidget(dismiss_btn, 0, Qt::AlignBottom | Qt::AlignLeft);
|
||||
QObject::connect(dismiss_btn, SIGNAL(released()), this, SIGNAL(closeAlerts()));
|
||||
QObject::connect(dismiss_btn, &QPushButton::released, this, &OffroadAlert::closeAlerts);
|
||||
|
||||
rebootBtn.setText("Reboot and Update");
|
||||
rebootBtn.setFixedSize(600, 125);
|
||||
|
||||
@@ -23,7 +23,7 @@ PairingQRWidget::PairingQRWidget(QWidget* parent) : QWidget(parent) {
|
||||
|
||||
QTimer* timer = new QTimer(this);
|
||||
timer->start(30 * 1000);
|
||||
connect(timer, SIGNAL(timeout()), this, SLOT(refresh()));
|
||||
connect(timer, &QTimer::timeout, this, &PairingQRWidget::refresh);
|
||||
refresh(); // don't wait for the first refresh
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ SetupWidget::SetupWidget(QWidget* parent) : QFrame(parent) {
|
||||
background: #585858;
|
||||
)");
|
||||
finishRegistationLayout->addWidget(finishButton);
|
||||
QObject::connect(finishButton, SIGNAL(released()), this, SLOT(showQrCode()));
|
||||
QObject::connect(finishButton, &QPushButton::released, this, &SetupWidget::showQrCode);
|
||||
|
||||
QWidget* finishRegistration = new QWidget;
|
||||
finishRegistration->setLayout(finishRegistationLayout);
|
||||
|
||||
@@ -45,7 +45,7 @@ SshControl::SshControl() : AbstractControl("SSH Keys", "Warning: This grants SSH
|
||||
networkTimer = new QTimer(this);
|
||||
networkTimer->setSingleShot(true);
|
||||
networkTimer->setInterval(5000);
|
||||
connect(networkTimer, SIGNAL(timeout()), this, SLOT(timeout()));
|
||||
connect(networkTimer, &QTimer::timeout, this, &SshControl::timeout);
|
||||
|
||||
refresh();
|
||||
}
|
||||
@@ -75,7 +75,7 @@ void SshControl::getUserKeys(QString username){
|
||||
#endif
|
||||
|
||||
reply = manager->get(request);
|
||||
connect(reply, SIGNAL(finished()), this, SLOT(parseResponse()));
|
||||
connect(reply, &QNetworkReply::finished, this, &SshControl::parseResponse);
|
||||
networkTimer->start();
|
||||
}
|
||||
|
||||
|
||||
@@ -17,13 +17,13 @@ MainWindow::MainWindow(QWidget *parent) : QWidget(parent) {
|
||||
main_layout->addWidget(settingsWindow);
|
||||
QObject::connect(settingsWindow, &SettingsWindow::closeSettings, this, &MainWindow::closeSettings);
|
||||
QObject::connect(&qs, &QUIState::offroadTransition, settingsWindow, &SettingsWindow::offroadTransition);
|
||||
QObject::connect(settingsWindow, SIGNAL(reviewTrainingGuide()), this, SLOT(reviewTrainingGuide()));
|
||||
QObject::connect(settingsWindow, &SettingsWindow::reviewTrainingGuide, this, &MainWindow::reviewTrainingGuide);
|
||||
|
||||
onboardingWindow = new OnboardingWindow(this);
|
||||
main_layout->addWidget(onboardingWindow);
|
||||
|
||||
main_layout->setCurrentWidget(onboardingWindow);
|
||||
QObject::connect(onboardingWindow, SIGNAL(onboardingDone()), this, SLOT(closeSettings()));
|
||||
QObject::connect(onboardingWindow, &OnboardingWindow::onboardingDone, this, &MainWindow::closeSettings);
|
||||
onboardingWindow->updateActiveScreen();
|
||||
|
||||
device.setAwake(true, true);
|
||||
|
||||
@@ -39,7 +39,7 @@ void Replay::addSegment(int i){
|
||||
lrs.insert(i, new LogReader(log_fn, &events, &events_lock, &unlogger->eidx));
|
||||
|
||||
lrs[i]->moveToThread(thread);
|
||||
QObject::connect(thread, SIGNAL (started()), lrs[i], SLOT (process()));
|
||||
QObject::connect(thread, &QThread::started, lrs[i], &LogReader::process);
|
||||
thread->start();
|
||||
|
||||
QString camera_fn = this->camera_paths.at(i).toString();
|
||||
|
||||
+1
-1
@@ -353,7 +353,7 @@ QUIState::QUIState(QObject *parent) : QObject(parent) {
|
||||
|
||||
// update timer
|
||||
timer = new QTimer(this);
|
||||
QObject::connect(timer, SIGNAL(timeout()), this, SLOT(update()));
|
||||
QObject::connect(timer, &QTimer::timeout, this, &QUIState::update);
|
||||
timer->start(0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user