diff options
author | Ken Moore <moorekou@gmail.com> | 2016-02-02 08:41:10 -0500 |
---|---|---|
committer | Ken Moore <moorekou@gmail.com> | 2016-02-02 08:41:10 -0500 |
commit | 1914eb08cf2cc9f9ed135ada27cf9c6751fa7354 (patch) | |
tree | 1d960752a5061055da2510b72c2c498e7b55b924 | |
parent | Merge branch 'master' of github.com:pcbsd/lumina (diff) | |
download | lumina-1914eb08cf2cc9f9ed135ada27cf9c6751fa7354.tar.gz lumina-1914eb08cf2cc9f9ed135ada27cf9c6751fa7354.tar.bz2 lumina-1914eb08cf2cc9f9ed135ada27cf9c6751fa7354.zip |
Add a few more built-in Qt paths to the OS-detect file, and commit a bit more work on the lumina-terminal app.
-rw-r--r-- | OS-detect.pri | 9 | ||||
-rw-r--r-- | desktop-utilities/lumina-terminal/TerminalWidget.cpp | 92 | ||||
-rw-r--r-- | desktop-utilities/lumina-terminal/TerminalWidget.h | 10 | ||||
-rw-r--r-- | desktop-utilities/lumina-terminal/lumina-terminal.pro | 2 | ||||
-rw-r--r-- | desktop-utilities/lumina-terminal/main.cpp | 5 |
5 files changed, 82 insertions, 36 deletions
diff --git a/OS-detect.pri b/OS-detect.pri index 1422130c..4b126148 100644 --- a/OS-detect.pri +++ b/OS-detect.pri @@ -19,9 +19,10 @@ !defined(OS){ message("Build OS Info: $${QMAKE_HOST.os}, $${QMAKE_HOST.arch}, $${QMAKE_HOST.version_string}") - #Load the initial library search locations (more can be added in the OS-specific sections below) - LIBS = -L$${PWD}/libLumina -L$$[QT_INSTALL_LIBS] - + #Load the initial library/includefile search locations (more can be added in the OS-specific sections below) + LIBS = -L$${PRO_FILE_PWD}/libLumina -L$$[QT_INSTALL_LIBS] + INCLUDEPATH = $${PRO_FILE_PWD}/libLumina $$[QT_INSTALL_HEADERS] $$[QT_INSTALL_PREFIX] + #Setup the default values for build settings (if not explicitly set previously) !defined(PREFIX){ PREFIX=/usr/local } !defined(LIBPREFIX){ LIBPREFIX=$${PREFIX}/lib } @@ -79,7 +80,7 @@ # Setup the dirs needed to find/load libraries QMAKE_LIBDIR = $$[QT_INSTALL_LIBS] $$LIBPREFIX/qt5 $$LIBPREFIX - INCLUDEPATH = $${PWD}/libLumina $$PREFIX/include + INCLUDEPATH +=$${PREFIX}/include # If the detailed install variables are not set - create them from the general vars !defined(L_BINDIR){ L_BINDIR = $${PREFIX}/bin } diff --git a/desktop-utilities/lumina-terminal/TerminalWidget.cpp b/desktop-utilities/lumina-terminal/TerminalWidget.cpp index 4cfd3849..589d3fa3 100644 --- a/desktop-utilities/lumina-terminal/TerminalWidget.cpp +++ b/desktop-utilities/lumina-terminal/TerminalWidget.cpp @@ -13,18 +13,43 @@ TerminalWidget::TerminalWidget(QWidget *parent, QString dir) : QTextEdit(parent){ //Setup the text widget this->setLineWrapMode(QTextEdit::WidgetWidth); - this->setReadOnly(true); //the key event catch will do the process/widget forwarding - this->setPlainText("WARNING: This utility is still incomplete and does not function properly yet"); - //Create/launch the process + //this->setReadOnly(true); //the key event catch will do the process/widget forwarding + //this->setPlainText("WARNING: This utility is still incomplete and does not function properly yet"); + + //Create/open the serial port + /*PROC = new QSerialPort(this); + QList<QSerialPortInfo> openports = QSerialPortInfo::availablePorts(); + //Now print out all the information + if(openports.isEmpty()){ this->setEnabled(false);} + else{ + //Go through the open ports until we find one that can be used + for(int i=0; i<openports.length(); i++){ + qDebug() << "Port:" << openports[i].description(); + qDebug() << "Name:" << openports[i].portName(); + qDebug() << "Serial Number:" << openports[i].serialNumber(); + qDebug() << "System Location:" << openports[i].systemLocation(); + PROC->setPort(openports[i]); + if(PROC->open(QIODevice::ReadWrite) ){ break; } + } + } + this->setEnabled(PROC->isOpen()); + //Connect the signals/slots + connect(PROC, SIGNAL(readyRead()), this, SLOT(UpdateText()) ); + connect(PROC, SIGNAL(aboutToClose()), this, SLOT(ShellClosed()) ); + */ + + //Create/launch the process PROC = new QProcess(this); + PROC->setProcessChannelMode(QProcess::MergedChannels); PROC->setProcessEnvironment(QProcessEnvironment::systemEnvironment()); + PROC->setProgram( PROC->processEnvironment().value("SHELL","/bin/sh") ); PROC->setWorkingDirectory(dir); - PROC->setProcessChannelMode(QProcess::MergedChannels); //Connect the signals/slots connect(PROC, SIGNAL(readyReadStandardOutput()), this, SLOT(UpdateText()) ); - connect(PROC, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(ShellClosed()) ); + connect(PROC, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(ShellClosed()) ); //Now start the shell - PROC->start( PROC->processEnvironment().value("SHELL","/bin/sh"), QIODevice::ReadWrite); + //PROC->start("login" , QStringList() << "-f" << getlogin(), QIODevice::ReadWrite); + PROC->start(QIODevice::ReadWrite); } @@ -33,19 +58,21 @@ TerminalWidget::~TerminalWidget(){ } void TerminalWidget::aboutToClose(){ - if(PROC->state()!=QProcess::NotRunning){ PROC->close(); } + //if(PROC->isOpen()){ PROC->close(); } if(PROC->state()!=QProcess::NotRunning){ PROC->kill(); } - if(PROC->state()!=QProcess::NotRunning){ PROC->terminate(); } } // ================== // PRIVATE SLOTS // ================== void TerminalWidget::UpdateText(){ - while(PROC->canReadLine()){ - QString line = PROC->readLine(); - this->insertPlainText( line ); - } + //read the data from the process + //QByteArray data = PROC->readAll(); + qDebug() << "Process Data Available"; + QByteArray data = PROC->readAllStandardOutput(); + this->insertPlainText(QString(data)); + //adjust the scrollbar as needed + } void TerminalWidget::ShellClosed(){ @@ -56,28 +83,35 @@ void TerminalWidget::ShellClosed(){ // PROTECTED // ================== void TerminalWidget::keyPressEvent(QKeyEvent *ev){ - //The way this works is by printing the keys directly to the text edit widget - // While also keeping an internal "buffer" of the input string so it can all be written to the process at the same time - - QString key = ev->text(); //Check for special key combinations first + QString txt = ev->text(); switch(ev->key()){ - case Qt::Key_Enter: - case Qt::Key_Return: - //send the current input buffer to the process - qDebug() << "Write to process:" << inBuffer; - this->insertPlainText("\n"); - PROC->write( QString(inBuffer+"\n").toLocal8Bit() ); - inBuffer.clear(); - qDebug() << "Current Dir:" << PROC->workingDirectory(); - break; case Qt::Key_Backspace: - inBuffer.chop(1); + case Qt::Key_Left: + case Qt::Key_Right: + case Qt::Key_Up: + case Qt::Key_Down: break; + case Qt::Key_Return: + case Qt::Key_Enter: + txt = "\r"; default: - this->insertPlainText(key); - inBuffer.append(key); + //All other events can get echoed onto the widget (non-movement) + QTextEdit::keyPressEvent(ev); //echo the input on the widget } + qDebug() << "Forward Input:" << txt << ev->key(); + PROC->write(txt.toLocal8Bit()); +} + +void TerminalWidget::mousePressEvent(QMouseEvent *ev){ + this->setFocus(); + Q_UNUSED(ev); +} + +void TerminalWidget::mouseDoubleClickEvent(QMouseEvent *ev){ + Q_UNUSED(ev); +} - ev->ignore(); +void TerminalWidget::contextMenuEvent(QContextMenuEvent *ev){ + Q_UNUSED(ev); }
\ No newline at end of file diff --git a/desktop-utilities/lumina-terminal/TerminalWidget.h b/desktop-utilities/lumina-terminal/TerminalWidget.h index b16d298d..d4bdec09 100644 --- a/desktop-utilities/lumina-terminal/TerminalWidget.h +++ b/desktop-utilities/lumina-terminal/TerminalWidget.h @@ -10,6 +10,8 @@ #include <QTextEdit> #include <QProcess> #include <QKeyEvent> +#include <QSerialPort> +#include <QSerialPortInfo> class TerminalWidget : public QTextEdit{ Q_OBJECT @@ -20,8 +22,9 @@ public: void aboutToClose(); private: + //QSerialPort *PROC; QProcess *PROC; - QString inBuffer; + private slots: void UpdateText(); void ShellClosed(); @@ -30,7 +33,10 @@ signals: void ProcessClosed(QString); protected: - void keyPressEvent(QKeyEvent *event); + void keyPressEvent(QKeyEvent *ev); + void mousePressEvent(QMouseEvent *ev); + void mouseDoubleClickEvent(QMouseEvent *ev); + void contextMenuEvent(QContextMenuEvent *ev); }; #endif
\ No newline at end of file diff --git a/desktop-utilities/lumina-terminal/lumina-terminal.pro b/desktop-utilities/lumina-terminal/lumina-terminal.pro index 82a5f8a4..3656b553 100644 --- a/desktop-utilities/lumina-terminal/lumina-terminal.pro +++ b/desktop-utilities/lumina-terminal/lumina-terminal.pro @@ -1,6 +1,6 @@ TEMPLATE = app LANGUAGE = C++ -QT += core gui widgets network +QT += core gui widgets network serialport CONFIG += qt warn_on release isEmpty(PREFIX) { diff --git a/desktop-utilities/lumina-terminal/main.cpp b/desktop-utilities/lumina-terminal/main.cpp index c117b8fb..48da4556 100644 --- a/desktop-utilities/lumina-terminal/main.cpp +++ b/desktop-utilities/lumina-terminal/main.cpp @@ -6,6 +6,7 @@ //=========================================== #include <QSystemTrayIcon> #include <QDebug> +#include <QSerialPortInfo> #include <LuminaSingleApplication.h> #include <LuminaThemes.h> @@ -14,6 +15,10 @@ #include "TrayIcon.h" int main(int argc, char *argv[]) { + if(QSerialPortInfo::availablePorts().isEmpty()){ + qDebug() << "No Serial Ports available!!!"; + return 1; + } LTHEME::LoadCustomEnvSettings(); LSingleApplication a(argc, argv, "lumina-terminal"); if( !a.isPrimaryProcess() ){ return 0; } //poked the current process instead |