summaryrefslogtreecommitdiff
path: root/core/apps/embeddedkonsole/konsole.cpp
Side-by-side diff
Diffstat (limited to 'core/apps/embeddedkonsole/konsole.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp68
1 files changed, 64 insertions, 4 deletions
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
@@ -45,24 +45,26 @@
#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 ) {
@@ -197,24 +199,26 @@ void Konsole::initCommandList()
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));
@@ -279,29 +283,30 @@ void Konsole::init(const char* _pgm, QStrList & _args)
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 );
@@ -605,45 +610,50 @@ void Konsole::switchSession(QWidget* 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);
@@ -703,39 +713,56 @@ void Konsole::colorMenuSelected(int iD)
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");
@@ -876,12 +903,45 @@ void Konsole::parseCommandLine() {
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();
+}