-rw-r--r-- | core/apps/embeddedkonsole/config.in | 2 | ||||
-rwxr-xr-x | core/apps/embeddedkonsole/embeddedkonsole.pro | 4 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 12 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/main.cpp | 12 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/opie-embeddedkonsole.control | 2 |
5 files changed, 11 insertions, 21 deletions
diff --git a/core/apps/embeddedkonsole/config.in b/core/apps/embeddedkonsole/config.in index 3a421d6..a3a1844 100644 --- a/core/apps/embeddedkonsole/config.in +++ b/core/apps/embeddedkonsole/config.in @@ -1,4 +1,4 @@ config EMBEDDEDKONSOLE boolean "opie-embeddedkonsole (konsole from KDE adapted for Qt/Embedded)" default "y" - depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBQTAUX diff --git a/core/apps/embeddedkonsole/embeddedkonsole.pro b/core/apps/embeddedkonsole/embeddedkonsole.pro index 427c013..2743488 100755 --- a/core/apps/embeddedkonsole/embeddedkonsole.pro +++ b/core/apps/embeddedkonsole/embeddedkonsole.pro @@ -1,38 +1,38 @@ QMAKE_CFLAGS = -DHAVE_OPENPTY TMAKE_FLAGS += -DHAVE_OPENPTY QMAKE_LIBS = -lutil CONFIG += qt warn_on release quick-app HEADERS = TEWidget.h \ TEScreen.h \ TECommon.h \ TEHistory.h \ TEmulation.h \ TEmuVt102.h \ session.h \ keytrans.h \ konsole.h \ commandeditdialog.h \ commandeditwidget.h \ playlistselection.h \ MyPty.h SOURCES = TEScreen.cpp \ TEWidget.cpp \ TEHistory.cpp \ TEmulation.cpp \ TEmuVt102.cpp \ session.cpp \ keytrans.cpp \ konsole.cpp \ commandeditdialog.cpp \ commandeditwidget.cpp \ playlistselection.cpp \ MyPty.cpp \ - main.cpp + main.cpp INTERFACES = commandeditdialogbase.ui smallcommandeditdialogbase.ui TARGET = embeddedkonsole INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include -LIBS += -lqpe -lopie +LIBS += -lqpe -lopiecore2 -lqtaux2 TMAKE_CXXFLAGS += -DQT_QWS_OPIE -DHAVE_OPENPTY include ( $(OPIEDIR)/include.pro ) diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index d10b66d..46c0203 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp @@ -1,453 +1,453 @@ /* ---------------------------------------------------------------------- */ /* */ /* [main.C] Konsole */ /* */ /* ---------------------------------------------------------------------- */ /* */ /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ /* */ /* This file is part of Konsole, an X terminal. */ /* */ /* The material contained in here more or less directly orginates from */ /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ /* */ /* ---------------------------------------------------------------------- */ /* */ /* Ported Konsole to Qt/Embedded */ /* */ /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ /* */ /* -------------------------------------------------------------------------- */ // enhancements added by L.J. Potter <ljp@llornkcor.com> //#define QT_QWS_OPIE #include <stdlib.h> +#ifdef QT_QWS_OPIE +#include <opie2/ocolorpopupmenu.h> +#endif + #include <qpe/resource.h> #include <qdir.h> #include <qevent.h> #include <qdragobject.h> #include <qobjectlist.h> #include <qtoolbutton.h> #include <qtoolbar.h> #include <qpushbutton.h> #include <qfontdialog.h> #include <qglobal.h> #include <qpainter.h> #include <qmenubar.h> #include <qmessagebox.h> #include <qaction.h> #include <qapplication.h> #include <qfontmetrics.h> #include <qcombobox.h> #include <qevent.h> #include <qtabwidget.h> #include <qtabbar.h> #include <qpe/config.h> #include <qstringlist.h> #include <qpalette.h> #include <qfontdatabase.h> #include <qfile.h> #include <qspinbox.h> #include <qlayout.h> #include <qvbox.h> #include <sys/wait.h> #include <stdio.h> #include <stdlib.h> #include <assert.h> #include "konsole.h" #include "keytrans.h" #include "commandeditdialog.h" -#ifdef QT_QWS_OPIE -#include <opie/colorpopupmenu.h> -#endif - class EKNumTabBar : public QTabBar { public: EKNumTabBar(QWidget *parent = 0, const char *name = 0) : QTabBar(parent, name) {} // QList<QTab> *getTabList() { return(tabList()); } void numberTabs() { // Yes, it really is this messy. QTabWidget needs functions // that provide acces to tabs in a sequential way. int m=INT_MIN; for (int i=0; i<count(); i++) { QTab* left=0; QListIterator<QTab> it(*tabList()); int x=INT_MAX; for( QTab* t; (t=it.current()); ++it ) { int tx = t->rect().x(); if ( tx<x && tx>m ) { x = tx; left = t; } } if ( left ) { left->setText(QString::number(i+1)); m = left->rect().x(); } } } virtual QSize sizeHint() const { if (isHidden()) { return(QSize(0,0)); } else { QSize size = QTabBar::sizeHint(); int shrink = 5; if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) { shrink = 10; } size.setHeight(size.height() - shrink); return(size); } } }; class EKNumTabWidget : public QTabWidget { public: EKNumTabWidget(QWidget* parent) : QTabWidget(parent) { setTabBar(new EKNumTabBar(parent,"EKTabBar")); setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); } EKNumTabBar *getTabBar() const { return ((EKNumTabBar*)tabBar()); } void addTab(QWidget* w) { QTab* t = new QTab(QString::number(tabBar()->count()+1)); QTabWidget::addTab(w,t); } void removeTab(QWidget* w) { removePage(w); ((EKNumTabBar*)tabBar())->numberTabs(); } }; // This could be configurable or dynamicly generated from the bash history // file of the user static const char *commonCmds[] = { "ls ", // I left this here, cause it looks better than the first alpha "cardctl eject", "cat ", "cd ", "chmod ", "clear", "cp ", "dc ", "df ", "dmesg", "echo ", "env", "find ", "free", "grep ", "ifconfig ", "ipkg ", "mkdir ", "mv ", "nc localhost 7776", "nc localhost 7777", "netstat ", "nslookup ", "ping ", "ps aux", "pwd ", "qcop QPE/System 'linkChanged(QString)' ''", "qcop QPE/System 'restart()'", "qcop QPE/System 'quit()'", "rm ", "rmdir ", "route ", "set ", "traceroute", /* "gzip", "gunzip", "chgrp", "chown", "date", "dd", "df", "dmesg", "fuser", "hostname", "kill", "killall", "ln", "ping", "mount", "more", "sort", "touch", "umount", "mknod", "netstat", */ "exit", NULL }; Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : QMainWindow(parent, name, fl) { QStrList args; init("/bin/bash",args); } Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) : QMainWindow(0, name) { init(_pgm,_args); } struct HistoryItem { HistoryItem(int c, const QString &l) { count = c; line = l; } int count; QString line; }; class HistoryList : public QList<HistoryItem> { virtual int compareItems( QCollection::Item item1, QCollection::Item item2) { int c1 = ((HistoryItem*)item1)->count; int c2 = ((HistoryItem*)item2)->count; if (c1 > c2) return(1); if (c1 < c2) return(-1); return(0); } }; void Konsole::initCommandList() { // qDebug("Konsole::initCommandList"); Config cfg("Qkonsole"); cfg.setGroup("Commands"); // commonCombo->setInsertionPolicy(QComboBox::AtCurrent); commonCombo->clear(); if (cfg.readEntry("ShellHistory","TRUE") == "TRUE") { QString histfilename = QString(getenv("HOME")) + "/.bash_history"; histfilename = cfg.readEntry("ShellHistoryPath",histfilename); QFile histfile(histfilename); // note: compiler barfed on: // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); if (histfile.open( IO_ReadOnly )) { QString line; uint i; HistoryList items; int lineno = 0; while(!histfile.atEnd()) { if (histfile.readLine(line, 200) < 0) { break; } line = line.left(line.length()-1); lineno++; for(i=0; i<items.count(); i++) { if (line == items.at(i)->line) { // weight recent commands & repeated commands more // by adding up the index of each command items.at(i)->count += lineno; break; } } if (i >= items.count()) { items.append(new HistoryItem(lineno, line)); } } items.sort(); int n = items.count(); if (n > 40) { n = 40; } for(int i=0; i<n; i++) { // should insert start of command, but keep whole thing if (items.at(items.count()-i-1)->line.length() < 30) { commonCombo->insertItem(items.at(items.count()-i-1)->line); } } histfile.close(); } } if (cfg.readEntry("Commands Set","FALSE") == "FALSE") { for (int i = 0; commonCmds[i] != NULL; i++) { commonCombo->insertItem(commonCmds[i]); } } else { for (int i = 0; i < 100; i++) { if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); } } } static void sig_handler(int x) { printf("got signal %d\n",x); } void Konsole::init(const char* _pgm, QStrList & _args) { #if 0 for(int i=1; i<=31; i++) { if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV && i != SIGINT && i != SIGILL && i != SIGTERM && i != SIGBUS) signal(i,sig_handler); } #endif signal(SIGSTOP, sig_handler); signal(SIGCONT, sig_handler); signal(SIGTSTP, sig_handler); b_scroll = TRUE; // histon; n_keytab = 0; n_render = 0; startUp=0; fromMenu = FALSE; fullscreen = false; setCaption( "Qkonsole" ); setIcon( Resource::loadPixmap( "qkonsole/qkonsole" ) ); Config cfg("Qkonsole"); cfg.setGroup("Font"); QString tmp; // initialize the list of allowed fonts /////////////////////////////////// QString cfgFontName = cfg.readEntry("FontName","Lcfont"); int cfgFontSize = cfg.readNumEntry("FontSize",18); cfont = -1; // this code causes repeated access to all the font files // which does slow down startup QFontDatabase fontDB; QStringList familyNames; familyNames = fontDB.families( FALSE ); QString s; int fontIndex = 0; int familyNum = 0; fontList = new QPopupMenu( this ); for(uint j = 0; j < (uint)familyNames.count(); j++) { s = familyNames[j]; if ( s.contains('-') ) { int i = s.find('-'); s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]"; } s[0] = s[0].upper(); QValueList<int> sizes = fontDB.pointSizes( familyNames[j] ); printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(), sizes.count()); if (sizes.count() > 0) { QPopupMenu *sizeMenu; QFont f; int last_width = -1; sizeMenu = NULL; for(uint i = 0; i < (uint)sizes.count() + 4; i++) { // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]); // need to divide by 10 on the Z, but not otherwise int size; if (i >= (uint)sizes.count()) { // try for expandable fonts size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1); } else { printf("sizes[%d] = %d\n", i, sizes[i]); size = sizes[i]; } #ifndef __i386__ // a hack, sizes on Z seem to be points*10 size /= 10; #endif f = QFont(familyNames[j], size); f.setFixedPitch(true); QFontMetrics fm(f); // don't trust f.fixedPitch() or f.exactMatch(), they lie!! if (fm.width("l") == fm.width("m") && (i < (uint)sizes.count() || fm.width("m") > last_width)) { if (i < (uint)sizes.count()) { last_width = fm.width("m"); } if (sizeMenu == NULL) { sizeMenu = new QPopupMenu(); } @@ -1146,773 +1146,773 @@ void Konsole::doneSession(TEWidget* te, int ) if (te != 0) { te->currentSession->setConnect(FALSE); tab->removeTab(te); delete te->currentSession; delete te; sessionList->removeItem(nsessions); nsessions--; } if (nsessions == 0) { close(); } } void Konsole::changeTitle(TEWidget* te, QString newTitle ) { if (te == getTe()) { setCaption(newTitle + " - QKonsole"); } } void Konsole::newSession() { if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory? TEWidget* te = new TEWidget(tab); Config cfg("Qkonsole"); cfg.setGroup("Menubar"); // FIXME use more defaults from config file te->useBeep=cfg.readBoolEntry("useBeep",0); // te->setBackgroundMode(PaletteBase); //we want transparent!! cfg.setGroup("Font"); QString sn = "Session" + QString::number(nsessions+1); printf("read font session %s\n", sn.latin1()); QString fontName = cfg.readEntry("FontName"+sn, cfg.readEntry("FontName", fonts.at(cfont)->getFamily())); int fontSize = cfg.readNumEntry("FontSize"+sn, cfg.readNumEntry("FontSize", fonts.at(cfont)->getSize())); cfont = findFont(fontName, fontSize, false); printf("lookup font %s size %d got %d\n", fontName.latin1(), fontSize, cfont); if (cfont < 0) cfont = 0; te->setVTFont(fonts.at(cfont)->getFont()); tab->addTab(te); TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); te->currentSession = se; connect( se, SIGNAL(done(TEWidget*,int)), this, SLOT(doneSession(TEWidget*,int)) ); connect( se, SIGNAL(changeTitle(TEWidget*,QString)), this, SLOT(changeTitle(TEWidget*,QString)) ); connect(te, SIGNAL(changeFontSize(int)), this, SLOT(changeFontSize(int))); connect(te, SIGNAL(changeSession(int)), this, SLOT(changeSession(int))); connect(te, SIGNAL(newSession()), this, SLOT(newSession())); connect(te, SIGNAL(toggleFullScreen()), this, SLOT(toggleFullScreen())); connect(te, SIGNAL(setFullScreen(bool)), this, SLOT(setFullScreen(bool))); se->run(); se->setConnect(TRUE); se->setHistory(b_scroll); nsessions++; sessionList->insertItem(QString::number(nsessions), nsessions); sessionListSelected(nsessions); doWrap(); setColor(nsessions-1); } } TEWidget* Konsole::getTe() { if (nsessions) { return (TEWidget *) tab->currentPage(); } else { return 0; } } void Konsole::sessionListSelected(int id) { if (id < 0) { return; } QString selected = sessionList->text(id); EKNumTabBar *tabBar = tab->getTabBar(); int n = 0; for(int i = 0; n < tabBar->count(); i++) { if (tabBar->tab(i)) { // printf("selected = %s tab %d = %s\n", selected.latin1(), // i, tabBar->tab(i)->text().latin1()); if (tabBar->tab(i)->text() == selected) { tab->setCurrentPage(i); break; } n++; } } } void Konsole::changeSession(int delta) { printf("delta session %d\n", delta); QTabBar *tabBar = tab->getTabBar(); int i = tabBar->tab(tabBar->currentTab())->text().toInt() - 1; i += delta; if (i < 0) i += tabBar->count(); if (i >= tabBar->count()) i -= tabBar->count(); QString selected = QString::number(i+1); int n = 0; for(int i = 0; n < tabBar->count(); i++) { if (tabBar->tab(i)) { printf("selected = %s tab %d = %s\n", selected.latin1(), i, tabBar->tab(i)->text().latin1()); if (tabBar->tab(i)->text() == selected) { tab->setCurrentPage(i); break; } n++; } } } void Konsole::switchSession(QWidget* w) { TEWidget* te = (TEWidget *) w; QFont teFnt = te->getVTFont(); int familyNum = -1; for(uint i = 0; i < fonts.count(); i++) { VTFont *fnt = fonts.at(i); bool cf = fnt->getFont() == teFnt; fontList->setItemChecked(i, cf); if (cf) { cfont = i; familyNum = fnt->getFamilyNum(); } } for(int i = 0; i < (int)fontList->count(); i++) { fontList->setItemChecked(i + 1000, i == familyNum); } if (! te->currentSession->Title().isEmpty() ) { setCaption(te->currentSession->Title() + " - QKonsole"); } else { setCaption( "Qkonsole" ); } // colorMenuSelected(te->color_menu_item); } void Konsole::toggleFullScreen() { setFullScreen(! fullscreen); } void Konsole::setFullScreen ( bool b ) { static QSize normalsize; static bool listHidden; if (b == fullscreen) { return; } fullscreen = b; if ( b ) { if ( !normalsize. isValid ( )) { normalsize = size ( ); } setFixedSize ( qApp-> desktop ( )-> size ( )); showNormal ( ); reparent ( 0, WStyle_Customize | WStyle_NoBorder, QPoint ( 0, 0 )); showFullScreen ( ); menuToolBar->hide(); toolBar->hide(); listHidden = secondToolBar->isHidden(); secondToolBar->hide(); // commonCombo->hide(); tab->getTabBar()->hide(); tab->setMargin(tab->margin()); if (show_fullscreen_msg) { fullscreen_msg-> move(tab->x() + tab->width()/2 - fullscreen_msg->width()/2, qApp->desktop()->height()/16 - fullscreen_msg->height()/2); fullscreen_msg->show(); fullscreen_timer->start(3000, true); show_fullscreen_msg = false; } } else { showNormal ( ); reparent ( 0, WStyle_Customize, QPoint ( 0, 0 )); resize ( normalsize ); showMaximized ( ); normalsize = QSize ( ); menuToolBar->show(); toolBar->show(); if(! listHidden) { secondToolBar->show(); } // commonCombo->show(); menuToolBar->show(); if (tabPos != tm_hidden) { tab->getTabBar()->show(); } } tab->setMargin(tab->margin()); // cause setup to run } void Konsole::fullscreenTimeout() { fullscreen_msg->hide(); } void Konsole::colorMenuIsSelected(int iD) { fromMenu = TRUE; colorMenuSelected(iD); } /// ------------------------------- some new stuff by L.J. Potter void Konsole::colorMenuSelected(int iD) { // this is NOT pretty, elegant or anything else besides functional // QString temp; // qDebug( temp.sprintf("colormenu %d", iD)); TEWidget* te = getTe(); Config cfg("Qkonsole"); cfg.setGroup("Colors"); ColorEntry m_table[TABLE_COLORS]; const ColorEntry * defaultCt=te->getdefaultColorTable(); int i; // te->color_menu_item = iD; colorMenu->setItemChecked(cm_ab,FALSE); colorMenu->setItemChecked(cm_bb,FALSE); colorMenu->setItemChecked(cm_wc,FALSE); colorMenu->setItemChecked(cm_cw,FALSE); colorMenu->setItemChecked(cm_mb,FALSE); colorMenu->setItemChecked(cm_bm,FALSE); colorMenu->setItemChecked(cm_gy,FALSE); colorMenu->setItemChecked(cm_rb,FALSE); colorMenu->setItemChecked(cm_br,FALSE); colorMenu->setItemChecked(cm_wb,FALSE); colorMenu->setItemChecked(cm_bw,FALSE); colorMenu->setItemChecked(cm_gb,FALSE); if(iD==cm_default) { // default default printf("default colors\n"); for (i = 0; i < TABLE_COLORS; i++) { m_table[i].color = defaultCt[i].color; if(i==1 || i == 11) m_table[i].transparent=1; colorMenu->setItemChecked(cm_default,TRUE); } te->setColorTable(m_table); } if(iD==cm_gb) { // green black foreground.setRgb(100,255,100); // (0x18,255,0x18); background.setRgb(0x00,0x00,0x00); colorMenu->setItemChecked(cm_gb,TRUE); } if(iD==cm_bw) { // black white foreground.setRgb(0x00,0x00,0x00); background.setRgb(0xFF,0xFF,0xFF); colorMenu->setItemChecked(cm_bw,TRUE); } if(iD==cm_wb) { // white black foreground.setRgb(0xFF,0xFF,0xFF); background.setRgb(0x00,0x00,0x00); colorMenu->setItemChecked(cm_wb,TRUE); } if(iD==cm_br) {// Black, Red foreground.setRgb(0x00,0x00,0x00); background.setRgb(255,85,85); //(0xB2,0x18,0x18); colorMenu->setItemChecked(cm_br,TRUE); } if(iD==cm_rb) {// Red, Black foreground.setRgb(255,85,85); background.setRgb(0x00,0x00,0x00); colorMenu->setItemChecked(cm_rb,TRUE); } if(iD==cm_gy) {// Green, Yellow - is ugly // foreground.setRgb(0x18,0xB2,0x18); foreground.setRgb(15,115,0); // background.setRgb(0xB2,0x68,0x18); background.setRgb(255,255,0); colorMenu->setItemChecked(cm_gy,TRUE); } if(iD==cm_bm) {// Blue, Magenta foreground.setRgb(3,24,132); background.setRgb(225,2,255); colorMenu->setItemChecked(cm_bm,TRUE); } if(iD==cm_mb) {// Magenta, Blue foreground.setRgb(225,2,255); background.setRgb(3,24,132); colorMenu->setItemChecked(cm_mb,TRUE); } if(iD==cm_cw) {// Cyan, White foreground.setRgb(8,91,129); background.setRgb(0xFF,0xFF,0xFF); colorMenu->setItemChecked(cm_cw,TRUE); } if(iD==cm_wc) {// White, Cyan background.setRgb(8,91,129); foreground.setRgb(0xFF,0xFF,0xFF); colorMenu->setItemChecked(cm_wc,TRUE); } if(iD==cm_bb) {// Black, Blue background.setRgb(0x00,0x00,0x00); foreground.setRgb(127,147,225); colorMenu->setItemChecked(cm_bb,TRUE); } if(iD==cm_ab) {// Black, Gold background.setRgb(0x00,0x00,0x00); foreground.setRgb(255,215,105); colorMenu->setItemChecked(cm_ab,TRUE); } #ifdef QT_QWS_OPIE if(iD==-19) { // Custom qDebug("do custom"); if(fromMenu) { - OColorPopupMenu* penColorPopupMenu = new OColorPopupMenu(Qt::black, this, "foreground color"); + Opie::OColorPopupMenu* penColorPopupMenu = new Opie::OColorPopupMenu(Qt::black, this, "foreground color"); connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeForegroundColor(const QColor&))); penColorPopupMenu->exec(); } if(!fromMenu) { foreground.setNamedColor(cfg.readEntry("foreground","")); background.setNamedColor(cfg.readEntry("background","")); } fromMenu=FALSE; colorMenu->setItemChecked(-19,TRUE); } #endif lastSelectedMenu = iD; setColors(foreground, background); QTabBar *tabBar = tab->getTabBar(); QString ss = QString("Session%1").arg(tabBar->currentTab()); // printf("current tab = %d\n", tabBar->currentTab()); if (tabBar->currentTab() == 0) { cfg.writeEntry("foregroundRed",QString::number(foreground.red())); cfg.writeEntry("foregroundGreen",QString::number(foreground.green())); cfg.writeEntry("foregroundBlue",QString::number(foreground.blue())); cfg.writeEntry("backgroundRed",QString::number(background.red())); cfg.writeEntry("backgroundGreen",QString::number(background.green())); cfg.writeEntry("backgroundBlue",QString::number(background.blue())); } cfg.writeEntry("foregroundRed"+ss,QString::number(foreground.red())); cfg.writeEntry("foregroundGreen"+ss,QString::number(foreground.green())); cfg.writeEntry("foregroundBlue"+ss,QString::number(foreground.blue())); cfg.writeEntry("backgroundRed"+ss,QString::number(background.red())); cfg.writeEntry("backgroundGreen"+ss,QString::number(background.green())); cfg.writeEntry("backgroundBlue"+ss,QString::number(background.blue())); update(); } void Konsole::setColors(QColor foreground, QColor background) { int i; ColorEntry m_table[TABLE_COLORS]; TEWidget* te = getTe(); const ColorEntry * defaultCt=te->getdefaultColorTable(); for (i = 0; i < TABLE_COLORS; i++) { if(i==0 || i == 10) { m_table[i].color = foreground; } else if(i==1 || i == 11) { m_table[i].color = background; m_table[i].transparent=0; } else m_table[i].color = defaultCt[i].color; } te->setColorTable(m_table); } void Konsole::tabMenuSelected(int id) { Config cfg("Qkonsole"); cfg.setGroup("Tabs"); tabMenu->setItemChecked(tabPos, false); if (id == tm_bottom) { printf("set bottom tab\n"); tab->getTabBar()->show(); tab->setTabPosition(QTabWidget::Bottom); tab->getTabBar()->show(); cfg.writeEntry("Position","Bottom"); } else if (id == tm_top) { printf("set top tab\n"); tab->getTabBar()->show(); tab->setTabPosition(QTabWidget::Bottom); tab->setTabPosition(QTabWidget::Top); tab->getTabBar()->show(); cfg.writeEntry("Position","Top"); } else if (id == tm_hidden) { tab->getTabBar()->hide(); tab->setMargin(tab->margin()); cfg.writeEntry("Position","Hidden"); } tabMenu->setItemChecked(id, true); tabPos = id; } void Konsole::configMenuSelected(int iD) { // QString temp; // qDebug( temp.sprintf("configmenu %d",iD)); TEWidget* te = getTe(); Config cfg("Qkonsole"); cfg.setGroup("Menubar"); if(iD == cm_wrap) { cfg.setGroup("ScrollBar"); bool b=cfg.readBoolEntry("HorzScroll",0); b=!b; cfg.writeEntry("HorzScroll", b ); cfg.write(); doWrap(); if(cfg.readNumEntry("Position",2) == 0) { te->setScrollbarLocation(1); } else { te->setScrollbarLocation(0); } te->setScrollbarLocation( cfg.readNumEntry("Position",2)); } if(iD == cm_beep) { cfg.setGroup("Menubar"); bool b=cfg.readBoolEntry("useBeep",0); b=!b; cfg.writeEntry("useBeep", b ); cfg.write(); configMenu->setItemChecked(cm_beep,b); te->useBeep=b; } } void Konsole::changeCommand(const QString &text, int c) { Config cfg("Qkonsole"); cfg.setGroup("Commands"); if(commonCmds[c] != text) { cfg.writeEntry(QString::number(c),text); commonCombo->clearEdit(); commonCombo->setCurrentItem(c); } } void Konsole::setColor(int sess) { Config cfg("Qkonsole"); cfg.setGroup("Colors"); QColor foreground, background; QString ss = QString("Session") + QString::number(sess); foreground.setRgb(cfg.readNumEntry("foregroundRed"+ss, cfg.readNumEntry("foregroundRed",0xff)), cfg.readNumEntry("foregroundGreen"+ss, cfg.readNumEntry("foregroundGreen",0xff)), cfg.readNumEntry("foregroundBlue"+ss, cfg.readNumEntry("foregroundBlue",0xff))); background.setRgb(cfg.readNumEntry("backgroundRed"+ss, cfg.readNumEntry("backgroundRed",0)), cfg.readNumEntry("backgroundGreen"+ss, cfg.readNumEntry("backgroundGreen",0)), cfg.readNumEntry("backgroundBlue"+ss, cfg.readNumEntry("backgroundBlue",0))); setColors(foreground, background); } void Konsole::scrollMenuSelected(int index) { // qDebug( "scrollbar menu %d",index); TEWidget* te = getTe(); Config cfg("Qkonsole"); cfg.setGroup("ScrollBar"); if(index == sm_none) { te->setScrollbarLocation(0); cfg.writeEntry("Position",0); } else if(index == sm_left) { te->setScrollbarLocation(1); cfg.writeEntry("Position",1); } else if(index == sm_right) { te->setScrollbarLocation(2); cfg.writeEntry("Position",2); } scrollMenu->setItemChecked(sm_none, index == sm_none); scrollMenu->setItemChecked(sm_left, index == sm_left); scrollMenu->setItemChecked(sm_right, index == sm_right); } // case -29: { // bool b=cfg.readBoolEntry("HorzScroll",0); // cfg.writeEntry("HorzScroll", !b ); // cfg.write(); // if(cfg.readNumEntry("Position",2) == 0) { // te->setScrollbarLocation(1); // te->setWrapAt(0); // } else { // te->setScrollbarLocation(0); // te->setWrapAt(120); // } // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); // } // break; void Konsole::editCommandListMenuSelected(int iD) { // QString temp; // qDebug( temp.sprintf("edit command list %d",iD)); // FIXME: more cleanup needed here TEWidget* te = getTe(); Config cfg("Qkonsole"); cfg.setGroup("Menubar"); if( iD == ec_cmdlist) { if(!secondToolBar->isHidden()) { secondToolBar->hide(); configMenu->changeItem( iD,tr( "Show Command List" )); cfg.writeEntry("Hidden","TRUE"); configMenu->setItemEnabled(ec_edit ,FALSE); configMenu->setItemEnabled(ec_quick ,FALSE); } else { secondToolBar->show(); configMenu->changeItem( iD,tr( "Hide Command List" )); cfg.writeEntry("Hidden","FALSE"); configMenu->setItemEnabled(ec_edit ,TRUE); configMenu->setItemEnabled(ec_quick ,TRUE); if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") { configMenu->setItemChecked(ec_edit,TRUE); commonCombo->setEditable( TRUE ); } else { configMenu->setItemChecked(ec_edit,FALSE); commonCombo->setEditable( FALSE ); } } } if( iD == ec_quick) { cfg.setGroup("Commands"); // qDebug("enableCommandEdit"); if( !configMenu->isItemChecked(iD) ) { commonCombo->setEditable( TRUE ); configMenu->setItemChecked(iD,TRUE); commonCombo->setCurrentItem(0); cfg.writeEntry("EditEnabled","TRUE"); } else { commonCombo->setEditable( FALSE ); configMenu->setItemChecked(iD,FALSE); cfg.writeEntry("EditEnabled","FALSE"); commonCombo->setFocusPolicy(QWidget::NoFocus); te->setFocus(); } } if(iD == ec_edit) { // "edit commands" CommandEditDialog *m = new CommandEditDialog(this); connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); m->showMaximized(); } } // $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V' void Konsole::setDocument( const QString &cmd) { newSession(); TEWidget* te = getTe(); if(cmd.find("-e", 0, TRUE) != -1) { QString cmd2; cmd2=cmd.right(cmd.length()-3)+" &"; system(cmd2.latin1()); if(startUp <= 1 && nsessions < 2) { doneSession(getTe(), 0); exit(0); } else doneSession(getTe(), 0); } else { if (te != 0) { te->emitText(cmd+"\r"); } } startUp++; } // what is the point of this when you can just // run commands by using the shell directly?? void Konsole::parseCommandLine() { QString cmd; // newSession(); for (int i=1;i< qApp->argc();i++) { if( QString(qApp->argv()[i]) == "-e") { i++; for ( int j=i;j< qApp->argc();j++) { cmd+=QString(qApp->argv()[j])+" "; } cmd.stripWhiteSpace(); system(cmd.latin1()); exit(0);//close(); } // end -e switch } startUp++; } void Konsole::changeForegroundColor(const QColor &color) { Config cfg("Qkonsole"); cfg.setGroup("Colors"); int r, g, b; color.rgb(&r,&g,&b); foreground.setRgb(r,g,b); cfg.writeEntry("foreground",color.name()); qDebug("foreground "+color.name()); cfg.write(); qDebug("do other dialog"); #ifdef QT_QWS_OPIE - OColorPopupMenu* penColorPopupMenu2 = new OColorPopupMenu(Qt::black, this,"background color"); + Opie::OColorPopupMenu* penColorPopupMenu2 = new Opie::OColorPopupMenu(Qt::black, this,"background color"); connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBackgroundColor(const QColor&))); penColorPopupMenu2->exec(); #endif } void Konsole::changeBackgroundColor(const QColor &color) { qDebug("Change background"); Config cfg("Qkonsole"); cfg.setGroup("Colors"); int r, g, b; color.rgb(&r,&g,&b); background.setRgb(r,g,b); cfg.writeEntry("background",color.name()); qDebug("background "+color.name()); cfg.write(); } void Konsole::doWrap() { Config cfg("Qkonsole"); cfg.setGroup("ScrollBar"); TEWidget* te = getTe(); if( !cfg.readBoolEntry("HorzScroll",0)) { te->setWrapAt(0); configMenu->setItemChecked( cm_wrap,TRUE); } else { // te->setWrapAt(90); te->setWrapAt(120); configMenu->setItemChecked( cm_wrap,FALSE); } } diff --git a/core/apps/embeddedkonsole/main.cpp b/core/apps/embeddedkonsole/main.cpp index a6a079c..fe30b7e 100644 --- a/core/apps/embeddedkonsole/main.cpp +++ b/core/apps/embeddedkonsole/main.cpp @@ -1,39 +1,29 @@ /* ---------------------------------------------------------------------- */ /* */ /* [main.C] Konsole */ /* */ /* ---------------------------------------------------------------------- */ /* */ /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ /* */ /* This file is part of Konsole, an X terminal. */ /* */ /* The material contained in here more or less directly orginates from */ /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ /* */ /* ---------------------------------------------------------------------- */ /* */ /* Ported Konsole to Qt/Embedded */ /* */ /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ /* */ /* -------------------------------------------------------------------------- */ #include "konsole.h" -#include <qpe/qpeapplication.h> -#include <opie/oapplicationfactory.h> - -#include <qfile.h> - -#include <unistd.h> -#include <stdio.h> -#include <stdlib.h> - -#include <pwd.h> -#include <sys/types.h> +#include <opie2/oapplicationfactory.h> /* --| main |------------------------------------------------------ */ OPIE_EXPORT_APP( OApplicationFactory<Konsole> ) diff --git a/core/apps/embeddedkonsole/opie-embeddedkonsole.control b/core/apps/embeddedkonsole/opie-embeddedkonsole.control index 5807cd1..a338e19 100644 --- a/core/apps/embeddedkonsole/opie-embeddedkonsole.control +++ b/core/apps/embeddedkonsole/opie-embeddedkonsole.control @@ -1,10 +1,10 @@ Package: opie-embeddedkonsole Files: plugins/application/libembeddedkonsole.so* bin/embeddedkonsole apps/Applications/embeddedkonsole.desktop pics/konsole Priority: optional Section: opie/applications Maintainer: L.J. Potter <lpotter@trolltech.com> Architecture: arm -Depends: task-opie-minimal, libopie1, opie-keytabs +Depends: task-opie-minimal, libopiecore2, libqtaux2, opie-keytabs Description: KDE's konsole (shell terminal) Ported to the Opie environment. Version: $QPE_VERSION$EXTRAVERSION |