VNC viewer support

This commit is contained in:
Nicolas Mailloux 2021-07-06 00:13:11 -04:00
parent 13803ef333
commit 87e133b8d6
8 changed files with 82 additions and 12 deletions

View file

@ -26,17 +26,15 @@ apps::apps(QWidget *parent) :
ui->vncLaunchBtn->setStyleSheet("background: lightGrey; font-size: 9pt; padding: 8px"); ui->vncLaunchBtn->setStyleSheet("background: lightGrey; font-size: 9pt; padding: 8px");
// Hiding KoBox apps button and label if X11 isn't enabled/wasn't started // Hiding KoBox apps button and label if X11 isn't enabled/wasn't started
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();
}
if(checkconfig("/external_root/boot/flags/X11_START") != true) {
ui->label_5->hide(); ui->label_5->hide();
ui->koboxAppsOpenButton->hide(); ui->koboxAppsOpenButton->hide();
ui->label_5->deleteLater(); ui->label_5->deleteLater();
ui->koboxAppsOpenButton->deleteLater(); ui->koboxAppsOpenButton->deleteLater();
ui->vncViewerLabel->hide();
ui->vncLaunchBtn->hide();
ui->vncViewerLabel->deleteLater();
ui->vncLaunchBtn->deleteLater();
} }
QFile stylesheetFile(":/resources/eink.qss"); QFile stylesheetFile(":/resources/eink.qss");
@ -98,5 +96,15 @@ void apps::on_koboxAppsOpenButton_clicked()
void apps::on_vncLaunchBtn_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();
} }

7
apps.h
View file

@ -26,16 +26,19 @@ private slots:
void on_savedWordsLaunchBtn_clicked(); void on_savedWordsLaunchBtn_clicked();
void on_calendarLaunchBtn_clicked(); void on_calendarLaunchBtn_clicked();
void on_calculatorLaunchBtn_clicked(); void on_calculatorLaunchBtn_clicked();
void on_koboxAppsOpenButton_clicked(); void on_koboxAppsOpenButton_clicked();
void on_vncLaunchBtn_clicked(); void on_vncLaunchBtn_clicked();
void refreshScreenNative();
private: private:
Ui::apps *ui; Ui::apps *ui;
savedwords *savedWordsWindow; savedwords *savedWordsWindow;
calendarApp *calendarWindow; calendarApp *calendarWindow;
koboxAppsDialog *koboxAppsDialogWindow; koboxAppsDialog *koboxAppsDialogWindow;
generalDialog *generalDialogWindow;
signals:
void refreshScreen();
}; };
#endif // APPS_H #endif // APPS_H

View file

@ -63,6 +63,7 @@ namespace global {
inline bool keyboardDialog; inline bool keyboardDialog;
inline bool keypadDialog; inline bool keypadDialog;
inline bool searchDialog; inline bool searchDialog;
inline bool vncDialog;
inline QString keyboardText; inline QString keyboardText;
inline QString keypadText; inline QString keypadText;
} }

View file

@ -239,6 +239,32 @@ void generalDialog::on_okBtn_clicked()
QMessageBox::critical(this, tr("Invalid argument"), tr("Please type in a search term.")); 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 { else {
global::keyboard::keyboardDialog = false; global::keyboard::keyboardDialog = false;
generalDialog::close(); generalDialog::close();
@ -291,14 +317,21 @@ void generalDialog::setupKeyboardDialog() {
if(global::keyboard::searchDialog == true) { if(global::keyboard::searchDialog == true) {
ui->topStackedWidget->setCurrentIndex(1); ui->topStackedWidget->setCurrentIndex(1);
ui->searchHeaderLabel->setText("Search"); 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 { else {
ui->headerLabel->setText("Enter a string"); ui->headerLabel->setText("Enter a string");
ui->okBtn->setText("OK");
ui->cancelBtn->setText("Cancel");
} }
keyboardWidget = new virtualkeyboard(); keyboardWidget = new virtualkeyboard();
connect(keyboardWidget, SIGNAL(adjust_size()), SLOT(adjust_size())); connect(keyboardWidget, SIGNAL(adjust_size()), SLOT(adjust_size()));
ui->okBtn->setText("Search");
ui->cancelBtn->setText("Close");
ui->mainStackedWidget->insertWidget(1, keyboardWidget); ui->mainStackedWidget->insertWidget(1, keyboardWidget);
ui->mainStackedWidget->setCurrentIndex(1); ui->mainStackedWidget->setCurrentIndex(1);
QTimer::singleShot(1000, this, SLOT(adjust_size())); QTimer::singleShot(1000, this, SLOT(adjust_size()));
@ -307,3 +340,14 @@ void generalDialog::setupKeyboardDialog() {
void generalDialog::refreshScreenNative() { void generalDialog::refreshScreenNative() {
emit refreshScreen(); 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();
}

View file

@ -33,7 +33,13 @@ public:
bool keyboardDialog = false; bool keyboardDialog = false;
bool keypadDialog = false; bool keypadDialog = false;
bool dictionaryResults = false; bool dictionaryResults = false;
bool vncServerSet = false;
bool vncPasswordSet = false;
QString vncServerAddress;
QString vncServerPassword;
QString vncServerPort;
void setupKeyboardDialog(); void setupKeyboardDialog();
void startVNC(QString server, QString password, QString port);
private slots: private slots:
void on_cancelBtn_clicked(); void on_cancelBtn_clicked();

View file

@ -593,6 +593,7 @@ void MainWindow::on_appsBtn_clicked()
// Create widget // Create widget
appsWindow = new apps(); appsWindow = new apps();
connect(appsWindow, SIGNAL(refreshScreen()), SLOT(refreshScreen()));
ui->stackedWidget->insertWidget(1, appsWindow); ui->stackedWidget->insertWidget(1, appsWindow);
global::mainwindow::tabSwitcher::appsWidgetCreated = true; global::mainwindow::tabSwitcher::appsWidgetCreated = true;

View file

@ -594,3 +594,9 @@ void virtualkeyboard::reverseKeys() {
void virtualkeyboard::adjust_size_function() { void virtualkeyboard::adjust_size_function() {
emit adjust_size(); emit adjust_size();
} }
void virtualkeyboard::clearLineEdit() {
ui->lineEdit->clear();
QString text = ui->lineEdit->text();
global::keyboard::keyboardText = text;
}

View file

@ -17,6 +17,7 @@ public:
~virtualkeyboard(); ~virtualkeyboard();
bool shift; bool shift;
void reverseKeys(); void reverseKeys();
void clearLineEdit();
private slots: private slots:
void on_spaceBtn_clicked(); void on_spaceBtn_clicked();