author | llornkcor <llornkcor> | 2002-02-01 14:11:46 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-02-01 14:11:46 (UTC) |
commit | 07ec85f797cad04431df30855a81b88f06fe27d3 (patch) (side-by-side diff) | |
tree | 72b6e4a2f63f47df4214df486333313128011840 /core/apps | |
parent | 2802e5a2b474101a50bf95e707061ca5542876fd (diff) | |
download | opie-07ec85f797cad04431df30855a81b88f06fe27d3.zip opie-07ec85f797cad04431df30855a81b88f06fe27d3.tar.gz opie-07ec85f797cad04431df30855a81b88f06fe27d3.tar.bz2 |
Added editable commandlist, tabs position, and user selectable colors.
-rw-r--r-- | core/apps/embeddedkonsole/TECommon.h | 0 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/TEWidget.cpp | 12 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/TEWidget.h | 2 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 322 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/konsole.h | 14 |
5 files changed, 305 insertions, 45 deletions
diff --git a/core/apps/embeddedkonsole/TECommon.h b/core/apps/embeddedkonsole/TECommon.h index 261d51b..5db41ad 100644 --- a/core/apps/embeddedkonsole/TECommon.h +++ b/core/apps/embeddedkonsole/TECommon.h diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp index dc83998..f10bfb2 100644 --- a/core/apps/embeddedkonsole/TEWidget.cpp +++ b/core/apps/embeddedkonsole/TEWidget.cpp @@ -17,3 +17,2 @@ /* -------------------------------------------------------------------------- */ - /*! \class TEWidget @@ -117,3 +116,3 @@ static const ColorEntry base_color_table[TABLE_COLORS] = ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ), - ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0xFF), 0, 0 ), + ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 ) @@ -139,2 +138,8 @@ const ColorEntry* TEWidget::getColorTable() const +const ColorEntry* TEWidget::getdefaultColorTable() const +{ + return base_color_table; +} + + const QPixmap *TEWidget::backgroundPixmap() @@ -256,4 +261,3 @@ void TEWidget::setVTFont(const QFont& f) -QFont TEWidget::getVTFont() -{ +QFont TEWidget::getVTFont() { return font(); diff --git a/core/apps/embeddedkonsole/TEWidget.h b/core/apps/embeddedkonsole/TEWidget.h index 3f9f4ae..40e1aea 100644 --- a/core/apps/embeddedkonsole/TEWidget.h +++ b/core/apps/embeddedkonsole/TEWidget.h @@ -17,3 +17,2 @@ /* -------------------------------------------------------------------------- */ - #ifndef TE_WIDGET_H @@ -54,2 +53,3 @@ public: const ColorEntry* getColorTable() const; + const ColorEntry* getdefaultColorTable() const; void setColorTable(const ColorEntry table[]); diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index 7253baf..1102ef3 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp @@ -43,2 +43,4 @@ #include <qpe/config.h> +#include <qstringlist.h> +#include <qpalette.h> @@ -101,35 +103,30 @@ static const char *commonCmds[] = { - "ls ", - //"ls -la ", + "ls ", // I left this here, cause it looks better than the first alpha + "cardctl eject", + "cat ", "cd ", - "pwd", - //"cat", - //"less ", - //"vi ", - //"man ", + "chmod ", + "cp ", + "dc ", + "df ", + "dmesg", "echo ", - "set ", - //"ps", - "ps aux", - //"tar", - //"tar -zxf", + "find ", + "free", "grep ", - //"grep -i", - //"mkdir", - "cp ", + "ifconfig ", + "ipkg ", + "mkdir ", "mv ", + "nc localhost 7776", + "nc localhost 7777", + "nslookup ", + "ping ", + "ps aux", + "pwd ", "rm ", "rmdir ", - //"chmod", - //"su", -// "top", - //"find", - //"make", - //"tail", - "cardctl eject", - "ifconfig ", -// "iwconfig eth0 ", - "nc localhost 7777", - "nc localhost 7776", - //"mount /dev/hda1", + "route ", + "set ", + "traceroute", @@ -188,3 +185,3 @@ void Konsole::init(const char* _pgm, QStrList & _args) cfg.setGroup("Konsole"); - + QString tmp; // initialize the list of allowed fonts /////////////////////////////////// @@ -205,4 +202,5 @@ void Konsole::init(const char* _pgm, QStrList & _args) nsessions = 0; + tab = new EKNumTabWidget(this); - tab->setTabPosition(QTabWidget::Bottom); + connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); @@ -223,5 +221,46 @@ void Konsole::init(const char* _pgm, QStrList & _args) + configMenu = new QPopupMenu( this); + colorMenu = new QPopupMenu( this); + + bool listHidden; + cfg.setGroup("Menubar"); + if( cfg.readEntry("Hidden","FALSE") == "TRUE") { + configMenu->insertItem("Show command list"); + listHidden=TRUE; + } else { + configMenu->insertItem("Hide command list"); + listHidden=FALSE; + } + + cfg.setGroup("Tabs"); + tmp=cfg.readEntry("Position","Bottom"); + if(tmp=="Top") { + tab->setTabPosition(QTabWidget::Top); + configMenu->insertItem("Tabs on Bottom"); + } else { + tab->setTabPosition(QTabWidget::Bottom); + configMenu->insertItem("Tabs on Top"); + } + configMenu->insertSeparator(2); + + colorMenu->insertItem("Green on Black"); + colorMenu->insertItem("Black on White"); + colorMenu->insertItem("White on Black"); + colorMenu->insertItem("Black on Transparent"); + colorMenu->insertItem("Black on Red"); + colorMenu->insertItem("Red on Black"); + colorMenu->insertItem("Green on Yellow"); + colorMenu->insertItem("Blue on Magenta"); + colorMenu->insertItem("Magenta on Blue"); + colorMenu->insertItem("Cyan on White"); + colorMenu->insertItem("White on Cyan"); + colorMenu->insertItem("Blue on Black"); + configMenu->insertItem("Colors",colorMenu); + connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); + connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); + connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuSelected(int) )); menuBar->insertItem( tr("Font"), fontList ); + menuBar->insertItem( tr("Options"), configMenu ); @@ -253,9 +292,21 @@ void Konsole::init(const char* _pgm, QStrList & _args) - QPEToolBar *secondToolBar = new QPEToolBar( this ); + secondToolBar = new QPEToolBar( this ); secondToolBar->setHorizontalStretchable( TRUE ); - QComboBox *commonCombo = new QComboBox( secondToolBar ); -// commonCombo->setEditable( TRUE ); - for (int i = 0; commonCmds[i] != NULL; i++) + commonCombo = new QComboBox( secondToolBar ); + + if( listHidden) + secondToolBar->hide(); + configMenu->insertItem( "Edit Command List"); + + cfg.setGroup("Commands"); + commonCombo->setInsertionPolicy(QComboBox::AtCurrent); + + for (int i = 0; commonCmds[i] != NULL; i++) { commonCombo->insertItem( commonCmds[i], i ); + tmp = cfg.readEntry( QString::number(i),""); + if(tmp != "") + commonCombo->changeItem( tmp,i ); + } + connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); @@ -280,2 +331,3 @@ void Konsole::init(const char* _pgm, QStrList & _args) defaultSize = size(); + } @@ -323,2 +375,3 @@ void Konsole::fontChanged(int f) + void Konsole::enterCommand(int c) @@ -327,4 +380,8 @@ void Konsole::enterCommand(int c) if (te != 0) { - QString text = commonCmds[c]; + if(!commonCombo->editable()) { + QString text = commonCombo->text(c); //commonCmds[c]; te->emitText(text); + } else { + changeCommand( commonCombo->text(c), c); + } } @@ -475,6 +532,6 @@ void Konsole::doneSession(TESession*, int ) - void Konsole::newSession() { + if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory? TEWidget* te = new TEWidget(tab); - te->setBackgroundMode(PaletteBase); +// te->setBackgroundMode(PaletteBase); //we want transparent!! te->setVTFont(fonts.at(cfont)->getFont()); @@ -489,2 +546,4 @@ void Konsole::newSession() { nsessions++; + setColor(); + } } @@ -512 +571,192 @@ void Konsole::switchSession(QWidget* w) { } + +/// ------------------------------- some new stuff by L.J. Potter +void Konsole::colorMenuSelected(int iD) +{ // this is NOT pretty, elegant or anything else besides functional +// QString temp; +// temp.sprintf("%d", iD); +// qDebug(temp); + TEWidget* te = getTe(); + Config cfg("Konsole"); + cfg.setGroup("Colors"); + QColor foreground; + QColor background; + colorMenu->setItemChecked(lastSelectedMenu,FALSE); + ColorEntry m_table[TABLE_COLORS]; + const ColorEntry * defaultCt=te->getdefaultColorTable(); + /////////// fore back + int i; + if(iD==-8) { // default default + for (i = 0; i < TABLE_COLORS; i++) { + m_table[i].color = defaultCt[i].color; + if(i==1 || i == 11) + m_table[i].transparent=1; + cfg.writeEntry("Schema","8"); + colorMenu->setItemChecked(-8,TRUE); + } + } else { + if(iD==-5) { // green black + foreground.setRgb(0x18,255,0x18); + background.setRgb(0x00,0x00,0x00); + cfg.writeEntry("Schema","5"); + colorMenu->setItemChecked(-5,TRUE); + } + if(iD==-6) { // black white + foreground.setRgb(0x00,0x00,0x00); + background.setRgb(0xFF,0xFF,0xFF); + cfg.writeEntry("Schema","6"); + colorMenu->setItemChecked(-6,TRUE); + } + if(iD==-7) { // white black + foreground.setRgb(0xFF,0xFF,0xFF); + background.setRgb(0x00,0x00,0x00); + cfg.writeEntry("Schema","7"); + colorMenu->setItemChecked(-7,TRUE); + } + if(iD==-9) {// Black, Red + foreground.setRgb(0x00,0x00,0x00); + background.setRgb(0xB2,0x18,0x18); + cfg.writeEntry("Schema","9"); + colorMenu->setItemChecked(-9,TRUE); + } + if(iD==-10) {// Red, Black + foreground.setRgb(230,31,31); //0xB2,0x18,0x18 + background.setRgb(0x00,0x00,0x00); + cfg.writeEntry("Schema","10"); + colorMenu->setItemChecked(-10,TRUE); + } + if(iD==-11) {// Green, Yellow - is ugly +// foreground.setRgb(0x18,0xB2,0x18); + foreground.setRgb(36,139,10); +// background.setRgb(0xB2,0x68,0x18); + background.setRgb(255,255,0); + cfg.writeEntry("Schema","11"); + colorMenu->setItemChecked(-11,TRUE); + } + if(iD==-12) {// Blue, Magenta + foreground.setRgb(0x18,0xB2,0xB2); + background.setRgb(0x18,0x18,0xB2); + cfg.writeEntry("Schema","12"); + colorMenu->setItemChecked(-12,TRUE); + } + if(iD==-13) {// Magenta, Blue + foreground.setRgb(0x18,0x18,0xB2); + background.setRgb(0x18,0xB2,0xB2); + cfg.writeEntry("Schema","13"); + colorMenu->setItemChecked(-13,TRUE); + } + if(iD==-14) {// Cyan, White + foreground.setRgb(0x18,0xB2,0xB2); + background.setRgb(0xFF,0xFF,0xFF); + cfg.writeEntry("Schema","14"); + colorMenu->setItemChecked(-14,TRUE); + } + if(iD==-15) {// White, Cyan + background.setRgb(0x18,0xB2,0xB2); + foreground.setRgb(0xFF,0xFF,0xFF); + cfg.writeEntry("Schema","15"); + colorMenu->setItemChecked(-15,TRUE); + } + if(iD==-16) {// Black, Blue + background.setRgb(0x00,0x00,0x00); + foreground.setRgb(0x18,0xB2,0xB2); + cfg.writeEntry("Schema","16"); + colorMenu->setItemChecked(-16,TRUE); + } + + 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; + } + } + lastSelectedMenu = iD; + te->setColorTable(m_table); +// update(); +} + +void Konsole::configMenuSelected(int iD) +{ +// QString temp; +// temp.sprintf("%d",iD); +// qDebug(temp); + TEWidget* te = getTe(); + Config cfg("Konsole"); + cfg.setGroup("Menubar"); + if( iD == -2) { + if(!secondToolBar->isHidden()) { + secondToolBar->hide(); + configMenu->changeItem( iD,"Show Command List"); + cfg.writeEntry("Hidden","TRUE"); + configMenu->setItemEnabled(-20 ,FALSE); + } else { + secondToolBar->show(); + configMenu->changeItem( iD,"Hide Command List"); + cfg.writeEntry("Hidden","FALSE"); + configMenu->setItemEnabled(-20 ,TRUE); + + if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") { + configMenu->setItemChecked(-16,TRUE); + commonCombo->setEditable( TRUE ); + } else { + configMenu->setItemChecked(-20,FALSE); + commonCombo->setEditable( FALSE ); + } + } + } + if( iD == -3) { + cfg.setGroup("Tabs"); + QString tmp=cfg.readEntry("Position","Top"); + + if(tmp=="Top") { + tab->setTabPosition(QTabWidget::Bottom); + configMenu->changeItem( iD,"Tabs on Top"); + cfg.writeEntry("Position","Bottom"); + } else { + tab->setTabPosition(QTabWidget::Top); + configMenu->changeItem( iD,"Tabs on Bottom"); + cfg.writeEntry("Position","Top"); + } + } + if( iD == -20) { + 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(); + } + } +} + +void Konsole::changeCommand(const QString &text, int c) +{ + Config cfg("Konsole"); + cfg.setGroup("Commands"); + if(commonCmds[c] != text) { + cfg.writeEntry(QString::number(c),text); + commonCombo->clearEdit(); + commonCombo->setCurrentItem(c); + } +} + +void Konsole::setColor() +{ + Config cfg("Konsole"); + cfg.setGroup("Colors"); + int scheme = cfg.readNumEntry("Schema",1); + if(scheme != 1) colorMenuSelected( -scheme); + +} diff --git a/core/apps/embeddedkonsole/konsole.h b/core/apps/embeddedkonsole/konsole.h index 819ea5d..40003d4 100644 --- a/core/apps/embeddedkonsole/konsole.h +++ b/core/apps/embeddedkonsole/konsole.h @@ -32,2 +32,4 @@ #include <qtabwidget.h> +#include <qpe/qpetoolbar.h> +#include <qcombobox.h> @@ -50,5 +52,6 @@ public: void setColLin(int columns, int lines); - + QPEToolBar *secondToolBar; void show(); - + void setColor(); + int lastSelectedMenu; private slots: @@ -57,2 +60,4 @@ private slots: void fontChanged(int); + void configMenuSelected(int ); + void colorMenuSelected(int); void enterCommand(int); @@ -66,2 +71,3 @@ private slots: void newSession(); + void changeCommand(const QString &, int); @@ -108,4 +114,4 @@ private: - QPopupMenu* fontList; - + QPopupMenu* fontList,*configMenu,*colorMenu; + QComboBox *commonCombo; // history scrolling I think |