From 7a32f03febbcd8650330967a8ef69cb711be808c Mon Sep 17 00:00:00 2001 From: Igor Beloschapkin Date: Mon, 22 Mar 2021 13:44:28 +0100 Subject: [PATCH] Implement uncheckable Buttons --- mainwindow.cpp | 80 +++++++++++++++++-------------------------------- mainwindow.h | 14 ++++----- mainwindow.ui | 12 ++++---- ui_mainwindow.h | 12 ++++---- 4 files changed, 45 insertions(+), 73 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 939c80a..bb19bca 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -29,12 +29,6 @@ MainWindow::MainWindow(QWidget *parent) : stylesheet_tac_unmarked = "QLabel {background-color: white;}"; logBCIData = true; - tac1ON = false; - tac2ON = false; - tac3ON = false; - tac4ON = false; - tac5ON = false; - tac6ON = false; lastBufferStr = "0"; @@ -53,12 +47,12 @@ void MainWindow::setupSignalsAndSlots() connect(ui->check_LogBCI, SIGNAL(toggled(bool)), this, SLOT(setLogBCIData(bool))); connect(ui->push_ClearLog, SIGNAL(clicked()), this, SLOT(clearLog())); - connect(ui->push_Tac1, SIGNAL(clicked(bool)), this, SLOT(pushTac1(bool))); - connect(ui->push_Tac2, SIGNAL(clicked(bool)), this, SLOT(pushTac2(bool))); - connect(ui->push_Tac3, SIGNAL(clicked(bool)), this, SLOT(pushTac3(bool))); - connect(ui->push_Tac4, SIGNAL(clicked(bool)), this, SLOT(pushTac4(bool))); - connect(ui->push_Tac5, SIGNAL(clicked(bool)), this, SLOT(pushTac5(bool))); - connect(ui->push_Tac6, SIGNAL(clicked(bool)), this, SLOT(pushTac6(bool))); + connect(ui->push_Tac1, SIGNAL(clicked(bool)), this, SLOT(pushTac1())); + connect(ui->push_Tac2, SIGNAL(clicked(bool)), this, SLOT(pushTac2())); + connect(ui->push_Tac3, SIGNAL(clicked(bool)), this, SLOT(pushTac3())); + connect(ui->push_Tac4, SIGNAL(clicked(bool)), this, SLOT(pushTac4())); + connect(ui->push_Tac5, SIGNAL(clicked(bool)), this, SLOT(pushTac5())); + connect(ui->push_Tac6, SIGNAL(clicked(bool)), this, SLOT(pushTac6())); } void MainWindow::log(QString logtext) @@ -241,6 +235,7 @@ void MainWindow::readPCSocketData() } if(bufferStr != lastBufferStr){ + //TODO Buffer nur von 1-6 weiterschicken, andere hier schon rausfiltern! QByteArray data = bufferStr.toUtf8(); udpSocket_Feather->writeDatagram(data, FeatherIP_full, FeatherPort); lastBufferStr = bufferStr; @@ -255,6 +250,14 @@ void MainWindow::markDirectionTactile(const QString direction) //qDebug() << i_direction; switch (i_direction) { + case 0: //all Low + ui->label_Tac1->setStyleSheet(stylesheet_tac_unmarked); + ui->label_Tac2->setStyleSheet(stylesheet_tac_unmarked); + ui->label_Tac3->setStyleSheet(stylesheet_tac_unmarked); + ui->label_Tac4->setStyleSheet(stylesheet_tac_unmarked); + ui->label_Tac5->setStyleSheet(stylesheet_tac_unmarked); + ui->label_Tac6->setStyleSheet(stylesheet_tac_unmarked); + break; case 1: //Tac1 ui->label_Tac1->setStyleSheet(stylesheet_tac_marked); ui->label_Tac2->setStyleSheet(stylesheet_tac_unmarked); @@ -316,61 +319,32 @@ void MainWindow::clearLog() ui->plain_Log->clear(); } -void MainWindow::pushTac1(const bool state) +void MainWindow::pushTac1() { - tac1ON = state; - pushDirection(); + udpSocket_Feather->writeDatagram(QByteArray::number(1), FeatherIP_full, FeatherPort); } -void MainWindow::pushTac2(const bool state) +void MainWindow::pushTac2() { - tac2ON = state; - pushDirection(); - + udpSocket_Feather->writeDatagram(QByteArray::number(2), FeatherIP_full, FeatherPort); } -void MainWindow::pushTac3(const bool state) +void MainWindow::pushTac3() { - tac3ON = state; - pushDirection(); - + udpSocket_Feather->writeDatagram(QByteArray::number(3), FeatherIP_full, FeatherPort); } -void MainWindow::pushTac4(const bool state) +void MainWindow::pushTac4() { - tac4ON = state; - pushDirection(); + udpSocket_Feather->writeDatagram(QByteArray::number(4), FeatherIP_full, FeatherPort); } -void MainWindow::pushTac5(const bool state) +void MainWindow::pushTac5() { - tac5ON = state; - pushDirection(); + udpSocket_Feather->writeDatagram(QByteArray::number(5), FeatherIP_full, FeatherPort); } -void MainWindow::pushTac6(const bool state) +void MainWindow::pushTac6() { - tac6ON = state; - pushDirection(); -} - -void MainWindow::pushDirection() -{ - if(tac1ON) - udpSocket_Feather->writeDatagram(QByteArray::number(1), FeatherIP_full, FeatherPort); - - if(tac2ON) - udpSocket_Feather->writeDatagram(QByteArray::number(2), FeatherIP_full, FeatherPort); - - if(tac3ON) - udpSocket_Feather->writeDatagram(QByteArray::number(3), FeatherIP_full, FeatherPort); - - if(tac4ON) - udpSocket_Feather->writeDatagram(QByteArray::number(4), FeatherIP_full, FeatherPort); - - if(tac5ON) - udpSocket_Feather->writeDatagram(QByteArray::number(5), FeatherIP_full, FeatherPort); - - if(tac6ON) - udpSocket_Feather->writeDatagram(QByteArray::number(6), FeatherIP_full, FeatherPort); + udpSocket_Feather->writeDatagram(QByteArray::number(6), FeatherIP_full, FeatherPort); } diff --git a/mainwindow.h b/mainwindow.h index eb6f4be..59d1b76 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -21,12 +21,12 @@ private slots: void readPCSocketData(); void setLogBCIData(const bool log); void clearLog(); - void pushTac1(const bool checked); - void pushTac2(const bool checked); - void pushTac3(const bool state); - void pushTac4(const bool state); - void pushTac5(const bool state); - void pushTac6(const bool state); + void pushTac1(); + void pushTac2(); + void pushTac3(); + void pushTac4(); + void pushTac5(); + void pushTac6(); private: Ui::MainWindow *ui; @@ -52,8 +52,6 @@ private: bool logBCIData; - bool tac1ON, tac2ON, tac3ON, tac4ON, tac5ON, tac6ON; - void pushDirection(); bool checkPort(const quint16 port); }; diff --git a/mainwindow.ui b/mainwindow.ui index bb33daf..000bd50 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -822,7 +822,7 @@ Motor 4 - true + false @@ -844,7 +844,7 @@ Motor 3 - true + false @@ -866,7 +866,7 @@ Motor 5 - true + false @@ -888,7 +888,7 @@ Motor 1 - true + false false @@ -913,7 +913,7 @@ Motor 6 - true + false @@ -935,7 +935,7 @@ Motor 2 - true + false diff --git a/ui_mainwindow.h b/ui_mainwindow.h index bbb3405..53e36f4 100644 --- a/ui_mainwindow.h +++ b/ui_mainwindow.h @@ -527,7 +527,7 @@ public: push_Tac4->setObjectName(QString::fromUtf8("push_Tac4")); push_Tac4->setMinimumSize(QSize(0, 40)); push_Tac4->setFont(font); - push_Tac4->setCheckable(true); + push_Tac4->setCheckable(false); gridLayout_3->addWidget(push_Tac4, 1, 1, 1, 1); @@ -535,7 +535,7 @@ public: push_Tac3->setObjectName(QString::fromUtf8("push_Tac3")); push_Tac3->setMinimumSize(QSize(0, 40)); push_Tac3->setFont(font); - push_Tac3->setCheckable(true); + push_Tac3->setCheckable(false); gridLayout_3->addWidget(push_Tac3, 1, 0, 1, 1); @@ -543,7 +543,7 @@ public: push_Tac5->setObjectName(QString::fromUtf8("push_Tac5")); push_Tac5->setMinimumSize(QSize(0, 40)); push_Tac5->setFont(font); - push_Tac5->setCheckable(true); + push_Tac5->setCheckable(false); gridLayout_3->addWidget(push_Tac5, 2, 0, 1, 1); @@ -551,7 +551,7 @@ public: push_Tac1->setObjectName(QString::fromUtf8("push_Tac1")); push_Tac1->setMinimumSize(QSize(0, 40)); push_Tac1->setFont(font); - push_Tac1->setCheckable(true); + push_Tac1->setCheckable(false); push_Tac1->setFlat(false); gridLayout_3->addWidget(push_Tac1, 0, 0, 1, 1); @@ -560,7 +560,7 @@ public: push_Tac6->setObjectName(QString::fromUtf8("push_Tac6")); push_Tac6->setMinimumSize(QSize(0, 40)); push_Tac6->setFont(font); - push_Tac6->setCheckable(true); + push_Tac6->setCheckable(false); gridLayout_3->addWidget(push_Tac6, 2, 1, 1, 1); @@ -568,7 +568,7 @@ public: push_Tac2->setObjectName(QString::fromUtf8("push_Tac2")); push_Tac2->setMinimumSize(QSize(0, 40)); push_Tac2->setFont(font); - push_Tac2->setCheckable(true); + push_Tac2->setCheckable(false); gridLayout_3->addWidget(push_Tac2, 0, 1, 1, 1);