summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2005-08-10 08:14:56 (UTC)
committer llornkcor <llornkcor>2005-08-10 08:14:56 (UTC)
commitae7eb0bd76bd93cee70f258f3c4aef1accee766c (patch) (side-by-side diff)
tree08fa3a0118b258b51b8107608e9632bb51de763c
parentcfc9ff35215081a33adde29872553513d08f58bb (diff)
downloadopie-ae7eb0bd76bd93cee70f258f3c4aef1accee766c.zip
opie-ae7eb0bd76bd93cee70f258f3c4aef1accee766c.tar.gz
opie-ae7eb0bd76bd93cee70f258f3c4aef1accee766c.tar.bz2
add close session button
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp10
-rw-r--r--core/apps/embeddedkonsole/konsole.h1
2 files changed, 9 insertions, 2 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp
index 7f3ea65..f4ca0bf 100644
--- a/core/apps/embeddedkonsole/konsole.cpp
+++ b/core/apps/embeddedkonsole/konsole.cpp
@@ -529,195 +529,198 @@ void Konsole::init(const char* _pgm, QStrList & _args)
tmp=cfg.readEntry("Position","Top");
if(tmp=="Top")
{
tab->setTabPosition(QTabWidget::Top);
tab->getTabBar()->show();
tabPos = tm_top;
}
else if (tmp=="Bottom")
{
tab->setTabPosition(QTabWidget::Bottom);
tab->getTabBar()->show();
tabPos = tm_bottom;
}
else
{
tab->getTabBar()->hide();
tab->setMargin(tab->margin());
tabPos = tm_hidden;
}
cm_bw = colorMenu->insertItem(tr( "Black on White"));
cm_wb = colorMenu->insertItem(tr( "White on Black"));
cm_gb = colorMenu->insertItem(tr( "Green on Black"));
// cm_bt = colorMenu->insertItem(tr( "Black on Transparent"));
cm_br = colorMenu->insertItem(tr( "Black on Pink"));
cm_rb = colorMenu->insertItem(tr( "Pink on Black"));
cm_gy = colorMenu->insertItem(tr( "Green on Yellow"));
cm_bm = colorMenu->insertItem(tr( "Blue on Magenta"));
cm_mb = colorMenu->insertItem(tr( "Magenta on Blue"));
cm_cw = colorMenu->insertItem(tr( "Cyan on White"));
cm_wc = colorMenu->insertItem(tr( "White on Cyan"));
cm_bb = colorMenu->insertItem(tr( "Blue on Black"));
cm_ab = colorMenu->insertItem(tr( "Amber on Black"));
cm_default = colorMenu->insertItem(tr("default"));
#ifdef QT_QWS_OPIE
colorMenu->insertItem(tr( "Custom"));
#endif
configMenu->insertItem(tr( "Colors") ,colorMenu);
sessionList = new QPopupMenu(this);
sessionList-> insertItem ( Opie::Core::OResource::loadPixmap( "konsole/Terminal", Opie::Core::OResource::SmallIcon ),
tr( "new session" ), this, SLOT(newSession()) );
// 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( colorMenuIsSelected(int) ));
connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) ));
connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int)));
connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int)));
connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) );
menuBar->insertItem( tr("View"), configMenu );
menuBar->insertItem( tr("Fonts"), fontList );
menuBar->insertItem( tr("Sessions"), sessionList );
toolBar = new QToolBar( this );
QAction *a;
// Button Commands
a = new QAction( tr("New"), Opie::Core::OResource::loadPixmap( "konsole/konsole", Opie::Core::OResource::SmallIcon ),
QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) );
a->addTo( toolBar );
a = new QAction( tr("Full Screen"), Opie::Core::OResource::loadPixmap( "fullscreen", Opie::Core::OResource::SmallIcon ),
QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) );
a->addTo( toolBar );
a = new QAction( tr("Zoom"), Opie::Core::OResource::loadPixmap( "zoom", Opie::Core::OResource::SmallIcon ),
QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) );
a->addTo( toolBar );
a = new QAction( tr("Enter"), Opie::Core::OResource::loadPixmap( "konsole/enter", Opie::Core::OResource::SmallIcon ),
QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar );
a = new QAction( tr("Space"), Opie::Core::OResource::loadPixmap( "konsole/space", Opie::Core::OResource::SmallIcon ),
QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar );
a = new QAction( tr("Tab"), Opie::Core::OResource::loadPixmap( "konsole/tab", Opie::Core::OResource::SmallIcon ),
QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar );
a = new QAction( tr("Up"), Opie::Core::OResource::loadPixmap( "konsole/up", Opie::Core::OResource::SmallIcon ),
QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar );
a = new QAction( tr("Down"), Opie::Core::OResource::loadPixmap( "konsole/down", Opie::Core::OResource::SmallIcon ),
QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar );
- a = new QAction( tr("Paste"), Opie::Core::OResource::loadPixmap( "paste", Opie::Core::OResource::SmallIcon ),
- QString::null, 0, this, 0 );
+ a = new QAction( tr("Paste"), Opie::Core::OResource::loadPixmap( "paste", Opie::Core::OResource::SmallIcon ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) );
+
+ a = new QAction( tr("Close"), Opie::Core::OResource::loadPixmap( "close", Opie::Core::OResource::SmallIcon ),QString::null, 0, this, 0 );
+ connect( a, SIGNAL( activated() ), this, SLOT( closeSession() ) );
+
a->addTo( toolBar );
secondToolBar = new QToolBar( this );
secondToolBar->setHorizontalStretchable( TRUE );
commonCombo = new QComboBox( secondToolBar );
// commonCombo->setMaximumWidth(236);
ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) );
if( listHidden)
{
secondToolBar->hide();
editCommandListMenu->setItemEnabled(ec_quick ,FALSE);
}
ec_edit = editCommandListMenu->insertItem(tr( "Edit..." ) );
cfg.setGroup("Commands");
commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
initCommandList();
// 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) ));
sm_none = scrollMenu->insertItem(tr( "None" ));
sm_left = scrollMenu->insertItem(tr( "Left" ));
sm_right = scrollMenu->insertItem(tr( "Right" ));
// scrollMenu->insertSeparator(4);
// scrollMenu->insertItem(tr( "Horizontal" ));
configMenu->insertItem(tr( "ScrollBar" ),scrollMenu);
configMenu->insertItem(tr( "History..." ), this, SLOT(historyDialog()));
cm_wrap = configMenu->insertItem(tr( "Wrap" ));
cfg.setGroup("ScrollBar");
configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0));
cm_beep = configMenu->insertItem(tr( "Use Beep" ));
cfg.setGroup("Menubar");
configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0));
fullscreen_msg = new QLabel(this);
fullscreen_msg-> setAlignment ( AlignCenter | SingleLine );
fullscreen_msg-> hide();
fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding ));
fullscreen_msg-> setAutoResize(true);
fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
fullscreen_msg-> setText(tr("To exit fullscreen, tap here."));
fullscreen_timer = new QTimer(this);
connect(fullscreen_timer, SIGNAL(timeout()),
this, SLOT(fullscreenTimeout()));
show_fullscreen_msg = true;
//scrollMenuSelected(-29);
// cfg.setGroup("ScrollBar");
// if(cfg.readBoolEntry("HorzScroll",0)) {
// if(cfg.readNumEntry("Position",2) == 0)
// te->setScrollbarLocation(1);
// else
// te->setScrollbarLocation(0);
// te->setScrollbarLocation( cfg.readNumEntry("Position",2));
// te->setWrapAt(120);
// }
// create applications /////////////////////////////////////////////////////
setCentralWidget(tab);
// load keymaps ////////////////////////////////////////////////////////////
KeyTrans::loadAll();
for (int i = 0; i < KeyTrans::count(); i++)
{
KeyTrans* s = KeyTrans::find(i);
assert( s );
}
se_pgm = _pgm;
se_args = _args;
cfg.setGroup("CommandLine");
if (cfg.hasKey("shell_args"))
{
QStringList se_args_list = cfg.readListEntry("shell_args",'|');
for(uint i = 0; i < se_args_list.count(); i++)
{
se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1());
}
}
else
{
@@ -1823,96 +1826,99 @@ void Konsole::setDocument( const QString &cmd)
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( "Konsole" );
cfg.setGroup("Colors");
int r, g, b;
color.rgb(&r,&g,&b);
foreground.setRgb(r,g,b);
cfg.writeEntry("foreground",color.name());
odebug << "foreground "+color.name() << oendl;
cfg.write();
odebug << "do other dialog" << oendl;
#ifdef QT_QWS_OPIE
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)
{
odebug << "Change background" << oendl;
Config cfg( "Konsole" );
cfg.setGroup("Colors");
int r, g, b;
color.rgb(&r,&g,&b);
background.setRgb(r,g,b);
cfg.writeEntry("background",color.name());
odebug << "background "+color.name() << oendl;
cfg.write();
}
void Konsole::doWrap()
{
Config cfg( "Konsole" );
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);
}
}
+void Konsole::closeSession() {
+ doneSession(getTe(), 0);
+}
diff --git a/core/apps/embeddedkonsole/konsole.h b/core/apps/embeddedkonsole/konsole.h
index e163cb8..40f5284 100644
--- a/core/apps/embeddedkonsole/konsole.h
+++ b/core/apps/embeddedkonsole/konsole.h
@@ -8,192 +8,193 @@
/* */
/* 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> */
/* */
/* -------------------------------------------------------------------------- */
#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 <qtoolbar.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:
static QString appName()
{
return QString::fromLatin1("embeddedkonsole");
}
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);
QToolBar *secondToolBar;
void show();
void setColor(int);
int lastSelectedMenu;
int startUp;
public slots:
void changeFontSize(int);
void toggleFullScreen();
void setFullScreen(bool);
void changeSession(int);
void cycleZoom();
void newSession();
private slots:
void setDocument(const QString &);
void doneSession(TEWidget*,int);
void changeTitle(TEWidget*, const QString&);
void changeColumns(int);
void setFont(int);
// void fontChanged(int);
void configMenuSelected(int );
void colorMenuSelected(int);
void colorMenuIsSelected(int);
void tabMenuSelected(int);
void sessionListSelected(int);
void enterCommand(int);
void hitEnter();
void hitSpace();
void hitTab();
void hitPaste();
void hitUp();
void hitDown();
void switchSession(QWidget *);
void changeCommand(const QString &, int);
void initCommandList();
void scrollMenuSelected(int);
void editCommandListMenuSelected(int);
void parseCommandLine();
void changeForegroundColor(const QColor &);
void changeBackgroundColor(const QColor &);
void historyDialog();
void fullscreenTimeout();
+ void closeSession();
private:
void doWrap();
void init(const char* _pgm, QStrList & _args);
void initSession(const char* _pgm, QStrList & _args);
void runSession(TESession* s);
void setColorPixmaps();
void setHistory(bool);
void setColors(QColor foreground, QColor background);
int findFont(const QString& name, int size, bool exact = false);
QSize calcSize(int columns, int lines);
TEWidget* getTe();
QStringList commands;
QLabel * msgLabel;
QColor foreground, background;
bool fromMenu;
bool fullscreen;
private:
class VTFont
{
public:
VTFont(const QString& name, QFont& font, const QString& family, int familyNum, int size)
{
this->name = name;
this->font = font;
this->family = family;
this->size = size;
this->familyNum = familyNum;
}
QFont& getFont()
{
return font;
}
QString getName()
{
return name;
}
int getSize()
{
return(size);
}
QString getFamily()
{
return(family);
}
int getFamilyNum()
{
return(familyNum);
}
private:
QFont font;
QString name;
QString family;
int familyNum;
int size;
};
EKNumTabWidget* tab;
int tabPos;
int nsessions;
QList<VTFont> fonts;
int cfont;
QCString se_pgm;
QStrList se_args;
QToolBar *menuToolBar;
QToolBar *toolBar;
QComboBox *commonCombo;
QPopupMenu *fontList,*configMenu,*colorMenu,*scrollMenu,*editCommandListMenu;
QPopupMenu *sessionList, *tabMenu;
int sm_none, sm_left, sm_right;
int cm_beep, cm_wrap;
int cm_default;
int cm_bw, cm_wb, cm_gb, cm_bt, cm_br, cm_rb, cm_gy, cm_bm, cm_mb, cm_cw, cm_wc, cm_bb, cm_ab;
int tm_top, tm_bottom, tm_hidden;
int ec_edit, ec_cmdlist, ec_quick;
bool show_fullscreen_msg;
QTimer *fullscreen_timer;
QLabel *fullscreen_msg;
// history scrolling I think
bool b_scroll;
int n_keytab;
int n_scroll;
int n_render;
QString pmPath; // pixmap path
QString dropText;