-rw-r--r-- | core/apps/embeddedkonsole/commandeditdialog.cpp | 224 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/commandeditdialog.h | 25 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/commandeditdialogbase.ui | 296 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/commandeditwidget.cpp | 45 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/commandeditwidget.h | 33 | ||||
-rwxr-xr-x | core/apps/embeddedkonsole/embeddedkonsole.pro | 20 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 268 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/konsole.h | 5 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/playlistselection.cpp | 161 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/playlistselection.h | 74 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/smallcommandeditdialogbase.ui | 62 |
11 files changed, 1108 insertions, 105 deletions
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 <qstring.h> +#include <qpe/config.h> +#include <qpe/qpetoolbar.h> +#include <qwidget.h> +#include <qpe/qpemenubar.h> +#include <qpe/resource.h> +#include <qlist.h> +#include <qtoolbutton.h> +#include <qvbox.h> +#include <qlistview.h> +#include <qlineedit.h> +#include <qheader.h> +#include <qlabel.h> +#include <qmessagebox.h> +#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 @@ +<!DOCTYPE UI><UI> +<class>CommandEditDialogBase</class> +<widget> + <class>QDialog</class> + <property stdset="1"> + <name>name</name> + <cstring>CommandEditDialogBase</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>0</x> + <y>0</y> + <width>196</width> + <height>414</height> + </rect> + </property> + <property stdset="1"> + <name>caption</name> + <string>Commands</string> + </property> + <grid> + <property stdset="1"> + <name>margin</name> + <number>11</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget row="0" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel1</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>text</name> + <string><B>Commands</B>:</string> + </property> + </widget> + <widget row="1" column="2" > + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout2</cstring> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QToolButton</class> + <property stdset="1"> + <name>name</name> + <cstring>ToolButton1</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + </sizepolicy> + </property> + </widget> + <widget> + <class>QToolButton</class> + <property stdset="1"> + <name>name</name> + <cstring>ToolButton2</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + </sizepolicy> + </property> + </widget> + <widget> + <class>QToolButton</class> + <property stdset="1"> + <name>name</name> + <cstring>ToolButton3</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + </sizepolicy> + </property> + </widget> + <widget> + <class>QToolButton</class> + <property stdset="1"> + <name>name</name> + <cstring>ToolButton4</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + </sizepolicy> + </property> + </widget> + <widget> + <class>QToolButton</class> + <property stdset="1"> + <name>name</name> + <cstring>ToolButton5</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + </sizepolicy> + </property> + </widget> + </vbox> + </widget> + <spacer row="0" column="2" > + <property> + <name>name</name> + <cstring>Spacer3</cstring> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Horizontal</enum> + </property> + <property stdset="1"> + <name>sizeType</name> + <enum>Fixed</enum> + </property> + <property> + <name>sizeHint</name> + <size> + <width>21</width> + <height>20</height> + </size> + </property> + </spacer> + <widget row="2" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel1_2</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>text</name> + <string><B>Suggested Commands</B>:</string> + </property> + </widget> + <widget row="1" column="0" rowspan="1" colspan="2" > + <class>PlayListSelection</class> + <property stdset="1"> + <name>name</name> + <cstring>m_PlayListSelection</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + </sizepolicy> + </property> + </widget> + <spacer row="2" column="1" > + <property> + <name>name</name> + <cstring>Spacer17</cstring> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Vertical</enum> + </property> + <property stdset="1"> + <name>sizeType</name> + <enum>Fixed</enum> + </property> + <property> + <name>sizeHint</name> + <size> + <width>20</width> + <height>30</height> + </size> + </property> + </spacer> + <spacer row="2" column="2" > + <property> + <name>name</name> + <cstring>Spacer2</cstring> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Vertical</enum> + </property> + <property stdset="1"> + <name>sizeType</name> + <enum>Fixed</enum> + </property> + <property> + <name>sizeHint</name> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget row="3" column="0" rowspan="1" colspan="2" > + <class>QListView</class> + <property stdset="1"> + <name>name</name> + <cstring>m_SuggestedCommandList</cstring> + </property> + </widget> + </grid> +</widget> +<customwidgets> + <customwidget> + <class>PlayListSelection</class> + <header location="local">playlistselection.h</header> + <sizehint> + <width>-1</width> + <height>-1</height> + </sizehint> + <container>0</container> + <sizepolicy> + <hordata>5</hordata> + <verdata>5</verdata> + </sizepolicy> + <pixmap>image0</pixmap> + <slot access="public">prev()</slot> + <slot access="public">next()</slot> + <slot access="public">first()</slot> + <slot access="public">last()</slot> + <slot access="public">moveSelectedDown()</slot> + <slot access="public">moveSelectedUp()</slot> + </customwidget> + <customwidget> + <class>QToolButton</class> + <header location="global">qtoolbutton.h</header> + <sizehint> + <width>-1</width> + <height>-1</height> + </sizehint> + <container>0</container> + <sizepolicy> + <hordata>5</hordata> + <verdata>5</verdata> + </sizepolicy> + <pixmap>image0</pixmap> + </customwidget> + <customwidget> + <class>QListView</class> + <header location="global">qlistview.h</header> + <sizehint> + <width>-1</width> + <height>-1</height> + </sizehint> + <container>0</container> + <sizepolicy> + <hordata>5</hordata> + <verdata>5</verdata> + </sizepolicy> + <pixmap>image0</pixmap> + </customwidget> +</customwidgets> +<images> + <image> + <name>image0</name> + <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753</data> + </image> +</images> +</UI> 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 <qpushbutton.h> +#include "playlistselection.h" +#include <qlayout.h> +#include <qvariant.h> +#include <qtooltip.h> +#include <qwhatsthis.h> + +/* + * 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 <qvariant.h> +#include <qwidget.h> +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,7 +1,4 @@ TEMPLATE = app - CONFIG += qt warn_on release - DESTDIR = $(OPIEDIR)/bin - HEADERS = TEWidget.h \ @@ -15,4 +12,6 @@ HEADERS = TEWidget.h \ konsole.h \ + commandeditdialog.h \ + commandeditwidget.h \ + playlistselection.h \ MyPty.h - SOURCES = TEScreen.cpp \ @@ -25,13 +24,12 @@ SOURCES = TEScreen.cpp \ konsole.cpp \ - main.cpp \ - MyPty.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 - 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 @@ -53,2 +53,3 @@ #include "keytrans.h" +#include "commandeditdialog.h" @@ -177,2 +178,22 @@ Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) +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) @@ -227,2 +248,5 @@ void Konsole::init(const char* _pgm, QStrList & _args) scrollMenu = new QPopupMenu( this); + editCommandListMenu = new QPopupMenu( this); + + configMenu->insertItem("Command List",editCommandListMenu); @@ -231,6 +255,6 @@ void Konsole::init(const char* _pgm, QStrList & _args) 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; @@ -268,3 +292,3 @@ void Konsole::init(const char* _pgm, QStrList & _args) connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); - + connect(editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); menuBar->insertItem( tr("Font"), fontList ); @@ -303,7 +327,9 @@ void Konsole::init(const char* _pgm, QStrList & _args) 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"); @@ -312,8 +338,9 @@ void Konsole::init(const char* _pgm, QStrList & _args) - 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 ); +// } @@ -589,3 +616,3 @@ void Konsole::colorMenuSelected(int iD) // QString temp; -// qDebug( temp.sprintf("%d", iD)); +// qDebug( temp.sprintf("colormenu %d", iD)); TEWidget* te = getTe(); @@ -600,3 +627,3 @@ void Konsole::colorMenuSelected(int iD) int i; - if(iD==-8) { // default default + if(iD==-9) { // default default for (i = 0; i < TABLE_COLORS; i++) { @@ -605,37 +632,37 @@ void Konsole::colorMenuSelected(int iD) 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); @@ -644,8 +671,2 @@ void Konsole::colorMenuSelected(int iD) 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"); @@ -653,5 +674,5 @@ void Konsole::colorMenuSelected(int iD) } - 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"); @@ -659,5 +680,5 @@ void Konsole::colorMenuSelected(int iD) } - 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"); @@ -665,5 +686,5 @@ void Konsole::colorMenuSelected(int iD) } - 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"); @@ -671,5 +692,5 @@ void Konsole::colorMenuSelected(int iD) } - 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"); @@ -677,5 +698,5 @@ void Konsole::colorMenuSelected(int iD) } - 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"); @@ -683,2 +704,8 @@ void Konsole::colorMenuSelected(int iD) } + if(iD==-18) {// Black, Gold + background.setRgb(0x00,0x00,0x00); + foreground.setRgb(255,215,0); + cfg.writeEntry("Schema","18"); + colorMenu->setItemChecked(-18,TRUE); + } @@ -703,3 +730,3 @@ void Konsole::configMenuSelected(int iD) QString temp; - qDebug( temp.sprintf("%d",iD)); + qDebug( temp.sprintf("configmenu %d",iD)); TEWidget* te = getTe(); @@ -707,24 +734,24 @@ void Konsole::configMenuSelected(int iD) 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"); @@ -742,18 +769,18 @@ void Konsole::configMenuSelected(int iD) } - 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(); +// } +// } } @@ -781,2 +808,4 @@ void Konsole::scrollMenuSelected(int index) { +// QString temp; +// qDebug( temp.sprintf("scrollbar menu %d",index)); TEWidget* te = getTe(); @@ -785,3 +814,3 @@ void Konsole::scrollMenuSelected(int index) switch( index){ - case -21: + case -24: te->setScrollbarLocation(0); @@ -789,3 +818,3 @@ void Konsole::scrollMenuSelected(int index) break; - case -22: + case -25: te->setScrollbarLocation(1); @@ -793,3 +822,3 @@ void Konsole::scrollMenuSelected(int index) break; - case -23: + case -26: te->setScrollbarLocation(2); @@ -800 +829,54 @@ void Konsole::scrollMenuSelected(int index) } + +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 @@ -72,3 +72,5 @@ private slots: void changeCommand(const QString &, int); + void initCommandList(); void scrollMenuSelected(int); + void editCommandListMenuSelected(int); private: @@ -81,2 +83,3 @@ private: TEWidget* getTe(); + QStringList commands; @@ -114,3 +117,3 @@ private: - QPopupMenu* fontList,*configMenu,*colorMenu,*scrollMenu; + QPopupMenu *fontList,*configMenu,*colorMenu,*scrollMenu,*editCommandListMenu; QComboBox *commonCombo; 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 <qpe/applnk.h> +#include <qpe/resource.h> +#include <qpainter.h> +#include <qimage.h> +#include <qheader.h> +#include <qlistview.h> +#include <qlist.h> +#include <qpixmap.h> + +#include "playlistselection.h" + +#include <stdlib.h> + + + + + +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 <qlist.h> +#include <qlistview.h> +#include <qpe/applnk.h> + +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 @@ +<!DOCTYPE UI><UI> +<class>editCommandBase</class> +<widget> + <class>QDialog</class> + <property stdset="1"> + <name>name</name> + <cstring>editCommandBase</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>0</x> + <y>0</y> + <width>222</width> + <height>94</height> + </rect> + </property> + <property stdset="1"> + <name>caption</name> + <string>Add command</string> + </property> + <property> + <name>layoutMargin</name> + </property> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>10</x> + <y>10</y> + <width>151</width> + <height>20</height> + </rect> + </property> + <property stdset="1"> + <name>text</name> + <string>Enter command to add:</string> + </property> + </widget> + <widget> + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>commandEdit</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>10</x> + <y>40</y> + <width>201</width> + <height>22</height> + </rect> + </property> + </widget> +</widget> +</UI> |