From 09c3eed0c594f4c93157faf5269ef4d975a310ca Mon Sep 17 00:00:00 2001 From: llornkcor Date: Sun, 03 Feb 2002 18:23:27 +0000 Subject: merged in Marks commandlist edit dialog --- diff --git a/core/apps/embeddedkonsole/commandeditdialog.cpp b/core/apps/embeddedkonsole/commandeditdialog.cpp new file mode 100644 index 0000000..e8ef858 --- a/dev/null +++ b/core/apps/embeddedkonsole/commandeditdialog.cpp @@ -0,0 +1,224 @@ +//comandeditdialog.cpp + +#include "commandeditdialog.h" +#include "playlistselection.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "smallcommandeditdialogbase.h" + +CommandEditDialog::CommandEditDialog(QWidget *parent, const char* name, WFlags fl ) + : CommandEditDialogBase(parent, name, TRUE, fl) + +{ + m_SuggestedCommandList->addColumn( tr("Command Selection") ); + m_SuggestedCommandList->header()->hide(); + m_SuggestedCommandList->setSorting(-1,FALSE); + m_SuggestedCommandList->clearSelection(); + m_SuggestedCommandList->setSorting(0,TRUE); + + QListViewItem *item; + + + item = new QListViewItem( m_SuggestedCommandList,"ls "); + + item = new QListViewItem( m_SuggestedCommandList,"cat "); + item = new QListViewItem( m_SuggestedCommandList,"cd "); + item = new QListViewItem( m_SuggestedCommandList,"chmod "); + item = new QListViewItem( m_SuggestedCommandList,"cp "); + item = new QListViewItem( m_SuggestedCommandList,"dc "); + item = new QListViewItem( m_SuggestedCommandList,"df "); + item = new QListViewItem( m_SuggestedCommandList,"dmesg "); + item = new QListViewItem( m_SuggestedCommandList,"echo "); + item = new QListViewItem( m_SuggestedCommandList,"export "); + item = new QListViewItem( m_SuggestedCommandList,"env "); + item = new QListViewItem( m_SuggestedCommandList,"find "); + item = new QListViewItem( m_SuggestedCommandList,"free "); + item = new QListViewItem( m_SuggestedCommandList,"ifconfig "); + item = new QListViewItem( m_SuggestedCommandList,"ipkg "); + item = new QListViewItem( m_SuggestedCommandList,"mkdir "); + item = new QListViewItem( m_SuggestedCommandList,"mv "); + item = new QListViewItem( m_SuggestedCommandList,"nc localhost 7776 "); + item = new QListViewItem( m_SuggestedCommandList,"nc localhost 7777 "); + item = new QListViewItem( m_SuggestedCommandList,"nslookup "); + item = new QListViewItem( m_SuggestedCommandList,"ping "); + item = new QListViewItem( m_SuggestedCommandList,"ps aux"); + item = new QListViewItem( m_SuggestedCommandList,"pwd "); + item = new QListViewItem( m_SuggestedCommandList,"rm "); + item = new QListViewItem( m_SuggestedCommandList,"rmdir "); + item = new QListViewItem( m_SuggestedCommandList,"route "); + item = new QListViewItem( m_SuggestedCommandList,"gzip "); + item = new QListViewItem( m_SuggestedCommandList,"gunzip "); + item = new QListViewItem( m_SuggestedCommandList,"chgrp "); + item = new QListViewItem( m_SuggestedCommandList,"chown "); + item = new QListViewItem( m_SuggestedCommandList,"date "); + item = new QListViewItem( m_SuggestedCommandList,"dd "); + item = new QListViewItem( m_SuggestedCommandList,"df "); + item = new QListViewItem( m_SuggestedCommandList,"dmesg "); + item = new QListViewItem( m_SuggestedCommandList,"fuser "); + item = new QListViewItem( m_SuggestedCommandList,"hostname "); + item = new QListViewItem( m_SuggestedCommandList,"kill "); + item = new QListViewItem( m_SuggestedCommandList,"killall "); + item = new QListViewItem( m_SuggestedCommandList,"ln "); + item = new QListViewItem( m_SuggestedCommandList,"ln -s "); + item = new QListViewItem( m_SuggestedCommandList,"mount "); + item = new QListViewItem( m_SuggestedCommandList,"more "); + item = new QListViewItem( m_SuggestedCommandList,"sort "); + item = new QListViewItem( m_SuggestedCommandList,"touch "); + item = new QListViewItem( m_SuggestedCommandList,"umount "); + item = new QListViewItem( m_SuggestedCommandList,"mknod "); + item = new QListViewItem( m_SuggestedCommandList,"netstat "); + item = new QListViewItem( m_SuggestedCommandList,"cardctl eject "); + m_SuggestedCommandList->setSelected(m_SuggestedCommandList->firstChild(),TRUE); + m_SuggestedCommandList->sort(); + + connect( m_SuggestedCommandList, SIGNAL( clicked( QListViewItem * ) ), m_PlayListSelection, SLOT( addToSelection( QListViewItem *) ) ); + + + + ToolButton1->setTextLabel("new"); + ToolButton1->setPixmap(Resource::loadPixmap("new")); + ToolButton1->setAutoRaise(TRUE); + ToolButton1->setFocusPolicy(QWidget::NoFocus); + connect(ToolButton1,SIGNAL(clicked()),this,SLOT(showAddDialog())); + + ToolButton2->setTextLabel("edit"); + ToolButton2->setPixmap(Resource::loadPixmap("edit")); + ToolButton2->setAutoRaise(TRUE); + ToolButton2->setFocusPolicy(QWidget::NoFocus); + connect(ToolButton2,SIGNAL(clicked()),this,SLOT(showEditDialog())); + + ToolButton3->setTextLabel("delete"); + ToolButton3->setPixmap(Resource::loadPixmap("editdelete")); + ToolButton3->setAutoRaise(TRUE); + ToolButton3->setFocusPolicy(QWidget::NoFocus); + connect(ToolButton3,SIGNAL(clicked()),m_PlayListSelection,SLOT(removeSelected())); + + ToolButton4->setTextLabel("up"); + ToolButton4->setPixmap(Resource::loadPixmap("up")); + ToolButton4->setAutoRaise(TRUE); + ToolButton4->setFocusPolicy(QWidget::NoFocus); + connect(ToolButton4,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedUp())); + + ToolButton5->setTextLabel("down"); + ToolButton5->setPixmap(Resource::loadPixmap("down")); + ToolButton5->setAutoRaise(TRUE); + ToolButton5->setFocusPolicy(QWidget::NoFocus); + +connect(ToolButton5,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedDown())); + + + + + QListViewItem *current = m_SuggestedCommandList->selectedItem(); + if ( current ) + item->moveItem( current ); + m_SuggestedCommandList->setSelected( item, TRUE ); + m_SuggestedCommandList->ensureItemVisible( m_SuggestedCommandList->selectedItem() ); + Config cfg("Konsole"); + cfg.setGroup("Commands"); + if (cfg.readEntry("Commands Set","FALSE") == "TRUE") { + for (int i = 0; i < 100; i++) { + QString tmp; + tmp = cfg.readEntry( QString::number(i),""); + if (!tmp.isEmpty()) + m_PlayListSelection->addStringToSelection(tmp); + } + } else { + +m_PlayListSelection->addStringToSelection("ls "); +m_PlayListSelection->addStringToSelection("cardctl eject"); +m_PlayListSelection->addStringToSelection("cat "); +m_PlayListSelection->addStringToSelection("cd "); +m_PlayListSelection->addStringToSelection("chmod "); +m_PlayListSelection->addStringToSelection("cp "); +m_PlayListSelection->addStringToSelection("dc "); +m_PlayListSelection->addStringToSelection("df "); +m_PlayListSelection->addStringToSelection("dmesg"); +m_PlayListSelection->addStringToSelection("echo "); +m_PlayListSelection->addStringToSelection("env"); +m_PlayListSelection->addStringToSelection("find "); +m_PlayListSelection->addStringToSelection("free"); +m_PlayListSelection->addStringToSelection("grep "); +m_PlayListSelection->addStringToSelection("ifconfig "); +m_PlayListSelection->addStringToSelection("ipkg "); +m_PlayListSelection->addStringToSelection("mkdir "); +m_PlayListSelection->addStringToSelection("mv "); +m_PlayListSelection->addStringToSelection("nc localhost 7776"); +m_PlayListSelection->addStringToSelection("nc localhost 7777"); +m_PlayListSelection->addStringToSelection("nslookup "); +m_PlayListSelection->addStringToSelection("ping "); +m_PlayListSelection->addStringToSelection("ps aux"); +m_PlayListSelection->addStringToSelection("pwd "); +m_PlayListSelection->addStringToSelection("rm "); +m_PlayListSelection->addStringToSelection("rmdir "); +m_PlayListSelection->addStringToSelection("route "); +m_PlayListSelection->addStringToSelection("set "); +m_PlayListSelection->addStringToSelection("traceroute"); + +} +} +CommandEditDialog::~CommandEditDialog() +{ +} + +void CommandEditDialog::accept() +{ +int i = 0; + Config *cfg = new Config("Konsole"); + cfg->setGroup("Commands"); + cfg->clearGroup(); + + QListViewItemIterator it( m_PlayListSelection ); + + for ( ; it.current(); ++it ) { +// qDebug(it.current()->text(0)); + cfg->writeEntry(QString::number(i),it.current()->text(0)); + i++; + + } + cfg->writeEntry("Commands Set","TRUE"); +// qDebug("CommandEditDialog::accept() - written"); + delete cfg; + emit commandsEdited(); + close(); + + + + + +} + +void CommandEditDialog::showEditDialog() +{ +editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); +d->setCaption("Edit command"); +d->TextLabel->setText("Edit command:"); +d->commandEdit->setText(m_PlayListSelection->currentItem()->text(0)); +int i = d->exec(); +if ((i==1) && (!(d->commandEdit->text()).isEmpty())) + m_PlayListSelection->currentItem()->setText(0,(d->commandEdit->text())); +} + +void CommandEditDialog::showAddDialog() +{ + +editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); +int i = d->exec(); +if ((i==1) && (!(d->commandEdit->text()).isEmpty())) +m_PlayListSelection->addStringToSelection(d->commandEdit->text()); + +} + + diff --git a/core/apps/embeddedkonsole/commandeditdialog.h b/core/apps/embeddedkonsole/commandeditdialog.h new file mode 100644 index 0000000..6dcf93f --- a/dev/null +++ b/core/apps/embeddedkonsole/commandeditdialog.h @@ -0,0 +1,25 @@ +//comandeditdialog.h +#ifndef COMMAND_EDIT_DIALOG_H +#define COMMAND_EDIT_DIALOG_H +#include "commandeditdialogbase.h" +class CommandEditDialog : public CommandEditDialogBase +{ +Q_OBJECT + +public: + + CommandEditDialog( QWidget* parent = 0, const char* name = 0, WFlags fl = 0); + ~CommandEditDialog(); + +protected: + void accept(); + +public slots: + void showEditDialog(); + void showAddDialog(); + +signals: + void commandsEdited(); +}; + +#endif diff --git a/core/apps/embeddedkonsole/commandeditdialogbase.ui b/core/apps/embeddedkonsole/commandeditdialogbase.ui new file mode 100644 index 0000000..dc22e87 --- a/dev/null +++ b/core/apps/embeddedkonsole/commandeditdialogbase.ui @@ -0,0 +1,296 @@ + +CommandEditDialogBase + + QDialog + + name + CommandEditDialogBase + + + geometry + + 0 + 0 + 196 + 414 + + + + caption + Commands + + + + margin + 11 + + + spacing + 6 + + + QLabel + + name + TextLabel1 + + + sizePolicy + + 0 + 0 + + + + text + <B>Commands</B>: + + + + QLayoutWidget + + name + Layout2 + + + + margin + 0 + + + spacing + 6 + + + QToolButton + + name + ToolButton1 + + + sizePolicy + + 5 + 5 + + + + + QToolButton + + name + ToolButton2 + + + sizePolicy + + 5 + 5 + + + + + QToolButton + + name + ToolButton3 + + + sizePolicy + + 5 + 5 + + + + + QToolButton + + name + ToolButton4 + + + sizePolicy + + 5 + 5 + + + + + QToolButton + + name + ToolButton5 + + + sizePolicy + + 5 + 5 + + + + + + + + name + Spacer3 + + + orientation + Horizontal + + + sizeType + Fixed + + + sizeHint + + 21 + 20 + + + + + QLabel + + name + TextLabel1_2 + + + sizePolicy + + 0 + 0 + + + + text + <B>Suggested Commands</B>: + + + + PlayListSelection + + name + m_PlayListSelection + + + sizePolicy + + 5 + 5 + + + + + + name + Spacer17 + + + orientation + Vertical + + + sizeType + Fixed + + + sizeHint + + 20 + 30 + + + + + + name + Spacer2 + + + orientation + Vertical + + + sizeType + Fixed + + + sizeHint + + 20 + 20 + + + + + QListView + + name + m_SuggestedCommandList + + + + + + + PlayListSelection +
playlistselection.h
+ + -1 + -1 + + 0 + + 5 + 5 + + image0 + prev() + next() + first() + last() + moveSelectedDown() + moveSelectedUp() +
+ + QToolButton +
qtoolbutton.h
+ + -1 + -1 + + 0 + + 5 + 5 + + image0 +
+ + QListView +
qlistview.h
+ + -1 + -1 + + 0 + + 5 + 5 + + image0 +
+
+ + + image0 + 789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753 + + +
diff --git a/core/apps/embeddedkonsole/commandeditwidget.cpp b/core/apps/embeddedkonsole/commandeditwidget.cpp new file mode 100644 index 0000000..84962ef --- a/dev/null +++ b/core/apps/embeddedkonsole/commandeditwidget.cpp @@ -0,0 +1,45 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'commandeditwidget.ui' +** +** Created: Sat Feb 2 11:08:25 2002 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "commandeditwidget.h" + +#include +#include "playlistselection.h" +#include +#include +#include +#include + +/* + * Constructs a Form1 which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + */ +Form1::Form1( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + if ( !name ) + setName( "Form1" ); + resize( 596, 480 ); + setCaption( tr( "Form1" ) ); + Form1Layout = new QGridLayout( this ); + Form1Layout->setSpacing( 6 ); + Form1Layout->setMargin( 11 ); + + MyCustomWidget1 = new PlayListSelection( this, "MyCustomWidget1" ); + + Form1Layout->addWidget( MyCustomWidget1, 0, 0 ); +} + +/* + * Destroys the object and frees any allocated resources + */ +Form1::~Form1() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/core/apps/embeddedkonsole/commandeditwidget.h b/core/apps/embeddedkonsole/commandeditwidget.h new file mode 100644 index 0000000..c88de73 --- a/dev/null +++ b/core/apps/embeddedkonsole/commandeditwidget.h @@ -0,0 +1,33 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'commandeditwidget.ui' +** +** Created: Sat Feb 2 11:08:25 2002 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef FORM1_H +#define FORM1_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class PlayListSelection; + +class Form1 : public QWidget +{ + Q_OBJECT + +public: + Form1( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~Form1(); + + PlayListSelection* MyCustomWidget1; + +protected: + QGridLayout* Form1Layout; +}; + +#endif // FORM1_H diff --git a/core/apps/embeddedkonsole/embeddedkonsole.pro b/core/apps/embeddedkonsole/embeddedkonsole.pro index 3452014..f4e1f2d 100755 --- a/core/apps/embeddedkonsole/embeddedkonsole.pro +++ b/core/apps/embeddedkonsole/embeddedkonsole.pro @@ -1,38 +1,36 @@ -TEMPLATE = app - -CONFIG += qt warn_on release - -DESTDIR = $(OPIEDIR)/bin - -HEADERS = TEWidget.h \ - TEScreen.h \ - TECommon.h \ - TEHistory.h \ - TEmulation.h \ - TEmuVt102.h \ - session.h \ - keytrans.h \ - konsole.h \ - MyPty.h - -SOURCES = TEScreen.cpp \ - TEWidget.cpp \ - TEHistory.cpp \ - TEmulation.cpp \ - TEmuVt102.cpp \ - session.cpp \ - keytrans.cpp \ - konsole.cpp \ - main.cpp \ - MyPty.cpp - -TARGET = embeddedkonsole - +TEMPLATE = app +CONFIG += qt warn_on release +DESTDIR = $(OPIEDIR)/bin +HEADERS = TEWidget.h \ + TEScreen.h \ + TECommon.h \ + TEHistory.h \ + TEmulation.h \ + TEmuVt102.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 - +DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe - -REQUIRES = embeddedkonsole +REQUIRES = embeddedkonsole diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index 23c12f8..bc5a766 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp @@ -51,6 +51,7 @@ #include "konsole.h" #include "keytrans.h" +#include "commandeditdialog.h" class EKNumTabBar : public QTabBar { public: @@ -175,6 +176,26 @@ Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) init(_pgm,_args); } +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; @@ -225,14 +246,17 @@ void Konsole::init(const char* _pgm, QStrList & _args) configMenu = new QPopupMenu( this); colorMenu = new QPopupMenu( this); scrollMenu = new QPopupMenu( this); + editCommandListMenu = new QPopupMenu( this); + + configMenu->insertItem("Command List",editCommandListMenu); bool listHidden; cfg.setGroup("Menubar"); if( cfg.readEntry("Hidden","FALSE") == "TRUE") { - configMenu->insertItem("Show command list"); + editCommandListMenu->insertItem("Show command list"); listHidden=TRUE; } else { - configMenu->insertItem("Hide command list"); + editCommandListMenu->insertItem("Hide command list"); listHidden=FALSE; } @@ -266,7 +290,7 @@ void Konsole::init(const char* _pgm, QStrList & _args) connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuSelected(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 ); @@ -301,21 +325,24 @@ void Konsole::init(const char* _pgm, QStrList & _args) commonCombo = new QComboBox( secondToolBar ); commonCombo->setMaximumWidth(236); - configMenu->insertItem( "Edit Command List"); + + editCommandListMenu->insertItem( "Quick Edit"); if( listHidden) { secondToolBar->hide(); - configMenu->setItemEnabled(-20 ,FALSE); + editCommandListMenu->setItemEnabled(-22 ,FALSE); } + editCommandListMenu->insertItem( "Edit"); 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 ); - } + + 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) )); @@ -586,8 +613,8 @@ 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; -// qDebug( temp.sprintf("%d", iD)); +// QString temp; +// qDebug( temp.sprintf("colormenu %d", iD)); TEWidget* te = getTe(); Config cfg("Konsole"); cfg.setGroup("Colors"); @@ -598,89 +625,89 @@ void Konsole::colorMenuSelected(int iD) const ColorEntry * defaultCt=te->getdefaultColorTable(); /////////// fore back int i; - if(iD==-8) { // default default + 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","8"); - colorMenu->setItemChecked(-8,TRUE); + cfg.writeEntry("Schema","98"); + colorMenu->setItemChecked(-9,TRUE); } } else { - if(iD==-5) { // green black + if(iD==-6) { // green black foreground.setRgb(0x18,255,0x18); background.setRgb(0x00,0x00,0x00); - cfg.writeEntry("Schema","5"); - colorMenu->setItemChecked(-5,TRUE); + cfg.writeEntry("Schema","6"); + colorMenu->setItemChecked(-6,TRUE); } - if(iD==-6) { // black white + if(iD==-7) { // black white foreground.setRgb(0x00,0x00,0x00); background.setRgb(0xFF,0xFF,0xFF); - cfg.writeEntry("Schema","6"); - colorMenu->setItemChecked(-6,TRUE); + cfg.writeEntry("Schema","7"); + colorMenu->setItemChecked(-7,TRUE); } - if(iD==-7) { // white black + if(iD==-8) { // white black foreground.setRgb(0xFF,0xFF,0xFF); background.setRgb(0x00,0x00,0x00); - cfg.writeEntry("Schema","7"); - colorMenu->setItemChecked(-7,TRUE); + cfg.writeEntry("Schema","8"); + colorMenu->setItemChecked(-8,TRUE); } - if(iD==-9) {// Black, Red + if(iD==-10) {// Black, Red foreground.setRgb(0x00,0x00,0x00); background.setRgb(0xB2,0x18,0x18); - cfg.writeEntry("Schema","9"); - colorMenu->setItemChecked(-9,TRUE); + cfg.writeEntry("Schema","10"); + colorMenu->setItemChecked(-10,TRUE); } - if(iD==-10) {// Red, Black + if(iD==-11) {// Red, Black foreground.setRgb(230,31,31); //0xB2,0x18,0x18 background.setRgb(0x00,0x00,0x00); - cfg.writeEntry("Schema","10"); - colorMenu->setItemChecked(-10,TRUE); + cfg.writeEntry("Schema","11"); + colorMenu->setItemChecked(-11,TRUE); } - if(iD==-11) {// Green, Yellow - is ugly + if(iD==-12) {// 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); + if(iD==-13) {// Blue, Magenta + foreground.setRgb(0x18,0xB2,0xB2); + background.setRgb(0x18,0x18,0xB2); cfg.writeEntry("Schema","13"); colorMenu->setItemChecked(-13,TRUE); } - if(iD==-14) {// Cyan, White - foreground.setRgb(0x18,0xB2,0xB2); - background.setRgb(0xFF,0xFF,0xFF); + if(iD==-14) {// Magenta, Blue + foreground.setRgb(0x18,0x18,0xB2); + background.setRgb(0x18,0xB2,0xB2); cfg.writeEntry("Schema","14"); colorMenu->setItemChecked(-14,TRUE); } - if(iD==-15) {// White, Cyan - background.setRgb(0x18,0xB2,0xB2); - foreground.setRgb(0xFF,0xFF,0xFF); + 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) {// Black, Blue - background.setRgb(0x00,0x00,0x00); - foreground.setRgb(0x18,0xB2,0xB2); + 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, Gold + if(iD==-17) {// Black, Blue background.setRgb(0x00,0x00,0x00); - foreground.setRgb(255,215,0); + 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); + } for (i = 0; i < TABLE_COLORS; i++) { if(i==0 || i == 10) { @@ -700,33 +727,33 @@ void Konsole::colorMenuSelected(int iD) void Konsole::configMenuSelected(int iD) { - QString temp; - qDebug( temp.sprintf("%d",iD)); + QString temp; + qDebug( temp.sprintf("configmenu %d",iD)); 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(-20,TRUE); - commonCombo->setEditable( TRUE ); - } else { - configMenu->setItemChecked(-20,FALSE); - commonCombo->setEditable( FALSE ); - } - } - } - if( iD == -3) { +// 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(-20,TRUE); +// commonCombo->setEditable( TRUE ); +// } else { +// configMenu->setItemChecked(-20,FALSE); +// commonCombo->setEditable( FALSE ); +// } +// } +// } + if( iD == -4) { cfg.setGroup("Tabs"); QString tmp=cfg.readEntry("Position","Top"); @@ -740,22 +767,22 @@ void Konsole::configMenuSelected(int iD) 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(); - } - } +// 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) @@ -779,22 +806,77 @@ void Konsole::setColor() void Konsole::scrollMenuSelected(int index) { +// QString temp; +// qDebug( temp.sprintf("scrollbar menu %d",index)); TEWidget* te = getTe(); Config cfg("Konsole"); cfg.setGroup("Scrollbar"); switch( index){ - case -21: + case -24: te->setScrollbarLocation(0); cfg.writeEntry("Position",0); break; - case -22: + case -25: te->setScrollbarLocation(1); cfg.writeEntry("Position",1); break; - case -23: + case -26: te->setScrollbarLocation(2); cfg.writeEntry("Position",2); break; }; } + +void Konsole::editCommandListMenuSelected(int iD) +{ +// QString temp; +// qDebug( temp.sprintf("edit command list %d",iD)); + TEWidget* te = getTe(); + Config cfg("Konsole"); + cfg.setGroup("Menubar"); + if( iD == -3) { + if(!secondToolBar->isHidden()) { + secondToolBar->hide(); + configMenu->changeItem( iD,"Show Command List"); + cfg.writeEntry("Hidden","TRUE"); + configMenu->setItemEnabled(-22 ,FALSE); + } else { + secondToolBar->show(); + configMenu->changeItem( iD,"Hide Command List"); + cfg.writeEntry("Hidden","FALSE"); + configMenu->setItemEnabled(-22 ,TRUE); + + if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") { + configMenu->setItemChecked(-22,TRUE); + commonCombo->setEditable( TRUE ); + } else { + configMenu->setItemChecked(-22,FALSE); + commonCombo->setEditable( FALSE ); + } + } + } + if( iD == -22) { + 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(); + } + } + if(iD == -23) { + // "edit commands" + CommandEditDialog *m = new CommandEditDialog(this); + connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); + m->showMaximized(); + } + +} diff --git a/core/apps/embeddedkonsole/konsole.h b/core/apps/embeddedkonsole/konsole.h index b4e5d87..b508cf8 100644 --- a/core/apps/embeddedkonsole/konsole.h +++ b/core/apps/embeddedkonsole/konsole.h @@ -70,7 +70,9 @@ private slots: void switchSession(QWidget *); void newSession(); void changeCommand(const QString &, int); + void initCommandList(); void scrollMenuSelected(int); + void editCommandListMenuSelected(int); private: void init(const char* _pgm, QStrList & _args); void initSession(const char* _pgm, QStrList & _args); @@ -79,7 +81,8 @@ private: void setHistory(bool); QSize calcSize(int columns, int lines); TEWidget* getTe(); - + QStringList commands; + private: class VTFont { @@ -112,7 +115,7 @@ private: QCString se_pgm; QStrList se_args; - QPopupMenu* fontList,*configMenu,*colorMenu,*scrollMenu; + QPopupMenu *fontList,*configMenu,*colorMenu,*scrollMenu,*editCommandListMenu; QComboBox *commonCombo; // history scrolling I think bool b_scroll; diff --git a/core/apps/embeddedkonsole/playlistselection.cpp b/core/apps/embeddedkonsole/playlistselection.cpp new file mode 100644 index 0000000..b9b9401 --- a/dev/null +++ b/core/apps/embeddedkonsole/playlistselection.cpp @@ -0,0 +1,161 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of Qtopia Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "playlistselection.h" + +#include + + + + + +PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) + : QListView( parent, name ) +{ + setAllColumnsShowFocus( TRUE ); + addColumn( tr( "Command Selection" ) ); + header()->hide(); + setSorting( -1, FALSE ); +} + + +PlayListSelection::~PlayListSelection() { +} + + + +void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { + if ( event->state() == QMouseEvent::LeftButton ) { + QListViewItem *currentItem = selectedItem(); + QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); + if ( currentItem && currentItem->itemAbove() == itemUnder ) + moveSelectedUp(); + else if ( currentItem && currentItem->itemBelow() == itemUnder ) + moveSelectedDown(); + } +} + + +const QString *PlayListSelection::current() { + PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); + if ( item ) + return item->file(); + return NULL; +} + + +void PlayListSelection::addToSelection( QListViewItem *lnk ) { +PlayListSelectionItem *item = new PlayListSelectionItem( this, new QString( lnk->text(0) ) ); + QListViewItem *current = selectedItem(); + if ( current ) + item->moveItem( current ); + setSelected( item, TRUE ); + ensureItemVisible( selectedItem() ); +} + +void PlayListSelection::addStringToSelection (const QString & lnk) { + PlayListSelectionItem *item = new PlayListSelectionItem( this, new QString( lnk ) ); + QListViewItem *current = selectedItem(); + if ( current ) + item->moveItem( current ); + setSelected( item, TRUE ); + ensureItemVisible( selectedItem() ); + +} +void PlayListSelection::removeSelected() { + qDebug("removeSelected()"); + QListViewItem *item = selectedItem(); + if ( item ) + delete item; + setSelected( currentItem(), TRUE ); + ensureItemVisible( selectedItem() ); +} + + +void PlayListSelection::moveSelectedUp() { + QListViewItem *item = selectedItem(); + if ( item && item->itemAbove() ) + item->itemAbove()->moveItem( item ); + ensureItemVisible( selectedItem() ); +} + + +void PlayListSelection::moveSelectedDown() { + QListViewItem *item = selectedItem(); + if ( item && item->itemBelow() ) + item->moveItem( item->itemBelow() ); + ensureItemVisible( selectedItem() ); +} + + +bool PlayListSelection::prev() { + QListViewItem *item = selectedItem(); + if ( item && item->itemAbove() ) + setSelected( item->itemAbove(), TRUE ); + else + return FALSE; + ensureItemVisible( selectedItem() ); + return TRUE; +} + + +bool PlayListSelection::next() { + QListViewItem *item = selectedItem(); + if ( item && item->itemBelow() ) + setSelected( item->itemBelow(), TRUE ); + else + return FALSE; + ensureItemVisible( selectedItem() ); + return TRUE; +} + + +bool PlayListSelection::first() { + QListViewItem *item = firstChild(); + if ( item ) + setSelected( item, TRUE ); + else + return FALSE; + ensureItemVisible( selectedItem() ); + return TRUE; +} + + +bool PlayListSelection::last() { + QListViewItem *prevItem = NULL; + QListViewItem *item = firstChild(); + while ( ( item = item->nextSibling() ) ) + prevItem = item; + if ( prevItem ) + setSelected( prevItem, TRUE ); + else + return FALSE; + ensureItemVisible( selectedItem() ); + return TRUE; +} + diff --git a/core/apps/embeddedkonsole/playlistselection.h b/core/apps/embeddedkonsole/playlistselection.h new file mode 100644 index 0000000..c307f14 --- a/dev/null +++ b/core/apps/embeddedkonsole/playlistselection.h @@ -0,0 +1,74 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of Qtopia Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ +#ifndef PLAY_LIST_SELECTION_H +#define PLAY_LIST_SELECTION_H + + +#include +#include +#include + +class PlayListSelectionItem : public QListViewItem { +public: + PlayListSelectionItem( QListView *parent, QString *f ) : QListViewItem( parent ), fl( f ) { + setText(0, *f ); + } + + ~PlayListSelectionItem() { + }; + + const QString *file() const { return fl; } + +private: + const QString *fl; +}; + +class PlayListSelection : public QListView { + Q_OBJECT +public: + PlayListSelection( QWidget *parent, const char *name=0 ); + ~PlayListSelection(); + + const QString *current(); // retrieve the current playlist entry (media file link) + +public slots: + void addToSelection( QListViewItem * ); // Add a media file to the playlist + void addStringToSelection ( const QString &); + void removeSelected(); // Remove a media file from the playlist + void moveSelectedUp(); // Move the media file up the playlist so it is played earlier + void moveSelectedDown(); // Move the media file down the playlist so it is played later + bool prev(); + bool next(); + bool first(); + bool last(); + +protected: + virtual void contentsMouseMoveEvent(QMouseEvent *); + + +private: + QStringList selectedList; + QString *cmd; +}; + + +#endif // PLAY_LIST_SELECTION_H + + diff --git a/core/apps/embeddedkonsole/smallcommandeditdialogbase.ui b/core/apps/embeddedkonsole/smallcommandeditdialogbase.ui new file mode 100644 index 0000000..2625a57 --- a/dev/null +++ b/core/apps/embeddedkonsole/smallcommandeditdialogbase.ui @@ -0,0 +1,62 @@ + +editCommandBase + + QDialog + + name + editCommandBase + + + geometry + + 0 + 0 + 222 + 94 + + + + caption + Add command + + + layoutMargin + + + QLabel + + name + TextLabel + + + geometry + + 10 + 10 + 151 + 20 + + + + text + Enter command to add: + + + + QLineEdit + + name + commandEdit + + + geometry + + 10 + 40 + 201 + 22 + + + + + -- cgit v0.9.0.2