From e9c17ca382a1a3f1b9fb0f5f5720d7626f7b12b5 Mon Sep 17 00:00:00 2001 From: Nicolas Mailloux Date: Mon, 5 Jul 2021 16:01:32 -0400 Subject: [PATCH] Virtual keyboard! --- apps.cpp | 7 + apps.h | 2 + apps.ui | 169 ++++++++----- generaldialog.cpp | 21 ++ generaldialog.h | 4 + inkbox.pro | 3 + mainwindow.cpp | 9 + mainwindow.h | 1 + reader.cpp | 1 - virtualkeyboard.cpp | 595 ++++++++++++++++++++++++++++++++++++++++++++ virtualkeyboard.h | 72 ++++++ virtualkeyboard.ui | 388 +++++++++++++++++++++++++++++ virtualkeypad.h | 1 + 13 files changed, 1206 insertions(+), 67 deletions(-) create mode 100644 virtualkeyboard.cpp create mode 100644 virtualkeyboard.h create mode 100644 virtualkeyboard.ui diff --git a/apps.cpp b/apps.cpp index ef9335c..aa2c6df 100644 --- a/apps.cpp +++ b/apps.cpp @@ -15,6 +15,7 @@ apps::apps(QWidget *parent) : ui->calendarLaunchBtn->setProperty("type", "borderless"); ui->savedWordsLaunchBtn->setProperty("type", "borderless"); ui->calculatorLaunchBtn->setProperty("type", "borderless"); + ui->vncLaunchBtn->setProperty("type", "borderless"); ui->koboxAppsOpenButton->setStyleSheet("background: lightGrey; font-size: 9pt; padding: 8px"); ui->scribbleLaunchBtn->setStyleSheet("background: lightGrey; font-size: 9pt; padding: 8px"); @@ -22,6 +23,7 @@ apps::apps(QWidget *parent) : ui->calendarLaunchBtn->setStyleSheet("background: lightGrey; font-size: 9pt; padding: 8px"); ui->savedWordsLaunchBtn->setStyleSheet("background: lightGrey; font-size: 9pt; padding: 8px"); ui->calculatorLaunchBtn->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 if(checkconfig("/external_root/boot/flags/X11_START") != true) { @@ -93,3 +95,8 @@ void apps::on_koboxAppsOpenButton_clicked() koboxAppsDialogWindow->setAttribute(Qt::WA_DeleteOnClose); koboxAppsDialogWindow->show(); } + +void apps::on_vncLaunchBtn_clicked() +{ + +} diff --git a/apps.h b/apps.h index 4084f92..a512104 100644 --- a/apps.h +++ b/apps.h @@ -29,6 +29,8 @@ private slots: void on_koboxAppsOpenButton_clicked(); + void on_vncLaunchBtn_clicked(); + private: Ui::apps *ui; savedwords *savedWordsWindow; diff --git a/apps.ui b/apps.ui index 9dbe1e0..46ada23 100644 --- a/apps.ui +++ b/apps.ui @@ -56,45 +56,8 @@ 0 - - - - - Inter - false - - - - Launch - - - - - - - - Inter - - - - Launch - - - - - - - - Inter - - - - Launch - - - - - + + 75 @@ -102,7 +65,34 @@ - Light Maps + Scribble + + + + + + + + Inter + 75 + true + + + + Launch + + + + + + + + 75 + true + + + + KoBox apps @@ -119,25 +109,13 @@ - - - - - 75 - true - - - - Scribble - - - - - + + Inter - false + 75 + true @@ -158,11 +136,27 @@ - - + + + + + 75 + true + + + + Light Maps + + + + + Inter + 75 + false + true @@ -183,8 +177,51 @@ - - + + + + + Inter + 75 + true + + + + Open + + + + + + + + Inter + 75 + true + + + + Launch + + + + + + + + Inter + 75 + false + true + + + + Launch + + + + + 75 @@ -192,21 +229,21 @@ - KoBox apps + VNC viewer - - + + Inter - 50 - false + 75 + true - Open + Launch diff --git a/generaldialog.cpp b/generaldialog.cpp index 8407243..5f48035 100644 --- a/generaldialog.cpp +++ b/generaldialog.cpp @@ -8,6 +8,7 @@ #include #include #include +#include generalDialog::generalDialog(QWidget *parent) : QDialog(parent), @@ -111,6 +112,17 @@ generalDialog::generalDialog(QWidget *parent) : ui->bodyLabel->setText("This will erase all KoBox user data. KoBox settings will be reset."); this->adjustSize(); } + else if(global::keyboard::keyboardDialog == true) { + keyboardDialog = true; + keyboardWidget = new virtualkeyboard(); + connect(keyboardWidget, SIGNAL(adjust_size()), SLOT(adjust_size())); + ui->headerLabel->setText("Enter a string"); + ui->okBtn->setText("OK"); + ui->cancelBtn->setText("Cancel"); + ui->mainStackedWidget->insertWidget(1, keyboardWidget); + ui->mainStackedWidget->setCurrentIndex(1); + QTimer::singleShot(1000, this, SLOT(adjust_size())); + } else if(global::keyboard::keypadDialog == true) { keypadDialog = true; keypadWidget = new virtualkeypad(); @@ -233,3 +245,12 @@ void generalDialog::on_acceptBtn_clicked() // We don't have any other option ;p generalDialog::close(); } + +void generalDialog::adjust_size() { + this->adjustSize(); + QRect screenGeometry = QGuiApplication::screens()[0]->geometry(); + int x = (screenGeometry.width() - this->width()) / 2; + int y = (screenGeometry.height() - this->height()) / 2; + this->move(x, y); + emit refreshScreen(); +} diff --git a/generaldialog.h b/generaldialog.h index ee4f5dc..9bbbd26 100644 --- a/generaldialog.h +++ b/generaldialog.h @@ -5,6 +5,7 @@ #include "usbms_splash.h" #include "textwidget.h" +#include "virtualkeyboard.h" #include "virtualkeypad.h" using namespace std; @@ -35,15 +36,18 @@ private slots: void on_cancelBtn_clicked(); void on_okBtn_clicked(); void on_acceptBtn_clicked(); + void adjust_size(); private: Ui::generalDialog *ui; usbms_splash *usbmsWindow; textwidget *textwidgetWindow; + virtualkeyboard *keyboardWidget; virtualkeypad *keypadWidget; signals: void gotoPageSelected(int value); + void refreshScreen(); }; #endif // GENERALDIALOG_H diff --git a/inkbox.pro b/inkbox.pro index af0e0b4..3a7c45f 100644 --- a/inkbox.pro +++ b/inkbox.pro @@ -27,6 +27,7 @@ SOURCES += \ settingschooser.cpp \ textwidget.cpp \ usbms_splash.cpp \ + virtualkeyboard.cpp \ virtualkeypad.cpp HEADERS += \ @@ -46,6 +47,7 @@ HEADERS += \ settingschooser.h \ textwidget.h \ usbms_splash.h \ + virtualkeyboard.h \ virtualkeypad.h FORMS += \ @@ -64,6 +66,7 @@ FORMS += \ settingschooser.ui \ textwidget.ui \ usbms_splash.ui \ + virtualkeyboard.ui \ virtualkeypad.ui # Default rules for deployment. diff --git a/mainwindow.cpp b/mainwindow.cpp index 5b9e37a..6b8667b 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -618,6 +618,11 @@ void MainWindow::on_pushButton_clicked() void MainWindow::on_searchBtn_clicked() { // Hopefully this button will do something one day... + global::keyboard::keyboardDialog = true; + generalDialogWindow = new generalDialog(); + generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose); + connect(generalDialogWindow, SIGNAL(refreshScreen()), SLOT(refreshScreen())); + generalDialogWindow->show(); } void MainWindow::on_quitBtn_clicked() @@ -801,3 +806,7 @@ void MainWindow::setInitialBrightness() { cinematicBrightness(brightness_value, 0); } } + +void MainWindow::refreshScreen() { + this->repaint(); +} diff --git a/mainwindow.h b/mainwindow.h index 0fccdc9..b85056e 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -68,6 +68,7 @@ private slots: void openUpdateDialog(); void setInitialBrightness(); void on_homeBtn_clicked(); + void refreshScreen(); private: Ui::MainWindow *ui; diff --git a/reader.cpp b/reader.cpp index f3c048f..eda632c 100644 --- a/reader.cpp +++ b/reader.cpp @@ -602,7 +602,6 @@ reader::reader(QWidget *parent) : getTotalEpubPagesNumber(); } setupPageWidget(); - //connect(this, SIGNAL(gotoPageSelected(int)), this, SLOT(gotoPage(int))); } reader::~reader() diff --git a/virtualkeyboard.cpp b/virtualkeyboard.cpp new file mode 100644 index 0000000..ee777a0 --- /dev/null +++ b/virtualkeyboard.cpp @@ -0,0 +1,595 @@ +#include "virtualkeyboard.h" +#include "ui_virtualkeyboard.h" + +#include + +virtualkeyboard::virtualkeyboard(QWidget *parent) : + QWidget(parent), + ui(new Ui::virtualkeyboard) +{ + ui->setupUi(this); + shift = false; + + ui->n1->setProperty("type", "borderless"); + ui->n2->setProperty("type", "borderless"); + ui->n3->setProperty("type", "borderless"); + ui->n4->setProperty("type", "borderless"); + ui->n5->setProperty("type", "borderless"); + ui->n6->setProperty("type", "borderless"); + ui->n7->setProperty("type", "borderless"); + ui->n8->setProperty("type", "borderless"); + ui->n9->setProperty("type", "borderless"); + ui->n0->setProperty("type", "borderless"); + + ui->la->setProperty("type", "borderless"); + ui->lb->setProperty("type", "borderless"); + ui->lc->setProperty("type", "borderless"); + ui->ld->setProperty("type", "borderless"); + ui->le->setProperty("type", "borderless"); + ui->lf->setProperty("type", "borderless"); + ui->lg->setProperty("type", "borderless"); + ui->lh->setProperty("type", "borderless"); + ui->li->setProperty("type", "borderless"); + ui->lj->setProperty("type", "borderless"); + ui->lk->setProperty("type", "borderless"); + ui->ll->setProperty("type", "borderless"); + ui->lm->setProperty("type", "borderless"); + ui->ln->setProperty("type", "borderless"); + ui->lo->setProperty("type", "borderless"); + ui->lp->setProperty("type", "borderless"); + ui->lq->setProperty("type", "borderless"); + ui->lr->setProperty("type", "borderless"); + ui->ls->setProperty("type", "borderless"); + ui->lt->setProperty("type", "borderless"); + ui->lu->setProperty("type", "borderless"); + ui->lv->setProperty("type", "borderless"); + ui->lw->setProperty("type", "borderless"); + ui->lx->setProperty("type", "borderless"); + ui->ly->setProperty("type", "borderless"); + ui->lz->setProperty("type", "borderless"); + + ui->eraseBtn->setProperty("type", "borderless"); + ui->shiftBtn->setProperty("type", "borderless"); + ui->spt->setProperty("type", "borderless"); + ui->sat->setProperty("type", "borderless"); + + ui->n1->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->n2->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->n3->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->n4->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->n5->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->n6->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->n7->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->n8->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->n9->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->n0->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + + ui->la->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->lb->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->lc->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->ld->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->le->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->lf->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->lg->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->lh->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->li->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->lj->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->lk->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->ll->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->lm->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->ln->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->lo->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->lp->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->lq->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->lr->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->ls->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->lt->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->lu->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->lv->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->lw->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->lx->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->ly->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->lz->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + + ui->eraseBtn->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->shiftBtn->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->spt->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->sat->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 13px"); + ui->spaceBtn->setStyleSheet("font-weight: bold; font-size: 9pt; padding: 10px; border: 1px solid black"); + + ui->lineEdit->setStyleSheet("border: 3px solid black"); +} + +virtualkeyboard::~virtualkeyboard() +{ + delete ui; +} + +void virtualkeyboard::on_spaceBtn_clicked() +{ + ui->lineEdit->insert(" "); + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_eraseBtn_clicked() +{ + ui->lineEdit->backspace(); + QString text = ui->lineEdit->text(); + global::keyboard::keypadText = text; +} + +void virtualkeyboard::on_spt_clicked() +{ + ui->lineEdit->insert("."); + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_sat_clicked() +{ + ui->lineEdit->insert("@"); + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_n1_clicked() +{ + ui->lineEdit->insert("1"); + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_n2_clicked() +{ + ui->lineEdit->insert("2"); + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_n3_clicked() +{ + ui->lineEdit->insert("3"); + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_n4_clicked() +{ + ui->lineEdit->insert("4"); + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_n5_clicked() +{ + ui->lineEdit->insert("5"); + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_n6_clicked() +{ + ui->lineEdit->insert("6"); + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_n7_clicked() +{ + ui->lineEdit->insert("7"); + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_n8_clicked() +{ + ui->lineEdit->insert("8"); + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_n9_clicked() +{ + ui->lineEdit->insert("9"); + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_n0_clicked() +{ + ui->lineEdit->insert("0"); + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_lq_clicked() +{ + if(shift == true) { + ui->lineEdit->insert("Q"); + } + else { + ui->lineEdit->insert("q"); + } + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_lw_clicked() +{ + if(shift == true) { + ui->lineEdit->insert("W"); + } + else { + ui->lineEdit->insert("w"); + } + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_le_clicked() +{ + if(shift == true) { + ui->lineEdit->insert("E"); + } + else { + ui->lineEdit->insert("e"); + } + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_lr_clicked() +{ + if(shift == true) { + ui->lineEdit->insert("R"); + } + else { + ui->lineEdit->insert("r"); + } + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_lt_clicked() +{ + if(shift == true) { + ui->lineEdit->insert("T"); + } + else { + ui->lineEdit->insert("t"); + } + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_ly_clicked() +{ + if(shift == true) { + ui->lineEdit->insert("Y"); + } + else { + ui->lineEdit->insert("y"); + } + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_lu_clicked() +{ + if(shift == true) { + ui->lineEdit->insert("U"); + } + else { + ui->lineEdit->insert("u"); + } + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_li_clicked() +{ + if(shift == true) { + ui->lineEdit->insert("I"); + } + else { + ui->lineEdit->insert("i"); + } + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_lo_clicked() +{ + if(shift == true) { + ui->lineEdit->insert("O"); + } + else { + ui->lineEdit->insert("o"); + } + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_lp_clicked() +{ + if(shift == true) { + ui->lineEdit->insert("P"); + } + else { + ui->lineEdit->insert("p"); + } + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_la_clicked() +{ + if(shift == true) { + ui->lineEdit->insert("A"); + } + else { + ui->lineEdit->insert("a"); + } + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_ls_clicked() +{ + if(shift == true) { + ui->lineEdit->insert("S"); + } + else { + ui->lineEdit->insert("s"); + } + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_ld_clicked() +{ + if(shift == true) { + ui->lineEdit->insert("D"); + } + else { + ui->lineEdit->insert("d"); + } + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_lf_clicked() +{ + if(shift == true) { + ui->lineEdit->insert("F"); + } + else { + ui->lineEdit->insert("f"); + } + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_lg_clicked() +{ + if(shift == true) { + ui->lineEdit->insert("G"); + } + else { + ui->lineEdit->insert("g"); + } + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_lh_clicked() +{ + if(shift == true) { + ui->lineEdit->insert("H"); + } + else { + ui->lineEdit->insert("h"); + } + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_lj_clicked() +{ + if(shift == true) { + ui->lineEdit->insert("J"); + } + else { + ui->lineEdit->insert("j"); + } + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_lk_clicked() +{ + if(shift == true) { + ui->lineEdit->insert("K"); + } + else { + ui->lineEdit->insert("k"); + } + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_ll_clicked() +{ + if(shift == true) { + ui->lineEdit->insert("L"); + } + else { + ui->lineEdit->insert("l"); + } + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_lz_clicked() +{ + if(shift == true) { + ui->lineEdit->insert("Z"); + } + else { + ui->lineEdit->insert("z"); + } + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_lx_clicked() +{ + if(shift == true) { + ui->lineEdit->insert("X"); + } + else { + ui->lineEdit->insert("x"); + } + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_lc_clicked() +{ + if(shift == true) { + ui->lineEdit->insert("C"); + } + else { + ui->lineEdit->insert("c"); + } + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_lv_clicked() +{ + if(shift == true) { + ui->lineEdit->insert("V"); + } + else { + ui->lineEdit->insert("v"); + } + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_lb_clicked() +{ + if(shift == true) { + ui->lineEdit->insert("B"); + } + else { + ui->lineEdit->insert("b"); + } + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_ln_clicked() +{ + if(shift == true) { + ui->lineEdit->insert("N"); + } + else { + ui->lineEdit->insert("n"); + } + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_lm_clicked() +{ + if(shift == true) { + ui->lineEdit->insert("M"); + } + else { + ui->lineEdit->insert("m"); + } + QString text = ui->lineEdit->text(); + global::keyboard::keyboardText = text; +} + +void virtualkeyboard::on_shiftBtn_clicked() +{ + if(shift == true) { + shift = false; + } + else { + shift = true; + } + reverseKeys(); +} + +void virtualkeyboard::reverseKeys() { + if(shift == true) { + ui->shiftBtn->setText("⇪"); + + ui->la->setText("A"); + ui->lb->setText("B"); + ui->lc->setText("C"); + ui->ld->setText("D"); + ui->le->setText("E"); + ui->lf->setText("F"); + ui->lg->setText("G"); + ui->lh->setText("H"); + ui->li->setText("I"); + ui->lj->setText("J"); + ui->lk->setText("K"); + ui->ll->setText("L"); + ui->lm->setText("M"); + ui->ln->setText("N"); + ui->lo->setText("O"); + ui->lp->setText("P"); + ui->lq->setText("Q"); + ui->lr->setText("R"); + ui->ls->setText("S"); + ui->lt->setText("T"); + ui->lu->setText("U"); + ui->lv->setText("V"); + ui->lw->setText("W"); + ui->lx->setText("X"); + ui->ly->setText("Y"); + ui->lz->setText("Z"); + } + else { + ui->shiftBtn->setText("⇧"); + + ui->la->setText("a"); + ui->lb->setText("b"); + ui->lc->setText("c"); + ui->ld->setText("d"); + ui->le->setText("e"); + ui->lf->setText("f"); + ui->lg->setText("g"); + ui->lh->setText("h"); + ui->li->setText("i"); + ui->lj->setText("j"); + ui->lk->setText("k"); + ui->ll->setText("l"); + ui->lm->setText("m"); + ui->ln->setText("n"); + ui->lo->setText("o"); + ui->lp->setText("p"); + ui->lq->setText("q"); + ui->lr->setText("r"); + ui->ls->setText("s"); + ui->lt->setText("t"); + ui->lu->setText("u"); + ui->lv->setText("v"); + ui->lw->setText("w"); + ui->lx->setText("x"); + ui->ly->setText("y"); + ui->lz->setText("z"); + } + QTimer::singleShot(1000, this, SLOT(adjust_size_function())); +} + +void virtualkeyboard::adjust_size_function() { + emit adjust_size(); +} diff --git a/virtualkeyboard.h b/virtualkeyboard.h new file mode 100644 index 0000000..b97d608 --- /dev/null +++ b/virtualkeyboard.h @@ -0,0 +1,72 @@ +#ifndef VIRTUALKEYBOARD_H +#define VIRTUALKEYBOARD_H + +#include +#include "functions.h" + +namespace Ui { +class virtualkeyboard; +} + +class virtualkeyboard : public QWidget +{ + Q_OBJECT + +public: + explicit virtualkeyboard(QWidget *parent = nullptr); + ~virtualkeyboard(); + bool shift; + void reverseKeys(); + +private slots: + void on_spaceBtn_clicked(); + void on_eraseBtn_clicked(); + void on_spt_clicked(); + void on_n1_clicked(); + void on_n2_clicked(); + void on_n3_clicked(); + void on_n4_clicked(); + void on_n5_clicked(); + void on_n6_clicked(); + void on_n7_clicked(); + void on_n8_clicked(); + void on_n9_clicked(); + void on_n0_clicked(); + void on_lq_clicked(); + void on_lw_clicked(); + void on_le_clicked(); + void on_lr_clicked(); + void on_lt_clicked(); + void on_ly_clicked(); + void on_lu_clicked(); + void on_li_clicked(); + void on_lo_clicked(); + void on_lp_clicked(); + void on_la_clicked(); + void on_ls_clicked(); + void on_ld_clicked(); + void on_lf_clicked(); + void on_lg_clicked(); + void on_lh_clicked(); + void on_lj_clicked(); + void on_lk_clicked(); + void on_ll_clicked(); + void on_sat_clicked(); + void on_lz_clicked(); + void on_lx_clicked(); + void on_lc_clicked(); + void on_lv_clicked(); + void on_lb_clicked(); + void on_ln_clicked(); + void on_lm_clicked(); + void on_shiftBtn_clicked(); + void adjust_size_function(); + +private: + Ui::virtualkeyboard *ui; + +signals: + void adjust_size(); +}; + +#endif // VIRTUALKEYBOARD_H diff --git a/virtualkeyboard.ui b/virtualkeyboard.ui new file mode 100644 index 0000000..e64bb5d --- /dev/null +++ b/virtualkeyboard.ui @@ -0,0 +1,388 @@ + + + virtualkeyboard + + + + 0 + 0 + 999 + 283 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + 0 + + + + + + + + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + l + + + + + + + . + + + + + + + f + + + + + + + + + + + + + + i + + + + + + + c + + + + + + + m + + + + + + + + + + + + + + y + + + + + + + 0 + + + + + + + 1 + + + + + + + e + + + + + + + o + + + + + + + x + + + + + + + 3 + + + + + + + 7 + + + + + + + u + + + + + + + a + + + + + + + @ + + + + + + + 9 + + + + + + + g + + + + + + + w + + + + + + + t + + + + + + + q + + + + + + + s + + + + + + + 6 + + + + + + + 5 + + + + + + + v + + + + + + + p + + + + + + + 2 + + + + + + + b + + + + + + + h + + + + + + + j + + + + + + + k + + + + + + + n + + + + + + + r + + + + + + + 4 + + + + + + + d + + + + + + + 8 + + + + + + + z + + + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Space + + + + + + + + + + diff --git a/virtualkeypad.h b/virtualkeypad.h index d06da65..0a5d58f 100644 --- a/virtualkeypad.h +++ b/virtualkeypad.h @@ -2,6 +2,7 @@ #define VIRTUALKEYPAD_H #include +#include "functions.h" namespace Ui { class virtualkeypad;