-rwxr-xr-x | core/apps/embeddedkonsole/embeddedkonsole.pro | 28 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 68 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/konsole.h | 8 |
3 files changed, 85 insertions, 19 deletions
diff --git a/core/apps/embeddedkonsole/embeddedkonsole.pro b/core/apps/embeddedkonsole/embeddedkonsole.pro index de0cfa1..6b7af27 100755 --- a/core/apps/embeddedkonsole/embeddedkonsole.pro +++ b/core/apps/embeddedkonsole/embeddedkonsole.pro | |||
@@ -26,25 +26,25 @@ SOURCES = TEScreen.cpp \ | |||
26 | commandeditwidget.cpp \ | 26 | commandeditwidget.cpp \ |
27 | playlistselection.cpp \ | 27 | playlistselection.cpp \ |
28 | MyPty.cpp \ | 28 | MyPty.cpp \ |
29 | main.cpp | 29 | main.cpp |
30 | INTERFACES = commandeditdialogbase.ui smallcommandeditdialogbase.ui | 30 | INTERFACES = commandeditdialogbase.ui smallcommandeditdialogbase.ui |
31 | TARGET = embeddedkonsole | 31 | TARGET = embeddedkonsole |
32 | INCLUDEPATH += $(OPIEDIR)/include | 32 | INCLUDEPATH += $(OPIEDIR)/include |
33 | DEPENDPATH += $(OPIEDIR)/include | 33 | DEPENDPATH += $(OPIEDIR)/include |
34 | LIBS += -lqpe | 34 | LIBS += -lqpe -lopie |
35 | REQUIRES = embeddedkonsole | 35 | REQUIRES = embeddedkonsole |
36 | 36 | ||
37 | TRANSLATIONS = ../../../i18n/de/embeddedkonsole.ts \ | 37 | TRANSLATIONS = ../../../i18n/de/embeddedkonsole.ts \ |
38 | ../../../i18n/en/embeddedkonsole.ts \ | 38 | ../../../i18n/en/embeddedkonsole.ts \ |
39 | ../../../i18n/es/embeddedkonsole.ts \ | 39 | ../../../i18n/es/embeddedkonsole.ts \ |
40 | ../../../i18n/fr/embeddedkonsole.ts \ | 40 | ../../../i18n/fr/embeddedkonsole.ts \ |
41 | ../../../i18n/hu/embeddedkonsole.ts \ | 41 | ../../../i18n/hu/embeddedkonsole.ts \ |
42 | ../../../i18n/ja/embeddedkonsole.ts \ | 42 | ../../../i18n/ja/embeddedkonsole.ts \ |
43 | ../../../i18n/ko/embeddedkonsole.ts \ | 43 | ../../../i18n/ko/embeddedkonsole.ts \ |
44 | ../../../i18n/no/embeddedkonsole.ts \ | 44 | ../../../i18n/no/embeddedkonsole.ts \ |
45 | ../../../i18n/pl/embeddedkonsole.ts \ | 45 | ../../../i18n/pl/embeddedkonsole.ts \ |
46 | ../../../i18n/pt/embeddedkonsole.ts \ | 46 | ../../../i18n/pt/embeddedkonsole.ts \ |
47 | ../../../i18n/pt_BR/embeddedkonsole.ts \ | 47 | ../../../i18n/pt_BR/embeddedkonsole.ts \ |
48 | ../../../i18n/sl/embeddedkonsole.ts \ | 48 | ../../../i18n/sl/embeddedkonsole.ts \ |
49 | ../../../i18n/zh_CN/embeddedkonsole.ts \ | 49 | ../../../i18n/zh_CN/embeddedkonsole.ts \ |
50 | ../../../i18n/zh_TW/embeddedkonsole.ts | 50 | ../../../i18n/zh_TW/embeddedkonsole.ts |
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index b0d28fc..8b1e066 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp | |||
@@ -49,16 +49,18 @@ | |||
49 | #include <stdio.h> | 49 | #include <stdio.h> |
50 | #include <stdlib.h> | 50 | #include <stdlib.h> |
51 | #include <assert.h> | 51 | #include <assert.h> |
52 | 52 | ||
53 | #include "konsole.h" | 53 | #include "konsole.h" |
54 | #include "keytrans.h" | 54 | #include "keytrans.h" |
55 | #include "commandeditdialog.h" | 55 | #include "commandeditdialog.h" |
56 | 56 | ||
57 | #include <opie/colorpopupmenu.h> | ||
58 | |||
57 | class EKNumTabBar : public QTabBar { | 59 | class EKNumTabBar : public QTabBar { |
58 | public: | 60 | public: |
59 | void numberTabs() | 61 | void numberTabs() |
60 | { | 62 | { |
61 | // Yes, it really is this messy. QTabWidget needs functions | 63 | // Yes, it really is this messy. QTabWidget needs functions |
62 | // that provide acces to tabs in a sequential way. | 64 | // that provide acces to tabs in a sequential way. |
63 | int m=INT_MIN; | 65 | int m=INT_MIN; |
64 | for (int i=0; i<count(); i++) { | 66 | for (int i=0; i<count(); i++) { |
@@ -201,16 +203,18 @@ void Konsole::initCommandList() | |||
201 | } | 203 | } |
202 | 204 | ||
203 | void Konsole::init(const char* _pgm, QStrList & _args) | 205 | void Konsole::init(const char* _pgm, QStrList & _args) |
204 | { | 206 | { |
205 | b_scroll = TRUE; // histon; | 207 | b_scroll = TRUE; // histon; |
206 | n_keytab = 0; | 208 | n_keytab = 0; |
207 | n_render = 0; | 209 | n_render = 0; |
208 | startUp=0; | 210 | startUp=0; |
211 | fromMenu = FALSE; | ||
212 | |||
209 | setCaption( tr("Terminal") ); | 213 | setCaption( tr("Terminal") ); |
210 | setIcon( Resource::loadPixmap( "konsole" ) ); | 214 | setIcon( Resource::loadPixmap( "konsole" ) ); |
211 | 215 | ||
212 | Config cfg("Konsole"); | 216 | Config cfg("Konsole"); |
213 | cfg.setGroup("Konsole"); | 217 | cfg.setGroup("Konsole"); |
214 | QString tmp; | 218 | QString tmp; |
215 | // initialize the list of allowed fonts /////////////////////////////////// | 219 | // initialize the list of allowed fonts /////////////////////////////////// |
216 | cfont = cfg.readNumEntry("FontID", 1); | 220 | cfont = cfg.readNumEntry("FontID", 1); |
@@ -283,21 +287,22 @@ void Konsole::init(const char* _pgm, QStrList & _args) | |||
283 | colorMenu->insertItem(tr( "Red on Black")); | 287 | colorMenu->insertItem(tr( "Red on Black")); |
284 | colorMenu->insertItem(tr( "Green on Yellow")); | 288 | colorMenu->insertItem(tr( "Green on Yellow")); |
285 | colorMenu->insertItem(tr( "Blue on Magenta")); | 289 | colorMenu->insertItem(tr( "Blue on Magenta")); |
286 | colorMenu->insertItem(tr( "Magenta on Blue")); | 290 | colorMenu->insertItem(tr( "Magenta on Blue")); |
287 | colorMenu->insertItem(tr( "Cyan on White")); | 291 | colorMenu->insertItem(tr( "Cyan on White")); |
288 | colorMenu->insertItem(tr( "White on Cyan")); | 292 | colorMenu->insertItem(tr( "White on Cyan")); |
289 | colorMenu->insertItem(tr( "Blue on Black")); | 293 | colorMenu->insertItem(tr( "Blue on Black")); |
290 | colorMenu->insertItem(tr( "Amber on Black")); | 294 | colorMenu->insertItem(tr( "Amber on Black")); |
295 | colorMenu->insertItem(tr( "Custom")); | ||
291 | configMenu->insertItem(tr( "Colors") ,colorMenu); | 296 | configMenu->insertItem(tr( "Colors") ,colorMenu); |
292 | 297 | ||
293 | connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); | 298 | connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); |
294 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); | 299 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); |
295 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuSelected(int) )); | 300 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); |
296 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); | 301 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); |
297 | connect(editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); | 302 | connect(editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); |
298 | menuBar->insertItem( tr("Font"), fontList ); | 303 | menuBar->insertItem( tr("Font"), fontList ); |
299 | menuBar->insertItem( tr("Options"), configMenu ); | 304 | menuBar->insertItem( tr("Options"), configMenu ); |
300 | 305 | ||
301 | QPEToolBar *toolbar = new QPEToolBar( this ); | 306 | QPEToolBar *toolbar = new QPEToolBar( this ); |
302 | 307 | ||
303 | QAction *a; | 308 | QAction *a; |
@@ -609,37 +614,42 @@ void Konsole::switchSession(QWidget* w) { | |||
609 | bool cf = fnt->getFont() == teFnt; | 614 | bool cf = fnt->getFont() == teFnt; |
610 | fontList->setItemChecked(i, cf); | 615 | fontList->setItemChecked(i, cf); |
611 | if (cf) { | 616 | if (cf) { |
612 | cfont = i; | 617 | cfont = i; |
613 | } | 618 | } |
614 | } | 619 | } |
615 | } | 620 | } |
616 | 621 | ||
622 | void Konsole::colorMenuIsSelected(int iD) { | ||
623 | fromMenu = TRUE; | ||
624 | colorMenuSelected(iD); | ||
625 | } | ||
626 | |||
617 | /// ------------------------------- some new stuff by L.J. Potter | 627 | /// ------------------------------- some new stuff by L.J. Potter |
618 | void Konsole::colorMenuSelected(int iD) | 628 | void Konsole::colorMenuSelected(int iD) |
619 | { // this is NOT pretty, elegant or anything else besides functional | 629 | { // this is NOT pretty, elegant or anything else besides functional |
620 | // QString temp; | 630 | // QString temp; |
621 | // qDebug( temp.sprintf("colormenu %d", iD)); | 631 | // qDebug( temp.sprintf("colormenu %d", iD)); |
622 | TEWidget* te = getTe(); | 632 | TEWidget* te = getTe(); |
623 | Config cfg("Konsole"); | 633 | Config cfg("Konsole"); |
624 | cfg.setGroup("Colors"); | 634 | cfg.setGroup("Colors"); |
625 | QColor foreground; | 635 | // QColor foreground; |
626 | QColor background; | 636 | // QColor background; |
627 | colorMenu->setItemChecked(lastSelectedMenu,FALSE); | 637 | colorMenu->setItemChecked(lastSelectedMenu,FALSE); |
628 | ColorEntry m_table[TABLE_COLORS]; | 638 | ColorEntry m_table[TABLE_COLORS]; |
629 | const ColorEntry * defaultCt=te->getdefaultColorTable(); | 639 | const ColorEntry * defaultCt=te->getdefaultColorTable(); |
630 | /////////// fore back | 640 | /////////// fore back |
631 | int i; | 641 | int i; |
632 | if(iD==-9) { // default default | 642 | if(iD==-9) { // default default |
633 | for (i = 0; i < TABLE_COLORS; i++) { | 643 | for (i = 0; i < TABLE_COLORS; i++) { |
634 | m_table[i].color = defaultCt[i].color; | 644 | m_table[i].color = defaultCt[i].color; |
635 | if(i==1 || i == 11) | 645 | if(i==1 || i == 11) |
636 | m_table[i].transparent=1; | 646 | m_table[i].transparent=1; |
637 | cfg.writeEntry("Schema","98"); | 647 | cfg.writeEntry("Schema","9"); |
638 | colorMenu->setItemChecked(-9,TRUE); | 648 | colorMenu->setItemChecked(-9,TRUE); |
639 | } | 649 | } |
640 | } else { | 650 | } else { |
641 | if(iD==-6) { // green black | 651 | if(iD==-6) { // green black |
642 | foreground.setRgb(0x18,255,0x18); | 652 | foreground.setRgb(0x18,255,0x18); |
643 | background.setRgb(0x00,0x00,0x00); | 653 | background.setRgb(0x00,0x00,0x00); |
644 | cfg.writeEntry("Schema","6"); | 654 | cfg.writeEntry("Schema","6"); |
645 | colorMenu->setItemChecked(-6,TRUE); | 655 | colorMenu->setItemChecked(-6,TRUE); |
@@ -707,31 +717,48 @@ void Konsole::colorMenuSelected(int iD) | |||
707 | colorMenu->setItemChecked(-17,TRUE); | 717 | colorMenu->setItemChecked(-17,TRUE); |
708 | } | 718 | } |
709 | if(iD==-18) {// Black, Gold | 719 | if(iD==-18) {// Black, Gold |
710 | background.setRgb(0x00,0x00,0x00); | 720 | background.setRgb(0x00,0x00,0x00); |
711 | foreground.setRgb(255,215,0); | 721 | foreground.setRgb(255,215,0); |
712 | cfg.writeEntry("Schema","18"); | 722 | cfg.writeEntry("Schema","18"); |
713 | colorMenu->setItemChecked(-18,TRUE); | 723 | colorMenu->setItemChecked(-18,TRUE); |
714 | } | 724 | } |
725 | if(iD==-19) {// Custom | ||
726 | qDebug("do custom"); | ||
727 | if(fromMenu) { | ||
728 | ColorPopupMenu* penColorPopupMenu = new ColorPopupMenu(Qt::black, this, "foreground color"); | ||
729 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, | ||
730 | SLOT(changeForegroundColor(const QColor&))); | ||
731 | penColorPopupMenu->exec(); | ||
732 | } | ||
733 | cfg.writeEntry("Schema","19"); | ||
734 | if(!fromMenu) { | ||
735 | foreground.setNamedColor(cfg.readEntry("foreground","")); | ||
736 | background.setNamedColor(cfg.readEntry("background","")); | ||
737 | } | ||
738 | fromMenu=FALSE; | ||
739 | colorMenu->setItemChecked(-19,TRUE); | ||
740 | } | ||
715 | 741 | ||
716 | for (i = 0; i < TABLE_COLORS; i++) { | 742 | for (i = 0; i < TABLE_COLORS; i++) { |
717 | if(i==0 || i == 10) { | 743 | if(i==0 || i == 10) { |
718 | m_table[i].color = foreground; | 744 | m_table[i].color = foreground; |
719 | } | 745 | } |
720 | else if(i==1 || i == 11) { | 746 | else if(i==1 || i == 11) { |
721 | m_table[i].color = background; m_table[i].transparent=0; | 747 | m_table[i].color = background; m_table[i].transparent=0; |
722 | } | 748 | } |
723 | else | 749 | else |
724 | m_table[i].color = defaultCt[i].color; | 750 | m_table[i].color = defaultCt[i].color; |
725 | } | 751 | } |
726 | } | 752 | } |
727 | lastSelectedMenu = iD; | 753 | lastSelectedMenu = iD; |
728 | te->setColorTable(m_table); | 754 | te->setColorTable(m_table); |
729 | update(); | 755 | update(); |
756 | |||
730 | } | 757 | } |
731 | 758 | ||
732 | void Konsole::configMenuSelected(int iD) | 759 | void Konsole::configMenuSelected(int iD) |
733 | { | 760 | { |
734 | // QString temp; | 761 | // QString temp; |
735 | // qDebug( temp.sprintf("configmenu %d",iD)); | 762 | // qDebug( temp.sprintf("configmenu %d",iD)); |
736 | TEWidget* te = getTe(); | 763 | TEWidget* te = getTe(); |
737 | Config cfg("Konsole"); | 764 | Config cfg("Konsole"); |
@@ -880,8 +907,41 @@ void Konsole::parseCommandLine() { | |||
880 | } | 907 | } |
881 | cmd.stripWhiteSpace(); | 908 | cmd.stripWhiteSpace(); |
882 | system(cmd.latin1()); | 909 | system(cmd.latin1()); |
883 | exit(0);//close(); | 910 | exit(0);//close(); |
884 | } // end -e switch | 911 | } // end -e switch |
885 | } | 912 | } |
886 | startUp++; | 913 | startUp++; |
887 | } | 914 | } |
915 | |||
916 | void Konsole::changeForegroundColor(const QColor &color) { | ||
917 | Config cfg("Konsole"); | ||
918 | cfg.setGroup("Colors"); | ||
919 | int r, g, b; | ||
920 | color.rgb(&r,&g,&b); | ||
921 | foreground.setRgb(r,g,b); | ||
922 | // QString colors; | ||
923 | // colors.sprintf("%d,%d,%d"color.red,color.green,color.blue); | ||
924 | cfg.writeEntry("foreground",color.name()); | ||
925 | cfg.write(); | ||
926 | |||
927 | qDebug("do other dialog"); | ||
928 | ColorPopupMenu* penColorPopupMenu2 = new ColorPopupMenu(Qt::black, this,"background color"); | ||
929 | connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, | ||
930 | SLOT(changeBackgroundColor(const QColor&))); | ||
931 | penColorPopupMenu2->exec(); | ||
932 | |||
933 | } | ||
934 | |||
935 | void Konsole::changeBackgroundColor(const QColor &color) { | ||
936 | |||
937 | qDebug("Change background"); | ||
938 | Config cfg("Konsole"); | ||
939 | cfg.setGroup("Colors"); | ||
940 | int r, g, b; | ||
941 | color.rgb(&r,&g,&b); | ||
942 | background.setRgb(r,g,b); | ||
943 | // QString colors; | ||
944 | // colors.sprintf("%d,%d,%d"color.red,color.green,color.blue); | ||
945 | cfg.writeEntry("background",color.name()); | ||
946 | cfg.write(); | ||
947 | } | ||
diff --git a/core/apps/embeddedkonsole/konsole.h b/core/apps/embeddedkonsole/konsole.h index 40edaec..0bf3fb3 100644 --- a/core/apps/embeddedkonsole/konsole.h +++ b/core/apps/embeddedkonsole/konsole.h | |||
@@ -27,16 +27,17 @@ | |||
27 | #include <qaction.h> | 27 | #include <qaction.h> |
28 | #include <qpopupmenu.h> | 28 | #include <qpopupmenu.h> |
29 | #include <qstrlist.h> | 29 | #include <qstrlist.h> |
30 | #include <qintdict.h> | 30 | #include <qintdict.h> |
31 | #include <qptrdict.h> | 31 | #include <qptrdict.h> |
32 | #include <qtabwidget.h> | 32 | #include <qtabwidget.h> |
33 | #include <qpe/qpetoolbar.h> | 33 | #include <qpe/qpetoolbar.h> |
34 | #include <qcombobox.h> | 34 | #include <qcombobox.h> |
35 | #include <qcolor.h> | ||
35 | 36 | ||
36 | #include "MyPty.h" | 37 | #include "MyPty.h" |
37 | #include "TEWidget.h" | 38 | #include "TEWidget.h" |
38 | #include "TEmuVt102.h" | 39 | #include "TEmuVt102.h" |
39 | #include "session.h" | 40 | #include "session.h" |
40 | 41 | ||
41 | class EKNumTabWidget; | 42 | class EKNumTabWidget; |
42 | 43 | ||
@@ -57,40 +58,45 @@ public: | |||
57 | int startUp; | 58 | int startUp; |
58 | private slots: | 59 | private slots: |
59 | void setDocument(const QString &); | 60 | void setDocument(const QString &); |
60 | void doneSession(TESession*,int); | 61 | void doneSession(TESession*,int); |
61 | void changeColumns(int); | 62 | void changeColumns(int); |
62 | void fontChanged(int); | 63 | void fontChanged(int); |
63 | void configMenuSelected(int ); | 64 | void configMenuSelected(int ); |
64 | void colorMenuSelected(int); | 65 | void colorMenuSelected(int); |
66 | void colorMenuIsSelected(int); | ||
65 | void enterCommand(int); | 67 | void enterCommand(int); |
66 | void hitEnter(); | 68 | void hitEnter(); |
67 | void hitSpace(); | 69 | void hitSpace(); |
68 | void hitTab(); | 70 | void hitTab(); |
69 | void hitPaste(); | 71 | void hitPaste(); |
70 | void hitUp(); | 72 | void hitUp(); |
71 | void hitDown(); | 73 | void hitDown(); |
72 | void switchSession(QWidget *); | 74 | void switchSession(QWidget *); |
73 | void newSession(); | 75 | void newSession(); |
74 | void changeCommand(const QString &, int); | 76 | void changeCommand(const QString &, int); |
75 | void initCommandList(); | 77 | void initCommandList(); |
76 | void scrollMenuSelected(int); | 78 | void scrollMenuSelected(int); |
77 | void editCommandListMenuSelected(int); | 79 | void editCommandListMenuSelected(int); |
78 | void parseCommandLine(); | 80 | void parseCommandLine(); |
81 | void changeForegroundColor(const QColor &); | ||
82 | void changeBackgroundColor(const QColor &); | ||
79 | private: | 83 | private: |
80 | void init(const char* _pgm, QStrList & _args); | 84 | void init(const char* _pgm, QStrList & _args); |
81 | void initSession(const char* _pgm, QStrList & _args); | 85 | void initSession(const char* _pgm, QStrList & _args); |
82 | void runSession(TESession* s); | 86 | void runSession(TESession* s); |
83 | void setColorPixmaps(); | 87 | void setColorPixmaps(); |
84 | void setHistory(bool); | 88 | void setHistory(bool); |
85 | QSize calcSize(int columns, int lines); | 89 | QSize calcSize(int columns, int lines); |
86 | TEWidget* getTe(); | 90 | TEWidget* getTe(); |
87 | QStringList commands; | 91 | QStringList commands; |
88 | 92 | QLabel * msgLabel; | |
93 | QColor foreground, background; | ||
94 | bool fromMenu; | ||
89 | private: | 95 | private: |
90 | class VTFont | 96 | class VTFont |
91 | { | 97 | { |
92 | public: | 98 | public: |
93 | VTFont(QString name, QFont& font) | 99 | VTFont(QString name, QFont& font) |
94 | { | 100 | { |
95 | this->name = name; | 101 | this->name = name; |
96 | this->font = font; | 102 | this->font = font; |