diff --git a/apps.cpp b/apps.cpp index aa2c6df..a1156fe 100644 --- a/apps.cpp +++ b/apps.cpp @@ -26,17 +26,15 @@ apps::apps(QWidget *parent) : ui->vncLaunchBtn->setStyleSheet("background: lightGrey; font-size: 9pt; padding: 8px"); // Hiding KoBox apps button and label if X11 isn't enabled/wasn't started - if(checkconfig("/external_root/boot/flags/X11_START") != true) { - ui->label_5->hide(); - ui->koboxAppsOpenButton->hide(); - ui->label_5->deleteLater(); - ui->koboxAppsOpenButton->deleteLater(); - } - if(checkconfig("/external_root/boot/flags/X11_START") != true) { + if(checkconfig("/external_root/boot/flags/X11_START") == false) { ui->label_5->hide(); ui->koboxAppsOpenButton->hide(); ui->label_5->deleteLater(); ui->koboxAppsOpenButton->deleteLater(); + ui->vncViewerLabel->hide(); + ui->vncLaunchBtn->hide(); + ui->vncViewerLabel->deleteLater(); + ui->vncLaunchBtn->deleteLater(); } QFile stylesheetFile(":/resources/eink.qss"); @@ -98,5 +96,15 @@ void apps::on_koboxAppsOpenButton_clicked() void apps::on_vncLaunchBtn_clicked() { - + global::keyboard::keyboardDialog = true; + global::keyboard::vncDialog = true; + global::keyboard::keyboardText = ""; + generalDialogWindow = new generalDialog(); + generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose); + connect(generalDialogWindow, SIGNAL(refreshScreen()), SLOT(refreshScreenNative())); + generalDialogWindow->show(); +} + +void apps::refreshScreenNative() { + emit refreshScreen(); } diff --git a/apps.h b/apps.h index a512104..9c2446d 100644 --- a/apps.h +++ b/apps.h @@ -26,16 +26,19 @@ private slots: void on_savedWordsLaunchBtn_clicked(); void on_calendarLaunchBtn_clicked(); void on_calculatorLaunchBtn_clicked(); - void on_koboxAppsOpenButton_clicked(); - void on_vncLaunchBtn_clicked(); + void refreshScreenNative(); private: Ui::apps *ui; savedwords *savedWordsWindow; calendarApp *calendarWindow; koboxAppsDialog *koboxAppsDialogWindow; + generalDialog *generalDialogWindow; + +signals: + void refreshScreen(); }; #endif // APPS_H diff --git a/functions.h b/functions.h index fc95eb2..e6fd028 100644 --- a/functions.h +++ b/functions.h @@ -63,6 +63,7 @@ namespace global { inline bool keyboardDialog; inline bool keypadDialog; inline bool searchDialog; + inline bool vncDialog; inline QString keyboardText; inline QString keypadText; } diff --git a/generaldialog.cpp b/generaldialog.cpp index 06c3cfd..2618226 100644 --- a/generaldialog.cpp +++ b/generaldialog.cpp @@ -239,6 +239,32 @@ void generalDialog::on_okBtn_clicked() QMessageBox::critical(this, tr("Invalid argument"), tr("Please type in a search term.")); } } + else if(global::keyboard::vncDialog == true) { + if(global::keyboard::keyboardText != "") { + if(vncServerSet != true) { + vncServerAddress = global::keyboard::keyboardText; + vncServerSet = true; + keyboardWidget->clearLineEdit(); + ui->headerLabel->setText("Enter the server's password"); + } + else if(vncPasswordSet != true) { + vncServerPassword = global::keyboard::keyboardText; + vncPasswordSet = true; + keyboardWidget->clearLineEdit(); + ui->headerLabel->setText("Enter the server's port"); + } + else { + vncServerPort = global::keyboard::keyboardText; + global::keyboard::vncDialog = false; + global::keyboard::keyboardDialog = false; + startVNC(vncServerAddress, vncServerPassword, vncServerPort); + generalDialog::close(); + } + } + else { + QMessageBox::critical(this, tr("Invalid argument"), tr("Please type in the required argument.")); + } + } else { global::keyboard::keyboardDialog = false; generalDialog::close(); @@ -291,14 +317,21 @@ void generalDialog::setupKeyboardDialog() { if(global::keyboard::searchDialog == true) { ui->topStackedWidget->setCurrentIndex(1); ui->searchHeaderLabel->setText("Search"); + ui->okBtn->setText("Search"); + ui->cancelBtn->setText("Close"); + } + else if(global::keyboard::vncDialog == true) { + ui->headerLabel->setText("Enter the server's IP address"); + ui->okBtn->setText("OK"); + ui->cancelBtn->setText("Cancel"); } else { ui->headerLabel->setText("Enter a string"); + ui->okBtn->setText("OK"); + ui->cancelBtn->setText("Cancel"); } keyboardWidget = new virtualkeyboard(); connect(keyboardWidget, SIGNAL(adjust_size()), SLOT(adjust_size())); - ui->okBtn->setText("Search"); - ui->cancelBtn->setText("Close"); ui->mainStackedWidget->insertWidget(1, keyboardWidget); ui->mainStackedWidget->setCurrentIndex(1); QTimer::singleShot(1000, this, SLOT(adjust_size())); @@ -307,3 +340,14 @@ void generalDialog::setupKeyboardDialog() { void generalDialog::refreshScreenNative() { emit refreshScreen(); } + +void generalDialog::startVNC(QString server, QString password, QString port) { + std::string server_str = server.toStdString(); + std::string password_str = password.toStdString(); + std::string port_str = port.toStdString(); + string_writeconfig("/external_root/tmp/app_vnc_server", server_str); + string_writeconfig("/external_root/tmp/app_vnc_password", password_str); + string_writeconfig("/external_root/tmp/app_vnc_port", port_str); + string_writeconfig("/opt/ibxd", "app_start_vnc"); + qApp->quit(); +} diff --git a/generaldialog.h b/generaldialog.h index 8fd7437..4e6dda3 100644 --- a/generaldialog.h +++ b/generaldialog.h @@ -33,7 +33,13 @@ public: bool keyboardDialog = false; bool keypadDialog = false; bool dictionaryResults = false; + bool vncServerSet = false; + bool vncPasswordSet = false; + QString vncServerAddress; + QString vncServerPassword; + QString vncServerPort; void setupKeyboardDialog(); + void startVNC(QString server, QString password, QString port); private slots: void on_cancelBtn_clicked(); diff --git a/mainwindow.cpp b/mainwindow.cpp index 4467928..b37bc71 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -593,6 +593,7 @@ void MainWindow::on_appsBtn_clicked() // Create widget appsWindow = new apps(); + connect(appsWindow, SIGNAL(refreshScreen()), SLOT(refreshScreen())); ui->stackedWidget->insertWidget(1, appsWindow); global::mainwindow::tabSwitcher::appsWidgetCreated = true; diff --git a/virtualkeyboard.cpp b/virtualkeyboard.cpp index 27578e8..c295a67 100644 --- a/virtualkeyboard.cpp +++ b/virtualkeyboard.cpp @@ -594,3 +594,9 @@ void virtualkeyboard::reverseKeys() { void virtualkeyboard::adjust_size_function() { emit adjust_size(); } + +void virtualkeyboard::clearLineEdit() { + ui->lineEdit->clear(); + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} diff --git a/virtualkeyboard.h b/virtualkeyboard.h index b97d608..abd8825 100644 --- a/virtualkeyboard.h +++ b/virtualkeyboard.h @@ -17,6 +17,7 @@ public: ~virtualkeyboard(); bool shift; void reverseKeys(); + void clearLineEdit(); private slots: void on_spaceBtn_clicked();