summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rwxr-xr-xcore/apps/embeddedkonsole/embeddedkonsole.pro28
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp68
-rw-r--r--core/apps/embeddedkonsole/konsole.h8
3 files changed, 85 insertions, 19 deletions
diff --git a/core/apps/embeddedkonsole/embeddedkonsole.pro b/core/apps/embeddedkonsole/embeddedkonsole.pro
index de0cfa1..6b7af27 100755
--- a/core/apps/embeddedkonsole/embeddedkonsole.pro
+++ b/core/apps/embeddedkonsole/embeddedkonsole.pro
@@ -10,41 +10,41 @@ HEADERS = TEWidget.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
INTERFACES = commandeditdialogbase.ui smallcommandeditdialogbase.ui
TARGET = embeddedkonsole
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
-LIBS += -lqpe
+LIBS += -lqpe -lopie
REQUIRES = embeddedkonsole
TRANSLATIONS = ../../../i18n/de/embeddedkonsole.ts \
- ../../../i18n/en/embeddedkonsole.ts \
- ../../../i18n/es/embeddedkonsole.ts \
- ../../../i18n/fr/embeddedkonsole.ts \
- ../../../i18n/hu/embeddedkonsole.ts \
- ../../../i18n/ja/embeddedkonsole.ts \
- ../../../i18n/ko/embeddedkonsole.ts \
- ../../../i18n/no/embeddedkonsole.ts \
- ../../../i18n/pl/embeddedkonsole.ts \
- ../../../i18n/pt/embeddedkonsole.ts \
- ../../../i18n/pt_BR/embeddedkonsole.ts \
- ../../../i18n/sl/embeddedkonsole.ts \
- ../../../i18n/zh_CN/embeddedkonsole.ts \
- ../../../i18n/zh_TW/embeddedkonsole.ts
+ ../../../i18n/en/embeddedkonsole.ts \
+ ../../../i18n/es/embeddedkonsole.ts \
+ ../../../i18n/fr/embeddedkonsole.ts \
+ ../../../i18n/hu/embeddedkonsole.ts \
+ ../../../i18n/ja/embeddedkonsole.ts \
+ ../../../i18n/ko/embeddedkonsole.ts \
+ ../../../i18n/no/embeddedkonsole.ts \
+ ../../../i18n/pl/embeddedkonsole.ts \
+ ../../../i18n/pt/embeddedkonsole.ts \
+ ../../../i18n/pt_BR/embeddedkonsole.ts \
+ ../../../i18n/sl/embeddedkonsole.ts \
+ ../../../i18n/zh_CN/embeddedkonsole.ts \
+ ../../../i18n/zh_TW/embeddedkonsole.ts
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp
index b0d28fc..8b1e066 100644
--- a/core/apps/embeddedkonsole/konsole.cpp
+++ b/core/apps/embeddedkonsole/konsole.cpp
@@ -33,48 +33,50 @@
#include <qglobal.h>
#include <qpainter.h>
#include <qpe/qpemenubar.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 <sys/wait.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "konsole.h"
#include "keytrans.h"
#include "commandeditdialog.h"
+#include <opie/colorpopupmenu.h>
+
class EKNumTabBar : public QTabBar {
public:
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();
}
}
}
@@ -185,48 +187,50 @@ void Konsole::initCommandList()
// qDebug("Konsole::initCommandList");
Config cfg("Konsole");
cfg.setGroup("Commands");
commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
commonCombo->clear();
if (cfg.readEntry("Commands Set","FALSE") == "FALSE") {
for (int i = 0; commonCmds[i] != NULL; i++) {
commonCombo->insertItem(commonCmds[i],i);
}
} else {
for (int i = 0; i < 100; i++) {
if (!(cfg.readEntry( QString::number(i),"")).isEmpty())
commonCombo->insertItem((cfg.readEntry( QString::number(i),"")));
}
}
}
void Konsole::init(const char* _pgm, QStrList & _args)
{
b_scroll = TRUE; // histon;
n_keytab = 0;
n_render = 0;
startUp=0;
+ fromMenu = FALSE;
+
setCaption( tr("Terminal") );
setIcon( Resource::loadPixmap( "konsole" ) );
Config cfg("Konsole");
cfg.setGroup("Konsole");
QString tmp;
// initialize the list of allowed fonts ///////////////////////////////////
cfont = cfg.readNumEntry("FontID", 1);
QFont f = QFont("Micro", 4, QFont::Normal);
f.setFixedPitch(TRUE);
fonts.append(new VTFont(tr("Micro"), f));
f = QFont("Fixed", 7, QFont::Normal);
f.setFixedPitch(TRUE);
fonts.append(new VTFont(tr("Small Fixed"), f));
f = QFont("Fixed", 12, QFont::Normal);
f.setFixedPitch(TRUE);
fonts.append(new VTFont(tr("Medium Fixed"), f));
// create terminal emulation framework ////////////////////////////////////
nsessions = 0;
tab = new EKNumTabWidget(this);
@@ -267,53 +271,54 @@ void Konsole::init(const char* _pgm, QStrList & _args)
cfg.setGroup("Tabs");
tmp=cfg.readEntry("Position","Bottom");
if(tmp=="Top") {
tab->setTabPosition(QTabWidget::Top);
configMenu->insertItem( tr( "Tabs on Bottom" ) );
} else {
tab->setTabPosition(QTabWidget::Bottom);
configMenu->insertItem("Tabs on Top");
}
configMenu->insertSeparator(2);
colorMenu->insertItem(tr( "Green on Black"));
colorMenu->insertItem(tr( "Black on White"));
colorMenu->insertItem(tr( "White on Black"));
colorMenu->insertItem(tr( "Black on Transparent"));
colorMenu->insertItem(tr( "Black on Red"));
colorMenu->insertItem(tr( "Red on Black"));
colorMenu->insertItem(tr( "Green on Yellow"));
colorMenu->insertItem(tr( "Blue on Magenta"));
colorMenu->insertItem(tr( "Magenta on Blue"));
colorMenu->insertItem(tr( "Cyan on White"));
colorMenu->insertItem(tr( "White on Cyan"));
colorMenu->insertItem(tr( "Blue on Black"));
colorMenu->insertItem(tr( "Amber on Black"));
+ colorMenu->insertItem(tr( "Custom"));
configMenu->insertItem(tr( "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) ));
+ connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) ));
connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int)));
connect(editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int)));
menuBar->insertItem( tr("Font"), fontList );
menuBar->insertItem( tr("Options"), configMenu );
QPEToolBar *toolbar = new QPEToolBar( this );
QAction *a;
// Button Commands
a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar );
a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar );
a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar );
a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar );
a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar );
a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar );
a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar );
@@ -593,69 +598,74 @@ void Konsole::newSession() {
}
TEWidget* Konsole::getTe() {
if (nsessions) {
return (TEWidget *) tab->currentPage();
} else {
return 0;
}
}
void Konsole::switchSession(QWidget* w) {
TEWidget* te = (TEWidget *) w;
QFont teFnt = te->getVTFont();
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;
}
}
}
+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("Konsole");
cfg.setGroup("Colors");
- QColor foreground;
- QColor background;
+// QColor foreground;
+// QColor background;
colorMenu->setItemChecked(lastSelectedMenu,FALSE);
ColorEntry m_table[TABLE_COLORS];
const ColorEntry * defaultCt=te->getdefaultColorTable();
/////////// fore back
int i;
if(iD==-9) { // 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","98");
+ cfg.writeEntry("Schema","9");
colorMenu->setItemChecked(-9,TRUE);
}
} else {
if(iD==-6) { // green black
foreground.setRgb(0x18,255,0x18);
background.setRgb(0x00,0x00,0x00);
cfg.writeEntry("Schema","6");
colorMenu->setItemChecked(-6,TRUE);
}
if(iD==-7) { // black white
foreground.setRgb(0x00,0x00,0x00);
background.setRgb(0xFF,0xFF,0xFF);
cfg.writeEntry("Schema","7");
colorMenu->setItemChecked(-7,TRUE);
}
if(iD==-8) { // white black
foreground.setRgb(0xFF,0xFF,0xFF);
background.setRgb(0x00,0x00,0x00);
cfg.writeEntry("Schema","8");
colorMenu->setItemChecked(-8,TRUE);
}
if(iD==-10) {// Black, Red
foreground.setRgb(0x00,0x00,0x00);
background.setRgb(0xB2,0x18,0x18);
@@ -691,63 +701,80 @@ void Konsole::colorMenuSelected(int iD)
if(iD==-15) {// Cyan, White
foreground.setRgb(0x18,0xB2,0xB2);
background.setRgb(0xFF,0xFF,0xFF);
cfg.writeEntry("Schema","15");
colorMenu->setItemChecked(-15,TRUE);
}
if(iD==-16) {// White, Cyan
background.setRgb(0x18,0xB2,0xB2);
foreground.setRgb(0xFF,0xFF,0xFF);
cfg.writeEntry("Schema","16");
colorMenu->setItemChecked(-16,TRUE);
}
if(iD==-17) {// Black, Blue
background.setRgb(0x00,0x00,0x00);
foreground.setRgb(0x18,0xB2,0xB2);
cfg.writeEntry("Schema","17");
colorMenu->setItemChecked(-17,TRUE);
}
if(iD==-18) {// Black, Gold
background.setRgb(0x00,0x00,0x00);
foreground.setRgb(255,215,0);
cfg.writeEntry("Schema","18");
colorMenu->setItemChecked(-18,TRUE);
}
+ if(iD==-19) {// Custom
+ qDebug("do custom");
+ if(fromMenu) {
+ ColorPopupMenu* penColorPopupMenu = new ColorPopupMenu(Qt::black, this, "foreground color");
+ connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this,
+ SLOT(changeForegroundColor(const QColor&)));
+ penColorPopupMenu->exec();
+ }
+ cfg.writeEntry("Schema","19");
+ if(!fromMenu) {
+ foreground.setNamedColor(cfg.readEntry("foreground",""));
+ background.setNamedColor(cfg.readEntry("background",""));
+ }
+ fromMenu=FALSE;
+ colorMenu->setItemChecked(-19,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;
// qDebug( temp.sprintf("configmenu %d",iD));
TEWidget* te = getTe();
Config cfg("Konsole");
cfg.setGroup("Menubar");
if( iD == -4) {
cfg.setGroup("Tabs");
QString tmp=cfg.readEntry("Position","Bottom");
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");
}
}
}
@@ -864,24 +891,57 @@ void Konsole::setDocument( const QString &cmd) {
} else {
if (te != 0) {
te->emitText(cmd+"\r");
}
}
startUp++;
}
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("Konsole");
+ cfg.setGroup("Colors");
+ int r, g, b;
+ color.rgb(&r,&g,&b);
+ foreground.setRgb(r,g,b);
+// QString colors;
+// colors.sprintf("%d,%d,%d"color.red,color.green,color.blue);
+ cfg.writeEntry("foreground",color.name());
+ cfg.write();
+
+qDebug("do other dialog");
+ ColorPopupMenu* penColorPopupMenu2 = new ColorPopupMenu(Qt::black, this,"background color");
+ connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this,
+ SLOT(changeBackgroundColor(const QColor&)));
+ penColorPopupMenu2->exec();
+
+}
+
+void Konsole::changeBackgroundColor(const QColor &color) {
+
+ qDebug("Change background");
+ Config cfg("Konsole");
+ cfg.setGroup("Colors");
+ int r, g, b;
+ color.rgb(&r,&g,&b);
+ background.setRgb(r,g,b);
+// QString colors;
+// colors.sprintf("%d,%d,%d"color.red,color.green,color.blue);
+ cfg.writeEntry("background",color.name());
+ cfg.write();
+}
diff --git a/core/apps/embeddedkonsole/konsole.h b/core/apps/embeddedkonsole/konsole.h
index 40edaec..0bf3fb3 100644
--- a/core/apps/embeddedkonsole/konsole.h
+++ b/core/apps/embeddedkonsole/konsole.h
@@ -11,102 +11,108 @@
/* 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> */
/* */
/* -------------------------------------------------------------------------- */
#ifndef KONSOLE_H
#define KONSOLE_H
#include <qmainwindow.h>
#include <qaction.h>
#include <qpopupmenu.h>
#include <qstrlist.h>
#include <qintdict.h>
#include <qptrdict.h>
#include <qtabwidget.h>
#include <qpe/qpetoolbar.h>
#include <qcombobox.h>
+#include <qcolor.h>
#include "MyPty.h"
#include "TEWidget.h"
#include "TEmuVt102.h"
#include "session.h"
class EKNumTabWidget;
class Konsole : public QMainWindow
{
Q_OBJECT
public:
Konsole(QWidget* parent = 0, const char* name = 0, WFlags fl = 0);
Konsole(const char * name, const char* pgm, QStrList & _args, int histon);
~Konsole();
void setColLin(int columns, int lines);
QPEToolBar *secondToolBar;
void show();
void setColor();
int lastSelectedMenu;
int startUp;
private slots:
void setDocument(const QString &);
void doneSession(TESession*,int);
void changeColumns(int);
void fontChanged(int);
void configMenuSelected(int );
void colorMenuSelected(int);
+ void colorMenuIsSelected(int);
void enterCommand(int);
void hitEnter();
void hitSpace();
void hitTab();
void hitPaste();
void hitUp();
void hitDown();
void switchSession(QWidget *);
void newSession();
void changeCommand(const QString &, int);
void initCommandList();
void scrollMenuSelected(int);
void editCommandListMenuSelected(int);
void parseCommandLine();
+ void changeForegroundColor(const QColor &);
+ void changeBackgroundColor(const QColor &);
private:
void init(const char* _pgm, QStrList & _args);
void initSession(const char* _pgm, QStrList & _args);
void runSession(TESession* s);
void setColorPixmaps();
void setHistory(bool);
QSize calcSize(int columns, int lines);
TEWidget* getTe();
QStringList commands;
-
+ QLabel * msgLabel;
+ QColor foreground, background;
+bool fromMenu;
private:
class VTFont
{
public:
VTFont(QString name, QFont& font)
{
this->name = name;
this->font = font;
}
QFont& getFont()
{
return font;
}
QString getName()
{
return name;
}
private:
QString name;
QFont font;
};