summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp34
1 files changed, 20 insertions, 14 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp
index 4480fe2..8885b58 100644
--- a/core/apps/embeddedkonsole/konsole.cpp
+++ b/core/apps/embeddedkonsole/konsole.cpp
@@ -489,559 +489,565 @@ void Konsole::hitTab()
489 te->emitText(QString("\t")); 489 te->emitText(QString("\t"));
490 } 490 }
491} 491}
492 492
493void Konsole::hitPaste() 493void Konsole::hitPaste()
494{ 494{
495 TEWidget* te = getTe(); 495 TEWidget* te = getTe();
496 if (te != 0) { 496 if (te != 0) {
497 te->pasteClipboard(); 497 te->pasteClipboard();
498 } 498 }
499} 499}
500 500
501void Konsole::hitUp() 501void Konsole::hitUp()
502{ 502{
503 TEWidget* te = getTe(); 503 TEWidget* te = getTe();
504 if (te != 0) { 504 if (te != 0) {
505 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); 505 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0);
506 QApplication::sendEvent( te, &ke ); 506 QApplication::sendEvent( te, &ke );
507 } 507 }
508} 508}
509 509
510void Konsole::hitDown() 510void Konsole::hitDown()
511{ 511{
512 TEWidget* te = getTe(); 512 TEWidget* te = getTe();
513 if (te != 0) { 513 if (te != 0) {
514 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); 514 QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0);
515 QApplication::sendEvent( te, &ke ); 515 QApplication::sendEvent( te, &ke );
516 } 516 }
517} 517}
518 518
519/** 519/**
520 This function calculates the size of the external widget 520 This function calculates the size of the external widget
521 needed for the internal widget to be 521 needed for the internal widget to be
522 */ 522 */
523QSize Konsole::calcSize(int columns, int lines) { 523QSize Konsole::calcSize(int columns, int lines) {
524 TEWidget* te = getTe(); 524 TEWidget* te = getTe();
525 if (te != 0) { 525 if (te != 0) {
526 QSize size = te->calcSize(columns, lines); 526 QSize size = te->calcSize(columns, lines);
527 return size; 527 return size;
528 } else { 528 } else {
529 QSize size; 529 QSize size;
530 return size; 530 return size;
531 } 531 }
532} 532}
533 533
534/** 534/**
535 sets application window to a size based on columns X lines of the te 535 sets application window to a size based on columns X lines of the te
536 guest widget. Call with (0,0) for setting default size. 536 guest widget. Call with (0,0) for setting default size.
537*/ 537*/
538 538
539void Konsole::setColLin(int columns, int lines) 539void Konsole::setColLin(int columns, int lines)
540{ 540{
541 qDebug("konsole::setColLin:: Columns %d", columns); 541 qDebug("konsole::setColLin:: Columns %d", columns);
542 542
543 if ((columns==0) || (lines==0)) 543 if ((columns==0) || (lines==0))
544 { 544 {
545 if (defaultSize.isEmpty()) // not in config file : set default value 545 if (defaultSize.isEmpty()) // not in config file : set default value
546 { 546 {
547 defaultSize = calcSize(80,24); 547 defaultSize = calcSize(80,24);
548 // notifySize(24,80); // set menu items (strange arg order !) 548 // notifySize(24,80); // set menu items (strange arg order !)
549 } 549 }
550 resize(defaultSize); 550 resize(defaultSize);
551 } else { 551 } else {
552 resize(calcSize(columns, lines)); 552 resize(calcSize(columns, lines));
553 // notifySize(lines,columns); // set menu items (strange arg order !) 553 // notifySize(lines,columns); // set menu items (strange arg order !)
554 } 554 }
555} 555}
556 556
557/* 557/*
558void Konsole::setFont(int fontno) 558void Konsole::setFont(int fontno)
559{ 559{
560 QFont f; 560 QFont f;
561 if (fontno == 0) 561 if (fontno == 0)
562 f = defaultFont = QFont( "Helvetica", 12 ); 562 f = defaultFont = QFont( "Helvetica", 12 );
563 else 563 else
564 if (fonts[fontno][0] == '-') 564 if (fonts[fontno][0] == '-')
565 f.setRawName( fonts[fontno] ); 565 f.setRawName( fonts[fontno] );
566 else 566 else
567 { 567 {
568 f.setFamily(fonts[fontno]); 568 f.setFamily(fonts[fontno]);
569 f.setRawMode( TRUE ); 569 f.setRawMode( TRUE );
570 } 570 }
571 if ( !f.exactMatch() && fontno != 0) 571 if ( !f.exactMatch() && fontno != 0)
572 { 572 {
573 QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); 573 QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]);
574 QMessageBox(this, msg); 574 QMessageBox(this, msg);
575 return; 575 return;
576 } 576 }
577 if (se) se->setFontNo(fontno); 577 if (se) se->setFontNo(fontno);
578 te->setVTFont(f); 578 te->setVTFont(f);
579 n_font = fontno; 579 n_font = fontno;
580} 580}
581*/ 581*/
582 582
583// --| color selection |------------------------------------------------------- 583// --| color selection |-------------------------------------------------------
584 584
585void Konsole::changeColumns(int columns) 585void Konsole::changeColumns(int columns)
586{ 586{
587 qDebug("change columns"); 587 qDebug("change columns");
588 TEWidget* te = getTe(); 588 TEWidget* te = getTe();
589 if (te != 0) { 589 if (te != 0) {
590 setColLin(columns,te->Lines()); 590 setColLin(columns,te->Lines());
591 te->update(); 591 te->update();
592 } 592 }
593} 593}
594 594
595//FIXME: If a child dies during session swap, 595//FIXME: If a child dies during session swap,
596// this routine might be called before 596// this routine might be called before
597// session swap is completed. 597// session swap is completed.
598 598
599void Konsole::doneSession(TESession*, int ) 599void Konsole::doneSession(TESession*, int )
600{ 600{
601 TEWidget *te = getTe(); 601 TEWidget *te = getTe();
602 if (te != 0) { 602 if (te != 0) {
603 te->currentSession->setConnect(FALSE); 603 te->currentSession->setConnect(FALSE);
604 tab->removeTab(te); 604 tab->removeTab(te);
605 delete te->currentSession; 605 delete te->currentSession;
606 delete te; 606 delete te;
607 nsessions--; 607 nsessions--;
608 } 608 }
609 609
610 if (nsessions == 0) { 610 if (nsessions == 0) {
611 close(); 611 close();
612 } 612 }
613} 613}
614 614
615void Konsole::newSession() { 615void Konsole::newSession() {
616 if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory? 616 if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory?
617 TEWidget* te = new TEWidget(tab); 617 TEWidget* te = new TEWidget(tab);
618// te->setBackgroundMode(PaletteBase); //we want transparent!! 618// te->setBackgroundMode(PaletteBase); //we want transparent!!
619 te->setVTFont(fonts.at(cfont)->getFont()); 619 te->setVTFont(fonts.at(cfont)->getFont());
620 tab->addTab(te); 620 tab->addTab(te);
621 TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); 621 TESession* se = new TESession(this, te, se_pgm, se_args, "xterm");
622 te->currentSession = se; 622 te->currentSession = se;
623 connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) ); 623 connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) );
624 se->run(); 624 se->run();
625 se->setConnect(TRUE); 625 se->setConnect(TRUE);
626 se->setHistory(b_scroll); 626 se->setHistory(b_scroll);
627 tab->setCurrentPage(nsessions); 627 tab->setCurrentPage(nsessions);
628 nsessions++; 628 nsessions++;
629 doWrap(); 629 doWrap();
630 setColor(); 630 setColor();
631 } 631 }
632} 632}
633 633
634TEWidget* Konsole::getTe() { 634TEWidget* Konsole::getTe() {
635 if (nsessions) { 635 if (nsessions) {
636 return (TEWidget *) tab->currentPage(); 636 return (TEWidget *) tab->currentPage();
637 } else { 637 } else {
638 return 0; 638 return 0;
639 } 639 }
640} 640}
641 641
642void Konsole::switchSession(QWidget* w) { 642void Konsole::switchSession(QWidget* w) {
643 TEWidget* te = (TEWidget *) w; 643 TEWidget* te = (TEWidget *) w;
644 644
645 QFont teFnt = te->getVTFont(); 645 QFont teFnt = te->getVTFont();
646 for(uint i = 0; i < fonts.count(); i++) { 646 for(uint i = 0; i < fonts.count(); i++) {
647 VTFont *fnt = fonts.at(i); 647 VTFont *fnt = fonts.at(i);
648 bool cf = fnt->getFont() == teFnt; 648 bool cf = fnt->getFont() == teFnt;
649 fontList->setItemChecked(i, cf); 649 fontList->setItemChecked(i, cf);
650 if (cf) { 650 if (cf) {
651 cfont = i; 651 cfont = i;
652 } 652 }
653 } 653 }
654} 654}
655 655
656void Konsole::colorMenuIsSelected(int iD) { 656void Konsole::colorMenuIsSelected(int iD) {
657 fromMenu = TRUE; 657 fromMenu = TRUE;
658 colorMenuSelected(iD); 658 colorMenuSelected(iD);
659} 659}
660 660
661/// ------------------------------- some new stuff by L.J. Potter 661/// ------------------------------- some new stuff by L.J. Potter
662void Konsole::colorMenuSelected(int iD) 662void Konsole::colorMenuSelected(int iD)
663{ // this is NOT pretty, elegant or anything else besides functional 663{ // this is NOT pretty, elegant or anything else besides functional
664// QString temp; 664// QString temp;
665// qDebug( temp.sprintf("colormenu %d", iD)); 665// qDebug( temp.sprintf("colormenu %d", iD));
666 TEWidget* te = getTe(); 666 TEWidget* te = getTe();
667 Config cfg("Konsole"); 667 Config cfg("Konsole");
668 cfg.setGroup("Colors"); 668 cfg.setGroup("Colors");
669// QColor foreground; 669// QColor foreground;
670// QColor background; 670// QColor background;
671 colorMenu->setItemChecked(lastSelectedMenu,FALSE); 671 colorMenu->setItemChecked(lastSelectedMenu,FALSE);
672 ColorEntry m_table[TABLE_COLORS]; 672 ColorEntry m_table[TABLE_COLORS];
673 const ColorEntry * defaultCt=te->getdefaultColorTable(); 673 const ColorEntry * defaultCt=te->getdefaultColorTable();
674 /////////// fore back 674 /////////// fore back
675 int i; 675 int i;
676 if(iD==-9) { // default default 676 if(iD==-9) { // default default
677 for (i = 0; i < TABLE_COLORS; i++) { 677 for (i = 0; i < TABLE_COLORS; i++) {
678 m_table[i].color = defaultCt[i].color; 678 m_table[i].color = defaultCt[i].color;
679 if(i==1 || i == 11) 679 if(i==1 || i == 11)
680 m_table[i].transparent=1; 680 m_table[i].transparent=1;
681 cfg.writeEntry("Schema","9"); 681 cfg.writeEntry("Schema","9");
682 colorMenu->setItemChecked(-9,TRUE); 682 colorMenu->setItemChecked(-9,TRUE);
683 } 683 }
684 } else { 684 } else {
685 if(iD==-6) { // green black 685 if(iD==-6) { // green black
686 foreground.setRgb(0x18,255,0x18); 686 foreground.setRgb(0x18,255,0x18);
687 background.setRgb(0x00,0x00,0x00); 687 background.setRgb(0x00,0x00,0x00);
688 cfg.writeEntry("Schema","6"); 688 cfg.writeEntry("Schema","6");
689 colorMenu->setItemChecked(-6,TRUE); 689 colorMenu->setItemChecked(-6,TRUE);
690 } 690 }
691 if(iD==-7) { // black white 691 if(iD==-7) { // black white
692 foreground.setRgb(0x00,0x00,0x00); 692 foreground.setRgb(0x00,0x00,0x00);
693 background.setRgb(0xFF,0xFF,0xFF); 693 background.setRgb(0xFF,0xFF,0xFF);
694 cfg.writeEntry("Schema","7"); 694 cfg.writeEntry("Schema","7");
695 colorMenu->setItemChecked(-7,TRUE); 695 colorMenu->setItemChecked(-7,TRUE);
696 } 696 }
697 if(iD==-8) { // white black 697 if(iD==-8) { // white black
698 foreground.setRgb(0xFF,0xFF,0xFF); 698 foreground.setRgb(0xFF,0xFF,0xFF);
699 background.setRgb(0x00,0x00,0x00); 699 background.setRgb(0x00,0x00,0x00);
700 cfg.writeEntry("Schema","8"); 700 cfg.writeEntry("Schema","8");
701 colorMenu->setItemChecked(-8,TRUE); 701 colorMenu->setItemChecked(-8,TRUE);
702 } 702 }
703 if(iD==-10) {// Black, Red 703 if(iD==-10) {// Black, Red
704 foreground.setRgb(0x00,0x00,0x00); 704 foreground.setRgb(0x00,0x00,0x00);
705 background.setRgb(0xB2,0x18,0x18); 705 background.setRgb(0xB2,0x18,0x18);
706 cfg.writeEntry("Schema","10"); 706 cfg.writeEntry("Schema","10");
707 colorMenu->setItemChecked(-10,TRUE); 707 colorMenu->setItemChecked(-10,TRUE);
708 } 708 }
709 if(iD==-11) {// Red, Black 709 if(iD==-11) {// Red, Black
710 foreground.setRgb(230,31,31); //0xB2,0x18,0x18 710 foreground.setRgb(230,31,31); //0xB2,0x18,0x18
711 background.setRgb(0x00,0x00,0x00); 711 background.setRgb(0x00,0x00,0x00);
712 cfg.writeEntry("Schema","11"); 712 cfg.writeEntry("Schema","11");
713 colorMenu->setItemChecked(-11,TRUE); 713 colorMenu->setItemChecked(-11,TRUE);
714 } 714 }
715 if(iD==-12) {// Green, Yellow - is ugly 715 if(iD==-12) {// Green, Yellow - is ugly
716// foreground.setRgb(0x18,0xB2,0x18); 716// foreground.setRgb(0x18,0xB2,0x18);
717 foreground.setRgb(36,139,10); 717 foreground.setRgb(36,139,10);
718// background.setRgb(0xB2,0x68,0x18); 718// background.setRgb(0xB2,0x68,0x18);
719 background.setRgb(255,255,0); 719 background.setRgb(255,255,0);
720 cfg.writeEntry("Schema","12"); 720 cfg.writeEntry("Schema","12");
721 colorMenu->setItemChecked(-12,TRUE); 721 colorMenu->setItemChecked(-12,TRUE);
722 } 722 }
723 if(iD==-13) {// Blue, Magenta 723 if(iD==-13) {// Blue, Magenta
724 foreground.setRgb(0x18,0xB2,0xB2); 724 foreground.setRgb(0x18,0xB2,0xB2);
725 background.setRgb(0x18,0x18,0xB2); 725 background.setRgb(0x18,0x18,0xB2);
726 cfg.writeEntry("Schema","13"); 726 cfg.writeEntry("Schema","13");
727 colorMenu->setItemChecked(-13,TRUE); 727 colorMenu->setItemChecked(-13,TRUE);
728 } 728 }
729 if(iD==-14) {// Magenta, Blue 729 if(iD==-14) {// Magenta, Blue
730 foreground.setRgb(0x18,0x18,0xB2); 730 foreground.setRgb(0x18,0x18,0xB2);
731 background.setRgb(0x18,0xB2,0xB2); 731 background.setRgb(0x18,0xB2,0xB2);
732 cfg.writeEntry("Schema","14"); 732 cfg.writeEntry("Schema","14");
733 colorMenu->setItemChecked(-14,TRUE); 733 colorMenu->setItemChecked(-14,TRUE);
734 } 734 }
735 if(iD==-15) {// Cyan, White 735 if(iD==-15) {// Cyan, White
736 foreground.setRgb(0x18,0xB2,0xB2); 736 foreground.setRgb(0x18,0xB2,0xB2);
737 background.setRgb(0xFF,0xFF,0xFF); 737 background.setRgb(0xFF,0xFF,0xFF);
738 cfg.writeEntry("Schema","15"); 738 cfg.writeEntry("Schema","15");
739 colorMenu->setItemChecked(-15,TRUE); 739 colorMenu->setItemChecked(-15,TRUE);
740 } 740 }
741 if(iD==-16) {// White, Cyan 741 if(iD==-16) {// White, Cyan
742 background.setRgb(0x18,0xB2,0xB2); 742 background.setRgb(0x18,0xB2,0xB2);
743 foreground.setRgb(0xFF,0xFF,0xFF); 743 foreground.setRgb(0xFF,0xFF,0xFF);
744 cfg.writeEntry("Schema","16"); 744 cfg.writeEntry("Schema","16");
745 colorMenu->setItemChecked(-16,TRUE); 745 colorMenu->setItemChecked(-16,TRUE);
746 } 746 }
747 if(iD==-17) {// Black, Blue 747 if(iD==-17) {// Black, Blue
748 background.setRgb(0x00,0x00,0x00); 748 background.setRgb(0x00,0x00,0x00);
749 foreground.setRgb(0x18,0xB2,0xB2); 749 foreground.setRgb(0x18,0xB2,0xB2);
750 cfg.writeEntry("Schema","17"); 750 cfg.writeEntry("Schema","17");
751 colorMenu->setItemChecked(-17,TRUE); 751 colorMenu->setItemChecked(-17,TRUE);
752 } 752 }
753 if(iD==-18) {// Black, Gold 753 if(iD==-18) {// Black, Gold
754 background.setRgb(0x00,0x00,0x00); 754 background.setRgb(0x00,0x00,0x00);
755 foreground.setRgb(255,215,0); 755 foreground.setRgb(255,215,0);
756 cfg.writeEntry("Schema","18"); 756 cfg.writeEntry("Schema","18");
757 colorMenu->setItemChecked(-18,TRUE); 757 colorMenu->setItemChecked(-18,TRUE);
758 } 758 }
759#ifdef QT_QWS_OPIE 759#ifdef QT_QWS_OPIE
760 if(iD==-19) { 760 if(iD==-19) {
761// Custom 761// Custom
762 qDebug("do custom"); 762 qDebug("do custom");
763 if(fromMenu) { 763 if(fromMenu) {
764 ColorPopupMenu* penColorPopupMenu = new ColorPopupMenu(Qt::black, this, "foreground color"); 764 ColorPopupMenu* penColorPopupMenu = new ColorPopupMenu(Qt::black, this, "foreground color");
765 connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, 765 connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this,
766 SLOT(changeForegroundColor(const QColor&))); 766 SLOT(changeForegroundColor(const QColor&)));
767 penColorPopupMenu->exec(); 767 penColorPopupMenu->exec();
768 } 768 }
769 cfg.writeEntry("Schema","19"); 769 cfg.writeEntry("Schema","19");
770 if(!fromMenu) { 770 if(!fromMenu) {
771 foreground.setNamedColor(cfg.readEntry("foreground","")); 771 foreground.setNamedColor(cfg.readEntry("foreground",""));
772 background.setNamedColor(cfg.readEntry("background","")); 772 background.setNamedColor(cfg.readEntry("background",""));
773 } 773 }
774 fromMenu=FALSE; 774 fromMenu=FALSE;
775 colorMenu->setItemChecked(-19,TRUE); 775 colorMenu->setItemChecked(-19,TRUE);
776 } 776 }
777#endif 777#endif
778 for (i = 0; i < TABLE_COLORS; i++) { 778 for (i = 0; i < TABLE_COLORS; i++) {
779 if(i==0 || i == 10) { 779 if(i==0 || i == 10) {
780 m_table[i].color = foreground; 780 m_table[i].color = foreground;
781 } 781 }
782 else if(i==1 || i == 11) { 782 else if(i==1 || i == 11) {
783 m_table[i].color = background; m_table[i].transparent=0; 783 m_table[i].color = background; m_table[i].transparent=0;
784 } 784 }
785 else 785 else
786 m_table[i].color = defaultCt[i].color; 786 m_table[i].color = defaultCt[i].color;
787 } 787 }
788 } 788 }
789 lastSelectedMenu = iD; 789 lastSelectedMenu = iD;
790 te->setColorTable(m_table); 790 te->setColorTable(m_table);
791 update(); 791 update();
792 792
793} 793}
794 794
795void Konsole::configMenuSelected(int iD) 795void Konsole::configMenuSelected(int iD)
796{ 796{
797// QString temp; 797// QString temp;
798// qDebug( temp.sprintf("configmenu %d",iD)); 798// qDebug( temp.sprintf("configmenu %d",iD));
799 TEWidget* te = getTe(); 799 TEWidget* te = getTe();
800 Config cfg("Konsole"); 800 Config cfg("Konsole");
801 cfg.setGroup("Menubar"); 801 cfg.setGroup("Menubar");
802 int i,j; 802 int i,j;
803#ifdef QT_QWS_OPIE 803#ifdef QT_QWS_OPIE
804 i=-29;j=-30; 804 i=-29;j=-30;
805#else 805#else
806 i=-28;j=-29; 806 i=-28;j=-29;
807#endif 807#endif
808 808
809 if(iD == -4) { 809 if(iD == -4) {
810 cfg.setGroup("Tabs"); 810 cfg.setGroup("Tabs");
811 QString tmp=cfg.readEntry("Position","Bottom"); 811 QString tmp=cfg.readEntry("Position","Bottom");
812 812
813 if(tmp=="Top") { 813 if(tmp=="Top") {
814 tab->setTabPosition(QTabWidget::Bottom); 814 tab->setTabPosition(QTabWidget::Bottom);
815 configMenu->changeItem( iD,"Tabs on Top"); 815 configMenu->changeItem( iD,"Tabs on Top");
816 cfg.writeEntry("Position","Bottom"); 816 cfg.writeEntry("Position","Bottom");
817 } else { 817 } else {
818 tab->setTabPosition(QTabWidget::Top); 818 tab->setTabPosition(QTabWidget::Top);
819 configMenu->changeItem( iD,"Tabs on Bottom"); 819 configMenu->changeItem( iD,"Tabs on Bottom");
820 cfg.writeEntry("Position","Top"); 820 cfg.writeEntry("Position","Top");
821 } 821 }
822 } 822 }
823 if(iD == i) { 823 if(iD == i) {
824 cfg.setGroup("ScrollBar"); 824 cfg.setGroup("ScrollBar");
825 bool b=cfg.readBoolEntry("HorzScroll",0); 825 bool b=cfg.readBoolEntry("HorzScroll",0);
826 b=!b; 826 b=!b;
827 cfg.writeEntry("HorzScroll", b ); 827 cfg.writeEntry("HorzScroll", b );
828 cfg.write(); 828 cfg.write();
829 doWrap(); 829 doWrap();
830 if(cfg.readNumEntry("Position",2) == 0) { 830 if(cfg.readNumEntry("Position",2) == 0) {
831 te->setScrollbarLocation(1); 831 te->setScrollbarLocation(1);
832 } else { 832 } else {
833 te->setScrollbarLocation(0); 833 te->setScrollbarLocation(0);
834 } 834 }
835 te->setScrollbarLocation( cfg.readNumEntry("Position",2)); 835 te->setScrollbarLocation( cfg.readNumEntry("Position",2));
836 } 836 }
837 if(iD == j) { 837 if(iD == j) {
838 cfg.setGroup("Menubar"); 838 cfg.setGroup("Menubar");
839 bool b=cfg.readBoolEntry("useBeep",0); 839 bool b=cfg.readBoolEntry("useBeep",0);
840 b=!b; 840 b=!b;
841 cfg.writeEntry("useBeep", b ); 841 cfg.writeEntry("useBeep", b );
842 cfg.write(); 842 cfg.write();
843 configMenu->setItemChecked(j,b); 843 configMenu->setItemChecked(j,b);
844 te->useBeep=b; 844 te->useBeep=b;
845 } 845 }
846} 846}
847 847
848void Konsole::changeCommand(const QString &text, int c) 848void Konsole::changeCommand(const QString &text, int c)
849{ 849{
850 Config cfg("Konsole"); 850 Config cfg("Konsole");
851 cfg.setGroup("Commands"); 851 cfg.setGroup("Commands");
852 if(commonCmds[c] != text) { 852 if(commonCmds[c] != text) {
853 cfg.writeEntry(QString::number(c),text); 853 cfg.writeEntry(QString::number(c),text);
854 commonCombo->clearEdit(); 854 commonCombo->clearEdit();
855 commonCombo->setCurrentItem(c); 855 commonCombo->setCurrentItem(c);
856 } 856 }
857} 857}
858 858
859void Konsole::setColor() 859void Konsole::setColor()
860{ 860{
861 Config cfg("Konsole"); 861 Config cfg("Konsole");
862 cfg.setGroup("Colors"); 862 cfg.setGroup("Colors");
863 int scheme = cfg.readNumEntry("Schema",1); 863 int scheme = cfg.readNumEntry("Schema",1);
864 if(scheme != 1) colorMenuSelected( -scheme); 864 if(scheme != 1) colorMenuSelected( -scheme);
865} 865}
866 866
867void Konsole::scrollMenuSelected(int index) 867void Konsole::scrollMenuSelected(int index)
868{ 868{
869 qDebug( "scrollbar menu %d",index); 869 qDebug( "scrollbar menu %d",index);
870 TEWidget* te = getTe(); 870 TEWidget* te = getTe();
871 Config cfg("Konsole"); 871 Config cfg("Konsole");
872 cfg.setGroup("ScrollBar"); 872 cfg.setGroup("ScrollBar");
873 switch( index){ 873 int i,j,k;
874 case -25: 874#ifdef QT_QWS_OPIE
875 te->setScrollbarLocation(0); 875i=-25;j=-26;k=-27;
876 cfg.writeEntry("Position",0); 876#else
877 break; 877i=-24;j=-25;k=-26;
878 case -26: 878#endif
879 te->setScrollbarLocation(1); 879 if(index == i) {
880 cfg.writeEntry("Position",1); 880
881 break; 881 te->setScrollbarLocation(0);
882 case -27: 882 cfg.writeEntry("Position",0);
883 te->setScrollbarLocation(2); 883 } else if(index == j) {
884 cfg.writeEntry("Position",2); 884
885 break; 885 te->setScrollbarLocation(1);
886 cfg.writeEntry("Position",1);
887 } else if(index == k) {
888
889 te->setScrollbarLocation(2);
890 cfg.writeEntry("Position",2);
891 }
892
886// case -29: { 893// case -29: {
887// bool b=cfg.readBoolEntry("HorzScroll",0); 894// bool b=cfg.readBoolEntry("HorzScroll",0);
888// cfg.writeEntry("HorzScroll", !b ); 895// cfg.writeEntry("HorzScroll", !b );
889// cfg.write(); 896// cfg.write();
890// if(cfg.readNumEntry("Position",2) == 0) { 897// if(cfg.readNumEntry("Position",2) == 0) {
891// te->setScrollbarLocation(1); 898// te->setScrollbarLocation(1);
892// te->setWrapAt(0); 899// te->setWrapAt(0);
893// } else { 900// } else {
894// te->setScrollbarLocation(0); 901// te->setScrollbarLocation(0);
895// te->setWrapAt(120); 902// te->setWrapAt(120);
896// } 903// }
897// te->setScrollbarLocation( cfg.readNumEntry("Position",2)); 904// te->setScrollbarLocation( cfg.readNumEntry("Position",2));
898// } 905// }
899// break; 906// break;
900 };
901} 907}
902 908
903void Konsole::editCommandListMenuSelected(int iD) 909void Konsole::editCommandListMenuSelected(int iD)
904{ 910{
905// QString temp; 911// QString temp;
906// qDebug( temp.sprintf("edit command list %d",iD)); 912// qDebug( temp.sprintf("edit command list %d",iD));
907 TEWidget* te = getTe(); 913 TEWidget* te = getTe();
908 Config cfg("Konsole"); 914 Config cfg("Konsole");
909 cfg.setGroup("Menubar"); 915 cfg.setGroup("Menubar");
910 if( iD == -3) { 916 if( iD == -3) {
911 if(!secondToolBar->isHidden()) { 917 if(!secondToolBar->isHidden()) {
912 secondToolBar->hide(); 918 secondToolBar->hide();
913 configMenu->changeItem( iD,tr( "Show Command List" )); 919 configMenu->changeItem( iD,tr( "Show Command List" ));
914 cfg.writeEntry("Hidden","TRUE"); 920 cfg.writeEntry("Hidden","TRUE");
915 configMenu->setItemEnabled(-23 ,FALSE); 921 configMenu->setItemEnabled(-23 ,FALSE);
916 } else { 922 } else {
917 secondToolBar->show(); 923 secondToolBar->show();
918 configMenu->changeItem( iD,tr( "Hide Command List" )); 924 configMenu->changeItem( iD,tr( "Hide Command List" ));
919 cfg.writeEntry("Hidden","FALSE"); 925 cfg.writeEntry("Hidden","FALSE");
920 configMenu->setItemEnabled(-23 ,TRUE); 926 configMenu->setItemEnabled(-23 ,TRUE);
921 927
922 if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") { 928 if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") {
923 configMenu->setItemChecked(-23,TRUE); 929 configMenu->setItemChecked(-23,TRUE);
924 commonCombo->setEditable( TRUE ); 930 commonCombo->setEditable( TRUE );
925 } else { 931 } else {
926 configMenu->setItemChecked(-23,FALSE); 932 configMenu->setItemChecked(-23,FALSE);
927 commonCombo->setEditable( FALSE ); 933 commonCombo->setEditable( FALSE );
928 } 934 }
929 } 935 }
930 } 936 }
931 if( iD == -23) { 937 if( iD == -23) {
932 cfg.setGroup("Commands"); 938 cfg.setGroup("Commands");
933// qDebug("enableCommandEdit"); 939// qDebug("enableCommandEdit");
934 if( !configMenu->isItemChecked(iD) ) { 940 if( !configMenu->isItemChecked(iD) ) {
935 commonCombo->setEditable( TRUE ); 941 commonCombo->setEditable( TRUE );
936 configMenu->setItemChecked(iD,TRUE); 942 configMenu->setItemChecked(iD,TRUE);
937 commonCombo->setCurrentItem(0); 943 commonCombo->setCurrentItem(0);
938 cfg.writeEntry("EditEnabled","TRUE"); 944 cfg.writeEntry("EditEnabled","TRUE");
939 } else { 945 } else {
940 commonCombo->setEditable( FALSE ); 946 commonCombo->setEditable( FALSE );
941 configMenu->setItemChecked(iD,FALSE); 947 configMenu->setItemChecked(iD,FALSE);
942 cfg.writeEntry("EditEnabled","FALSE"); 948 cfg.writeEntry("EditEnabled","FALSE");
943 commonCombo->setFocusPolicy(QWidget::NoFocus); 949 commonCombo->setFocusPolicy(QWidget::NoFocus);
944 te->setFocus(); 950 te->setFocus();
945 } 951 }
946 } 952 }
947 if(iD == -24) { 953 if(iD == -24) {
948 // "edit commands" 954 // "edit commands"
949 CommandEditDialog *m = new CommandEditDialog(this); 955 CommandEditDialog *m = new CommandEditDialog(this);
950 connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); 956 connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList()));
951 m->showMaximized(); 957 m->showMaximized();
952 } 958 }
953 959
954} 960}
955 961
956// $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V' 962// $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V'
957void Konsole::setDocument( const QString &cmd) { 963void Konsole::setDocument( const QString &cmd) {
958 newSession(); 964 newSession();
959 TEWidget* te = getTe(); 965 TEWidget* te = getTe();
960 if(cmd.find("-e", 0, TRUE) != -1) { 966 if(cmd.find("-e", 0, TRUE) != -1) {
961 QString cmd2; 967 QString cmd2;
962 cmd2=cmd.right(cmd.length()-3)+" &"; 968 cmd2=cmd.right(cmd.length()-3)+" &";
963 system(cmd2.latin1()); 969 system(cmd2.latin1());
964 if(startUp <= 1 && nsessions < 2) { 970 if(startUp <= 1 && nsessions < 2) {
965 doneSession(getTe()->currentSession, 0); 971 doneSession(getTe()->currentSession, 0);
966 exit(0); 972 exit(0);
967 } else 973 } else
968 doneSession(getTe()->currentSession, 0); 974 doneSession(getTe()->currentSession, 0);
969 } else { 975 } else {
970 if (te != 0) { 976 if (te != 0) {
971 te->emitText(cmd+"\r"); 977 te->emitText(cmd+"\r");
972 } 978 }
973 } 979 }
974 startUp++; 980 startUp++;
975} 981}
976 982
977void Konsole::parseCommandLine() { 983void Konsole::parseCommandLine() {
978 QString cmd; 984 QString cmd;
979 // newSession(); 985 // newSession();
980 for (int i=1;i< qApp->argc();i++) { 986 for (int i=1;i< qApp->argc();i++) {
981 if( QString(qApp->argv()[i]) == "-e") { 987 if( QString(qApp->argv()[i]) == "-e") {
982 i++; 988 i++;
983 for ( int j=i;j< qApp->argc();j++) { 989 for ( int j=i;j< qApp->argc();j++) {
984 cmd+=QString(qApp->argv()[j])+" "; 990 cmd+=QString(qApp->argv()[j])+" ";
985 } 991 }
986 cmd.stripWhiteSpace(); 992 cmd.stripWhiteSpace();
987 system(cmd.latin1()); 993 system(cmd.latin1());
988 exit(0);//close(); 994 exit(0);//close();
989 } // end -e switch 995 } // end -e switch
990 } 996 }
991 startUp++; 997 startUp++;
992} 998}
993 999
994void Konsole::changeForegroundColor(const QColor &color) { 1000void Konsole::changeForegroundColor(const QColor &color) {
995 Config cfg("Konsole"); 1001 Config cfg("Konsole");
996 cfg.setGroup("Colors"); 1002 cfg.setGroup("Colors");
997 int r, g, b; 1003 int r, g, b;
998 color.rgb(&r,&g,&b); 1004 color.rgb(&r,&g,&b);
999 foreground.setRgb(r,g,b); 1005 foreground.setRgb(r,g,b);
1000 1006
1001 cfg.writeEntry("foreground",color.name()); 1007 cfg.writeEntry("foreground",color.name());
1002 qDebug("foreground "+color.name()); 1008 qDebug("foreground "+color.name());
1003 cfg.write(); 1009 cfg.write();
1004 1010
1005qDebug("do other dialog"); 1011qDebug("do other dialog");
1006#ifdef QT_QWS_OPIE 1012#ifdef QT_QWS_OPIE
1007 1013
1008 ColorPopupMenu* penColorPopupMenu2 = new ColorPopupMenu(Qt::black, this,"background color"); 1014 ColorPopupMenu* penColorPopupMenu2 = new ColorPopupMenu(Qt::black, this,"background color");
1009 connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, 1015 connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this,
1010 SLOT(changeBackgroundColor(const QColor&))); 1016 SLOT(changeBackgroundColor(const QColor&)));
1011 penColorPopupMenu2->exec(); 1017 penColorPopupMenu2->exec();
1012#endif 1018#endif
1013} 1019}
1014 1020
1015void Konsole::changeBackgroundColor(const QColor &color) { 1021void Konsole::changeBackgroundColor(const QColor &color) {
1016 1022
1017 qDebug("Change background"); 1023 qDebug("Change background");
1018 Config cfg("Konsole"); 1024 Config cfg("Konsole");
1019 cfg.setGroup("Colors"); 1025 cfg.setGroup("Colors");
1020 int r, g, b; 1026 int r, g, b;
1021 color.rgb(&r,&g,&b); 1027 color.rgb(&r,&g,&b);
1022 background.setRgb(r,g,b); 1028 background.setRgb(r,g,b);
1023 cfg.writeEntry("background",color.name()); 1029 cfg.writeEntry("background",color.name());
1024 qDebug("background "+color.name()); 1030 qDebug("background "+color.name());
1025 cfg.write(); 1031 cfg.write();
1026} 1032}
1027 1033
1028void Konsole::doWrap() { 1034void Konsole::doWrap() {
1029int i; 1035int i;
1030#ifdef QT_QWS_OPIE 1036#ifdef QT_QWS_OPIE
1031i=-29; 1037i=-29;
1032#else 1038#else
1033i=-28; 1039i=-28;
1034#endif 1040#endif
1035 1041
1036 Config cfg("Konsole"); 1042 Config cfg("Konsole");
1037 cfg.setGroup("ScrollBar"); 1043 cfg.setGroup("ScrollBar");
1038 TEWidget* te = getTe(); 1044 TEWidget* te = getTe();
1039 if( !cfg.readBoolEntry("HorzScroll",0)) { 1045 if( !cfg.readBoolEntry("HorzScroll",0)) {
1040 te->setWrapAt(0); 1046 te->setWrapAt(0);
1041 configMenu->setItemChecked( i,TRUE); 1047 configMenu->setItemChecked( i,TRUE);
1042 } else { 1048 } else {
1043// te->setWrapAt(90); 1049// te->setWrapAt(90);
1044 te->setWrapAt(120); 1050 te->setWrapAt(120);
1045 configMenu->setItemChecked( i,FALSE); 1051 configMenu->setItemChecked( i,FALSE);
1046 } 1052 }
1047} 1053}