11 Commits

Author SHA1 Message Date
Yannik Schmidt
c381a62e73 add buildfiles and results to gitignore 2021-02-25 19:49:25 +01:00
Yannik Schmidt
f7676f367a re-add accidentally deleted ui file 2021-02-25 19:48:28 +01:00
Yannik Schmidt
c05a38c45d remember most recently selected path/file 2020-09-17 20:26:15 +02:00
Yannik Schmidt
76b077a661 fix win explorer call 2020-09-17 20:17:21 +02:00
Yannik Schmidt
360e8a03d3 implement samedir transcript saving 2020-09-17 19:42:33 +02:00
Yannik Schmidt
31aec36202 initialize checkConfig with nullptr 2020-09-17 18:53:07 +02:00
Yannik Schmidt
529ff87c44 fix windows crash 2020-09-17 17:59:24 +02:00
Yannik Schmidt
7793499acc fix pp input 2020-09-07 20:12:13 +02:00
Yannik Schmidt
1839b4b28e implement server config remove button 2020-09-07 19:25:01 +02:00
Yannik Schmidt
29be79f278 remove forgotten debug msg 2020-09-07 18:32:22 +02:00
Yannik Schmidt
e21b1ac3ca implement clear cache option after context change 2020-09-07 16:00:58 +02:00
15 changed files with 160 additions and 12 deletions

4
.gitignore vendored
View File

@@ -1,3 +1,7 @@
*.user
*.stash
*.o
moc_*
ui_*
Makefile
speech-server-client-qt

View File

@@ -7,5 +7,9 @@ int main(int argc, char *argv[])
MainWindow w;
w.show();
a.setApplicationName("Speech-To-Text");
a.setOrganizationName("Lantia IT");
a.setOrganizationDomain("lantia-it.de");
return a.exec();
}

View File

@@ -148,12 +148,24 @@ void MainWindow::handleInitialSettings(){
}
void MainWindow::importFile(){
QString startDir = QDir::currentPath();
if(mySettings->contains(SETTING_MOST_RECENT_PATH)){
startDir = mySettings->value(SETTING_MOST_RECENT_PATH).toString();
}
QString filename = QFileDialog::getOpenFileName(
this,
"Open Document",
QDir::currentPath(),
startDir,
"All files (*.*) ;; Document files (*.doc *.rtf);; PNG files (*.png)");
/* set most recent path */
QFileInfo* fi = new QFileInfo(filename);
QDir dirInfo = fi->absoluteDir();
QString dirPath = dirInfo.absolutePath();
mySettings->setValue(SETTING_MOST_RECENT_PATH, dirPath);
if(filename.isNull()){
return;
}else{
@@ -175,7 +187,17 @@ void MainWindow::showNotification(QString str){
void MainWindow::openContainingDir(){
QString filePath = mySettings->value(SETTING_SAVE_DIR).toString();
QString settingPath = mySettings->value(SETTING_SAVE_DIR).toString();
QString filePath;
if(QString::compare(settingPath, ".") == 0){
QPushButton* senderButton = static_cast<QPushButton*>(sender());
filePath = senderButton->toolTip();
QFileInfo* fi = new QFileInfo(filePath);
QDir dirInfo = fi->absoluteDir();
filePath = dirInfo.absolutePath();
}else{
filePath = settingPath;
}
QStringList args;
/* OS specific explorer call */
@@ -184,7 +206,7 @@ void MainWindow::openContainingDir(){
QProcess::startDetached(mySettings->value(SETTING_LINUX_EXPLORER).toString(), args);
#endif
#ifdef Q_OS_WIN
args << "/select," << QDir::toNativeSeparators(filePath);
args << QDir::toNativeSeparators(filePath);
QProcess::startDetached("explorer", args);
#endif
}
@@ -259,6 +281,13 @@ void MainWindow::saveTranscript(QNetworkReply* reply){
/* save return data */
QString fullpath = QDir(mySettings->value(SETTING_SAVE_DIR).toString()).filePath(targetName);
QString settingPath = mySettings->value(SETTING_SAVE_DIR).toString();
if(QString::compare(settingPath, ".") == 0){
fullpath = tw->item(rowId, FILENAME_COL)->text() + ".txt";
}else{
/* do nothing */
}
QFile file(fullpath);
if (!file.open(QIODevice::WriteOnly)) {
QMessageBox::information(this, tr("Unable to open file"), file.errorString());
@@ -316,6 +345,7 @@ void MainWindow::addTrackingToList(QNetworkReply* reply){
auto *openDirCellContent = new QWidget();
openDirLayout->addWidget(dirButton);
dirButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
dirButton->setToolTip(filename);
openDirLayout->setContentsMargins(0,0,0,0);
openDirCellContent->setLayout(openDirLayout);

View File

@@ -0,0 +1 @@
#include "pushbuttonwithposition.h"

17
pushbuttonwithposition.h Normal file
View 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

View File

@@ -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();
@@ -91,7 +105,7 @@ void ServerConfig::addNewPP(){
MultiValueInputDialog *dialog = new MultiValueInputDialog(sl, wl);
if (dialog->exec() == QDialog::Accepted) {
auto keyword = static_cast<QLineEdit*>(wl->at(0));
auto replace = static_cast<QLineEdit*>(wl->at(0));
auto replace = static_cast<QLineEdit*>(wl->at(1));
if(!keyword->text().isEmpty() && !replace->text().isEmpty()){
sc->submitPostProcessorChange(keyword->text(), replace->text());
@@ -99,6 +113,16 @@ void ServerConfig::addNewPP(){
}
}
void ServerConfig::askFlushServerCache(){
QMessageBox::StandardButton reply;
reply = QMessageBox::question(this, "Server Cache",
"Sollen alte Transcripte auf dem Server, die ohne diese Konfiguration erstellt wurden gelöscht werden?",
QMessageBox::Yes|QMessageBox::No);
if (reply == QMessageBox::Yes) {
sc->flushCache();
}
}
void ServerConfig::addNewContext()
{
QStringList *sl = new QStringList();
@@ -112,6 +136,7 @@ void ServerConfig::addNewContext()
auto lineEdit = static_cast<QLineEdit*>(wl->at(0));
if(!lineEdit->text().isEmpty()){
sc->submitSpeechContextPhraseChange(lineEdit->text());
askFlushServerCache();
}
}
}
@@ -137,10 +162,25 @@ void ServerConfig::finishedRequest(QNetworkReply *reply){
QString addPP = sc->buildURLFromLocation(PP_EDIT);
QString addContext = sc->buildURLFromLocation(CONTEXT_EDIT);
QString flushCache = sc->buildURLFromLocation(FLUSH_SERVER_CACHE);
if(QString::compare(reply->url().toString(), addPP) == 0){
sc->getUnifiedServerConfig();
}else if(QString::compare(reply->url().toString(), addContext) == 0){
sc->getUnifiedServerConfig();
}else if(QString::compare(reply->url().toString(), flushCache) == 0){
QMessageBox msgBox;
msgBox.setText("Server Cache Gelöscht");
QJsonObject jsonFlushCache = QJsonDocument::fromJson(reply->readAll()).object();
QJsonArray removals = jsonFlushCache["removals"].toArray();
QString display = "";
for(int i = 0; i < removals.size(); i++){
display += removals[i].toString();
display += "<br>";
}
msgBox.setInformativeText(display);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.exec();
}else{
/* this is the unified server config query */
/* get filename and tracking id from replay */
@@ -159,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);
@@ -175,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);

View File

@@ -23,6 +23,8 @@ private slots:
void finishedRequest(QNetworkReply*);
void addNewPP();
void addNewContext();
void removePP();
void removeContext();
private:
QGridLayout* mainLayout;
QSettings* mySettings;
@@ -30,6 +32,7 @@ private:
QTableWidget* ppTable;
QTableWidget* contextTable;
ServerConnection* sc;
void askFlushServerCache();
};
#endif // SERVERCONFIG_H

View File

@@ -149,3 +149,10 @@ void ServerConnection::getUnifiedServerConfig(){
request.setRawHeader(AUTH_HEADER_NAME, authHeaderData);
networkManager->get(request);
}
void ServerConnection::flushCache(){
QUrl serviceUrl = QUrl(buildURLFromLocation(QString(FLUSH_SERVER_CACHE)));
QNetworkRequest request(serviceUrl);
request.setRawHeader(AUTH_HEADER_NAME, authHeaderData);
networkManager->get(request);
}

View File

@@ -22,6 +22,7 @@ public:
void getSpeechContextPhrases();
void getUnifiedServerConfig();
QString buildURLFromLocation(const char *location);
void flushCache();
public slots:
void queryStatusAll();
private slots:

View File

@@ -11,5 +11,6 @@
#define SETTING_USER "user"
#define SETTING_PASS "pass"
#define SETTING_LINUX_EXPLORER "linux-explorer"
#define SETTING_MOST_RECENT_PATH "most-recent-path"
#endif // SETTINGKEYS_H

View File

@@ -53,10 +53,15 @@ Settings::Settings(QWidget *parent) :
#endif
this->setWindowTitle(SETTINGS_WINDOW_TITLE);
currentConfigCheckDisplay = nullptr;
}
void Settings::selectSettings(QSettings *selectedSettings){
this->mySettings = selectedSettings;
sc = new ServerConnection(this, mySettings);
connect(sc->getNetworkManager(), SIGNAL(finished(QNetworkReply*)), this, SLOT(handleTestConnectionResult(QNetworkReply*)));
/* config options layout */
auto cw = this->findChild<QWidget*>("centralwidget");
@@ -98,8 +103,6 @@ void Settings::selectSettings(QSettings *selectedSettings){
void Settings::checkConfig(){
saveSetting();
ServerConnection *sc = new ServerConnection(this, mySettings);
connect(sc->getNetworkManager(), SIGNAL(finished(QNetworkReply*)), this, SLOT(handleTestConnectionResult(QNetworkReply*)));
sc->queryServerVersion();
}
@@ -135,7 +138,9 @@ void Settings::handleTestConnectionResult(QNetworkReply* reply){
auto cw = this->findChild<QWidget*>("centralwidget");
QGridLayout *layout = static_cast<QGridLayout*>(cw->layout());
delete currentConfigCheckDisplay; //this removes it from the layout
if(currentConfigCheckDisplay != nullptr){
delete currentConfigCheckDisplay; //this removes it from the layout
}
currentConfigCheckDisplay = testResult;
layout->addWidget(testResult, configOptions->length(), 1);
}

View File

@@ -1,6 +1,8 @@
#ifndef SETTINGS_H
#define SETTINGS_H
#include "serverconnection.h"
#include <QMainWindow>
#include <QLineEdit>
#include <QSettings>
@@ -26,6 +28,7 @@ private slots:
void checkConfig();
void handleTestConnectionResult(QNetworkReply *reply);
private:
ServerConnection *sc;
Ui::settings *ui;
QSettings *mySettings;
QHash<QString, QLineEdit*> *configLineEditMap;

23
settings.ui Normal file
View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>settings</class>
<widget class="QMainWindow" name="settings">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>281</width>
<height>245</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -39,7 +39,8 @@ SOURCES += \
about.cpp \
serverconnection.cpp \
serverconfig.cpp \
multivalueinputdialog.cpp
multivalueinputdialog.cpp \
pushbuttonwithposition.cpp
HEADERS += \
mainwindow.h \
@@ -50,12 +51,14 @@ HEADERS += \
serverconnection.h \
serverconfig.h \
urls.h \
multivalueinputdialog.h
multivalueinputdialog.h \
pushbuttonwithposition.h
FORMS += \
mainwindow.ui \
listItemServeConfig.ui \
serverconfigitem.ui
serverconfigitem.ui \
settings.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin

2
urls.h
View File

@@ -10,4 +10,6 @@
#define UNIFIED_GET "/unified-server-settings"
#define SERVER_INFO "/server-info"
#define FLUSH_SERVER_CACHE "/flush-cache"
#endif // URLS_H