mirror of
https://github.com/FAUSheppy/speech-server-client-qt
synced 2025-12-06 17:01:35 +01:00
implement server config remove button
This commit is contained in:
1
pushbuttonwithposition.cpp
Normal file
1
pushbuttonwithposition.cpp
Normal file
@@ -0,0 +1 @@
|
|||||||
|
#include "pushbuttonwithposition.h"
|
||||||
17
pushbuttonwithposition.h
Normal file
17
pushbuttonwithposition.h
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#ifndef PUSHBUTTONWITHPOSITION_H
|
||||||
|
#define PUSHBUTTONWITHPOSITION_H
|
||||||
|
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class PushButtonWithPosition : public QPushButton
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PushButtonWithPosition(int row, QString text) : QPushButton(text){
|
||||||
|
this->row = row;
|
||||||
|
}
|
||||||
|
int row;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PUSHBUTTONWITHPOSITION_H
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include "multivalueinputdialog.h"
|
#include "multivalueinputdialog.h"
|
||||||
#include "urls.h"
|
#include "urls.h"
|
||||||
|
#include "pushbuttonwithposition.h"
|
||||||
|
|
||||||
ServerConfig::ServerConfig(QWidget *parent, QSettings *settings) : QMainWindow(parent) {
|
ServerConfig::ServerConfig(QWidget *parent, QSettings *settings) : QMainWindow(parent) {
|
||||||
|
|
||||||
@@ -78,6 +79,19 @@ ServerConfig::ServerConfig(QWidget *parent, QSettings *settings) : QMainWindow(p
|
|||||||
this->setCentralWidget(mainWidget);
|
this->setCentralWidget(mainWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ServerConfig::removePP(){
|
||||||
|
PushButtonWithPosition* pButton = static_cast<PushButtonWithPosition*>(sender());
|
||||||
|
auto key = ppTable->item(pButton->row, 0);
|
||||||
|
auto repl = ppTable->item(pButton->row, 1);
|
||||||
|
sc->submitPostProcessorChange(key->text(), repl->text(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServerConfig::removeContext(){
|
||||||
|
PushButtonWithPosition* pButton = static_cast<PushButtonWithPosition*>(sender());
|
||||||
|
auto label = contextTable->item(pButton->row, 0);
|
||||||
|
sc->submitSpeechContextPhraseChange(label->text(), true);
|
||||||
|
}
|
||||||
|
|
||||||
void ServerConfig::addNewPP(){
|
void ServerConfig::addNewPP(){
|
||||||
|
|
||||||
QStringList *sl = new QStringList();
|
QStringList *sl = new QStringList();
|
||||||
@@ -185,7 +199,9 @@ void ServerConfig::finishedRequest(QNetworkReply *reply){
|
|||||||
contextTable->setItem(i, 0, new QTableWidgetItem(phrases.at(i).toString()));
|
contextTable->setItem(i, 0, new QTableWidgetItem(phrases.at(i).toString()));
|
||||||
auto *deleteButtonLayout = new QGridLayout();
|
auto *deleteButtonLayout = new QGridLayout();
|
||||||
auto *deleteCell = new QWidget();
|
auto *deleteCell = new QWidget();
|
||||||
auto *deleteButton = new QPushButton("Entfernen");
|
auto *deleteButton = new PushButtonWithPosition(i, "Entfernen");
|
||||||
|
connect(deleteButton, SIGNAL (released()), this, SLOT (removeContext()));
|
||||||
|
|
||||||
deleteButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
deleteButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
deleteButtonLayout->addWidget(deleteButton);
|
deleteButtonLayout->addWidget(deleteButton);
|
||||||
deleteButtonLayout->setContentsMargins(0,0,0,0);
|
deleteButtonLayout->setContentsMargins(0,0,0,0);
|
||||||
@@ -201,7 +217,9 @@ void ServerConfig::finishedRequest(QNetworkReply *reply){
|
|||||||
ppTable->setItem(i, 1, new QTableWidgetItem(keywordMap[key].toString()));
|
ppTable->setItem(i, 1, new QTableWidgetItem(keywordMap[key].toString()));
|
||||||
auto *deleteButtonLayout = new QGridLayout();
|
auto *deleteButtonLayout = new QGridLayout();
|
||||||
auto *deleteCell = new QWidget();
|
auto *deleteCell = new QWidget();
|
||||||
auto *deleteButton = new QPushButton("Entfernen");
|
auto *deleteButton = new PushButtonWithPosition(i, "Entfernen");
|
||||||
|
connect(deleteButton, SIGNAL (released()), this, SLOT (removePP()));
|
||||||
|
|
||||||
deleteButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
deleteButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
deleteButtonLayout->addWidget(deleteButton);
|
deleteButtonLayout->addWidget(deleteButton);
|
||||||
deleteButtonLayout->setContentsMargins(0,0,0,0);
|
deleteButtonLayout->setContentsMargins(0,0,0,0);
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ private slots:
|
|||||||
void finishedRequest(QNetworkReply*);
|
void finishedRequest(QNetworkReply*);
|
||||||
void addNewPP();
|
void addNewPP();
|
||||||
void addNewContext();
|
void addNewContext();
|
||||||
|
void removePP();
|
||||||
|
void removeContext();
|
||||||
private:
|
private:
|
||||||
QGridLayout* mainLayout;
|
QGridLayout* mainLayout;
|
||||||
QSettings* mySettings;
|
QSettings* mySettings;
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ SOURCES += \
|
|||||||
about.cpp \
|
about.cpp \
|
||||||
serverconnection.cpp \
|
serverconnection.cpp \
|
||||||
serverconfig.cpp \
|
serverconfig.cpp \
|
||||||
multivalueinputdialog.cpp
|
multivalueinputdialog.cpp \
|
||||||
|
pushbuttonwithposition.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
mainwindow.h \
|
mainwindow.h \
|
||||||
@@ -50,7 +51,8 @@ HEADERS += \
|
|||||||
serverconnection.h \
|
serverconnection.h \
|
||||||
serverconfig.h \
|
serverconfig.h \
|
||||||
urls.h \
|
urls.h \
|
||||||
multivalueinputdialog.h
|
multivalueinputdialog.h \
|
||||||
|
pushbuttonwithposition.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
mainwindow.ui \
|
mainwindow.ui \
|
||||||
|
|||||||
Reference in New Issue
Block a user