mirror of
https://github.com/FAUSheppy/speech-server-client-qt
synced 2025-12-06 00:41: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 "urls.h"
|
||||
#include "pushbuttonwithposition.h"
|
||||
|
||||
ServerConfig::ServerConfig(QWidget *parent, QSettings *settings) : QMainWindow(parent) {
|
||||
|
||||
@@ -78,6 +79,19 @@ ServerConfig::ServerConfig(QWidget *parent, QSettings *settings) : QMainWindow(p
|
||||
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(){
|
||||
|
||||
QStringList *sl = new QStringList();
|
||||
@@ -185,7 +199,9 @@ void ServerConfig::finishedRequest(QNetworkReply *reply){
|
||||
contextTable->setItem(i, 0, new QTableWidgetItem(phrases.at(i).toString()));
|
||||
auto *deleteButtonLayout = new QGridLayout();
|
||||
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);
|
||||
deleteButtonLayout->addWidget(deleteButton);
|
||||
deleteButtonLayout->setContentsMargins(0,0,0,0);
|
||||
@@ -201,7 +217,9 @@ void ServerConfig::finishedRequest(QNetworkReply *reply){
|
||||
ppTable->setItem(i, 1, new QTableWidgetItem(keywordMap[key].toString()));
|
||||
auto *deleteButtonLayout = new QGridLayout();
|
||||
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);
|
||||
deleteButtonLayout->addWidget(deleteButton);
|
||||
deleteButtonLayout->setContentsMargins(0,0,0,0);
|
||||
|
||||
@@ -23,6 +23,8 @@ private slots:
|
||||
void finishedRequest(QNetworkReply*);
|
||||
void addNewPP();
|
||||
void addNewContext();
|
||||
void removePP();
|
||||
void removeContext();
|
||||
private:
|
||||
QGridLayout* mainLayout;
|
||||
QSettings* mySettings;
|
||||
|
||||
@@ -39,7 +39,8 @@ SOURCES += \
|
||||
about.cpp \
|
||||
serverconnection.cpp \
|
||||
serverconfig.cpp \
|
||||
multivalueinputdialog.cpp
|
||||
multivalueinputdialog.cpp \
|
||||
pushbuttonwithposition.cpp
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h \
|
||||
@@ -50,7 +51,8 @@ HEADERS += \
|
||||
serverconnection.h \
|
||||
serverconfig.h \
|
||||
urls.h \
|
||||
multivalueinputdialog.h
|
||||
multivalueinputdialog.h \
|
||||
pushbuttonwithposition.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui \
|
||||
|
||||
Reference in New Issue
Block a user