-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index cbea7bd..ff5c2f1 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp @@ -1,148 +1,148 @@ /* ---------------------------------------------------------------------- */ /* */ /* [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> // enhancements added by Phillip Kuhn #include <stdlib.h> #include <sys/types.h> #include <pwd.h> #include <unistd.h> #ifdef QT_QWS_OPIE #include <opie2/ocolorpopupmenu.h> +using namespace Opie; #endif #include <qpe/resource.h> #include <qmenubar.h> #include <qtabbar.h> #include <qpe/config.h> #include <qfontdatabase.h> #include <qfile.h> #include <qspinbox.h> #include <qlayout.h> #include <sys/wait.h> #include <stdio.h> #include <stdlib.h> #include <assert.h> #include "konsole.h" #include "commandeditdialog.h" -using namespace Opie; 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 ", @@ -420,194 +420,194 @@ void Konsole::init(const char* _pgm, QStrList & _args) { 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]; } 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(); } int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex); sizeMenu->setItemParameter(id, fontIndex); sizeMenu->connectItem(id, this, SLOT(setFont(int))); QString name = s + " " + QString::number(size); fonts.append(new VTFont(name, f, familyNames[j], familyNum, size)); if (familyNames[j] == cfgFontName && size == cfgFontSize) { cfont = fontIndex; } printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size); fontIndex++; } } if (sizeMenu) { fontList->insertItem(s, sizeMenu, familyNum + 1000); familyNum++; } } } if (cfont < 0 || cfont >= (int)fonts.count()) { cfont = 0; } // create terminal emulation framework //////////////////////////////////// nsessions = 0; tab = new EKNumTabWidget(this); // tab->setMargin(tab->margin()-5); connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); // create terminal toolbar //////////////////////////////////////////////// setToolBarsMovable( FALSE ); menuToolBar = new QToolBar( this ); menuToolBar->setHorizontalStretchable( TRUE ); QMenuBar *menuBar = new QMenuBar( menuToolBar ); setFont(cfont); configMenu = new QPopupMenu( this); - colorMenu = new QPopupMenu( this); - scrollMenu = new QPopupMenu( this); + colorMenu = new QPopupMenu( this); + scrollMenu = new QPopupMenu( this); editCommandListMenu = new QPopupMenu( this); configMenu->insertItem(tr("Command List"), editCommandListMenu); bool listHidden; cfg.setGroup("Menubar"); if( cfg.readEntry("Hidden","FALSE") == "TRUE") { ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" )); listHidden=TRUE; } else { ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" )); listHidden=FALSE; } cfg.setGroup("Tabs"); tabMenu = new QPopupMenu(this); tm_bottom = tabMenu->insertItem(tr("Bottom" )); tm_top = tabMenu->insertItem(tr("Top")); tm_hidden = tabMenu->insertItem(tr("Hidden")); configMenu->insertItem(tr("Tabs"), tabMenu); 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 ( Resource::loadPixmap ( "konsole/Terminal" ), 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"), Resource::loadPixmap( "konsole/Terminal" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolBar ); a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) ); a->addTo( toolBar ); |