32 Commits

Author SHA1 Message Date
Yannik Schmidt
326f395936 fix: indicate libqt5gui dependency 2024-07-14 22:04:36 +02:00
Yannik Schmidt
c372ca8478 update OS info 2021-11-22 15:11:25 +01:00
Yannik Schmidt
7e1aca3413 update ui picture 2021-11-07 13:55:34 +01:00
Yannik Schmidt
8f821d5d74 add window icon 2021-11-07 13:19:35 +01:00
Yannik Schmidt
79602900e6 remove spacer 2021-11-07 13:11:17 +01:00
Yannik Schmidt
ad07c80dc0 add reference to stylesheet author 2021-11-07 12:58:42 +01:00
Yannik Schmidt
414a6873b0 add dark orange stylesheet 2021-11-07 12:56:56 +01:00
Yannik Schmidt
ddc9f40186 Allow selection of multiple files 2021-11-06 15:09:33 +01:00
Yannik Schmidt
81950c1c99 fix meta info 2021-11-06 14:18:41 +01:00
Yannik Schmidt
4ada79c9a5 add offset to notification window 2021-11-06 14:17:49 +01:00
Yannik Schmidt
7cd3a4e36e update location of example picture 2021-03-22 16:35:44 +01:00
Yannik Schmidt
ab04997cff add flush cache on server button 2021-02-28 17:59:01 +01:00
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
Yannik Schmidt
3f6862e26b Save settings before running check
https://github.com/FAUSheppy/speech-server-client-qt/issues/1
2020-09-05 22:07:48 +02:00
Yannik Schmidt
4bee34fbd6 implement adding new serverconfig 2020-09-05 21:34:23 +02:00
Yannik Schmidt
5a4620191c fix list display 2020-09-04 23:54:34 +02:00
Yannik Schmidt
b7023d348b implement server settings window (readonly) 2020-09-04 23:33:24 +02:00
Yannik Schmidt
30291ef72d change option labels 2020-09-04 14:07:55 +02:00
Yannik Schmidt
758babcaf8 correctly name project 2020-09-04 13:21:40 +02:00
Yannik Schmidt
205f591dad add README.md 2020-09-04 13:16:11 +02:00
Yannik Schmidt
916005ddea add more information to about 2020-09-04 12:59:33 +02:00
Yannik Schmidt
41c29d43ce implement about window 2020-09-03 23:56:33 +02:00
27 changed files with 4147 additions and 53 deletions

6
.gitignore vendored
View File

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

33
README.md Normal file
View File

@@ -0,0 +1,33 @@
# Intro
This is the GUI Interface to a proprietary server that interfaces with speech recognition backends.
# Dependencies
apt-get install libqt5gui5
![GUI Main-Window](https://media.atlantishq.de/pictures/qt_client_dm.png)
# Build on Linux
This is a qt-creator project and can be imported as such. To build for Windows (on Linux) you need [MXE](https://github.com/mxe/mxe.git).
To download and compile MXE and dependencies:
git clone https://github.com/mxe/mxe.git
cd mxe && make qtbase
make -j 4 qt qt5 MXE_TARGETS='x86_64-w64-mingw32.shared i686-w64-mingw32.shared x86_64-w64-mingw32.static i686-w64-mingw32.static'
make qtbase
Setup the actual compilation enviroment:
MXE_ROOT=/path/to/mxe/root/
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$MXE_ROOT/usr/bin
$MXE_ROOT/usr/bin/i686-w64-mingw32.static-qmake-qt5
make
Also check the ``cross_compile.sh`` file in this project.
# Mac Support?
I do not own a Mac, so I haven't tried, but there is no reason why it wouldn't run on a Mac.
# Stylesheet
The stylesheet used is "Qt dark orange" by [LoneWolf](https://discourse.techart.online/t/release-qt-dark-orange-stylesheet/2287#post14381).

View File

@@ -1,49 +1,89 @@
#include "about.h"
#include "ui_about.h"
#include "serverconnection.h"
#include <QGridLayout>
#include <QGroupBox>
#include <QJsonDocument>
#include <QLabel>
About::About(QWidget *parent) : QMainWindow(parent) {
#define Y_POS_VERSION 0
#define Y_POS_SERVER_INFO 1
#define Y_POS_BUILD_DATE 2
#define Y_POS_BUILD_HOST 3
QGridLayout *mainLayout = new QGridLayout();
About::About(QWidget *parent, QSettings *settings) : QMainWindow(parent) {
mySettings = settings;
mainLayout = new QGridLayout();
/* config options layout */
QGridLayout *layoutLegal = new QGridLayout();
QGridLayout *layoutSoftwareinfo = new QGridLayout();
/* create legal box */
QGridLayout *layoutLegal = new QGridLayout();
QGroupBox *legalGroup = new QGroupBox();
legalGroup->setTitle("Rechtliches");
QLabel *licenseLabel = new QLabel("Diese Software wird unter der <a href=\"https://www.gnu.org/licenses/gpl-3.0-standalone.html\">GPLv3</a> verbreitet."
"<br>Code und Kompelierungsinstruktionen sind konform zur Lizenz <a href=\"https://github.com/FAUSheppy/speech-server-client-qt\">hier</a> "
"zugänglich.");
licenseLabel->setOpenExternalLinks(true);
layoutLegal->addWidget(licenseLabel, 0, 0);
layoutLegal->addWidget(new QLabel("Author: Yannik Schmidt"), 1, 0);
legalGroup->setLayout(layoutLegal);
/* create software infor group */
QGroupBox *softwareInfoGroup = new QGroupBox();
layoutSoftwareinfo = new QGridLayout();
softwareInfoGroup = new QGroupBox();
QString *version = getCurrentVersion();
QLabel *richText = new QLabel();
richText->setText(*version);
softwareInfoGroup->setTitle("Software Information");
QLabel *versionLabelIdent = new QLabel("GUI Version:");
QLabel *versionLabel = new QLabel();
serverInfo = new QLabel("Wird ermittelt..");
versionLabel->setText(*version);
layoutSoftwareinfo->addWidget(richText);
QLabel *buildDateLabelIdent = new QLabel("Version gebaut:");
QLabel *buildDateLabel = new QLabel(BUILD_DATE);
layoutSoftwareinfo->addWidget(buildDateLabelIdent, Y_POS_BUILD_DATE, 0);
layoutSoftwareinfo->addWidget(buildDateLabel, Y_POS_BUILD_DATE, 1);
QLabel *buildHostLabelIdent = new QLabel("Kompilations Host:");
QLabel *buildHostLabel = new QLabel(BUILD_HOST);
layoutSoftwareinfo->addWidget(buildHostLabelIdent, Y_POS_BUILD_HOST, 0);
layoutSoftwareinfo->addWidget(buildHostLabel, Y_POS_BUILD_HOST, 1);
softwareInfoGroup->setTitle("Software Information");
layoutSoftwareinfo->addWidget(versionLabelIdent, Y_POS_VERSION, 0);
layoutSoftwareinfo->addWidget(versionLabel, Y_POS_VERSION, 1);
layoutSoftwareinfo->addWidget(new QLabel("Server Version:"), Y_POS_SERVER_INFO, 0);
layoutSoftwareinfo->addWidget(serverInfo, Y_POS_SERVER_INFO, 1);
softwareInfoGroup->setLayout(layoutSoftwareinfo);
/* add groups to main layout */
mainLayout->addWidget(softwareInfoGroup);
mainLayout->addWidget(legalGroup);
/* setup main window */
QWidget *mainWidget = new QWidget(this);
mainWidget->setLayout(mainLayout);
this->setCentralWidget(mainWidget);
/* get server info and set as soon as possible*/
ServerConnection *sc = new ServerConnection(this, mySettings);
connect(sc->getNetworkManager(), SIGNAL(finished(QNetworkReply*)), this, SLOT(handleServerVersion(QNetworkReply*)));
sc->queryServerVersion();
}
About::~About()
{
}
QString* About::getCurrentVersion(){
return new QString("<p>LOLOLOL</p>");
void About::handleServerVersion(QNetworkReply* reply){
if(reply->error() != QNetworkReply::NoError){
serverInfo->setText(reply->errorString());
}else {
QJsonDocument json = QJsonDocument::fromJson(reply->readAll());
auto serverInfoValue = json["server-version"].toString();
serverInfo->setText(serverInfoValue + " (kompatibel)");
}
}
QString* About::getServerVersion(){
return new QString("<p>LOLOLOL</p>");
QString* About::getCurrentVersion(){
QString *string = new QString(GIT_VERSION);
return string;
}

16
about.h
View File

@@ -1,19 +1,31 @@
#ifndef ABOUT_H
#define ABOUT_H
#include <QBoxLayout>
#include <QGroupBox>
#include <QLabel>
#include <QMainWindow>
#include <QNetworkReply>
#include <QSettings>
class About : public QMainWindow
{
Q_OBJECT
public:
explicit About(QWidget *parent = nullptr);
explicit About(QWidget *parent = nullptr, QSettings *settings = nullptr);
~About();
private slots:
void handleServerVersion(QNetworkReply*);
private:
QGridLayout* mainLayout;
QGridLayout* layoutSoftwareinfo;
QLabel* serverInfo;
QGroupBox* softwareInfoGroup;
QSettings* mySettings;
QString* getCurrentVersion();
QString *getServerVersion();
QString* getServerVersion();
};
#endif // ABOUT_H

5
defaultres.qrc Normal file
View File

@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/.">
<file>icon.png</file>
</qresource>
</RCC>

BIN
icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

37
listItemServeConfig.ui Normal file
View File

@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListWidget" name="listWidget"/>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -7,5 +7,8 @@ int main(int argc, char *argv[])
MainWindow w;
w.show();
a.setApplicationName("Speech-To-Text");
a.setOrganizationName("Potaris IT | Yannik Schmidt");
a.setOrganizationDomain("potaris.de");
return a.exec();
}

View File

@@ -1,6 +1,7 @@
#include "about.h"
#include "mainwindow.h"
#include "notificationwidget.h"
#include "serverconfig.h"
#include "settings.h"
#include "ui_mainwindow.h"
#include <QCoreApplication>
@@ -22,6 +23,7 @@
#include <QString>
#include <settingkeys.h>
#include <serverconnection.h>
#include "urls.h"
#define FILENAME_COL 0
#define TRACKING_ID_COL 1
@@ -55,6 +57,9 @@ MainWindow::MainWindow(QWidget *parent):QMainWindow(parent), ui(new Ui::MainWind
button = ui->centralWidget->findChild<QPushButton*>("pushButton");
connect(button, SIGNAL (released()), this, SLOT (importFile()));
flushCacheButton = ui->centralWidget->findChild<QPushButton*>("flushCacheButton");
connect(flushCacheButton, SIGNAL (released()), this, SLOT (flushServerCacheRequest()));
/* table ui */
tw = ui->centralWidget->findChild<QTableWidget*>("tableWidget");
@@ -80,13 +85,20 @@ MainWindow::MainWindow(QWidget *parent):QMainWindow(parent), ui(new Ui::MainWind
timer->start(1000);
/* add handler for menu configuration */
ui->menuKonfiguration->addAction("Standards", this, SLOT(openConfigurationWindow()) );
ui->menuKonfiguration->addAction("Spracherkennung", this, SLOT(openSpeechConfigWindow()) );
ui->menuKonfiguration->addAction("Konfiguration", this, SLOT(openConfigurationWindow()) );
ui->menuKonfiguration->addAction("Über diese Software", this, SLOT(openAboutWindow()) );
/* set window options */
this->setWindowTitle(WINDOW_TITLE);
}
void MainWindow::openSpeechConfigWindow(){
ServerConfig *serverConfig = new ServerConfig(this, mySettings);
serverConfig->setAttribute(Qt::WA_DeleteOnClose);
serverConfig->show();
}
void MainWindow::openConfigurationWindow(){
Settings *settingsWindow = new Settings();
settingsWindow->selectSettings(this->mySettings);
@@ -96,7 +108,7 @@ void MainWindow::openConfigurationWindow(){
}
void MainWindow::openAboutWindow(){
About *aboutWindow = new About();
About *aboutWindow = new About(this, mySettings);
aboutWindow->setAttribute(Qt::WA_DeleteOnClose);
aboutWindow->show();
}
@@ -140,16 +152,33 @@ void MainWindow::handleInitialSettings(){
}
void MainWindow::importFile(){
QString filename = QFileDialog::getOpenFileName(
QString startDir = QDir::currentPath();
if(mySettings->contains(SETTING_MOST_RECENT_PATH)){
startDir = mySettings->value(SETTING_MOST_RECENT_PATH).toString();
}
QStringList filenames = QFileDialog::getOpenFileNames(
this,
"Open Document",
QDir::currentPath(),
startDir,
"All files (*.*) ;; Document files (*.doc *.rtf);; PNG files (*.png)");
if(filename.isNull()){
if(filenames.empty()){
return;
}else{
this->submitFileSlot(filename);
for(int i = 0; i<filenames.length(); i++){
if(i == 0){
/* set most recent path */
QFileInfo* fi = new QFileInfo(filenames[i]);
QDir dirInfo = fi->absoluteDir();
QString dirPath = dirInfo.absolutePath();
mySettings->setValue(SETTING_MOST_RECENT_PATH, dirPath);
}
this->submitFileSlot(filenames[i]);
}
}
}
@@ -157,7 +186,7 @@ void MainWindow::showNotification(QString str){
auto popUp = new NotificationWidget(this);
popUp->setPopupText(str);
popUp->setGeometry(0, 0, popUp->width(), popUp->height());
popUp->setGeometry(200, 100, popUp->width(), popUp->height());
popUp->show();
auto *timer = new QTimer();
connect(timer, SIGNAL(timeout()), popUp, SLOT(fadeOut()));
@@ -167,7 +196,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 */
@@ -176,7 +215,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
}
@@ -251,6 +290,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());
@@ -308,6 +354,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);
@@ -352,11 +399,19 @@ void MainWindow::submitFileSlot(QString filename){
qDebug("Request submission requested");
}
void MainWindow::flushServerCacheRequest(){
connect(serverConnection->getNetworkManager(), SIGNAL(finished(QNetworkReply*)), this,
SLOT(requestFinished(QNetworkReply*)), Qt::UniqueConnection);
qDebug("Req server flush");
serverConnection->flushCache();
}
void MainWindow::requestFinished(QNetworkReply *reply){
QString submitUrl = serverConnection->buildURLFromLocation(mySettings->value(SETTING_LOC_SUBMIT));
QString statusRequestUrl = serverConnection->buildURLFromLocation(mySettings->value(SETTING_LOC_STATE));
QString requestTranscriptUrl = serverConnection->buildURLFromLocation(mySettings->value(SETTING_LOC_TRANSCRIPT));
QString flushCacheUrl = serverConnection->buildURLFromLocation(QString(FLUSH_SERVER_CACHE));
if(QString::compare(reply->url().toString(), submitUrl) == 0){
addTrackingToList(reply);
@@ -365,6 +420,9 @@ void MainWindow::requestFinished(QNetworkReply *reply){
}else if (reply->url().toString().startsWith(requestTranscriptUrl)) {
qDebug("Saving transcript");
saveTranscript(reply);
}else if (reply->url().toString().startsWith(flushCacheUrl)) {
showNotification("Server um Cache-Löschung gebeten.");
qDebug("CacheFlushed");
}else{
qDebug("URL-Response: %s", qUtf8Printable(reply->url().toString()));
qFatal("Unexpected responding URL");

View File

@@ -29,10 +29,13 @@ private slots:
void openConfigurationWindow();
void appyConfigChanges();
void openAboutWindow();
void openSpeechConfigWindow();
void flushServerCacheRequest();
private:
Ui::MainWindow *ui;
QTableWidget *tw;
QPushButton *button;
QPushButton *flushCacheButton;
QAction *standardsMenu;
QSettings *mySettings;
ServerConnection *serverConnection;

View File

@@ -6,13 +6,477 @@
<rect>
<x>0</x>
<y>0</y>
<width>519</width>
<height>504</height>
<width>827</width>
<height>670</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<property name="windowIcon">
<iconset theme="icon.png"/>
</property>
<property name="styleSheet">
<string notr="true">QToolTip
{
border: 1px solid black;
background-color: #ffa02f;
padding: 1px;
border-radius: 3px;
opacity: 100;
}
QWidget
{
color: #b1b1b1;
background-color: #323232;
}
QWidget:item:hover
{
background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffa02f, stop: 1 #ca0619);
color: #000000;
}
QWidget:item:selected
{
background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffa02f, stop: 1 #d7801a);
}
QMenuBar::item
{
background: transparent;
}
QMenuBar::item:selected
{
background: transparent;
border: 1px solid #ffaa00;
}
QMenuBar::item:pressed
{
background: #444;
border: 1px solid #000;
background-color: QLinearGradient(
x1:0, y1:0,
x2:0, y2:1,
stop:1 #212121,
stop:0.4 #343434/*,
stop:0.2 #343434,
stop:0.1 #ffaa00*/
);
margin-bottom:-1px;
padding-bottom:1px;
}
QMenu
{
border: 1px solid #000;
}
QMenu::item
{
padding: 2px 20px 2px 20px;
}
QMenu::item:selected
{
color: #000000;
}
QWidget:disabled
{
color: #404040;
background-color: #323232;
}
QAbstractItemView
{
background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #4d4d4d, stop: 0.1 #646464, stop: 1 #5d5d5d);
}
QWidget:focus
{
/*border: 2px solid QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffa02f, stop: 1 #d7801a);*/
}
QLineEdit
{
background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #4d4d4d, stop: 0 #646464, stop: 1 #5d5d5d);
padding: 1px;
border-style: solid;
border: 1px solid #1e1e1e;
border-radius: 5;
}
QPushButton
{
color: #b1b1b1;
background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #565656, stop: 0.1 #525252, stop: 0.5 #4e4e4e, stop: 0.9 #4a4a4a, stop: 1 #464646);
border-width: 1px;
border-color: #1e1e1e;
border-style: solid;
border-radius: 6;
padding: 3px;
font-size: 12px;
padding-left: 5px;
padding-right: 5px;
}
QPushButton:pressed
{
background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #2d2d2d, stop: 0.1 #2b2b2b, stop: 0.5 #292929, stop: 0.9 #282828, stop: 1 #252525);
}
QComboBox
{
selection-background-color: #ffaa00;
background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #565656, stop: 0.1 #525252, stop: 0.5 #4e4e4e, stop: 0.9 #4a4a4a, stop: 1 #464646);
border-style: solid;
border: 1px solid #1e1e1e;
border-radius: 5;
}
QComboBox:hover,QPushButton:hover
{
border: 2px solid QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffa02f, stop: 1 #d7801a);
}
QComboBox:on
{
padding-top: 3px;
padding-left: 4px;
background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #2d2d2d, stop: 0.1 #2b2b2b, stop: 0.5 #292929, stop: 0.9 #282828, stop: 1 #252525);
selection-background-color: #ffaa00;
}
QComboBox QAbstractItemView
{
border: 2px solid darkgray;
selection-background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffa02f, stop: 1 #d7801a);
}
QComboBox::drop-down
{
subcontrol-origin: padding;
subcontrol-position: top right;
width: 15px;
border-left-width: 0px;
border-left-color: darkgray;
border-left-style: solid; /* just a single line */
border-top-right-radius: 3px; /* same radius as the QComboBox */
border-bottom-right-radius: 3px;
}
QComboBox::down-arrow
{
image: url(:/down_arrow.png);
}
QGroupBox:focus
{
border: 2px solid QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffa02f, stop: 1 #d7801a);
}
QTextEdit:focus
{
border: 2px solid QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffa02f, stop: 1 #d7801a);
}
QScrollBar:horizontal {
border: 1px solid #222222;
background: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0.0 #121212, stop: 0.2 #282828, stop: 1 #484848);
height: 7px;
margin: 0px 16px 0 16px;
}
QScrollBar::handle:horizontal
{
background: QLinearGradient( x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #ffa02f, stop: 0.5 #d7801a, stop: 1 #ffa02f);
min-height: 20px;
border-radius: 2px;
}
QScrollBar::add-line:horizontal {
border: 1px solid #1b1b19;
border-radius: 2px;
background: QLinearGradient( x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #ffa02f, stop: 1 #d7801a);
width: 14px;
subcontrol-position: right;
subcontrol-origin: margin;
}
QScrollBar::sub-line:horizontal {
border: 1px solid #1b1b19;
border-radius: 2px;
background: QLinearGradient( x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #ffa02f, stop: 1 #d7801a);
width: 14px;
subcontrol-position: left;
subcontrol-origin: margin;
}
QScrollBar::right-arrow:horizontal, QScrollBar::left-arrow:horizontal
{
border: 1px solid black;
width: 1px;
height: 1px;
background: white;
}
QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal
{
background: none;
}
QScrollBar:vertical
{
background: QLinearGradient( x1: 0, y1: 0, x2: 1, y2: 0, stop: 0.0 #121212, stop: 0.2 #282828, stop: 1 #484848);
width: 7px;
margin: 16px 0 16px 0;
border: 1px solid #222222;
}
QScrollBar::handle:vertical
{
background: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffa02f, stop: 0.5 #d7801a, stop: 1 #ffa02f);
min-height: 20px;
border-radius: 2px;
}
QScrollBar::add-line:vertical
{
border: 1px solid #1b1b19;
border-radius: 2px;
background: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffa02f, stop: 1 #d7801a);
height: 14px;
subcontrol-position: bottom;
subcontrol-origin: margin;
}
QScrollBar::sub-line:vertical
{
border: 1px solid #1b1b19;
border-radius: 2px;
background: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #d7801a, stop: 1 #ffa02f);
height: 14px;
subcontrol-position: top;
subcontrol-origin: margin;
}
QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical
{
border: 1px solid black;
width: 1px;
height: 1px;
background: white;
}
QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical
{
background: none;
}
QTextEdit
{
background-color: #242424;
}
QPlainTextEdit
{
background-color: #242424;
}
QHeaderView::section
{
background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, stop:0 #616161, stop: 0.5 #505050, stop: 0.6 #434343, stop:1 #656565);
color: white;
padding-left: 4px;
border: 1px solid #6c6c6c;
}
QCheckBox:disabled
{
color: #414141;
}
QDockWidget::title
{
text-align: center;
spacing: 3px; /* spacing between items in the tool bar */
background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, stop:0 #323232, stop: 0.5 #242424, stop:1 #323232);
}
QDockWidget::close-button, QDockWidget::float-button
{
text-align: center;
spacing: 1px; /* spacing between items in the tool bar */
background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, stop:0 #323232, stop: 0.5 #242424, stop:1 #323232);
}
QDockWidget::close-button:hover, QDockWidget::float-button:hover
{
background: #242424;
}
QDockWidget::close-button:pressed, QDockWidget::float-button:pressed
{
padding: 1px -1px -1px 1px;
}
QMainWindow::separator
{
background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, stop:0 #161616, stop: 0.5 #151515, stop: 0.6 #212121, stop:1 #343434);
color: white;
padding-left: 4px;
border: 1px solid #4c4c4c;
spacing: 3px; /* spacing between items in the tool bar */
}
QMainWindow::separator:hover
{
background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, stop:0 #d7801a, stop:0.5 #b56c17 stop:1 #ffa02f);
color: white;
padding-left: 4px;
border: 1px solid #6c6c6c;
spacing: 3px; /* spacing between items in the tool bar */
}
QToolBar::handle
{
spacing: 3px; /* spacing between items in the tool bar */
background: url(:/images/handle.png);
}
QMenu::separator
{
height: 2px;
background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, stop:0 #161616, stop: 0.5 #151515, stop: 0.6 #212121, stop:1 #343434);
color: white;
padding-left: 4px;
margin-left: 10px;
margin-right: 5px;
}
QProgressBar
{
border: 2px solid grey;
border-radius: 5px;
text-align: center;
}
QProgressBar::chunk
{
background-color: #d7801a;
width: 2.15px;
margin: 0.5px;
}
QTabBar::tab {
color: #b1b1b1;
border: 1px solid #444;
border-bottom-style: none;
background-color: #323232;
padding-left: 10px;
padding-right: 10px;
padding-top: 3px;
padding-bottom: 2px;
margin-right: -1px;
}
QTabWidget::pane {
border: 1px solid #444;
top: 1px;
}
QTabBar::tab:last
{
margin-right: 0; /* the last selected tab has nothing to overlap with on the right */
border-top-right-radius: 3px;
}
QTabBar::tab:first:!selected
{
margin-left: 0px; /* the last selected tab has nothing to overlap with on the right */
border-top-left-radius: 3px;
}
QTabBar::tab:!selected
{
color: #b1b1b1;
border-bottom-style: solid;
margin-top: 3px;
background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, stop:1 #212121, stop:.4 #343434);
}
QTabBar::tab:selected
{
border-top-left-radius: 3px;
border-top-right-radius: 3px;
margin-bottom: 0px;
}
QTabBar::tab:!selected:hover
{
/*border-top: 2px solid #ffaa00;
padding-bottom: 3px;*/
border-top-left-radius: 3px;
border-top-right-radius: 3px;
background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, stop:1 #212121, stop:0.4 #343434, stop:0.2 #343434, stop:0.1 #ffaa00);
}
QRadioButton::indicator:checked, QRadioButton::indicator:unchecked{
color: #b1b1b1;
background-color: #323232;
border: 1px solid #b1b1b1;
border-radius: 6px;
}
QRadioButton::indicator:checked
{
background-color: qradialgradient(
cx: 0.5, cy: 0.5,
fx: 0.5, fy: 0.5,
radius: 1.0,
stop: 0.25 #ffaa00,
stop: 0.3 #323232
);
}
QCheckBox::indicator{
color: #b1b1b1;
background-color: #323232;
border: 1px solid #b1b1b1;
width: 9px;
height: 9px;
}
QRadioButton::indicator
{
border-radius: 6px;
}
QRadioButton::indicator:hover, QCheckBox::indicator:hover
{
border: 1px solid #ffaa00;
}
QCheckBox::indicator:checked
{
image:url(:/images/checkbox.png);
}
QCheckBox::indicator:disabled, QRadioButton::indicator:disabled
{
border: 1px solid #444;
}</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
@@ -22,6 +486,13 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="flushCacheButton">
<property name="text">
<string>Server Cache Leeren</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QTableWidget" name="tableWidget"/>
</item>
@@ -32,25 +503,17 @@
<rect>
<x>0</x>
<y>0</y>
<width>519</width>
<width>827</width>
<height>20</height>
</rect>
</property>
<widget class="QMenu" name="menuKonfiguration">
<property name="title">
<string>&amp;Konfiguration</string>
<string>&amp;Weitere Optionen</string>
</property>
</widget>
<addaction name="menuKonfiguration"/>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<action name="actionServer">
<property name="text">
<string>&amp;Server</string>

24
multivalueinputdialog.cpp Normal file
View File

@@ -0,0 +1,24 @@
#include "multivalueinputdialog.h"
#include <QDialogButtonBox>
#include <QFormLayout>
#include <QLabel>
MultiValueInputDialog::MultiValueInputDialog(QStringList *inputValueLabels, QWidgetList *inputWidgets){
QFormLayout *form = new QFormLayout();
for(int i = 0; i<inputValueLabels->size(); i++){
form->addRow(new QLabel(inputValueLabels->at(i)));
form->addRow(inputWidgets->at(i));
}
// Add some text above the fields
// Add some standard buttons (Cancel/Ok) at the bottom of the dialog
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
form->addRow(buttonBox);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
this->setLayout(form);
}

13
multivalueinputdialog.h Normal file
View File

@@ -0,0 +1,13 @@
#ifndef MULTIVALUEINPUTDIALOG_H
#define MULTIVALUEINPUTDIALOG_H
#include <QDialog>
#include <QMainWindow>
class MultiValueInputDialog : public QDialog
{
public:
MultiValueInputDialog(QStringList *inputValueLabels, QWidgetList *inputWidgets);
};
#endif // MULTIVALUEINPUTDIALOG_H

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

2414
qrc_defaultres.cpp Normal file

File diff suppressed because it is too large Load Diff

238
serverconfig.cpp Normal file
View File

@@ -0,0 +1,238 @@
#include "serverconfig.h"
#include "serverconnection.h"
#include <QGridLayout>
#include <QGroupBox>
#include <QListWidget>
#include <QWidget>
#include <QtUiTools>
#include "multivalueinputdialog.h"
#include "urls.h"
#include "pushbuttonwithposition.h"
ServerConfig::ServerConfig(QWidget *parent, QSettings *settings) : QMainWindow(parent) {
mySettings = settings;
sc = new ServerConnection(this, mySettings);
connect(sc->getNetworkManager(), SIGNAL(finished(QNetworkReply*)), this, SLOT(finishedRequest(QNetworkReply*)), Qt::UniqueConnection);
sc->getUnifiedServerConfig();
/* post processing group */
QGroupBox *pp = new QGroupBox();
pp->setTitle("Post Processing");
ppTable = new QTableWidget();
/* table ui */
ppTable->verticalHeader()->setVisible(false);
ppTable->horizontalHeader()->setVisible(false);
ppTable->setRowCount(0);
QStringList *headerList = new QStringList();
headerList->append("Suchwort");
headerList->append("Ersetzen durch");
headerList->append("Entfernen");
ppTable->setColumnCount(headerList->length());
ppTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
QGridLayout *innerLayoutPP = new QGridLayout();
QPushButton *addNew = new QPushButton("Neue Regel");
innerLayoutPP->addWidget(ppTable);
innerLayoutPP->addWidget(addNew);
pp->setLayout(innerLayoutPP);
/* context phrases group */
QGridLayout *innerLayoutContext = new QGridLayout();
QGroupBox *context = new QGroupBox();
context->setTitle("Spracherkennungs Wörter");
contextTable = new QTableWidget();
/* table ui */
contextTable->verticalHeader()->setVisible(false);
contextTable->horizontalHeader()->setVisible(false);
contextTable->setRowCount(0);
QStringList *headerListContext = new QStringList();
headerListContext->append("Ausdruck/Wort");
headerListContext->append("Entfernen");
contextTable->setColumnCount(headerListContext->length());
contextTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
QPushButton *addNewContext = new QPushButton("Neuer Ausdruck");
innerLayoutContext->addWidget(contextTable);
innerLayoutContext->addWidget(addNewContext);
context->setLayout(innerLayoutContext);
/* connect buttons */
connect(addNew, SIGNAL (released()), this, SLOT (addNewPP()));
connect(addNewContext, SIGNAL (released()), this, SLOT (addNewContext()));
/* setup main window */
mainLayout = new QGridLayout();
mainLayout->addWidget(pp);
mainLayout->addWidget(context);
QWidget *mainWidget = new QWidget(this);
mainWidget->setLayout(mainLayout);
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();
sl->append("Schlüsselword");
sl->append("Ersetzung");
QWidgetList *wl = new QWidgetList();
wl->append(new QLineEdit());
wl->append(new QLineEdit());
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(1));
if(!keyword->text().isEmpty() && !replace->text().isEmpty()){
sc->submitPostProcessorChange(keyword->text(), replace->text());
}
}
}
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();
sl->append("Ausdruck");
QWidgetList *wl = new QWidgetList();
wl->append(new QLineEdit());
MultiValueInputDialog *dialog = new MultiValueInputDialog(sl, wl);
if (dialog->exec() == QDialog::Accepted) {
auto lineEdit = static_cast<QLineEdit*>(wl->at(0));
if(!lineEdit->text().isEmpty()){
sc->submitSpeechContextPhraseChange(lineEdit->text());
askFlushServerCache();
}
}
}
QWidget* ServerConfig::loatListItemUiForm()
{
QUiLoader loader;
QFile file(":/forms/serverconfigitem.ui");
file.open(QFile::ReadOnly);
QWidget *formWidget = loader.load(&file, this);
file.close();
return formWidget;
}
void ServerConfig::finishedRequest(QNetworkReply *reply){
if(reply->error() != QNetworkReply::NoError){
qDebug("unified sc fail..");
return;
}
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 */
QJsonObject json = QJsonDocument::fromJson(reply->readAll()).object();
auto keywordMap = json["keyword-map"].toObject();
auto phrases = json["phrases"].toArray();
contextTable->clear();
contextTable->setRowCount(0);
ppTable->clear();
ppTable->setRowCount(0);
for(int i = 0; i < phrases.size(); i++){
contextTable->insertRow(i);
contextTable->setItem(i, 0, new QTableWidgetItem(phrases.at(i).toString()));
auto *deleteButtonLayout = new QGridLayout();
auto *deleteCell = new QWidget();
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);
deleteCell->setLayout(deleteButtonLayout);
contextTable->setCellWidget(i, 1, deleteCell);
}
for(int i = 0; i < keywordMap.keys().size(); i++){
auto key = keywordMap.keys().at(i);
ppTable->insertRow(i);
ppTable->setItem(i, 0, new QTableWidgetItem(key));
ppTable->setItem(i, 1, new QTableWidgetItem(keywordMap[key].toString()));
auto *deleteButtonLayout = new QGridLayout();
auto *deleteCell = new QWidget();
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);
deleteCell->setLayout(deleteButtonLayout);
ppTable->setCellWidget(i, 2, deleteCell);
}
this->repaint();
}
}
ServerConfig::~ServerConfig()
{
}

38
serverconfig.h Normal file
View File

@@ -0,0 +1,38 @@
#ifndef SERVERCONFIG_H
#define SERVERCONFIG_H
#include "serverconnection.h"
#include <QGridLayout>
#include <QMainWindow>
#include <QNetworkReply>
#include <QSettings>
#include <QTableWidget>
#include <QWidget>
class ServerConfig : public QMainWindow
{
Q_OBJECT
public:
explicit ServerConfig(QWidget *parent = nullptr, QSettings *settings = nullptr);
virtual ~ServerConfig();
private slots:
void finishedRequest(QNetworkReply*);
void addNewPP();
void addNewContext();
void removePP();
void removeContext();
private:
QGridLayout* mainLayout;
QSettings* mySettings;
QWidget *loatListItemUiForm();
QTableWidget* ppTable;
QTableWidget* contextTable;
ServerConnection* sc;
void askFlushServerCache();
};
#endif // SERVERCONFIG_H

34
serverconfigitem.ui Normal file
View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="lineEdit_2"/>
</item>
<item>
<widget class="QLineEdit" name="lineEdit"/>
</item>
<item>
<widget class="QPushButton" name="buttonDelete">
<property name="text">
<string>Löschen</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -5,10 +5,13 @@
#include <QJsonObject>
#include <QNetworkAccessManager>
#include <QSettings>
#include <urls.h>
#define AUTH_HEADER_NAME "Authorization"
#define MIME_JSON "application/json"
ServerConnection::ServerConnection(QObject *parent, QSettings *settings)
{
setAuthHeader(settings->value(SETTING_USER).toString(), settings->value(SETTING_PASS).toString());
networkManager = new QNetworkAccessManager(parent);
mySettings = settings;
@@ -19,6 +22,10 @@ QString ServerConnection::buildURLFromLocation(QVariant location){
return buildURLFromLocation(location.toString());
}
QString ServerConnection::buildURLFromLocation(const char *location){
return buildURLFromLocation(QString(location));
}
QString ServerConnection::buildURLFromLocation(QString location){
QString proto = mySettings->value(SETTING_PROTO).toString();
QString host = mySettings->value(SETTING_HOST).toString();
@@ -48,7 +55,7 @@ void ServerConnection::queryStatusAll(){
QString statusRequestUrl = buildURLFromLocation(mySettings->value(SETTING_LOC_STATE));
QUrl trackingUrl = QUrl(statusRequestUrl);
QNetworkRequest request(trackingUrl);
request.setRawHeader("Authorization", authHeaderData);
request.setRawHeader(AUTH_HEADER_NAME, authHeaderData);
networkManager->get(request);
//qDebug("Status query sent");
}
@@ -58,7 +65,7 @@ void ServerConnection::queryTransscript(QString trackingId){
QString paramUrl = QString("%1?id=%2").arg(url, trackingId);
QUrl transcriptUrl = QUrl(paramUrl);
QNetworkRequest request(transcriptUrl);
request.setRawHeader("Authorization", authHeaderData);
request.setRawHeader(AUTH_HEADER_NAME, authHeaderData);
networkManager->get(request);
}
@@ -67,8 +74,8 @@ void ServerConnection::submitFile(QJsonDocument jsonDocument){
/* prepare request */
QUrl serviceUrl = QUrl(buildURLFromLocation(mySettings->value(SETTING_LOC_SUBMIT)));
QNetworkRequest request(serviceUrl);
request.setRawHeader("Authorization", authHeaderData);
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
request.setRawHeader(AUTH_HEADER_NAME, authHeaderData);
request.setHeader(QNetworkRequest::ContentTypeHeader, MIME_JSON);
/* make request */
networkManager->post(request, jsonDocument.toJson());
@@ -76,6 +83,76 @@ void ServerConnection::submitFile(QJsonDocument jsonDocument){
qDebug("Request submitted");
}
void ServerConnection::queryServerVersion(){
QUrl serviceUrl = QUrl(buildURLFromLocation(QString(SERVER_INFO)));
QNetworkRequest request(serviceUrl);
request.setRawHeader(AUTH_HEADER_NAME, authHeaderData);
networkManager->get(request);
}
QNetworkAccessManager *ServerConnection::getNetworkManager(){
return networkManager;
}
void ServerConnection::submitPostProcessorChange(QString keyword, QString repl, bool remove){
QJsonObject json = QJsonObject();
json["keyword-regex"] = keyword;
json["replacement"] = repl;
if(remove){
json["action"] = "delete";
}else{
json["action"] = "add";
}
QUrl serviceUrl = QUrl(buildURLFromLocation(QString(PP_EDIT)));
QNetworkRequest request(serviceUrl);
request.setRawHeader(AUTH_HEADER_NAME, authHeaderData);
request.setHeader(QNetworkRequest::ContentTypeHeader, MIME_JSON);
networkManager->post(request, QJsonDocument(json).toJson());
}
void ServerConnection::submitSpeechContextPhraseChange(QString phrase, bool remove){
QJsonObject json = QJsonObject();
json["phrase"] = phrase;
if(remove){
json["action"] = "delete";
}else{
json["action"] = "add";
}
QUrl serviceUrl = QUrl(buildURLFromLocation(QString(CONTEXT_EDIT)));
QNetworkRequest request(serviceUrl);
request.setRawHeader(AUTH_HEADER_NAME, authHeaderData);
request.setHeader(QNetworkRequest::ContentTypeHeader, MIME_JSON);
networkManager->post(request, QJsonDocument(json).toJson());
}
void ServerConnection::getSpeechContextPhrases(){
QUrl serviceUrl = QUrl(buildURLFromLocation(QString(CONTEXT_GET)));
QNetworkRequest request(serviceUrl);
request.setRawHeader(AUTH_HEADER_NAME, authHeaderData);
networkManager->get(request);
}
void ServerConnection::getPostProcessorMap(){
QUrl serviceUrl = QUrl(buildURLFromLocation(QString(PP_GET)));
QNetworkRequest request(serviceUrl);
request.setRawHeader(AUTH_HEADER_NAME, authHeaderData);
networkManager->get(request);
}
void ServerConnection::getUnifiedServerConfig(){
QUrl serviceUrl = QUrl(buildURLFromLocation(QString(UNIFIED_GET)));
QNetworkRequest request(serviceUrl);
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

@@ -15,6 +15,14 @@ public:
QString buildURLFromLocation(QVariant location);
QString buildURLFromLocation(QString location);
QNetworkAccessManager *getNetworkManager();
void queryServerVersion();
void getPostProcessorMap();
void submitPostProcessorChange(QString keyword, QString repl, bool remove = false);
void submitSpeechContextPhraseChange(QString phrase, bool remove = false);
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

@@ -1,13 +1,22 @@
#include "serverconnection.h"
#include "settings.h"
#include "ui_settings.h"
#include <QDialog>
#include <QFile>
#include <QFileInfo>
#include <QFileInfo>
#include <QLabel>
#include <QLineEdit>
#include <QMessageBox>
#include <QNetworkReply>
#include <QNetworkReply>
#include <QPushButton>
#include <QSettings>
#include <settingkeys.h>
#define SETTINGS_WINDOW_TITLE "Konfiguration"
#define BUTTON_TEXT_CHECK "Konfiguration Testen"
#define BUTTON_TEXT_ABORT "Abbrechen"
#define BUTTON_TEXT_OK "OK"
@@ -44,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");
@@ -74,16 +88,63 @@ void Settings::selectSettings(QSettings *selectedSettings){
}
/* buttons */
auto check = new QPushButton(BUTTON_TEXT_CHECK);
auto ok = new QPushButton(BUTTON_TEXT_OK);
auto cancle = new QPushButton(BUTTON_TEXT_ABORT);
layout->addWidget(ok, configOptions->length(), 0);
layout->addWidget(cancle, configOptions->length(), 1);
layout->addWidget(check, configOptions->length(), 0);
layout->addWidget(ok, configOptions->length()+1, 0);
layout->addWidget(cancle, configOptions->length()+1, 1);
connect(check, SIGNAL(released()), this, SLOT(checkConfig()));
connect(ok, SIGNAL(released()), this, SLOT(okClose()));
connect(cancle, SIGNAL(released()), this, SLOT(cancleClose()));
}
void Settings::checkConfig(){
saveSetting();
sc->queryServerVersion();
}
void Settings::handleTestConnectionResult(QNetworkReply* reply){
QString *dialogText;
bool error = false;
if(reply->error() != QNetworkReply::NoError){
dialogText = new QString(reply->errorString());
error = true;
}else {
dialogText = new QString("Verbinndung Ok");
}
#ifdef Q_OS_LINUX
auto *fi = new QFileInfo(mySettings->value(SETTING_LINUX_EXPLORER).toString());
if(!fi->isExecutable()){
dialogText->append("\nExplorer nicht ausführbar!");
error = true;
}
#endif
QLabel *testResult = new QLabel("Ok!");
testResult->setStyleSheet("QLabel { color : green; }");
if(error){
QMessageBox *info = new QMessageBox();
info->setAttribute(Qt::WA_DeleteOnClose);
info->setWindowTitle("Konfiguration - Fehler!");
info->setText(*dialogText);
info->show();
testResult = new QLabel("Konfigurationsfehler.");
testResult->setStyleSheet("QLabel { color : red; }");
}
auto cw = this->findChild<QWidget*>("centralwidget");
QGridLayout *layout = static_cast<QGridLayout*>(cw->layout());
if(currentConfigCheckDisplay != nullptr){
delete currentConfigCheckDisplay; //this removes it from the layout
}
currentConfigCheckDisplay = testResult;
layout->addWidget(testResult, configOptions->length(), 1);
}
void Settings::cancleClose(){
if(false){
// TODO warning
@@ -91,14 +152,18 @@ void Settings::cancleClose(){
this->close();
}
void Settings::okClose(){
void Settings::saveSetting(){
QSettings mySettings;
for(auto key : configLineEditMap->keys()){
QString input = configLineEditMap->take(key)->text();
QString input = configLineEditMap->value(key)->text();
if(input.compare("") != 0){
this->mySettings->setValue(key, input);
}
}
}
void Settings::okClose(){
saveSetting();
this->close();
}

View File

@@ -1,9 +1,13 @@
#ifndef SETTINGS_H
#define SETTINGS_H
#include "serverconnection.h"
#include <QMainWindow>
#include <QLineEdit>
#include <QSettings>
#include <QNetworkReply>
#include <QLabel>
namespace Ui {
class settings;
@@ -21,12 +25,17 @@ public:
private slots:
void okClose();
void cancleClose();
void checkConfig();
void handleTestConnectionResult(QNetworkReply *reply);
private:
ServerConnection *sc;
Ui::settings *ui;
QSettings *mySettings;
QHash<QString, QLineEdit*> *configLineEditMap;
QStringList *configOptionsKeys;
QStringList *configOptions;
void saveSetting();
QLabel *currentConfigCheckDisplay;
};
#endif // SETTINGS_H

View File

@@ -13,6 +13,467 @@
<property name="windowTitle">
<string>MainWindow</string>
</property>
<property name="styleSheet">
<string notr="true">QToolTip
{
border: 1px solid black;
background-color: #ffa02f;
padding: 1px;
border-radius: 3px;
opacity: 100;
}
QWidget
{
color: #b1b1b1;
background-color: #323232;
}
QWidget:item:hover
{
background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffa02f, stop: 1 #ca0619);
color: #000000;
}
QWidget:item:selected
{
background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffa02f, stop: 1 #d7801a);
}
QMenuBar::item
{
background: transparent;
}
QMenuBar::item:selected
{
background: transparent;
border: 1px solid #ffaa00;
}
QMenuBar::item:pressed
{
background: #444;
border: 1px solid #000;
background-color: QLinearGradient(
x1:0, y1:0,
x2:0, y2:1,
stop:1 #212121,
stop:0.4 #343434/*,
stop:0.2 #343434,
stop:0.1 #ffaa00*/
);
margin-bottom:-1px;
padding-bottom:1px;
}
QMenu
{
border: 1px solid #000;
}
QMenu::item
{
padding: 2px 20px 2px 20px;
}
QMenu::item:selected
{
color: #000000;
}
QWidget:disabled
{
color: #404040;
background-color: #323232;
}
QAbstractItemView
{
background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #4d4d4d, stop: 0.1 #646464, stop: 1 #5d5d5d);
}
QWidget:focus
{
/*border: 2px solid QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffa02f, stop: 1 #d7801a);*/
}
QLineEdit
{
background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #4d4d4d, stop: 0 #646464, stop: 1 #5d5d5d);
padding: 1px;
border-style: solid;
border: 1px solid #1e1e1e;
border-radius: 5;
}
QPushButton
{
color: #b1b1b1;
background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #565656, stop: 0.1 #525252, stop: 0.5 #4e4e4e, stop: 0.9 #4a4a4a, stop: 1 #464646);
border-width: 1px;
border-color: #1e1e1e;
border-style: solid;
border-radius: 6;
padding: 3px;
font-size: 12px;
padding-left: 5px;
padding-right: 5px;
}
QPushButton:pressed
{
background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #2d2d2d, stop: 0.1 #2b2b2b, stop: 0.5 #292929, stop: 0.9 #282828, stop: 1 #252525);
}
QComboBox
{
selection-background-color: #ffaa00;
background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #565656, stop: 0.1 #525252, stop: 0.5 #4e4e4e, stop: 0.9 #4a4a4a, stop: 1 #464646);
border-style: solid;
border: 1px solid #1e1e1e;
border-radius: 5;
}
QComboBox:hover,QPushButton:hover
{
border: 2px solid QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffa02f, stop: 1 #d7801a);
}
QComboBox:on
{
padding-top: 3px;
padding-left: 4px;
background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #2d2d2d, stop: 0.1 #2b2b2b, stop: 0.5 #292929, stop: 0.9 #282828, stop: 1 #252525);
selection-background-color: #ffaa00;
}
QComboBox QAbstractItemView
{
border: 2px solid darkgray;
selection-background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffa02f, stop: 1 #d7801a);
}
QComboBox::drop-down
{
subcontrol-origin: padding;
subcontrol-position: top right;
width: 15px;
border-left-width: 0px;
border-left-color: darkgray;
border-left-style: solid; /* just a single line */
border-top-right-radius: 3px; /* same radius as the QComboBox */
border-bottom-right-radius: 3px;
}
QComboBox::down-arrow
{
image: url(:/down_arrow.png);
}
QGroupBox:focus
{
border: 2px solid QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffa02f, stop: 1 #d7801a);
}
QTextEdit:focus
{
border: 2px solid QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffa02f, stop: 1 #d7801a);
}
QScrollBar:horizontal {
border: 1px solid #222222;
background: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0.0 #121212, stop: 0.2 #282828, stop: 1 #484848);
height: 7px;
margin: 0px 16px 0 16px;
}
QScrollBar::handle:horizontal
{
background: QLinearGradient( x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #ffa02f, stop: 0.5 #d7801a, stop: 1 #ffa02f);
min-height: 20px;
border-radius: 2px;
}
QScrollBar::add-line:horizontal {
border: 1px solid #1b1b19;
border-radius: 2px;
background: QLinearGradient( x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #ffa02f, stop: 1 #d7801a);
width: 14px;
subcontrol-position: right;
subcontrol-origin: margin;
}
QScrollBar::sub-line:horizontal {
border: 1px solid #1b1b19;
border-radius: 2px;
background: QLinearGradient( x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #ffa02f, stop: 1 #d7801a);
width: 14px;
subcontrol-position: left;
subcontrol-origin: margin;
}
QScrollBar::right-arrow:horizontal, QScrollBar::left-arrow:horizontal
{
border: 1px solid black;
width: 1px;
height: 1px;
background: white;
}
QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal
{
background: none;
}
QScrollBar:vertical
{
background: QLinearGradient( x1: 0, y1: 0, x2: 1, y2: 0, stop: 0.0 #121212, stop: 0.2 #282828, stop: 1 #484848);
width: 7px;
margin: 16px 0 16px 0;
border: 1px solid #222222;
}
QScrollBar::handle:vertical
{
background: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffa02f, stop: 0.5 #d7801a, stop: 1 #ffa02f);
min-height: 20px;
border-radius: 2px;
}
QScrollBar::add-line:vertical
{
border: 1px solid #1b1b19;
border-radius: 2px;
background: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffa02f, stop: 1 #d7801a);
height: 14px;
subcontrol-position: bottom;
subcontrol-origin: margin;
}
QScrollBar::sub-line:vertical
{
border: 1px solid #1b1b19;
border-radius: 2px;
background: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #d7801a, stop: 1 #ffa02f);
height: 14px;
subcontrol-position: top;
subcontrol-origin: margin;
}
QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical
{
border: 1px solid black;
width: 1px;
height: 1px;
background: white;
}
QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical
{
background: none;
}
QTextEdit
{
background-color: #242424;
}
QPlainTextEdit
{
background-color: #242424;
}
QHeaderView::section
{
background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, stop:0 #616161, stop: 0.5 #505050, stop: 0.6 #434343, stop:1 #656565);
color: white;
padding-left: 4px;
border: 1px solid #6c6c6c;
}
QCheckBox:disabled
{
color: #414141;
}
QDockWidget::title
{
text-align: center;
spacing: 3px; /* spacing between items in the tool bar */
background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, stop:0 #323232, stop: 0.5 #242424, stop:1 #323232);
}
QDockWidget::close-button, QDockWidget::float-button
{
text-align: center;
spacing: 1px; /* spacing between items in the tool bar */
background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, stop:0 #323232, stop: 0.5 #242424, stop:1 #323232);
}
QDockWidget::close-button:hover, QDockWidget::float-button:hover
{
background: #242424;
}
QDockWidget::close-button:pressed, QDockWidget::float-button:pressed
{
padding: 1px -1px -1px 1px;
}
QMainWindow::separator
{
background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, stop:0 #161616, stop: 0.5 #151515, stop: 0.6 #212121, stop:1 #343434);
color: white;
padding-left: 4px;
border: 1px solid #4c4c4c;
spacing: 3px; /* spacing between items in the tool bar */
}
QMainWindow::separator:hover
{
background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, stop:0 #d7801a, stop:0.5 #b56c17 stop:1 #ffa02f);
color: white;
padding-left: 4px;
border: 1px solid #6c6c6c;
spacing: 3px; /* spacing between items in the tool bar */
}
QToolBar::handle
{
spacing: 3px; /* spacing between items in the tool bar */
background: url(:/images/handle.png);
}
QMenu::separator
{
height: 2px;
background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, stop:0 #161616, stop: 0.5 #151515, stop: 0.6 #212121, stop:1 #343434);
color: white;
padding-left: 4px;
margin-left: 10px;
margin-right: 5px;
}
QProgressBar
{
border: 2px solid grey;
border-radius: 5px;
text-align: center;
}
QProgressBar::chunk
{
background-color: #d7801a;
width: 2.15px;
margin: 0.5px;
}
QTabBar::tab {
color: #b1b1b1;
border: 1px solid #444;
border-bottom-style: none;
background-color: #323232;
padding-left: 10px;
padding-right: 10px;
padding-top: 3px;
padding-bottom: 2px;
margin-right: -1px;
}
QTabWidget::pane {
border: 1px solid #444;
top: 1px;
}
QTabBar::tab:last
{
margin-right: 0; /* the last selected tab has nothing to overlap with on the right */
border-top-right-radius: 3px;
}
QTabBar::tab:first:!selected
{
margin-left: 0px; /* the last selected tab has nothing to overlap with on the right */
border-top-left-radius: 3px;
}
QTabBar::tab:!selected
{
color: #b1b1b1;
border-bottom-style: solid;
margin-top: 3px;
background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, stop:1 #212121, stop:.4 #343434);
}
QTabBar::tab:selected
{
border-top-left-radius: 3px;
border-top-right-radius: 3px;
margin-bottom: 0px;
}
QTabBar::tab:!selected:hover
{
/*border-top: 2px solid #ffaa00;
padding-bottom: 3px;*/
border-top-left-radius: 3px;
border-top-right-radius: 3px;
background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, stop:1 #212121, stop:0.4 #343434, stop:0.2 #343434, stop:0.1 #ffaa00);
}
QRadioButton::indicator:checked, QRadioButton::indicator:unchecked{
color: #b1b1b1;
background-color: #323232;
border: 1px solid #b1b1b1;
border-radius: 6px;
}
QRadioButton::indicator:checked
{
background-color: qradialgradient(
cx: 0.5, cy: 0.5,
fx: 0.5, fy: 0.5,
radius: 1.0,
stop: 0.25 #ffaa00,
stop: 0.3 #323232
);
}
QCheckBox::indicator{
color: #b1b1b1;
background-color: #323232;
border: 1px solid #b1b1b1;
width: 9px;
height: 9px;
}
QRadioButton::indicator
{
border-radius: 6px;
}
QRadioButton::indicator:hover, QCheckBox::indicator:hover
{
border: 1px solid #ffaa00;
}
QCheckBox::indicator:checked
{
image:url(:/images/checkbox.png);
}
QCheckBox::indicator:disabled, QRadioButton::indicator:disabled
{
border: 1px solid #444;
}</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout"/>
</widget>

View File

@@ -4,11 +4,15 @@
#
#-------------------------------------------------
QT += core gui network
GIT_STR_VERSION = $$system(git describe)
DATE_STR = $$system(date)
HOSTNAME_STR = $$system(hostname)
QT += core gui network uitools
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = untitled
TARGET = speech-server-client-qt
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
@@ -16,6 +20,9 @@ TEMPLATE = app
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
DEFINES += "GIT_VERSION=\"\\\"$$GIT_STR_VERSION\\\"\""
DEFINES += "BUILD_DATE=\"\\\"$$DATE_STR\\\"\""
DEFINES += "BUILD_HOST=\"\\\"$$HOSTNAME_STR\\\"\""
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
@@ -30,7 +37,10 @@ SOURCES += \
notificationwidget.cpp \
settings.cpp \
about.cpp \
serverconnection.cpp
serverconnection.cpp \
serverconfig.cpp \
multivalueinputdialog.cpp \
pushbuttonwithposition.cpp
HEADERS += \
mainwindow.h \
@@ -38,13 +48,22 @@ HEADERS += \
settings.h \
settingkeys.h \
about.h \
serverconnection.h
serverconnection.h \
serverconfig.h \
urls.h \
multivalueinputdialog.h \
pushbuttonwithposition.h
FORMS += \
mainwindow.ui \
listItemServeConfig.ui \
serverconfigitem.ui \
settings.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
RESOURCES += \
defaultres.qrc

15
urls.h Normal file
View File

@@ -0,0 +1,15 @@
#ifndef URLS_H
#define URLS_H
#define PP_GET "/keyword-map"
#define PP_EDIT "/add-pp-keyword"
#define CONTEXT_GET "/context-phrases"
#define CONTEXT_EDIT "/add-context-phrase"
#define UNIFIED_GET "/unified-server-settings"
#define SERVER_INFO "/server-info"
#define FLUSH_SERVER_CACHE "/flush-cache"
#endif // URLS_H