aboutsummaryrefslogtreecommitdiff
path: root/desktop-utilities/lumina-terminal
diff options
context:
space:
mode:
authorKen Moore <moorekou@gmail.com>2016-03-09 14:30:36 -0500
committerKen Moore <moorekou@gmail.com>2016-03-09 14:30:36 -0500
commit10dfd1fc351c3d4965f5e76779ddd15c285ef79a (patch)
tree615262b5d14243aade371d92c75d42d28502803c /desktop-utilities/lumina-terminal
parentUpdate the window movement routine to use an alternate ICCCM WM request for f... (diff)
downloadlumina-10dfd1fc351c3d4965f5e76779ddd15c285ef79a.tar.gz
lumina-10dfd1fc351c3d4965f5e76779ddd15c285ef79a.tar.bz2
lumina-10dfd1fc351c3d4965f5e76779ddd15c285ef79a.zip
Get a bunch more of the lumina-terminal app written up. Still not quite done yet, but getting close.
Diffstat (limited to 'desktop-utilities/lumina-terminal')
-rw-r--r--desktop-utilities/lumina-terminal/TerminalWidget.cpp61
-rw-r--r--desktop-utilities/lumina-terminal/TerminalWidget.h12
-rw-r--r--desktop-utilities/lumina-terminal/lumina-terminal.pro8
-rw-r--r--desktop-utilities/lumina-terminal/main.cpp8
4 files changed, 45 insertions, 44 deletions
diff --git a/desktop-utilities/lumina-terminal/TerminalWidget.cpp b/desktop-utilities/lumina-terminal/TerminalWidget.cpp
index 589d3fa3..326f1703 100644
--- a/desktop-utilities/lumina-terminal/TerminalWidget.cpp
+++ b/desktop-utilities/lumina-terminal/TerminalWidget.cpp
@@ -16,30 +16,23 @@ TerminalWidget::TerminalWidget(QWidget *parent, QString dir) : QTextEdit(parent)
//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; }
- }
- }
+ //Create/open the TTY port
+ PROC = new TTYProcess(this);
+ qDebug() << "Open new TTY";
+ bool ok = PROC->start( QProcessEnvironment::systemEnvironment().value("SHELL","/bin/sh") );
+ qDebug() << " - opened:" << ok;
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);
+
+ upTimer = new QTimer(this);
+ upTimer->setInterval(1000);
+ connect(upTimer, SIGNAL(timeout()), this, SLOT(UpdateText()) );
+
+ //Create/launch the QProcess
+ /*PROC = new QProcess(this);
PROC->setProcessChannelMode(QProcess::MergedChannels);
PROC->setProcessEnvironment(QProcessEnvironment::systemEnvironment());
PROC->setProgram( PROC->processEnvironment().value("SHELL","/bin/sh") );
@@ -48,18 +41,18 @@ TerminalWidget::TerminalWidget(QWidget *parent, QString dir) : QTextEdit(parent)
connect(PROC, SIGNAL(readyReadStandardOutput()), this, SLOT(UpdateText()) );
connect(PROC, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(ShellClosed()) );
//Now start the shell
- //PROC->start("login" , QStringList() << "-f" << getlogin(), QIODevice::ReadWrite);
- PROC->start(QIODevice::ReadWrite);
+ PROC->start(QIODevice::ReadWrite);*/
+ upTimer->start();
}
TerminalWidget::~TerminalWidget(){
-
+ aboutToClose();
}
void TerminalWidget::aboutToClose(){
- //if(PROC->isOpen()){ PROC->close(); }
- if(PROC->state()!=QProcess::NotRunning){ PROC->kill(); }
+ if(PROC->isOpen()){ PROC->close(); } //TTY PORT
+ //if(PROC->state()!=QProcess::NotRunning){ PROC->close(); PROC->kill(); } //QProcess
}
// ==================
@@ -67,9 +60,11 @@ void TerminalWidget::aboutToClose(){
// ==================
void TerminalWidget::UpdateText(){
//read the data from the process
- //QByteArray data = PROC->readAll();
- qDebug() << "Process Data Available";
- QByteArray data = PROC->readAllStandardOutput();
+ if(!PROC->isOpen()){ return; }
+ QByteArray data = PROC->readAll(); //TTY PORT
+ //QByteArray data = PROC->readAllStandardOutput(); //QProcess
+ if(data.length()<=0){ return; }
+ qDebug() << "Process Data:" << data;
this->insertPlainText(QString(data));
//adjust the scrollbar as needed
@@ -85,22 +80,24 @@ void TerminalWidget::ShellClosed(){
void TerminalWidget::keyPressEvent(QKeyEvent *ev){
//Check for special key combinations first
QString txt = ev->text();
+ if(txt.isEmpty()){ return; } // modifier key - nothing to send yet
switch(ev->key()){
- case Qt::Key_Backspace:
+ //case Qt::Key_Backspace:
case Qt::Key_Left:
case Qt::Key_Right:
case Qt::Key_Up:
case Qt::Key_Down:
break;
- case Qt::Key_Return:
+ /*case Qt::Key_Return:
case Qt::Key_Enter:
- txt = "\r";
+ txt = "\r";*/
default:
//All other events can get echoed onto the widget (non-movement)
QTextEdit::keyPressEvent(ev); //echo the input on the widget
}
+ QByteArray ba; ba.append(txt); //avoid any byte conversions
qDebug() << "Forward Input:" << txt << ev->key();
- PROC->write(txt.toLocal8Bit());
+ PROC->write(ba);
}
void TerminalWidget::mousePressEvent(QMouseEvent *ev){
diff --git a/desktop-utilities/lumina-terminal/TerminalWidget.h b/desktop-utilities/lumina-terminal/TerminalWidget.h
index d4bdec09..6f13348e 100644
--- a/desktop-utilities/lumina-terminal/TerminalWidget.h
+++ b/desktop-utilities/lumina-terminal/TerminalWidget.h
@@ -8,10 +8,10 @@
#define _LUMINA_DESKTOP_UTILITIES_TERMINAL_PROCESS_WIDGET_H
#include <QTextEdit>
-#include <QProcess>
#include <QKeyEvent>
-#include <QSerialPort>
-#include <QSerialPortInfo>
+#include <QTimer>
+
+#include "TtyProcess.h"
class TerminalWidget : public QTextEdit{
Q_OBJECT
@@ -22,8 +22,10 @@ public:
void aboutToClose();
private:
- //QSerialPort *PROC;
- QProcess *PROC;
+ TTYProcess *PROC;
+ //QProcess *PROC;
+
+ QTimer *upTimer;
private slots:
void UpdateText();
diff --git a/desktop-utilities/lumina-terminal/lumina-terminal.pro b/desktop-utilities/lumina-terminal/lumina-terminal.pro
index 3656b553..9cc58199 100644
--- a/desktop-utilities/lumina-terminal/lumina-terminal.pro
+++ b/desktop-utilities/lumina-terminal/lumina-terminal.pro
@@ -15,16 +15,18 @@ isEmpty(LIBPREFIX) {
HEADERS += TrayIcon.h \
TermWindow.h \
- TerminalWidget.h
+ TerminalWidget.h \
+ TtyProcess.h
SOURCES += main.cpp \
TrayIcon.cpp \
TermWindow.cpp \
- TerminalWidget.cpp
+ TerminalWidget.cpp \
+ TtyProcess.cpp
INCLUDEPATH += ../../libLumina $$PREFIX/include
-LIBS += -L../../libLumina -L$$LIBPREFIX -lLuminaUtils
+LIBS += -L../../libLumina -L$$LIBPREFIX -lLuminaUtils -lc
isEmpty(QT5LIBDIR) {
QT5LIBDIR = $$PREFIX/lib/qt5
diff --git a/desktop-utilities/lumina-terminal/main.cpp b/desktop-utilities/lumina-terminal/main.cpp
index 48da4556..9197561f 100644
--- a/desktop-utilities/lumina-terminal/main.cpp
+++ b/desktop-utilities/lumina-terminal/main.cpp
@@ -15,16 +15,16 @@
#include "TrayIcon.h"
int main(int argc, char *argv[]) {
- if(QSerialPortInfo::availablePorts().isEmpty()){
+ /*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
//First make sure a system tray is available
- qDebug() << "Checking for system tray";
+ /*qDebug() << "Checking for system tray";
bool ready = false;
for(int i=0; i<60 && !ready; i++){
ready = QSystemTrayIcon::isSystemTrayAvailable();
@@ -36,7 +36,7 @@ int main(int argc, char *argv[]) {
if(!ready){
qDebug() << "Could not find any available system tray after 5 minutes: exiting....";
return 1;
- }
+ }*/
//Now go ahead and setup the app
LuminaThemeEngine theme(&a);
bgstack15