summaryrefslogtreecommitdiffabout
path: root/microkde
Unidiff
Diffstat (limited to 'microkde') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kcolordialog.cpp1
-rw-r--r--microkde/kdeui/ktoolbar.cpp2
2 files changed, 3 insertions, 0 deletions
diff --git a/microkde/kcolordialog.cpp b/microkde/kcolordialog.cpp
index 9a76e5e..a3d8973 100644
--- a/microkde/kcolordialog.cpp
+++ b/microkde/kcolordialog.cpp
@@ -1,92 +1,93 @@
1#include "kcolordialog.h" 1#include "kcolordialog.h"
2#include <qdialog.h> 2#include <qdialog.h>
3#include <qlayout.h> 3#include <qlayout.h>
4#include <qlabel.h> 4#include <qlabel.h>
5#include <qslider.h> 5#include <qslider.h>
6#include <qhbox.h> 6#include <qhbox.h>
7#include <qapplication.h> 7#include <qapplication.h>
8#include <qpushbutton.h> 8#include <qpushbutton.h>
9 9
10#include <kglobal.h> 10#include <kglobal.h>
11QColor KColorDialog::getColor( ) const 11QColor KColorDialog::getColor( ) const
12{ 12{
13 QColor c ( r->value(), g->value(), b->value() ); 13 QColor c ( r->value(), g->value(), b->value() );
14 lar->setText ( "R: " + QString::number ( c.red() ) ); 14 lar->setText ( "R: " + QString::number ( c.red() ) );
15 lag->setText ( "G: " + QString::number ( c.green() ) ); 15 lag->setText ( "G: " + QString::number ( c.green() ) );
16 lab->setText ( "B: " + QString::number ( c.blue() ) ); 16 lab->setText ( "B: " + QString::number ( c.blue() ) );
17 return c; 17 return c;
18} 18}
19void KColorDialog::setColor( const QColor & d ) 19void KColorDialog::setColor( const QColor & d )
20{ 20{
21 r->setValue(d.red() ); 21 r->setValue(d.red() );
22 g->setValue(d.green() ); 22 g->setValue(d.green() );
23 b->setValue(d.blue() ); 23 b->setValue(d.blue() );
24 old_color->setPalette( QPalette( d.dark(), d ) ); 24 old_color->setPalette( QPalette( d.dark(), d ) );
25 lar->setText ( "R: " + QString::number ( d.red() ) ); 25 lar->setText ( "R: " + QString::number ( d.red() ) );
26 lag->setText ( "G: " + QString::number ( d.green() ) ); 26 lag->setText ( "G: " + QString::number ( d.green() ) );
27 lab->setText ( "B: " + QString::number ( d.blue() ) ); 27 lab->setText ( "B: " + QString::number ( d.blue() ) );
28 28
29} 29}
30KColorDialog::KColorDialog( QWidget *p ):QDialog( p, "input-dialog", true ) 30KColorDialog::KColorDialog( QWidget *p ):QDialog( p, "input-dialog", true )
31{ 31{
32 setCaption( i18n("Choose Color") ); 32 setCaption( i18n("Choose Color") );
33 33
34 setMaximumSize( QApplication::desktop()->width() - 20, QApplication::desktop()->height() - 40 ); // for zaurus 5500er. 34 setMaximumSize( QApplication::desktop()->width() - 20, QApplication::desktop()->height() - 40 ); // for zaurus 5500er.
35 QGridLayout* lay = new QGridLayout ( this, 4, 2 ); 35 QGridLayout* lay = new QGridLayout ( this, 4, 2 );
36 lay->setSpacing( 6 ); 36 lay->setSpacing( 6 );
37 lay->setMargin( 11 ); 37 lay->setMargin( 11 );
38 38
39 old_color = new QLabel("Old color",this); 39 old_color = new QLabel("Old color",this);
40 old_color->setFrameStyle( QFrame::Panel | QFrame::Plain ); 40 old_color->setFrameStyle( QFrame::Panel | QFrame::Plain );
41 old_color->setLineWidth( 1 ); 41 old_color->setLineWidth( 1 );
42 lay->addWidget(old_color, 0, 0); 42 lay->addWidget(old_color, 0, 0);
43 43
44 new_color = new QLabel("New color", this); 44 new_color = new QLabel("New color", this);
45 new_color->setFrameStyle( QFrame::Panel | QFrame::Plain ); 45 new_color->setFrameStyle( QFrame::Panel | QFrame::Plain );
46 new_color->setLineWidth( 1 ); 46 new_color->setLineWidth( 1 );
47 lay->addWidget(new_color, 0, 1); 47 lay->addWidget(new_color, 0, 1);
48 new_color->setAlignment( AlignCenter ); 48 new_color->setAlignment( AlignCenter );
49 49
50 QHBox* hb = new QHBox ( this ); 50 QHBox* hb = new QHBox ( this );
51 lar = new QLabel( hb ); 51 lar = new QLabel( hb );
52 lag = new QLabel( hb ); 52 lag = new QLabel( hb );
53 lab = new QLabel( hb ); 53 lab = new QLabel( hb );
54 lay->addMultiCellWidget( hb,1,1, 0,1 ); 54 lay->addMultiCellWidget( hb,1,1, 0,1 );
55 55
56 QLabel* lr = new QLabel ( "Red:", this ); 56 QLabel* lr = new QLabel ( "Red:", this );
57 lay->addWidget( lr,2,0 ); 57 lay->addWidget( lr,2,0 );
58 r = new QSlider ( 0, 255, 1, 1, Horizontal, this ); 58 r = new QSlider ( 0, 255, 1, 1, Horizontal, this );
59 lay->addWidget(r ,2,1 ); 59 lay->addWidget(r ,2,1 );
60 60
61 QLabel* lg = new QLabel( "Green:",this ); 61 QLabel* lg = new QLabel( "Green:",this );
62 lay->addWidget(lg ,3,0 ); 62 lay->addWidget(lg ,3,0 );
63 g = new QSlider ( 0, 255, 1, 1, Horizontal, this ); 63 g = new QSlider ( 0, 255, 1, 1, Horizontal, this );
64 lay->addWidget( g ,3,1 ); 64 lay->addWidget( g ,3,1 );
65 65
66 QLabel* lb = new QLabel ( "Blue:",this ); 66 QLabel* lb = new QLabel ( "Blue:",this );
67 lay->addWidget( lb,4,0 ); 67 lay->addWidget( lb,4,0 );
68 b = new QSlider ( 0, 255, 1, 1, Horizontal, this ); 68 b = new QSlider ( 0, 255, 1, 1, Horizontal, this );
69 lay->addWidget(b ,4,1 ); 69 lay->addWidget(b ,4,1 );
70 70
71 QColor d = backgroundColor(); 71 QColor d = backgroundColor();
72 r->setValue(d.red() ); 72 r->setValue(d.red() );
73 g->setValue(d.green() ); 73 g->setValue(d.green() );
74 b->setValue(d.blue() ); 74 b->setValue(d.blue() );
75 old_color->setPalette( QPalette( d.dark() , d ) ); 75 old_color->setPalette( QPalette( d.dark() , d ) );
76 // kannst du wieder reinnehmen, aber es geht auch so. 76 // kannst du wieder reinnehmen, aber es geht auch so.
77 QPushButton * ok = new QPushButton (i18n(" OK "), this ); 77 QPushButton * ok = new QPushButton (i18n(" OK "), this );
78 ok->setDefault( true );
78 QPushButton * cancel = new QPushButton (i18n(" Cancel "), this ); 79 QPushButton * cancel = new QPushButton (i18n(" Cancel "), this );
79 80
80 lay->addWidget(ok ,5,0 ); 81 lay->addWidget(ok ,5,0 );
81 lay->addWidget(cancel ,5,1 ); 82 lay->addWidget(cancel ,5,1 );
82 connect (ok, SIGNAL( clicked() ), this ,SLOT (accept() )); 83 connect (ok, SIGNAL( clicked() ), this ,SLOT (accept() ));
83 connect (cancel, SIGNAL( clicked() ), this ,SLOT (reject() )); 84 connect (cancel, SIGNAL( clicked() ), this ,SLOT (reject() ));
84 connect (r, SIGNAL( valueChanged ( int ) ), this ,SLOT (updateColor( int ) )); 85 connect (r, SIGNAL( valueChanged ( int ) ), this ,SLOT (updateColor( int ) ));
85 connect (g, SIGNAL( valueChanged ( int ) ), this ,SLOT (updateColor( int ) )); 86 connect (g, SIGNAL( valueChanged ( int ) ), this ,SLOT (updateColor( int ) ));
86 connect (b, SIGNAL( valueChanged ( int ) ), this ,SLOT (updateColor( int ) )); 87 connect (b, SIGNAL( valueChanged ( int ) ), this ,SLOT (updateColor( int ) ));
87} 88}
88void KColorDialog::updateColor( int ) 89void KColorDialog::updateColor( int )
89{ 90{
90 QColor c = getColor( ) ; 91 QColor c = getColor( ) ;
91 new_color->setPalette( QPalette( c.dark(), c ) ); 92 new_color->setPalette( QPalette( c.dark(), c ) );
92} 93}
diff --git a/microkde/kdeui/ktoolbar.cpp b/microkde/kdeui/ktoolbar.cpp
index 35d4916..36ede81 100644
--- a/microkde/kdeui/ktoolbar.cpp
+++ b/microkde/kdeui/ktoolbar.cpp
@@ -652,1467 +652,1469 @@ void KToolBar::insertComboItem (int id, const QString& text, int index)
652//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 652//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
653 QComboBox * comboBox = (QComboBox *)( *it ); 653 QComboBox * comboBox = (QComboBox *)( *it );
654 if (comboBox) 654 if (comboBox)
655 comboBox->insertItem( text, index ); 655 comboBox->insertItem( text, index );
656} 656}
657 657
658void KToolBar::insertComboList (int id, const QStringList &list, int index) 658void KToolBar::insertComboList (int id, const QStringList &list, int index)
659{ 659{
660 Id2WidgetMap::Iterator it = id2widget.find( id ); 660 Id2WidgetMap::Iterator it = id2widget.find( id );
661 if ( it == id2widget.end() ) 661 if ( it == id2widget.end() )
662 return; 662 return;
663//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 663//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
664 QComboBox * comboBox = (QComboBox *)( *it ); 664 QComboBox * comboBox = (QComboBox *)( *it );
665 if (comboBox) 665 if (comboBox)
666 comboBox->insertStringList( list, index ); 666 comboBox->insertStringList( list, index );
667} 667}
668 668
669 669
670void KToolBar::removeComboItem (int id, int index) 670void KToolBar::removeComboItem (int id, int index)
671{ 671{
672 Id2WidgetMap::Iterator it = id2widget.find( id ); 672 Id2WidgetMap::Iterator it = id2widget.find( id );
673 if ( it == id2widget.end() ) 673 if ( it == id2widget.end() )
674 return; 674 return;
675//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 675//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
676 QComboBox * comboBox = (QComboBox *)( *it ); 676 QComboBox * comboBox = (QComboBox *)( *it );
677 if (comboBox) 677 if (comboBox)
678 comboBox->removeItem( index ); 678 comboBox->removeItem( index );
679} 679}
680 680
681 681
682void KToolBar::setCurrentComboItem (int id, int index) 682void KToolBar::setCurrentComboItem (int id, int index)
683{ 683{
684 Id2WidgetMap::Iterator it = id2widget.find( id ); 684 Id2WidgetMap::Iterator it = id2widget.find( id );
685 if ( it == id2widget.end() ) 685 if ( it == id2widget.end() )
686 return; 686 return;
687//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 687//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
688 QComboBox * comboBox = (QComboBox *)( *it ); 688 QComboBox * comboBox = (QComboBox *)( *it );
689 if (comboBox) 689 if (comboBox)
690 comboBox->setCurrentItem( index ); 690 comboBox->setCurrentItem( index );
691} 691}
692 692
693 693
694void KToolBar::changeComboItem (int id, const QString& text, int index) 694void KToolBar::changeComboItem (int id, const QString& text, int index)
695{ 695{
696 Id2WidgetMap::Iterator it = id2widget.find( id ); 696 Id2WidgetMap::Iterator it = id2widget.find( id );
697 if ( it == id2widget.end() ) 697 if ( it == id2widget.end() )
698 return; 698 return;
699//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 699//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
700 QComboBox * comboBox = (QComboBox *)( *it ); 700 QComboBox * comboBox = (QComboBox *)( *it );
701 if (comboBox) 701 if (comboBox)
702 comboBox->changeItem( text, index ); 702 comboBox->changeItem( text, index );
703} 703}
704 704
705 705
706void KToolBar::clearCombo (int id) 706void KToolBar::clearCombo (int id)
707{ 707{
708 Id2WidgetMap::Iterator it = id2widget.find( id ); 708 Id2WidgetMap::Iterator it = id2widget.find( id );
709 if ( it == id2widget.end() ) 709 if ( it == id2widget.end() )
710 return; 710 return;
711//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 711//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
712 QComboBox * comboBox = (QComboBox *)( *it ); 712 QComboBox * comboBox = (QComboBox *)( *it );
713 if (comboBox) 713 if (comboBox)
714 comboBox->clear(); 714 comboBox->clear();
715} 715}
716 716
717 717
718QString KToolBar::getComboItem (int id, int index) const 718QString KToolBar::getComboItem (int id, int index) const
719{ 719{
720 Id2WidgetMap::ConstIterator it = id2widget.find( id ); 720 Id2WidgetMap::ConstIterator it = id2widget.find( id );
721 if ( it == id2widget.end() ) 721 if ( it == id2widget.end() )
722 return QString::null; 722 return QString::null;
723//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 723//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
724 QComboBox * comboBox = (QComboBox *)( *it ); 724 QComboBox * comboBox = (QComboBox *)( *it );
725 return comboBox ? comboBox->text( index ) : QString::null; 725 return comboBox ? comboBox->text( index ) : QString::null;
726} 726}
727 727
728 728
729KComboBox * KToolBar::getCombo(int id) 729KComboBox * KToolBar::getCombo(int id)
730{ 730{
731 Id2WidgetMap::Iterator it = id2widget.find( id ); 731 Id2WidgetMap::Iterator it = id2widget.find( id );
732 if ( it == id2widget.end() ) 732 if ( it == id2widget.end() )
733 return 0; 733 return 0;
734//US return dynamic_cast<KComboBox *>( *it ); 734//US return dynamic_cast<KComboBox *>( *it );
735 return (KComboBox *)( *it ); 735 return (KComboBox *)( *it );
736} 736}
737 737
738 738
739KLineEdit * KToolBar::getLined (int id) 739KLineEdit * KToolBar::getLined (int id)
740{ 740{
741 Id2WidgetMap::Iterator it = id2widget.find( id ); 741 Id2WidgetMap::Iterator it = id2widget.find( id );
742 if ( it == id2widget.end() ) 742 if ( it == id2widget.end() )
743 return 0; 743 return 0;
744//US return dynamic_cast<KLineEdit *>( *it ); 744//US return dynamic_cast<KLineEdit *>( *it );
745 return (KLineEdit *)( *it ); 745 return (KLineEdit *)( *it );
746} 746}
747 747
748 748
749KToolBarButton * KToolBar::getButton (int id) 749KToolBarButton * KToolBar::getButton (int id)
750{ 750{
751 Id2WidgetMap::Iterator it = id2widget.find( id ); 751 Id2WidgetMap::Iterator it = id2widget.find( id );
752 if ( it == id2widget.end() ) 752 if ( it == id2widget.end() )
753 return 0; 753 return 0;
754//US return dynamic_cast<KToolBarButton *>( *it ); 754//US return dynamic_cast<KToolBarButton *>( *it );
755 return (KToolBarButton *)( *it ); 755 return (KToolBarButton *)( *it );
756} 756}
757 757
758 758
759void KToolBar::alignItemRight (int id, bool right ) 759void KToolBar::alignItemRight (int id, bool right )
760{ 760{
761 Id2WidgetMap::Iterator it = id2widget.find( id ); 761 Id2WidgetMap::Iterator it = id2widget.find( id );
762 if ( it == id2widget.end() ) 762 if ( it == id2widget.end() )
763 return; 763 return;
764 if ( rightAligned && !right && (*it) == rightAligned ) 764 if ( rightAligned && !right && (*it) == rightAligned )
765 rightAligned = 0; 765 rightAligned = 0;
766 if ( (*it) && right ) 766 if ( (*it) && right )
767 rightAligned = (*it); 767 rightAligned = (*it);
768} 768}
769 769
770 770
771QWidget *KToolBar::getWidget (int id) 771QWidget *KToolBar::getWidget (int id)
772{ 772{
773 Id2WidgetMap::Iterator it = id2widget.find( id ); 773 Id2WidgetMap::Iterator it = id2widget.find( id );
774 return ( it == id2widget.end() ) ? 0 : (*it); 774 return ( it == id2widget.end() ) ? 0 : (*it);
775} 775}
776 776
777 777
778void KToolBar::setItemAutoSized (int id, bool yes ) 778void KToolBar::setItemAutoSized (int id, bool yes )
779{ 779{
780 QWidget *w = getWidget(id); 780 QWidget *w = getWidget(id);
781 if ( w && yes ) 781 if ( w && yes )
782 setStretchableWidget( w ); 782 setStretchableWidget( w );
783} 783}
784 784
785 785
786void KToolBar::clear () 786void KToolBar::clear ()
787{ 787{
788 QToolBar::clear(); 788 QToolBar::clear();
789 widget2id.clear(); 789 widget2id.clear();
790 id2widget.clear(); 790 id2widget.clear();
791} 791}
792 792
793 793
794void KToolBar::removeItem(int id) 794void KToolBar::removeItem(int id)
795{ 795{
796 Id2WidgetMap::Iterator it = id2widget.find( id ); 796 Id2WidgetMap::Iterator it = id2widget.find( id );
797 if ( it == id2widget.end() ) 797 if ( it == id2widget.end() )
798 { 798 {
799 kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl; 799 kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl;
800 return; 800 return;
801 } 801 }
802 QWidget * w = (*it); 802 QWidget * w = (*it);
803 id2widget.remove( id ); 803 id2widget.remove( id );
804 widget2id.remove( w ); 804 widget2id.remove( w );
805 widgets.removeRef( w ); 805 widgets.removeRef( w );
806 delete w; 806 delete w;
807} 807}
808 808
809 809
810void KToolBar::removeItemDelayed(int id) 810void KToolBar::removeItemDelayed(int id)
811{ 811{
812 Id2WidgetMap::Iterator it = id2widget.find( id ); 812 Id2WidgetMap::Iterator it = id2widget.find( id );
813 if ( it == id2widget.end() ) 813 if ( it == id2widget.end() )
814 { 814 {
815 kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl; 815 kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl;
816 return; 816 return;
817 } 817 }
818 QWidget * w = (*it); 818 QWidget * w = (*it);
819 id2widget.remove( id ); 819 id2widget.remove( id );
820 widget2id.remove( w ); 820 widget2id.remove( w );
821 widgets.removeRef( w ); 821 widgets.removeRef( w );
822 822
823 w->blockSignals(true); 823 w->blockSignals(true);
824 d->idleButtons.append(w); 824 d->idleButtons.append(w);
825 layoutTimer->start( 50, TRUE ); 825 layoutTimer->start( 50, TRUE );
826} 826}
827 827
828 828
829void KToolBar::hideItem (int id) 829void KToolBar::hideItem (int id)
830{ 830{
831 QWidget *w = getWidget(id); 831 QWidget *w = getWidget(id);
832 if ( w ) 832 if ( w )
833 w->hide(); 833 w->hide();
834} 834}
835 835
836 836
837void KToolBar::showItem (int id) 837void KToolBar::showItem (int id)
838{ 838{
839 QWidget *w = getWidget(id); 839 QWidget *w = getWidget(id);
840 if ( w ) 840 if ( w )
841 w->show(); 841 w->show();
842} 842}
843 843
844 844
845int KToolBar::itemIndex (int id) 845int KToolBar::itemIndex (int id)
846{ 846{
847 QWidget *w = getWidget(id); 847 QWidget *w = getWidget(id);
848 return w ? widgets.findRef(w) : -1; 848 return w ? widgets.findRef(w) : -1;
849} 849}
850 850
851 851
852void KToolBar::setFullSize(bool flag ) 852void KToolBar::setFullSize(bool flag )
853{ 853{
854 setHorizontalStretchable( flag ); 854 setHorizontalStretchable( flag );
855 setVerticalStretchable( flag ); 855 setVerticalStretchable( flag );
856} 856}
857 857
858 858
859bool KToolBar::fullSize() const 859bool KToolBar::fullSize() const
860{ 860{
861 return isHorizontalStretchable() || isVerticalStretchable(); 861 return isHorizontalStretchable() || isVerticalStretchable();
862} 862}
863 863
864 864
865void KToolBar::enableMoving(bool flag ) 865void KToolBar::enableMoving(bool flag )
866{ 866{
867//US setMovingEnabled(flag); 867//US setMovingEnabled(flag);
868 this->mainWindow()->setToolBarsMovable(flag); 868 this->mainWindow()->setToolBarsMovable(flag);
869} 869}
870 870
871 871
872void KToolBar::setBarPos (BarPosition bpos) 872void KToolBar::setBarPos (BarPosition bpos)
873{ 873{
874 if ( !mainWindow() ) 874 if ( !mainWindow() )
875 return; 875 return;
876//US mainWindow()->moveDockWindow( this, (Dock)bpos ); 876//US mainWindow()->moveDockWindow( this, (Dock)bpos );
877 mainWindow()->moveToolBar( this, (QMainWindow::ToolBarDock)bpos ); 877 mainWindow()->moveToolBar( this, (QMainWindow::ToolBarDock)bpos );
878} 878}
879 879
880 880
881const KToolBar::BarPosition KToolBar::barPos() 881const KToolBar::BarPosition KToolBar::barPos()
882{ 882{
883 if ( !(QMainWindow*)mainWindow() ) 883 if ( !(QMainWindow*)mainWindow() )
884 return KToolBar::Top; 884 return KToolBar::Top;
885//US Dock dock; 885//US Dock dock;
886 QMainWindow::ToolBarDock dock; 886 QMainWindow::ToolBarDock dock;
887 int dm1, dm2; 887 int dm1, dm2;
888 bool dm3; 888 bool dm3;
889 ((QMainWindow*)mainWindow())->getLocation( (QToolBar*)this, dock, dm1, dm3, dm2 ); 889 ((QMainWindow*)mainWindow())->getLocation( (QToolBar*)this, dock, dm1, dm3, dm2 );
890//US if ( dock == DockUnmanaged ) { 890//US if ( dock == DockUnmanaged ) {
891 if ( dock == QMainWindow::Unmanaged ) { 891 if ( dock == QMainWindow::Unmanaged ) {
892 return (KToolBar::BarPosition)Top; 892 return (KToolBar::BarPosition)Top;
893 } 893 }
894 return (BarPosition)dock; 894 return (BarPosition)dock;
895} 895}
896 896
897 897
898bool KToolBar::enable(BarStatus stat) 898bool KToolBar::enable(BarStatus stat)
899{ 899{
900 bool mystat = isVisible(); 900 bool mystat = isVisible();
901 901
902 if ( (stat == Toggle && mystat) || stat == Hide ) 902 if ( (stat == Toggle && mystat) || stat == Hide )
903 hide(); 903 hide();
904 else 904 else
905 show(); 905 show();
906 906
907 return isVisible() == mystat; 907 return isVisible() == mystat;
908} 908}
909 909
910 910
911void KToolBar::setMaxHeight ( int h ) 911void KToolBar::setMaxHeight ( int h )
912{ 912{
913 setMaximumHeight( h ); 913 setMaximumHeight( h );
914} 914}
915 915
916int KToolBar::maxHeight() 916int KToolBar::maxHeight()
917{ 917{
918 return maximumHeight(); 918 return maximumHeight();
919} 919}
920 920
921 921
922void KToolBar::setMaxWidth (int dw) 922void KToolBar::setMaxWidth (int dw)
923{ 923{
924 setMaximumWidth( dw ); 924 setMaximumWidth( dw );
925} 925}
926 926
927 927
928int KToolBar::maxWidth() 928int KToolBar::maxWidth()
929{ 929{
930 return maximumWidth(); 930 return maximumWidth();
931} 931}
932 932
933 933
934void KToolBar::setTitle (const QString& _title) 934void KToolBar::setTitle (const QString& _title)
935{ 935{
936 setLabel( _title ); 936 setLabel( _title );
937} 937}
938 938
939 939
940void KToolBar::enableFloating (bool ) 940void KToolBar::enableFloating (bool )
941{ 941{
942} 942}
943 943
944 944
945void KToolBar::setIconText(IconText it) 945void KToolBar::setIconText(IconText it)
946{ 946{
947 setIconText( it, true ); 947 setIconText( it, true );
948} 948}
949 949
950 950
951void KToolBar::setIconText(IconText icontext, bool update) 951void KToolBar::setIconText(IconText icontext, bool update)
952{ 952{
953 bool doUpdate=false; 953 bool doUpdate=false;
954 954
955 if (icontext != d->m_iconText) { 955 if (icontext != d->m_iconText) {
956 d->m_iconText = icontext; 956 d->m_iconText = icontext;
957 doUpdate=true; 957 doUpdate=true;
958 } 958 }
959 959
960 if (update == false) 960 if (update == false)
961 return; 961 return;
962 962
963 if (doUpdate) 963 if (doUpdate)
964 emit modechange(); // tell buttons what happened 964 emit modechange(); // tell buttons what happened
965 965
966 // ugly hack to force a QMainWindow::triggerLayout( TRUE ) 966 // ugly hack to force a QMainWindow::triggerLayout( TRUE )
967 if ( mainWindow() ) { 967 if ( mainWindow() ) {
968 QMainWindow *mw = mainWindow(); 968 QMainWindow *mw = mainWindow();
969 mw->setUpdatesEnabled( FALSE ); 969 mw->setUpdatesEnabled( FALSE );
970 mw->setToolBarsMovable( !mw->toolBarsMovable() ); 970 mw->setToolBarsMovable( !mw->toolBarsMovable() );
971 mw->setToolBarsMovable( !mw->toolBarsMovable() ); 971 mw->setToolBarsMovable( !mw->toolBarsMovable() );
972 mw->setUpdatesEnabled( TRUE ); 972 mw->setUpdatesEnabled( TRUE );
973 } 973 }
974} 974}
975 975
976 976
977KToolBar::IconText KToolBar::iconText() const 977KToolBar::IconText KToolBar::iconText() const
978{ 978{
979 return d->m_iconText; 979 return d->m_iconText;
980} 980}
981 981
982 982
983void KToolBar::setIconSize(int size) 983void KToolBar::setIconSize(int size)
984{ 984{
985 setIconSize( size, true ); 985 setIconSize( size, true );
986} 986}
987 987
988void KToolBar::setIconSize(int size, bool update) 988void KToolBar::setIconSize(int size, bool update)
989{ 989{
990 bool doUpdate=false; 990 bool doUpdate=false;
991 991
992 if ( size != d->m_iconSize ) { 992 if ( size != d->m_iconSize ) {
993 d->m_iconSize = size; 993 d->m_iconSize = size;
994 doUpdate=true; 994 doUpdate=true;
995 } 995 }
996 996
997 if (update == false) 997 if (update == false)
998 return; 998 return;
999 999
1000 if (doUpdate) 1000 if (doUpdate)
1001 emit modechange(); // tell buttons what happened 1001 emit modechange(); // tell buttons what happened
1002 1002
1003 // ugly hack to force a QMainWindow::triggerLayout( TRUE ) 1003 // ugly hack to force a QMainWindow::triggerLayout( TRUE )
1004 if ( mainWindow() ) { 1004 if ( mainWindow() ) {
1005 QMainWindow *mw = mainWindow(); 1005 QMainWindow *mw = mainWindow();
1006 mw->setUpdatesEnabled( FALSE ); 1006 mw->setUpdatesEnabled( FALSE );
1007 mw->setToolBarsMovable( !mw->toolBarsMovable() ); 1007 mw->setToolBarsMovable( !mw->toolBarsMovable() );
1008 mw->setToolBarsMovable( !mw->toolBarsMovable() ); 1008 mw->setToolBarsMovable( !mw->toolBarsMovable() );
1009 mw->setUpdatesEnabled( TRUE ); 1009 mw->setUpdatesEnabled( TRUE );
1010 } 1010 }
1011} 1011}
1012 1012
1013 1013
1014int KToolBar::iconSize() const 1014int KToolBar::iconSize() const
1015{ 1015{
1016/*US 1016/*US
1017 if ( !d->m_iconSize ) // default value? 1017 if ( !d->m_iconSize ) // default value?
1018 { 1018 {
1019 if (!::qstrcmp(QObject::name(), "mainToolBar")) 1019 if (!::qstrcmp(QObject::name(), "mainToolBar"))
1020 return KGlobal::iconLoader()->currentSize(KIcon::MainToolbar); 1020 return KGlobal::iconLoader()->currentSize(KIcon::MainToolbar);
1021 else 1021 else
1022 return KGlobal::iconLoader()->currentSize(KIcon::Toolbar); 1022 return KGlobal::iconLoader()->currentSize(KIcon::Toolbar);
1023 } 1023 }
1024 return d->m_iconSize; 1024 return d->m_iconSize;
1025*/ 1025*/
1026 int ret = 18; 1026 int ret = 18;
1027 if ( QApplication::desktop()->width() > 320 ) 1027 if ( QApplication::desktop()->width() > 320 )
1028 ret = 30; 1028 ret = 30;
1029 return ret; 1029 return ret;
1030} 1030}
1031 1031
1032 1032
1033void KToolBar::setEnableContextMenu(bool enable ) 1033void KToolBar::setEnableContextMenu(bool enable )
1034{ 1034{
1035 d->m_enableContext = enable; 1035 d->m_enableContext = enable;
1036} 1036}
1037 1037
1038 1038
1039bool KToolBar::contextMenuEnabled() const 1039bool KToolBar::contextMenuEnabled() const
1040{ 1040{
1041 return d->m_enableContext; 1041 return d->m_enableContext;
1042} 1042}
1043 1043
1044 1044
1045void KToolBar::setItemNoStyle(int id, bool no_style ) 1045void KToolBar::setItemNoStyle(int id, bool no_style )
1046{ 1046{
1047 Id2WidgetMap::Iterator it = id2widget.find( id ); 1047 Id2WidgetMap::Iterator it = id2widget.find( id );
1048 if ( it == id2widget.end() ) 1048 if ( it == id2widget.end() )
1049 return; 1049 return;
1050//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 1050//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
1051 KToolBarButton * button = (KToolBarButton *)( *it ); 1051 KToolBarButton * button = (KToolBarButton *)( *it );
1052 if (button) 1052 if (button)
1053 button->setNoStyle( no_style ); 1053 button->setNoStyle( no_style );
1054} 1054}
1055 1055
1056 1056
1057void KToolBar::setFlat (bool flag) 1057void KToolBar::setFlat (bool flag)
1058{ 1058{
1059 if ( !mainWindow() ) 1059 if ( !mainWindow() )
1060 return; 1060 return;
1061 if ( flag ) 1061 if ( flag )
1062//US mainWindow()->moveDockWindow( this, DockMinimized ); 1062//US mainWindow()->moveDockWindow( this, DockMinimized );
1063 mainWindow()->moveToolBar( this, QMainWindow::Minimized ); 1063 mainWindow()->moveToolBar( this, QMainWindow::Minimized );
1064 else 1064 else
1065//US mainWindow()->moveDockWindow( this, DockTop ); 1065//US mainWindow()->moveDockWindow( this, DockTop );
1066 mainWindow()->moveToolBar( this, QMainWindow::Top ); 1066 mainWindow()->moveToolBar( this, QMainWindow::Top );
1067 // And remember to save the new look later 1067 // And remember to save the new look later
1068/*US 1068/*US
1069 if ( mainWindow()->inherits( "KMainWindow" ) ) 1069 if ( mainWindow()->inherits( "KMainWindow" ) )
1070 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); 1070 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty();
1071*/ 1071*/
1072} 1072}
1073 1073
1074 1074
1075int KToolBar::count() const 1075int KToolBar::count() const
1076{ 1076{
1077 return id2widget.count(); 1077 return id2widget.count();
1078} 1078}
1079 1079
1080 1080
1081void KToolBar::saveState() 1081void KToolBar::saveState()
1082{ 1082{
1083/*US 1083/*US
1084 // first, try to save to the xml file 1084 // first, try to save to the xml file
1085 if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() ) { 1085 if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() ) {
1086 // go down one level to get to the right tags 1086 // go down one level to get to the right tags
1087 QDomElement elem = d->m_xmlguiClient->domDocument().documentElement().toElement(); 1087 QDomElement elem = d->m_xmlguiClient->domDocument().documentElement().toElement();
1088 elem = elem.firstChild().toElement(); 1088 elem = elem.firstChild().toElement();
1089 QString barname(!::qstrcmp(name(), "unnamed") ? "mainToolBar" : name()); 1089 QString barname(!::qstrcmp(name(), "unnamed") ? "mainToolBar" : name());
1090 QDomElement current; 1090 QDomElement current;
1091 // now try to find our toolbar 1091 // now try to find our toolbar
1092 d->modified = false; 1092 d->modified = false;
1093 for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) { 1093 for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) {
1094 current = elem; 1094 current = elem;
1095 1095
1096 if ( current.tagName().lower() != "toolbar" ) 1096 if ( current.tagName().lower() != "toolbar" )
1097 continue; 1097 continue;
1098 1098
1099 QString curname(current.attribute( "name" )); 1099 QString curname(current.attribute( "name" ));
1100 1100
1101 if ( curname == barname ) { 1101 if ( curname == barname ) {
1102 saveState( current ); 1102 saveState( current );
1103 break; 1103 break;
1104 } 1104 }
1105 } 1105 }
1106 // if we didn't make changes, then just return 1106 // if we didn't make changes, then just return
1107 if ( !d->modified ) 1107 if ( !d->modified )
1108 return; 1108 return;
1109 1109
1110 // now we load in the (non-merged) local file 1110 // now we load in the (non-merged) local file
1111 QString local_xml(KXMLGUIFactory::readConfigFile(d->m_xmlguiClient->xmlFile(), true, d->m_xmlguiClient->instance())); 1111 QString local_xml(KXMLGUIFactory::readConfigFile(d->m_xmlguiClient->xmlFile(), true, d->m_xmlguiClient->instance()));
1112 QDomDocument local; 1112 QDomDocument local;
1113 local.setContent(local_xml); 1113 local.setContent(local_xml);
1114 1114
1115 // make sure we don't append if this toolbar already exists locally 1115 // make sure we don't append if this toolbar already exists locally
1116 bool just_append = true; 1116 bool just_append = true;
1117 elem = local.documentElement().toElement(); 1117 elem = local.documentElement().toElement();
1118 KXMLGUIFactory::removeDOMComments( elem ); 1118 KXMLGUIFactory::removeDOMComments( elem );
1119 elem = elem.firstChild().toElement(); 1119 elem = elem.firstChild().toElement();
1120 for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) { 1120 for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) {
1121 if ( elem.tagName().lower() != "toolbar" ) 1121 if ( elem.tagName().lower() != "toolbar" )
1122 continue; 1122 continue;
1123 1123
1124 QString curname(elem.attribute( "name" )); 1124 QString curname(elem.attribute( "name" ));
1125 1125
1126 if ( curname == barname ) { 1126 if ( curname == barname ) {
1127 just_append = false; 1127 just_append = false;
1128 local.documentElement().replaceChild( current, elem ); 1128 local.documentElement().replaceChild( current, elem );
1129 break; 1129 break;
1130 } 1130 }
1131 } 1131 }
1132 1132
1133 if (just_append) 1133 if (just_append)
1134 local.documentElement().appendChild( current ); 1134 local.documentElement().appendChild( current );
1135 1135
1136 KXMLGUIFactory::saveConfigFile(local, d->m_xmlguiClient->localXMLFile(), d->m_xmlguiClient->instance() ); 1136 KXMLGUIFactory::saveConfigFile(local, d->m_xmlguiClient->localXMLFile(), d->m_xmlguiClient->instance() );
1137 1137
1138 return; 1138 return;
1139 } 1139 }
1140*/ 1140*/
1141 // if that didn't work, we save to the config file 1141 // if that didn't work, we save to the config file
1142 KConfig *config = KGlobal::config(); 1142 KConfig *config = KGlobal::config();
1143 saveSettings(config, QString::null); 1143 saveSettings(config, QString::null);
1144 config->sync(); 1144 config->sync();
1145} 1145}
1146 1146
1147QString KToolBar::settingsGroup() 1147QString KToolBar::settingsGroup()
1148{ 1148{
1149 QString configGroup; 1149 QString configGroup;
1150 if (!::qstrcmp(name(), "unnamed") || !::qstrcmp(name(), "mainToolBar")) 1150 if (!::qstrcmp(name(), "unnamed") || !::qstrcmp(name(), "mainToolBar"))
1151 configGroup = "Toolbar style"; 1151 configGroup = "Toolbar style";
1152 else 1152 else
1153 configGroup = QString(name()) + " Toolbar style"; 1153 configGroup = QString(name()) + " Toolbar style";
1154 if ( this->mainWindow() ) 1154 if ( this->mainWindow() )
1155 { 1155 {
1156 configGroup.prepend(" "); 1156 configGroup.prepend(" ");
1157 configGroup.prepend( this->mainWindow()->name() ); 1157 configGroup.prepend( this->mainWindow()->name() );
1158 } 1158 }
1159 return configGroup; 1159 return configGroup;
1160} 1160}
1161 1161
1162void KToolBar::saveSettings(KConfig *config, const QString &_configGroup) 1162void KToolBar::saveSettings(KConfig *config, const QString &_configGroup)
1163{ 1163{
1164 return;
1164 QString configGroup = _configGroup; 1165 QString configGroup = _configGroup;
1165 if (configGroup.isEmpty()) 1166 if (configGroup.isEmpty())
1166 configGroup = settingsGroup(); 1167 configGroup = settingsGroup();
1167 //kdDebug(220) << "KToolBar::saveSettings group=" << _configGroup << " -> " << configGroup << endl; 1168 //kdDebug(220) << "KToolBar::saveSettings group=" << _configGroup << " -> " << configGroup << endl;
1168 1169
1169 QString position, icontext; 1170 QString position, icontext;
1170 int index; 1171 int index;
1171 getAttributes( position, icontext, index ); 1172 getAttributes( position, icontext, index );
1172 1173
1173 //kdDebug(220) << "KToolBar::saveSettings " << name() << " newLine=" << newLine << endl; 1174 //kdDebug(220) << "KToolBar::saveSettings " << name() << " newLine=" << newLine << endl;
1174 1175
1175 KConfigGroupSaver saver(config, configGroup); 1176 KConfigGroupSaver saver(config, configGroup);
1176 1177
1177 if ( position != d->PositionDefault ) 1178 if ( position != d->PositionDefault )
1178 config->writeEntry("Position", position); 1179 config->writeEntry("Position", position);
1179 else 1180 else
1180 config->deleteEntry("Position"); 1181 config->deleteEntry("Position");
1181 1182
1182 if ( icontext != d->IconTextDefault ) 1183 if ( icontext != d->IconTextDefault )
1183 config->writeEntry("IconText", icontext); 1184 config->writeEntry("IconText", icontext);
1184 else 1185 else
1185 config->deleteEntry("IconText"); 1186 config->deleteEntry("IconText");
1186 1187
1187 if ( iconSize() != d->IconSizeDefault ) 1188 if ( iconSize() != d->IconSizeDefault )
1188 config->writeEntry("IconSize", iconSize()); 1189 config->writeEntry("IconSize", iconSize());
1189 else 1190 else
1190 config->deleteEntry("IconSize"); 1191 config->deleteEntry("IconSize");
1191 1192
1192 if ( isHidden() != d->HiddenDefault ) 1193 if ( isHidden() != d->HiddenDefault )
1193 config->writeEntry("Hidden", isHidden()); 1194 config->writeEntry("Hidden", isHidden());
1194 else 1195 else
1195 config->deleteEntry("Hidden"); 1196 config->deleteEntry("Hidden");
1196 1197
1197 if ( index != d->IndexDefault ) 1198 if ( index != d->IndexDefault )
1198 config->writeEntry( "Index", index ); 1199 config->writeEntry( "Index", index );
1199 else 1200 else
1200 config->deleteEntry("Index"); 1201 config->deleteEntry("Index");
1201//US the older version of KDE (used on the Zaurus) has no Offset property 1202//US the older version of KDE (used on the Zaurus) has no Offset property
1202/* if ( offset() != d->OffsetDefault ) 1203/* if ( offset() != d->OffsetDefault )
1203 config->writeEntry( "Offset", offset() ); 1204 config->writeEntry( "Offset", offset() );
1204 else 1205 else
1205*/ 1206*/
1206 config->deleteEntry("Offset"); 1207 config->deleteEntry("Offset");
1207 1208
1208//US the older version of KDE (used on the Zaurus) has no NewLine property 1209//US the older version of KDE (used on the Zaurus) has no NewLine property
1209/* 1210/*
1210 if ( newLine() != d->NewLineDefault ) 1211 if ( newLine() != d->NewLineDefault )
1211 config->writeEntry( "NewLine", newLine() ); 1212 config->writeEntry( "NewLine", newLine() );
1212 else 1213 else
1213*/ 1214*/
1214 config->deleteEntry("NewLine"); 1215 config->deleteEntry("NewLine");
1215} 1216}
1216 1217
1217void KToolBar::setXMLGUIClient( KXMLGUIClient *client ) 1218void KToolBar::setXMLGUIClient( KXMLGUIClient *client )
1218{ 1219{
1219 d->m_xmlguiClient = client; 1220 d->m_xmlguiClient = client;
1220} 1221}
1221 1222
1222void KToolBar::setText( const QString & txt ) 1223void KToolBar::setText( const QString & txt )
1223{ 1224{
1224//US setLabel( txt + " ( " + kapp->caption() + " ) " ); 1225//US setLabel( txt + " ( " + kapp->caption() + " ) " );
1225 setLabel( txt + " ( " + KGlobal::getAppName() + " ) " ); 1226 setLabel( txt + " ( " + KGlobal::getAppName() + " ) " );
1226} 1227}
1227 1228
1228 1229
1229QString KToolBar::text() const 1230QString KToolBar::text() const
1230{ 1231{
1231 return label(); 1232 return label();
1232} 1233}
1233 1234
1234 1235
1235void KToolBar::doConnections( KToolBarButton *button ) 1236void KToolBar::doConnections( KToolBarButton *button )
1236{ 1237{
1237 connect(button, SIGNAL(clicked(int)), this, SIGNAL( clicked( int ) ) ); 1238 connect(button, SIGNAL(clicked(int)), this, SIGNAL( clicked( int ) ) );
1238 connect(button, SIGNAL(doubleClicked(int)), this, SIGNAL( doubleClicked( int ) ) ); 1239 connect(button, SIGNAL(doubleClicked(int)), this, SIGNAL( doubleClicked( int ) ) );
1239 connect(button, SIGNAL(released(int)), this, SIGNAL( released( int ) ) ); 1240 connect(button, SIGNAL(released(int)), this, SIGNAL( released( int ) ) );
1240 connect(button, SIGNAL(pressed(int)), this, SIGNAL( pressed( int ) ) ); 1241 connect(button, SIGNAL(pressed(int)), this, SIGNAL( pressed( int ) ) );
1241 connect(button, SIGNAL(toggled(int)), this, SIGNAL( toggled( int ) ) ); 1242 connect(button, SIGNAL(toggled(int)), this, SIGNAL( toggled( int ) ) );
1242 connect(button, SIGNAL(highlighted(int, bool)), this, SIGNAL( highlighted( int, bool ) ) ); 1243 connect(button, SIGNAL(highlighted(int, bool)), this, SIGNAL( highlighted( int, bool ) ) );
1243} 1244}
1244 1245
1245void KToolBar::mousePressEvent ( QMouseEvent *m ) 1246void KToolBar::mousePressEvent ( QMouseEvent *m )
1246{ 1247{
1247 if ( !mainWindow() ) 1248 if ( !mainWindow() )
1248 return; 1249 return;
1249 QMainWindow *mw = mainWindow(); 1250 QMainWindow *mw = mainWindow();
1250 if ( mw->toolBarsMovable() && d->m_enableContext ) { 1251 if ( mw->toolBarsMovable() && d->m_enableContext ) {
1251 if ( m->button() == RightButton ) { 1252 if ( m->button() == RightButton ) {
1252 int i = contextMenu()->exec( m->globalPos(), 0 ); 1253 int i = contextMenu()->exec( m->globalPos(), 0 );
1253 switch ( i ) { 1254 switch ( i ) {
1254 case -1: 1255 case -1:
1255 return; // popup cancelled 1256 return; // popup cancelled
1256 case CONTEXT_LEFT: 1257 case CONTEXT_LEFT:
1257//US mw->moveDockWindow( this, DockLeft ); 1258//US mw->moveDockWindow( this, DockLeft );
1258 mw->moveToolBar( this, QMainWindow::Left ); 1259 mw->moveToolBar( this, QMainWindow::Left );
1259 break; 1260 break;
1260 case CONTEXT_RIGHT: 1261 case CONTEXT_RIGHT:
1261//US mw->moveDockWindow( this, DockRight ); 1262//US mw->moveDockWindow( this, DockRight );
1262 mw->moveToolBar( this, QMainWindow::Right ); 1263 mw->moveToolBar( this, QMainWindow::Right );
1263 break; 1264 break;
1264 case CONTEXT_TOP: 1265 case CONTEXT_TOP:
1265//US mw->moveDockWindow( this, DockTop ); 1266//US mw->moveDockWindow( this, DockTop );
1266 mw->moveToolBar( this, QMainWindow::Top ); 1267 mw->moveToolBar( this, QMainWindow::Top );
1267 break; 1268 break;
1268 case CONTEXT_BOTTOM: 1269 case CONTEXT_BOTTOM:
1269//US mw->moveDockWindow( this, DockBottom ); 1270//US mw->moveDockWindow( this, DockBottom );
1270 mw->moveToolBar( this, QMainWindow::Bottom ); 1271 mw->moveToolBar( this, QMainWindow::Bottom );
1271 break; 1272 break;
1272 case CONTEXT_FLOAT: 1273 case CONTEXT_FLOAT:
1273 break; 1274 break;
1274 case CONTEXT_FLAT: 1275 case CONTEXT_FLAT:
1275//US mw->moveDockWindow( this, DockMinimized ); 1276//US mw->moveDockWindow( this, DockMinimized );
1276 mw->moveToolBar( this, QMainWindow::Minimized ); 1277 mw->moveToolBar( this, QMainWindow::Minimized );
1277 break; 1278 break;
1278 case CONTEXT_ICONS: 1279 case CONTEXT_ICONS:
1279 setIconText( IconOnly ); 1280 setIconText( IconOnly );
1280 break; 1281 break;
1281 case CONTEXT_TEXTRIGHT: 1282 case CONTEXT_TEXTRIGHT:
1282 setIconText( IconTextRight ); 1283 setIconText( IconTextRight );
1283 break; 1284 break;
1284 case CONTEXT_TEXT: 1285 case CONTEXT_TEXT:
1285 setIconText( TextOnly ); 1286 setIconText( TextOnly );
1286 break; 1287 break;
1287 case CONTEXT_TEXTUNDER: 1288 case CONTEXT_TEXTUNDER:
1288 setIconText( IconTextBottom ); 1289 setIconText( IconTextBottom );
1289 break; 1290 break;
1290 default: 1291 default:
1291 if ( i >= CONTEXT_ICONSIZES ) 1292 if ( i >= CONTEXT_ICONSIZES )
1292 setIconSize( i - CONTEXT_ICONSIZES ); 1293 setIconSize( i - CONTEXT_ICONSIZES );
1293 else 1294 else
1294 return; // assume this was an action handled elsewhere, no need for setSettingsDirty() 1295 return; // assume this was an action handled elsewhere, no need for setSettingsDirty()
1295 } 1296 }
1296/*US 1297/*US
1297 if ( mw->inherits("KMainWindow") ) 1298 if ( mw->inherits("KMainWindow") )
1298 static_cast<KMainWindow *>(mw)->setSettingsDirty(); 1299 static_cast<KMainWindow *>(mw)->setSettingsDirty();
1299*/ 1300*/
1300 } 1301 }
1301 } 1302 }
1302} 1303}
1303 1304
1304 1305
1305void KToolBar::rebuildLayout() 1306void KToolBar::rebuildLayout()
1306{ 1307{
1307 1308
1308 for(QWidget *w=d->idleButtons.first(); w; w=d->idleButtons.next()) 1309 for(QWidget *w=d->idleButtons.first(); w; w=d->idleButtons.next())
1309 w->blockSignals(false); 1310 w->blockSignals(false);
1310 d->idleButtons.clear(); 1311 d->idleButtons.clear();
1311 1312
1312 layoutTimer->stop(); 1313 layoutTimer->stop();
1313 QApplication::sendPostedEvents( this, QEvent::ChildInserted ); 1314 QApplication::sendPostedEvents( this, QEvent::ChildInserted );
1314 QBoxLayout *l = boxLayout(); 1315 QBoxLayout *l = boxLayout();
1315 l->setMargin( 1 ); 1316 l->setMargin( 1 );
1316 // clear the old layout 1317 // clear the old layout
1317 QLayoutIterator it = l->iterator(); 1318 QLayoutIterator it = l->iterator();
1318 1319
1319 while ( it.current() ) { 1320 while ( it.current() ) {
1320 it.deleteCurrent(); 1321 it.deleteCurrent();
1321 } 1322 }
1322 for ( QWidget *w = widgets.first(); w; w = widgets.next() ) { 1323 for ( QWidget *w = widgets.first(); w; w = widgets.next() ) {
1323 if ( w == rightAligned ) { 1324 if ( w == rightAligned ) {
1324 continue; 1325 continue;
1325 } 1326 }
1326 if ( w->inherits( "KToolBarSeparator" ) && 1327 if ( w->inherits( "KToolBarSeparator" ) &&
1327 !( (KToolBarSeparator*)w )->showLine() ) { 1328 !( (KToolBarSeparator*)w )->showLine() ) {
1328 l->addSpacing( 6 ); 1329 l->addSpacing( 6 );
1329 w->hide(); 1330 w->hide();
1330 continue; 1331 continue;
1331 } 1332 }
1332 if ( w->inherits( "QPopupMenu" ) ) 1333 if ( w->inherits( "QPopupMenu" ) )
1333 continue; 1334 continue;
1334 l->addWidget( w ); 1335 l->addWidget( w );
1335 w->show(); 1336 w->show();
1336 } 1337 }
1337 if ( rightAligned ) { 1338 if ( rightAligned ) {
1338 l->addStretch(); 1339 l->addStretch();
1339 l->addWidget( rightAligned ); 1340 l->addWidget( rightAligned );
1340 rightAligned->show(); 1341 rightAligned->show();
1341 } 1342 }
1342 1343
1343 if ( fullSize() ) { 1344 if ( fullSize() ) {
1344 // This code sucks. It makes the last combo in a toolbar VERY big (e.g. zoom combo in kword). 1345 // This code sucks. It makes the last combo in a toolbar VERY big (e.g. zoom combo in kword).
1345 //if ( !stretchableWidget && widgets.last() && 1346 //if ( !stretchableWidget && widgets.last() &&
1346 // !widgets.last()->inherits( "QButton" ) && !widgets.last()->inherits( "KAnimWidget" ) ) 1347 // !widgets.last()->inherits( "QButton" ) && !widgets.last()->inherits( "KAnimWidget" ) )
1347 // setStretchableWidget( widgets.last() ); 1348 // setStretchableWidget( widgets.last() );
1348 if ( !rightAligned ) 1349 if ( !rightAligned )
1349 l->addStretch(); 1350 l->addStretch();
1350 if ( stretchableWidget ) 1351 if ( stretchableWidget )
1351 l->setStretchFactor( stretchableWidget, 10 ); 1352 l->setStretchFactor( stretchableWidget, 10 );
1352 } 1353 }
1353 l->invalidate(); 1354 l->invalidate();
1354 QApplication::postEvent( this, new QEvent( QEvent::LayoutHint ) ); 1355 QApplication::postEvent( this, new QEvent( QEvent::LayoutHint ) );
1355 //#endif //DESKTOP_VERSION 1356 //#endif //DESKTOP_VERSION
1356} 1357}
1357 1358
1358void KToolBar::childEvent( QChildEvent *e ) 1359void KToolBar::childEvent( QChildEvent *e )
1359{ 1360{
1360 1361
1361 if ( e->child()->isWidgetType() ) { 1362 if ( e->child()->isWidgetType() ) {
1362 QWidget * w = (QWidget*)e->child(); 1363 QWidget * w = (QWidget*)e->child();
1363 if ( e->type() == QEvent::ChildInserted ) { 1364 if ( e->type() == QEvent::ChildInserted ) {
1364 if ( !e->child()->inherits( "QPopupMenu" ) && 1365 if ( !e->child()->inherits( "QPopupMenu" ) &&
1365 ::qstrcmp( "qt_dockwidget_internal", e->child()->name() ) != 0 ) { 1366 ::qstrcmp( "qt_dockwidget_internal", e->child()->name() ) != 0 ) {
1366 1367
1367 // prevent items that have been explicitly inserted by insert*() from 1368 // prevent items that have been explicitly inserted by insert*() from
1368 // being inserted again 1369 // being inserted again
1369 if ( !widget2id.contains( w ) ) 1370 if ( !widget2id.contains( w ) )
1370 { 1371 {
1371 int dummy = -1; 1372 int dummy = -1;
1372 insertWidgetInternal( w, dummy, -1 ); 1373 insertWidgetInternal( w, dummy, -1 );
1373 } 1374 }
1374 } 1375 }
1375 } else { 1376 } else {
1376 removeWidgetInternal( w ); 1377 removeWidgetInternal( w );
1377 } 1378 }
1378 if ( isVisibleTo( 0 ) ) 1379 if ( isVisibleTo( 0 ) )
1379 { 1380 {
1380 QBoxLayout *l = boxLayout(); 1381 QBoxLayout *l = boxLayout();
1381 // QLayout *l = layout(); 1382 // QLayout *l = layout();
1382 1383
1383 // clear the old layout so that we don't get unnecassery layout 1384 // clear the old layout so that we don't get unnecassery layout
1384 // changes till we have rebuild the thing 1385 // changes till we have rebuild the thing
1385 QLayoutIterator it = l->iterator(); 1386 QLayoutIterator it = l->iterator();
1386 while ( it.current() ) { 1387 while ( it.current() ) {
1387 it.deleteCurrent(); 1388 it.deleteCurrent();
1388 } 1389 }
1389 layoutTimer->start( 50, TRUE ); 1390 layoutTimer->start( 50, TRUE );
1390 } 1391 }
1391 } 1392 }
1392 QToolBar::childEvent( e ); 1393 QToolBar::childEvent( e );
1393} 1394}
1394 1395
1395void KToolBar::insertWidgetInternal( QWidget *w, int &index, int id ) 1396void KToolBar::insertWidgetInternal( QWidget *w, int &index, int id )
1396{ 1397{
1397 // we can't have it in widgets, or something is really wrong 1398 // we can't have it in widgets, or something is really wrong
1398 //widgets.removeRef( w ); 1399 //widgets.removeRef( w );
1399 1400
1400 connect( w, SIGNAL( destroyed() ), 1401 connect( w, SIGNAL( destroyed() ),
1401 this, SLOT( widgetDestroyed() ) ); 1402 this, SLOT( widgetDestroyed() ) );
1402 if ( index == -1 || index > (int)widgets.count() ) { 1403 if ( index == -1 || index > (int)widgets.count() ) {
1403 widgets.append( w ); 1404 widgets.append( w );
1404 index = (int)widgets.count(); 1405 index = (int)widgets.count();
1405 } 1406 }
1406 else 1407 else
1407 widgets.insert( index, w ); 1408 widgets.insert( index, w );
1408 if ( id == -1 ) 1409 if ( id == -1 )
1409 id = id2widget.count(); 1410 id = id2widget.count();
1410 id2widget.insert( id, w ); 1411 id2widget.insert( id, w );
1411 widget2id.insert( w, id ); 1412 widget2id.insert( w, id );
1412} 1413}
1413void KToolBar::repaintMe() 1414void KToolBar::repaintMe()
1414{ 1415{
1415 setUpdatesEnabled( true ); 1416 setUpdatesEnabled( true );
1416 QToolBar::repaint( true ); 1417 QToolBar::repaint( true );
1417 //qDebug(" KToolBar::repaintMe() "); 1418 //qDebug(" KToolBar::repaintMe() ");
1418} 1419}
1419 1420
1420void KToolBar::showEvent( QShowEvent *e ) 1421void KToolBar::showEvent( QShowEvent *e )
1421{ 1422{
1422 QToolBar::showEvent( e ); 1423 QToolBar::showEvent( e );
1423 rebuildLayout(); 1424 rebuildLayout();
1424} 1425}
1425 1426
1426void KToolBar::setStretchableWidget( QWidget *w ) 1427void KToolBar::setStretchableWidget( QWidget *w )
1427{ 1428{
1428 QToolBar::setStretchableWidget( w ); 1429 QToolBar::setStretchableWidget( w );
1429 stretchableWidget = w; 1430 stretchableWidget = w;
1430} 1431}
1431 1432
1432QSizePolicy KToolBar::sizePolicy() const 1433QSizePolicy KToolBar::sizePolicy() const
1433{ 1434{
1434 if ( orientation() == Horizontal ) 1435 if ( orientation() == Horizontal )
1435 return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); 1436 return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
1436 else 1437 else
1437 return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ); 1438 return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding );
1438} 1439}
1439 1440
1440QSize KToolBar::sizeHint() const 1441QSize KToolBar::sizeHint() const
1441{ 1442{
1442 return QToolBar::sizeHint(); 1443 return QToolBar::sizeHint();
1443#if 0 1444#if 0
1444 QWidget::polish(); 1445 QWidget::polish();
1445 static int iii = 0; 1446 static int iii = 0;
1446 ++iii; 1447 ++iii;
1447 qDebug("++++++++ KToolBar::sizeHint() %d ", iii ); 1448 qDebug("++++++++ KToolBar::sizeHint() %d ", iii );
1448 int margin = static_cast<QWidget*>(ncThis)->layout()->margin(); 1449 int margin = static_cast<QWidget*>(ncThis)->layout()->margin();
1449 switch( barPos() ) 1450 switch( barPos() )
1450 { 1451 {
1451 case KToolBar::Top: 1452 case KToolBar::Top:
1452 case KToolBar::Bottom: 1453 case KToolBar::Bottom:
1453 for ( QWidget *w = widgets.first(); w; w =widgets.next() ) 1454 for ( QWidget *w = widgets.first(); w; w =widgets.next() )
1454 { 1455 {
1455 if ( w->inherits( "KToolBarSeparator" ) && 1456 if ( w->inherits( "KToolBarSeparator" ) &&
1456 !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) 1457 !( static_cast<KToolBarSeparator*>(w)->showLine() ) )
1457 { 1458 {
1458 minSize += QSize(6, 0); 1459 minSize += QSize(6, 0);
1459 } 1460 }
1460 else 1461 else
1461 { 1462 {
1462 QSize sh = w->sizeHint(); 1463 QSize sh = w->sizeHint();
1463 if (!sh.isValid()) 1464 if (!sh.isValid())
1464 sh = w->minimumSize(); 1465 sh = w->minimumSize();
1465 minSize = minSize.expandedTo(QSize(0, sh.height())); 1466 minSize = minSize.expandedTo(QSize(0, sh.height()));
1466 minSize += QSize(sh.width()+1, 0); 1467 minSize += QSize(sh.width()+1, 0);
1467 } 1468 }
1468 } 1469 }
1469/*US 1470/*US
1470 minSize += QSize(QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ), 0); 1471 minSize += QSize(QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ), 0);
1471*/ 1472*/
1472 minSize += QSize(margin*2, margin*2); 1473 minSize += QSize(margin*2, margin*2);
1473 break; 1474 break;
1474 1475
1475 case KToolBar::Left: 1476 case KToolBar::Left:
1476 case KToolBar::Right: 1477 case KToolBar::Right:
1477 for ( QWidget *w = widgets.first(); w; w = widgets.next() ) 1478 for ( QWidget *w = widgets.first(); w; w = widgets.next() )
1478 { 1479 {
1479 if ( w->inherits( "KToolBarSeparator" ) && 1480 if ( w->inherits( "KToolBarSeparator" ) &&
1480 !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) 1481 !( static_cast<KToolBarSeparator*>(w)->showLine() ) )
1481 { 1482 {
1482 minSize += QSize(0, 6); 1483 minSize += QSize(0, 6);
1483 } 1484 }
1484 else 1485 else
1485 { 1486 {
1486 QSize sh = w->sizeHint(); 1487 QSize sh = w->sizeHint();
1487 if (!sh.isValid()) 1488 if (!sh.isValid())
1488 sh = w->minimumSize(); 1489 sh = w->minimumSize();
1489 minSize = minSize.expandedTo(QSize(sh.width(), 0)); 1490 minSize = minSize.expandedTo(QSize(sh.width(), 0));
1490 minSize += QSize(0, sh.height()+1); 1491 minSize += QSize(0, sh.height()+1);
1491 } 1492 }
1492 } 1493 }
1493/*US 1494/*US
1494 minSize += QSize(0, QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent )); 1495 minSize += QSize(0, QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ));
1495*/ 1496*/
1496 minSize += QSize(margin*2, margin*2); 1497 minSize += QSize(margin*2, margin*2);
1497 break; 1498 break;
1498 1499
1499 default: 1500 default:
1500 minSize = QToolBar::sizeHint(); 1501 minSize = QToolBar::sizeHint();
1501 break; 1502 break;
1502 } 1503 }
1503 return minSize; 1504 return minSize;
1504#endif 1505#endif
1505} 1506}
1506 1507
1507QSize KToolBar::minimumSize() const 1508QSize KToolBar::minimumSize() const
1508{ 1509{
1509 return minimumSizeHint(); 1510 return minimumSizeHint();
1510} 1511}
1511 1512
1512QSize KToolBar::minimumSizeHint() const 1513QSize KToolBar::minimumSizeHint() const
1513{ 1514{
1514 return sizeHint(); 1515 return sizeHint();
1515} 1516}
1516 1517
1517bool KToolBar::highlight() const 1518bool KToolBar::highlight() const
1518{ 1519{
1519 return d->m_highlight; 1520 return d->m_highlight;
1520} 1521}
1521 1522
1522void KToolBar::hide() 1523void KToolBar::hide()
1523{ 1524{
1524 QToolBar::hide(); 1525 QToolBar::hide();
1525} 1526}
1526 1527
1527void KToolBar::show() 1528void KToolBar::show()
1528{ 1529{
1529 QToolBar::show(); 1530 QToolBar::show();
1530} 1531}
1531 1532
1532void KToolBar::resizeEvent( QResizeEvent *e ) 1533void KToolBar::resizeEvent( QResizeEvent *e )
1533{ 1534{
1534 bool b = isUpdatesEnabled(); 1535 bool b = isUpdatesEnabled();
1535 setUpdatesEnabled( FALSE ); 1536 setUpdatesEnabled( FALSE );
1536 QToolBar::resizeEvent( e ); 1537 QToolBar::resizeEvent( e );
1537 if (b) 1538 if (b)
1538 d->repaintTimer.start( 100, true ); 1539 d->repaintTimer.start( 100, true );
1539} 1540}
1540 1541
1541void KToolBar::slotIconChanged(int group) 1542void KToolBar::slotIconChanged(int group)
1542{ 1543{
1543 if ((group != KIcon::Toolbar) && (group != KIcon::MainToolbar)) 1544 if ((group != KIcon::Toolbar) && (group != KIcon::MainToolbar))
1544 return; 1545 return;
1545 if ((group == KIcon::MainToolbar) != !::qstrcmp(name(), "mainToolBar")) 1546 if ((group == KIcon::MainToolbar) != !::qstrcmp(name(), "mainToolBar"))
1546 return; 1547 return;
1547 1548
1548 emit modechange(); 1549 emit modechange();
1549 if (isVisible()) 1550 if (isVisible())
1550 updateGeometry(); 1551 updateGeometry();
1551} 1552}
1552 1553
1553void KToolBar::slotReadConfig() 1554void KToolBar::slotReadConfig()
1554{ 1555{
1555 //kdDebug(220) << "KToolBar::slotReadConfig" << endl; 1556 //kdDebug(220) << "KToolBar::slotReadConfig" << endl;
1556 // Read appearance settings (hmm, we used to do both here, 1557 // Read appearance settings (hmm, we used to do both here,
1557 // but a well behaved application will call applyMainWindowSettings 1558 // but a well behaved application will call applyMainWindowSettings
1558 // anyway, right ?) 1559 // anyway, right ?)
1559 applyAppearanceSettings(KGlobal::config(), QString::null ); 1560 applyAppearanceSettings(KGlobal::config(), QString::null );
1560} 1561}
1561 1562
1562void KToolBar::slotAppearanceChanged() 1563void KToolBar::slotAppearanceChanged()
1563{ 1564{
1564 // Read appearance settings from global file. 1565 // Read appearance settings from global file.
1565 applyAppearanceSettings(KGlobal::config(), QString::null, true /* lose local settings */ ); 1566 applyAppearanceSettings(KGlobal::config(), QString::null, true /* lose local settings */ );
1566 // And remember to save the new look later 1567 // And remember to save the new look later
1567/*US 1568/*US
1568 if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) 1569 if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) )
1569 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); 1570 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty();
1570*/ 1571*/
1571} 1572}
1572 1573
1573//static 1574//static
1574bool KToolBar::highlightSetting() 1575bool KToolBar::highlightSetting()
1575{ 1576{
1576 QString grpToolbar(QString::fromLatin1("Toolbar style")); 1577 QString grpToolbar(QString::fromLatin1("Toolbar style"));
1577 KConfigGroupSaver saver(KGlobal::config(), grpToolbar); 1578 KConfigGroupSaver saver(KGlobal::config(), grpToolbar);
1578 return KGlobal::config()->readBoolEntry(QString::fromLatin1("Highlighting"),true); 1579 return KGlobal::config()->readBoolEntry(QString::fromLatin1("Highlighting"),true);
1579} 1580}
1580 1581
1581//static 1582//static
1582bool KToolBar::transparentSetting() 1583bool KToolBar::transparentSetting()
1583{ 1584{
1584 QString grpToolbar(QString::fromLatin1("Toolbar style")); 1585 QString grpToolbar(QString::fromLatin1("Toolbar style"));
1585 KConfigGroupSaver saver(KGlobal::config(), grpToolbar); 1586 KConfigGroupSaver saver(KGlobal::config(), grpToolbar);
1586 return KGlobal::config()->readBoolEntry(QString::fromLatin1("TransparentMoving"),true); 1587 return KGlobal::config()->readBoolEntry(QString::fromLatin1("TransparentMoving"),true);
1587} 1588}
1588 1589
1589//static 1590//static
1590KToolBar::IconText KToolBar::iconTextSetting() 1591KToolBar::IconText KToolBar::iconTextSetting()
1591{ 1592{
1592 QString grpToolbar(QString::fromLatin1("Toolbar style")); 1593 QString grpToolbar(QString::fromLatin1("Toolbar style"));
1593 KConfigGroupSaver saver(KGlobal::config(), grpToolbar); 1594 KConfigGroupSaver saver(KGlobal::config(), grpToolbar);
1594 QString icontext = KGlobal::config()->readEntry(QString::fromLatin1("IconText"),QString::fromLatin1("IconOnly")); 1595 QString icontext = KGlobal::config()->readEntry(QString::fromLatin1("IconText"),QString::fromLatin1("IconOnly"));
1595 if ( icontext == "IconTextRight" ) 1596 if ( icontext == "IconTextRight" )
1596 return IconTextRight; 1597 return IconTextRight;
1597 else if ( icontext == "IconTextBottom" ) 1598 else if ( icontext == "IconTextBottom" )
1598 return IconTextBottom; 1599 return IconTextBottom;
1599 else if ( icontext == "TextOnly" ) 1600 else if ( icontext == "TextOnly" )
1600 return TextOnly; 1601 return TextOnly;
1601 else 1602 else
1602 return IconOnly; 1603 return IconOnly;
1603} 1604}
1604 1605
1605void KToolBar::applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal) 1606void KToolBar::applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal)
1606{ 1607{
1608 return;
1607 QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup; 1609 QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup;
1608 //kdDebug(220) << "KToolBar::applyAppearanceSettings: configGroup=" << configGroup << endl; 1610 //kdDebug(220) << "KToolBar::applyAppearanceSettings: configGroup=" << configGroup << endl;
1609 // We have application-specific settings in the XML file, 1611 // We have application-specific settings in the XML file,
1610 // and nothing in the application's config file 1612 // and nothing in the application's config file
1611 // -> don't apply the global defaults, the XML ones are preferred 1613 // -> don't apply the global defaults, the XML ones are preferred
1612 // See applySettings for a full explanation 1614 // See applySettings for a full explanation
1613/*US :we do not support xml files 1615/*US :we do not support xml files
1614 if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() && 1616 if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() &&
1615 !config->hasGroup(configGroup) ) 1617 !config->hasGroup(configGroup) )
1616 { 1618 {
1617 //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl; 1619 //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl;
1618 return; 1620 return;
1619 } 1621 }
1620*/ 1622*/
1621 if ( !config->hasGroup(configGroup) ) 1623 if ( !config->hasGroup(configGroup) )
1622 { 1624 {
1623 //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl; 1625 //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl;
1624 return; 1626 return;
1625 } 1627 }
1626 1628
1627 1629
1628 KConfig *gconfig = KGlobal::config(); 1630 KConfig *gconfig = KGlobal::config();
1629/*US 1631/*US
1630 static const QString &attrIconText = KGlobal::staticQString("IconText"); 1632 static const QString &attrIconText = KGlobal::staticQString("IconText");
1631 static const QString &attrHighlight = KGlobal::staticQString("Highlighting"); 1633 static const QString &attrHighlight = KGlobal::staticQString("Highlighting");
1632 static const QString &attrTrans = KGlobal::staticQString("TransparentMoving"); 1634 static const QString &attrTrans = KGlobal::staticQString("TransparentMoving");
1633 static const QString &attrSize = KGlobal::staticQString("IconSize"); 1635 static const QString &attrSize = KGlobal::staticQString("IconSize");
1634*/ 1636*/
1635 // we actually do this in two steps. 1637 // we actually do this in two steps.
1636 // First, we read in the global styles [Toolbar style] (from the KControl module). 1638 // First, we read in the global styles [Toolbar style] (from the KControl module).
1637 // Then, if the toolbar is NOT 'mainToolBar', we will also try to read in [barname Toolbar style] 1639 // Then, if the toolbar is NOT 'mainToolBar', we will also try to read in [barname Toolbar style]
1638 bool highlight; 1640 bool highlight;
1639 int transparent; 1641 int transparent;
1640 QString icontext; 1642 QString icontext;
1641 int iconsize = 0; 1643 int iconsize = 0;
1642 1644
1643 // this is the first iteration 1645 // this is the first iteration
1644 QString grpToolbar(QString::fromLatin1("Toolbar style")); 1646 QString grpToolbar(QString::fromLatin1("Toolbar style"));
1645 { // start block for KConfigGroupSaver 1647 { // start block for KConfigGroupSaver
1646 KConfigGroupSaver saver(gconfig, grpToolbar); 1648 KConfigGroupSaver saver(gconfig, grpToolbar);
1647 1649
1648 // first, get the generic settings 1650 // first, get the generic settings
1649//US highlight = gconfig->readBoolEntry(attrHighlight, true); 1651//US highlight = gconfig->readBoolEntry(attrHighlight, true);
1650 highlight = gconfig->readBoolEntry("Highlighting", true); 1652 highlight = gconfig->readBoolEntry("Highlighting", true);
1651//US transparent = gconfig->readBoolEntry(attrTrans, true); 1653//US transparent = gconfig->readBoolEntry(attrTrans, true);
1652 transparent = gconfig->readBoolEntry("TransparentMoving", true); 1654 transparent = gconfig->readBoolEntry("TransparentMoving", true);
1653 1655
1654 // we read in the IconText property *only* if we intend on actually 1656 // we read in the IconText property *only* if we intend on actually
1655 // honoring it 1657 // honoring it
1656 if (d->m_honorStyle) 1658 if (d->m_honorStyle)
1657//US d->IconTextDefault = gconfig->readEntry(attrIconText, d->IconTextDefault); 1659//US d->IconTextDefault = gconfig->readEntry(attrIconText, d->IconTextDefault);
1658 d->IconTextDefault = gconfig->readEntry("IconText", d->IconTextDefault); 1660 d->IconTextDefault = gconfig->readEntry("IconText", d->IconTextDefault);
1659 else 1661 else
1660 d->IconTextDefault = "IconOnly"; 1662 d->IconTextDefault = "IconOnly";
1661 1663
1662 // Use the default icon size for toolbar icons. 1664 // Use the default icon size for toolbar icons.
1663//US d->IconSizeDefault = gconfig->readNumEntry(attrSize, d->IconSizeDefault); 1665//US d->IconSizeDefault = gconfig->readNumEntry(attrSize, d->IconSizeDefault);
1664 d->IconSizeDefault = gconfig->readNumEntry("IconSize", d->IconSizeDefault); 1666 d->IconSizeDefault = gconfig->readNumEntry("IconSize", d->IconSizeDefault);
1665 1667
1666 if ( !forceGlobal && config->hasGroup(configGroup) ) 1668 if ( !forceGlobal && config->hasGroup(configGroup) )
1667 { 1669 {
1668 config->setGroup(configGroup); 1670 config->setGroup(configGroup);
1669 1671
1670 // first, get the generic settings 1672 // first, get the generic settings
1671//US highlight = config->readBoolEntry(attrHighlight, highlight); 1673//US highlight = config->readBoolEntry(attrHighlight, highlight);
1672 highlight = config->readBoolEntry("Highlighting", highlight); 1674 highlight = config->readBoolEntry("Highlighting", highlight);
1673//US transparent = config->readBoolEntry(attrTrans, transparent); 1675//US transparent = config->readBoolEntry(attrTrans, transparent);
1674 transparent = config->readBoolEntry("TransparentMoving", transparent); 1676 transparent = config->readBoolEntry("TransparentMoving", transparent);
1675 // now we always read in the IconText property 1677 // now we always read in the IconText property
1676//US icontext = config->readEntry(attrIconText, d->IconTextDefault); 1678//US icontext = config->readEntry(attrIconText, d->IconTextDefault);
1677 icontext = config->readEntry("IconText", d->IconTextDefault); 1679 icontext = config->readEntry("IconText", d->IconTextDefault);
1678 1680
1679 // now get the size 1681 // now get the size
1680//US iconsize = config->readNumEntry(attrSize, d->IconSizeDefault); 1682//US iconsize = config->readNumEntry(attrSize, d->IconSizeDefault);
1681 iconsize = config->readNumEntry("IconSize", d->IconSizeDefault); 1683 iconsize = config->readNumEntry("IconSize", d->IconSizeDefault);
1682 } 1684 }
1683 else 1685 else
1684 { 1686 {
1685 iconsize = d->IconSizeDefault; 1687 iconsize = d->IconSizeDefault;
1686 icontext = d->IconTextDefault; 1688 icontext = d->IconTextDefault;
1687 } 1689 }
1688 1690
1689 // revert back to the old group 1691 // revert back to the old group
1690 } // end block for KConfigGroupSaver 1692 } // end block for KConfigGroupSaver
1691 1693
1692 bool doUpdate = false; 1694 bool doUpdate = false;
1693 1695
1694 IconText icon_text; 1696 IconText icon_text;
1695 if ( icontext == "IconTextRight" ) 1697 if ( icontext == "IconTextRight" )
1696 icon_text = IconTextRight; 1698 icon_text = IconTextRight;
1697 else if ( icontext == "IconTextBottom" ) 1699 else if ( icontext == "IconTextBottom" )
1698 icon_text = IconTextBottom; 1700 icon_text = IconTextBottom;
1699 else if ( icontext == "TextOnly" ) 1701 else if ( icontext == "TextOnly" )
1700 icon_text = TextOnly; 1702 icon_text = TextOnly;
1701 else 1703 else
1702 icon_text = IconOnly; 1704 icon_text = IconOnly;
1703 1705
1704 // check if the icon/text has changed 1706 // check if the icon/text has changed
1705 if (icon_text != d->m_iconText) { 1707 if (icon_text != d->m_iconText) {
1706 //kdDebug(220) << "KToolBar::applyAppearanceSettings setIconText " << icon_text << endl; 1708 //kdDebug(220) << "KToolBar::applyAppearanceSettings setIconText " << icon_text << endl;
1707 setIconText(icon_text, false); 1709 setIconText(icon_text, false);
1708 doUpdate = true; 1710 doUpdate = true;
1709 } 1711 }
1710 1712
1711 // ...and check if the icon size has changed 1713 // ...and check if the icon size has changed
1712 if (iconsize != d->m_iconSize) { 1714 if (iconsize != d->m_iconSize) {
1713 setIconSize(iconsize, false); 1715 setIconSize(iconsize, false);
1714 doUpdate = true; 1716 doUpdate = true;
1715 } 1717 }
1716 1718
1717 QMainWindow *mw = mainWindow(); 1719 QMainWindow *mw = mainWindow();
1718 1720
1719 // ...and if we should highlight 1721 // ...and if we should highlight
1720 if ( highlight != d->m_highlight ) { 1722 if ( highlight != d->m_highlight ) {
1721 d->m_highlight = highlight; 1723 d->m_highlight = highlight;
1722 doUpdate = true; 1724 doUpdate = true;
1723 } 1725 }
1724 1726
1725 // ...and if we should move transparently 1727 // ...and if we should move transparently
1726 if ( mw && transparent != (!mw->opaqueMoving()) ) { 1728 if ( mw && transparent != (!mw->opaqueMoving()) ) {
1727 mw->setOpaqueMoving( !transparent ); 1729 mw->setOpaqueMoving( !transparent );
1728 } 1730 }
1729 1731
1730 if (doUpdate) 1732 if (doUpdate)
1731 emit modechange(); // tell buttons what happened 1733 emit modechange(); // tell buttons what happened
1732 if (isVisible ()) 1734 if (isVisible ())
1733 updateGeometry(); 1735 updateGeometry();
1734} 1736}
1735 1737
1736void KToolBar::applySettings(KConfig *config, const QString &_configGroup) 1738void KToolBar::applySettings(KConfig *config, const QString &_configGroup)
1737{ 1739{
1738 //kdDebug(220) << "KToolBar::applySettings group=" << _configGroup << endl; 1740 //kdDebug(220) << "KToolBar::applySettings group=" << _configGroup << endl;
1739 1741
1740 QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup; 1742 QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup;
1741 1743
1742 /* 1744 /*
1743 Let's explain this a bit more in details. 1745 Let's explain this a bit more in details.
1744 The order in which we apply settings is : 1746 The order in which we apply settings is :
1745 Global config / <appnamerc> user settings if no XMLGUI is used 1747 Global config / <appnamerc> user settings if no XMLGUI is used
1746 Global config / App-XML attributes / <appnamerc> user settings if XMLGUI is used 1748 Global config / App-XML attributes / <appnamerc> user settings if XMLGUI is used
1747 1749
1748 So in the first case, we simply read everything from KConfig as below, 1750 So in the first case, we simply read everything from KConfig as below,
1749 but in the second case we don't do anything here if there is no app-specific config, 1751 but in the second case we don't do anything here if there is no app-specific config,
1750 and the XMLGUI uses the static methods of this class to get the global defaults. 1752 and the XMLGUI uses the static methods of this class to get the global defaults.
1751 1753
1752 Global config doesn't include position (index, offset, newline and hidden/shown). 1754 Global config doesn't include position (index, offset, newline and hidden/shown).
1753 */ 1755 */
1754 1756
1755 // First the appearance stuff - the one which has a global config 1757 // First the appearance stuff - the one which has a global config
1756 applyAppearanceSettings( config, _configGroup ); 1758 applyAppearanceSettings( config, _configGroup );
1757 1759
1758 // ...and now the position stuff 1760 // ...and now the position stuff
1759 if ( config->hasGroup(configGroup) ) 1761 if ( config->hasGroup(configGroup) )
1760 { 1762 {
1761 KConfigGroupSaver cgs(config, configGroup); 1763 KConfigGroupSaver cgs(config, configGroup);
1762/*US 1764/*US
1763 static const QString &attrPosition = KGlobal::staticQString("Position"); 1765 static const QString &attrPosition = KGlobal::staticQString("Position");
1764 static const QString &attrIndex = KGlobal::staticQString("Index"); 1766 static const QString &attrIndex = KGlobal::staticQString("Index");
1765 static const QString &attrOffset = KGlobal::staticQString("Offset"); 1767 static const QString &attrOffset = KGlobal::staticQString("Offset");
1766 static const QString &attrNewLine = KGlobal::staticQString("NewLine"); 1768 static const QString &attrNewLine = KGlobal::staticQString("NewLine");
1767 static const QString &attrHidden = KGlobal::staticQString("Hidden"); 1769 static const QString &attrHidden = KGlobal::staticQString("Hidden");
1768 1770
1769 QString position = config->readEntry(attrPosition, d->PositionDefault); 1771 QString position = config->readEntry(attrPosition, d->PositionDefault);
1770 int index = config->readNumEntry(attrIndex, d->IndexDefault); 1772 int index = config->readNumEntry(attrIndex, d->IndexDefault);
1771 int offset = config->readNumEntry(attrOffset, d->OffsetDefault); 1773 int offset = config->readNumEntry(attrOffset, d->OffsetDefault);
1772 bool newLine = config->readBoolEntry(attrNewLine, d->NewLineDefault); 1774 bool newLine = config->readBoolEntry(attrNewLine, d->NewLineDefault);
1773 bool hidden = config->readBoolEntry(attrHidden, d->HiddenDefault); 1775 bool hidden = config->readBoolEntry(attrHidden, d->HiddenDefault);
1774*/ 1776*/
1775 1777
1776 QString position = config->readEntry("Position", d->PositionDefault); 1778 QString position = config->readEntry("Position", d->PositionDefault);
1777 int index = config->readNumEntry("Index", d->IndexDefault); 1779 int index = config->readNumEntry("Index", d->IndexDefault);
1778 int offset = config->readNumEntry("Offset", d->OffsetDefault); 1780 int offset = config->readNumEntry("Offset", d->OffsetDefault);
1779 bool newLine = config->readBoolEntry("NewLine", d->NewLineDefault); 1781 bool newLine = config->readBoolEntry("NewLine", d->NewLineDefault);
1780 bool hidden = config->readBoolEntry("Hidden", d->HiddenDefault); 1782 bool hidden = config->readBoolEntry("Hidden", d->HiddenDefault);
1781 1783
1782/*US Dock pos(DockTop); 1784/*US Dock pos(DockTop);
1783 if ( position == "Top" ) 1785 if ( position == "Top" )
1784 pos = DockTop; 1786 pos = DockTop;
1785 else if ( position == "Bottom" ) 1787 else if ( position == "Bottom" )
1786 pos = DockBottom; 1788 pos = DockBottom;
1787 else if ( position == "Left" ) 1789 else if ( position == "Left" )
1788 pos = DockLeft; 1790 pos = DockLeft;
1789 else if ( position == "Right" ) 1791 else if ( position == "Right" )
1790 pos = DockRight; 1792 pos = DockRight;
1791 else if ( position == "Floating" ) 1793 else if ( position == "Floating" )
1792 pos = DockTornOff; 1794 pos = DockTornOff;
1793 else if ( position == "Flat" ) 1795 else if ( position == "Flat" )
1794 pos = DockMinimized; 1796 pos = DockMinimized;
1795*/ 1797*/
1796 QMainWindow::ToolBarDock pos(QMainWindow::Top); 1798 QMainWindow::ToolBarDock pos(QMainWindow::Top);
1797 if ( position == "Top" ) 1799 if ( position == "Top" )
1798 pos = QMainWindow::Top; 1800 pos = QMainWindow::Top;
1799 else if ( position == "Bottom" ) 1801 else if ( position == "Bottom" )
1800 pos = QMainWindow::Bottom; 1802 pos = QMainWindow::Bottom;
1801 else if ( position == "Left" ) 1803 else if ( position == "Left" )
1802 pos = QMainWindow::Left; 1804 pos = QMainWindow::Left;
1803 else if ( position == "Right" ) 1805 else if ( position == "Right" )
1804 pos = QMainWindow::Right; 1806 pos = QMainWindow::Right;
1805 else if ( position == "Floating" ) 1807 else if ( position == "Floating" )
1806 pos = QMainWindow::TornOff; 1808 pos = QMainWindow::TornOff;
1807 else if ( position == "Flat" ) 1809 else if ( position == "Flat" )
1808 pos = QMainWindow::Minimized; 1810 pos = QMainWindow::Minimized;
1809 1811
1810 //kdDebug(220) << "KToolBar::applySettings hidden=" << hidden << endl; 1812 //kdDebug(220) << "KToolBar::applySettings hidden=" << hidden << endl;
1811 if (hidden) 1813 if (hidden)
1812 hide(); 1814 hide();
1813 else 1815 else
1814 show(); 1816 show();
1815 1817
1816 if ( mainWindow() ) 1818 if ( mainWindow() )
1817 { 1819 {
1818 QMainWindow *mw = mainWindow(); 1820 QMainWindow *mw = mainWindow();
1819 1821
1820 //kdDebug(220) << "KToolBar::applySettings updating ToolbarInfo" << endl; 1822 //kdDebug(220) << "KToolBar::applySettings updating ToolbarInfo" << endl;
1821 d->toolBarInfo = KToolBarPrivate::ToolBarInfo( pos, index, newLine, offset ); 1823 d->toolBarInfo = KToolBarPrivate::ToolBarInfo( pos, index, newLine, offset );
1822 1824
1823 // moveDockWindow calls QDockArea which does a reparent() on us with 1825 // moveDockWindow calls QDockArea which does a reparent() on us with
1824 // showIt = true, so we loose our visibility status 1826 // showIt = true, so we loose our visibility status
1825 bool doHide = isHidden(); 1827 bool doHide = isHidden();
1826 1828
1827//US mw->moveDockWindow( this, pos, newLine, index, offset ); 1829//US mw->moveDockWindow( this, pos, newLine, index, offset );
1828 mw->moveToolBar( this, pos, newLine, index, offset ); 1830 mw->moveToolBar( this, pos, newLine, index, offset );
1829 1831
1830 //kdDebug(220) << "KToolBar::applySettings " << name() << " moveDockWindow with pos=" << pos << " newLine=" << newLine << " idx=" << index << " offs=" << offset << endl; 1832 //kdDebug(220) << "KToolBar::applySettings " << name() << " moveDockWindow with pos=" << pos << " newLine=" << newLine << " idx=" << index << " offs=" << offset << endl;
1831 if ( doHide ) 1833 if ( doHide )
1832 hide(); 1834 hide();
1833 } 1835 }
1834 if (isVisible ()) 1836 if (isVisible ())
1835 updateGeometry(); 1837 updateGeometry();
1836 } 1838 }
1837} 1839}
1838 1840
1839bool KToolBar::event( QEvent *e ) 1841bool KToolBar::event( QEvent *e )
1840{ 1842{
1841 if ( (e->type() == QEvent::LayoutHint) && isUpdatesEnabled() ) 1843 if ( (e->type() == QEvent::LayoutHint) && isUpdatesEnabled() )
1842 d->repaintTimer.start( 100, true ); 1844 d->repaintTimer.start( 100, true );
1843 1845
1844 if (e->type() == QEvent::ChildInserted ) 1846 if (e->type() == QEvent::ChildInserted )
1845 { 1847 {
1846 // By pass QToolBar::event, 1848 // By pass QToolBar::event,
1847 // it will show() the inserted child and we don't want to 1849 // it will show() the inserted child and we don't want to
1848 // do that until we have rebuild the layout. 1850 // do that until we have rebuild the layout.
1849 childEvent((QChildEvent *)e); 1851 childEvent((QChildEvent *)e);
1850 return true; 1852 return true;
1851 } 1853 }
1852 1854
1853 return QToolBar::event( e ); 1855 return QToolBar::event( e );
1854} 1856}
1855 1857
1856void KToolBar::slotRepaint() 1858void KToolBar::slotRepaint()
1857{ 1859{
1858 setUpdatesEnabled( FALSE ); 1860 setUpdatesEnabled( FALSE );
1859 // Send a resizeEvent to update the "toolbar extension arrow" 1861 // Send a resizeEvent to update the "toolbar extension arrow"
1860 // (The button you get when your toolbar-items don't fit in 1862 // (The button you get when your toolbar-items don't fit in
1861 // the available space) 1863 // the available space)
1862 QResizeEvent ev(size(), size()); 1864 QResizeEvent ev(size(), size());
1863 resizeEvent(&ev); 1865 resizeEvent(&ev);
1864 //#ifdef DESKTOP_VERSION 1866 //#ifdef DESKTOP_VERSION
1865 QApplication::sendPostedEvents( this, QEvent::LayoutHint ); 1867 QApplication::sendPostedEvents( this, QEvent::LayoutHint );
1866 //#endif //DESKTOP_VERSION 1868 //#endif //DESKTOP_VERSION
1867 setUpdatesEnabled( TRUE ); 1869 setUpdatesEnabled( TRUE );
1868 repaint( TRUE ); 1870 repaint( TRUE );
1869} 1871}
1870 1872
1871void KToolBar::toolBarPosChanged( QToolBar *tb ) 1873void KToolBar::toolBarPosChanged( QToolBar *tb )
1872{ 1874{
1873 if ( tb != this ) 1875 if ( tb != this )
1874 return; 1876 return;
1875//US if ( d->oldPos == DockMinimized ) 1877//US if ( d->oldPos == DockMinimized )
1876 if ( d->oldPos == QMainWindow::Minimized ) 1878 if ( d->oldPos == QMainWindow::Minimized )
1877 rebuildLayout(); 1879 rebuildLayout();
1878 d->oldPos = (QMainWindow::ToolBarDock)barPos(); 1880 d->oldPos = (QMainWindow::ToolBarDock)barPos();
1879/*US 1881/*US
1880 if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) 1882 if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) )
1881 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); 1883 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty();
1882*/ 1884*/
1883} 1885}
1884 1886
1885/*US 1887/*US
1886void KToolBar::loadState( const QDomElement &element ) 1888void KToolBar::loadState( const QDomElement &element )
1887{ 1889{
1888 //kdDebug(220) << "KToolBar::loadState " << this << endl; 1890 //kdDebug(220) << "KToolBar::loadState " << this << endl;
1889 if ( !mainWindow() ) 1891 if ( !mainWindow() )
1890 return; 1892 return;
1891 1893
1892 { 1894 {
1893 QCString text = element.namedItem( "text" ).toElement().text().utf8(); 1895 QCString text = element.namedItem( "text" ).toElement().text().utf8();
1894 if ( text.isEmpty() ) 1896 if ( text.isEmpty() )
1895 text = element.namedItem( "Text" ).toElement().text().utf8(); 1897 text = element.namedItem( "Text" ).toElement().text().utf8();
1896 if ( !text.isEmpty() ) 1898 if ( !text.isEmpty() )
1897 setText( i18n( text ) ); 1899 setText( i18n( text ) );
1898 } 1900 }
1899 1901
1900 { 1902 {
1901 QCString attrFullWidth = element.attribute( "fullWidth" ).lower().latin1(); 1903 QCString attrFullWidth = element.attribute( "fullWidth" ).lower().latin1();
1902 if ( !attrFullWidth.isEmpty() ) 1904 if ( !attrFullWidth.isEmpty() )
1903 setFullSize( attrFullWidth == "true" ); 1905 setFullSize( attrFullWidth == "true" );
1904 } 1906 }
1905 1907
1906 Dock dock = DockTop; 1908 Dock dock = DockTop;
1907 { 1909 {
1908 QCString attrPosition = element.attribute( "position" ).lower().latin1(); 1910 QCString attrPosition = element.attribute( "position" ).lower().latin1();
1909 //kdDebug(220) << "KToolBar::loadState attrPosition=" << attrPosition << endl; 1911 //kdDebug(220) << "KToolBar::loadState attrPosition=" << attrPosition << endl;
1910 if ( !attrPosition.isEmpty() ) { 1912 if ( !attrPosition.isEmpty() ) {
1911 if ( attrPosition == "top" ) 1913 if ( attrPosition == "top" )
1912 dock = DockTop; 1914 dock = DockTop;
1913 else if ( attrPosition == "left" ) 1915 else if ( attrPosition == "left" )
1914 dock = DockLeft; 1916 dock = DockLeft;
1915 else if ( attrPosition == "right" ) 1917 else if ( attrPosition == "right" )
1916 dock = DockRight; 1918 dock = DockRight;
1917 else if ( attrPosition == "bottom" ) 1919 else if ( attrPosition == "bottom" )
1918 dock = DockBottom; 1920 dock = DockBottom;
1919 else if ( attrPosition == "floating" ) 1921 else if ( attrPosition == "floating" )
1920 dock = DockTornOff; 1922 dock = DockTornOff;
1921 else if ( attrPosition == "flat" ) 1923 else if ( attrPosition == "flat" )
1922 dock = DockMinimized; 1924 dock = DockMinimized;
1923 } 1925 }
1924 } 1926 }
1925 1927
1926 { 1928 {
1927 QCString attrIconText = element.attribute( "iconText" ).lower().latin1(); 1929 QCString attrIconText = element.attribute( "iconText" ).lower().latin1();
1928 if ( !attrIconText.isEmpty() ) { 1930 if ( !attrIconText.isEmpty() ) {
1929 //kdDebug(220) << "KToolBar::loadState attrIconText=" << attrIconText << endl; 1931 //kdDebug(220) << "KToolBar::loadState attrIconText=" << attrIconText << endl;
1930 if ( attrIconText == "icontextright" ) 1932 if ( attrIconText == "icontextright" )
1931 setIconText( KToolBar::IconTextRight ); 1933 setIconText( KToolBar::IconTextRight );
1932 else if ( attrIconText == "textonly" ) 1934 else if ( attrIconText == "textonly" )
1933 setIconText( KToolBar::TextOnly ); 1935 setIconText( KToolBar::TextOnly );
1934 else if ( attrIconText == "icontextbottom" ) 1936 else if ( attrIconText == "icontextbottom" )
1935 setIconText( KToolBar::IconTextBottom ); 1937 setIconText( KToolBar::IconTextBottom );
1936 else if ( attrIconText == "icononly" ) 1938 else if ( attrIconText == "icononly" )
1937 setIconText( KToolBar::IconOnly ); 1939 setIconText( KToolBar::IconOnly );
1938 } else 1940 } else
1939 // Use global setting 1941 // Use global setting
1940 setIconText( iconTextSetting() ); 1942 setIconText( iconTextSetting() );
1941 } 1943 }
1942 1944
1943 { 1945 {
1944 QString attrIconSize = element.attribute( "iconSize" ).lower(); 1946 QString attrIconSize = element.attribute( "iconSize" ).lower();
1945 if ( !attrIconSize.isEmpty() ) 1947 if ( !attrIconSize.isEmpty() )
1946 d->IconSizeDefault = attrIconSize.toInt(); 1948 d->IconSizeDefault = attrIconSize.toInt();
1947 setIconSize( d->IconSizeDefault ); 1949 setIconSize( d->IconSizeDefault );
1948 } 1950 }
1949 1951
1950 { 1952 {
1951 QString attrIndex = element.attribute( "index" ).lower(); 1953 QString attrIndex = element.attribute( "index" ).lower();
1952 if ( !attrIndex.isEmpty() ) 1954 if ( !attrIndex.isEmpty() )
1953 d->IndexDefault = attrIndex.toInt(); 1955 d->IndexDefault = attrIndex.toInt();
1954 } 1956 }
1955 1957
1956 { 1958 {
1957 QString attrOffset = element.attribute( "offset" ).lower(); 1959 QString attrOffset = element.attribute( "offset" ).lower();
1958 if ( !attrOffset.isEmpty() ) 1960 if ( !attrOffset.isEmpty() )
1959 d->OffsetDefault = attrOffset.toInt(); 1961 d->OffsetDefault = attrOffset.toInt();
1960 } 1962 }
1961 1963
1962 { 1964 {
1963 QString attrNewLine = element.attribute( "newline" ).lower(); 1965 QString attrNewLine = element.attribute( "newline" ).lower();
1964 if ( !attrNewLine.isEmpty() ) 1966 if ( !attrNewLine.isEmpty() )
1965 d->NewLineDefault = attrNewLine == "true"; 1967 d->NewLineDefault = attrNewLine == "true";
1966 } 1968 }
1967 1969
1968 { 1970 {
1969 QString attrHidden = element.attribute( "hidden" ).lower(); 1971 QString attrHidden = element.attribute( "hidden" ).lower();
1970 if ( !attrHidden.isEmpty() ) 1972 if ( !attrHidden.isEmpty() )
1971 d->HiddenDefault = attrHidden == "true"; 1973 d->HiddenDefault = attrHidden == "true";
1972 } 1974 }
1973 1975
1974 d->toolBarInfo = KToolBarPrivate::ToolBarInfo( dock, d->IndexDefault, d->NewLineDefault, d->OffsetDefault ); 1976 d->toolBarInfo = KToolBarPrivate::ToolBarInfo( dock, d->IndexDefault, d->NewLineDefault, d->OffsetDefault );
1975 mainWindow()->addDockWindow( this, dock, d->NewLineDefault ); 1977 mainWindow()->addDockWindow( this, dock, d->NewLineDefault );
1976//US mainWindow()->moveDockWindow( this, dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); 1978//US mainWindow()->moveDockWindow( this, dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault );
1977 mainWindow()->moveToolBar( this, dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); 1979 mainWindow()->moveToolBar( this, dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault );
1978 1980
1979 // Apply the highlight button setting 1981 // Apply the highlight button setting
1980 d->m_highlight = highlightSetting(); 1982 d->m_highlight = highlightSetting();
1981 1983
1982 // Apply transparent-toolbar-moving setting (ok, this is global to the mainwindow, 1984 // Apply transparent-toolbar-moving setting (ok, this is global to the mainwindow,
1983 // but we do it only if there are toolbars...) 1985 // but we do it only if there are toolbars...)
1984 if ( transparentSetting() != !mainWindow()->opaqueMoving() ) 1986 if ( transparentSetting() != !mainWindow()->opaqueMoving() )
1985 mainWindow()->setOpaqueMoving( !transparentSetting() ); 1987 mainWindow()->setOpaqueMoving( !transparentSetting() );
1986 1988
1987 if ( d->HiddenDefault ) 1989 if ( d->HiddenDefault )
1988 hide(); 1990 hide();
1989 else 1991 else
1990 show(); 1992 show();
1991 1993
1992 getAttributes( d->PositionDefault, d->IconTextDefault, d->IndexDefault ); 1994 getAttributes( d->PositionDefault, d->IconTextDefault, d->IndexDefault );
1993} 1995}
1994*/ 1996*/
1995 1997
1996void KToolBar::getAttributes( QString &position, QString &icontext, int &index ) 1998void KToolBar::getAttributes( QString &position, QString &icontext, int &index )
1997{ 1999{
1998 // get all of the stuff to save 2000 // get all of the stuff to save
1999 switch ( barPos() ) { 2001 switch ( barPos() ) {
2000 case KToolBar::Flat: 2002 case KToolBar::Flat:
2001 position = "Flat"; 2003 position = "Flat";
2002 break; 2004 break;
2003 case KToolBar::Bottom: 2005 case KToolBar::Bottom:
2004 position = "Bottom"; 2006 position = "Bottom";
2005 break; 2007 break;
2006 case KToolBar::Left: 2008 case KToolBar::Left:
2007 position = "Left"; 2009 position = "Left";
2008 break; 2010 break;
2009 case KToolBar::Right: 2011 case KToolBar::Right:
2010 position = "Right"; 2012 position = "Right";
2011 break; 2013 break;
2012 case KToolBar::Floating: 2014 case KToolBar::Floating:
2013 position = "Floating"; 2015 position = "Floating";
2014 break; 2016 break;
2015 case KToolBar::Top: 2017 case KToolBar::Top:
2016 default: 2018 default:
2017 position = "Top"; 2019 position = "Top";
2018 break; 2020 break;
2019 } 2021 }
2020 2022
2021 if ( mainWindow() ) { 2023 if ( mainWindow() ) {
2022 QMainWindow::ToolBarDock dock; 2024 QMainWindow::ToolBarDock dock;
2023 bool newLine; 2025 bool newLine;
2024 int offset; 2026 int offset;
2025 mainWindow()->getLocation( this, dock, index, newLine, offset ); 2027 mainWindow()->getLocation( this, dock, index, newLine, offset );
2026 } 2028 }
2027 2029
2028 switch (d->m_iconText) { 2030 switch (d->m_iconText) {
2029 case KToolBar::IconTextRight: 2031 case KToolBar::IconTextRight:
2030 icontext = "IconTextRight"; 2032 icontext = "IconTextRight";
2031 break; 2033 break;
2032 case KToolBar::IconTextBottom: 2034 case KToolBar::IconTextBottom:
2033 icontext = "IconTextBottom"; 2035 icontext = "IconTextBottom";
2034 break; 2036 break;
2035 case KToolBar::TextOnly: 2037 case KToolBar::TextOnly:
2036 icontext = "TextOnly"; 2038 icontext = "TextOnly";
2037 break; 2039 break;
2038 case KToolBar::IconOnly: 2040 case KToolBar::IconOnly:
2039 default: 2041 default:
2040 icontext = "IconOnly"; 2042 icontext = "IconOnly";
2041 break; 2043 break;
2042 } 2044 }
2043} 2045}
2044/*US 2046/*US
2045void KToolBar::saveState( QDomElement &current ) 2047void KToolBar::saveState( QDomElement &current )
2046{ 2048{
2047 QString position, icontext; 2049 QString position, icontext;
2048 int index = -1; 2050 int index = -1;
2049 getAttributes( position, icontext, index ); 2051 getAttributes( position, icontext, index );
2050 2052
2051 current.setAttribute( "noMerge", "1" ); 2053 current.setAttribute( "noMerge", "1" );
2052 current.setAttribute( "position", position ); 2054 current.setAttribute( "position", position );
2053 current.setAttribute( "iconText", icontext ); 2055 current.setAttribute( "iconText", icontext );
2054 current.setAttribute( "index", index ); 2056 current.setAttribute( "index", index );
2055 current.setAttribute( "offset", offset() ); 2057 current.setAttribute( "offset", offset() );
2056 current.setAttribute( "newline", newLine() ); 2058 current.setAttribute( "newline", newLine() );
2057 if ( isHidden() ) 2059 if ( isHidden() )
2058 current.setAttribute( "hidden", "true" ); 2060 current.setAttribute( "hidden", "true" );
2059 d->modified = true; 2061 d->modified = true;
2060} 2062}
2061*/ 2063*/
2062 2064
2063void KToolBar::positionYourself( bool force ) 2065void KToolBar::positionYourself( bool force )
2064{ 2066{
2065 if (force) 2067 if (force)
2066 d->positioned = false; 2068 d->positioned = false;
2067 2069
2068 if ( d->positioned || !mainWindow() ) 2070 if ( d->positioned || !mainWindow() )
2069 { 2071 {
2070 //kdDebug(220) << "KToolBar::positionYourself d->positioned=true ALREADY DONE" << endl; 2072 //kdDebug(220) << "KToolBar::positionYourself d->positioned=true ALREADY DONE" << endl;
2071 return; 2073 return;
2072 } 2074 }
2073 // we can't test for ForceHide after moveDockWindow because QDockArea 2075 // we can't test for ForceHide after moveDockWindow because QDockArea
2074 // does a reparent() with showIt == true 2076 // does a reparent() with showIt == true
2075 bool doHide = isHidden(); 2077 bool doHide = isHidden();
2076 //kdDebug(220) << "positionYourself " << name() << " dock=" << d->toolBarInfo.dock << " newLine=" << d->toolBarInfo.newline << " offset=" << d->toolBarInfo.offset << endl; 2078 //kdDebug(220) << "positionYourself " << name() << " dock=" << d->toolBarInfo.dock << " newLine=" << d->toolBarInfo.newline << " offset=" << d->toolBarInfo.offset << endl;
2077/*US mainWindow()->moveDockWindow( this, d->toolBarInfo.dock, 2079/*US mainWindow()->moveDockWindow( this, d->toolBarInfo.dock,
2078 d->toolBarInfo.newline, 2080 d->toolBarInfo.newline,
2079 d->toolBarInfo.index, 2081 d->toolBarInfo.index,
2080 d->toolBarInfo.offset ); 2082 d->toolBarInfo.offset );
2081*/ 2083*/
2082 mainWindow()->moveToolBar( this, d->toolBarInfo.dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); 2084 mainWindow()->moveToolBar( this, d->toolBarInfo.dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault );
2083 2085
2084 if ( doHide ) 2086 if ( doHide )
2085 hide(); 2087 hide();
2086 // This method can only have an effect once - unless force is set 2088 // This method can only have an effect once - unless force is set
2087 d->positioned = TRUE; 2089 d->positioned = TRUE;
2088} 2090}
2089 2091
2090//US KPopupMenu *KToolBar::contextMenu() 2092//US KPopupMenu *KToolBar::contextMenu()
2091QPopupMenu *KToolBar::contextMenu() 2093QPopupMenu *KToolBar::contextMenu()
2092{ 2094{
2093 if ( context ) 2095 if ( context )
2094 return context; 2096 return context;
2095 2097
2096 // Construct our context popup menu. Name it qt_dockwidget_internal so it 2098 // Construct our context popup menu. Name it qt_dockwidget_internal so it
2097 // won't be deleted by QToolBar::clear(). 2099 // won't be deleted by QToolBar::clear().
2098//US context = new KPopupMenu( this, "qt_dockwidget_internal" ); 2100//US context = new KPopupMenu( this, "qt_dockwidget_internal" );
2099 context = new QPopupMenu( this, "qt_dockwidget_internal" ); 2101 context = new QPopupMenu( this, "qt_dockwidget_internal" );
2100//US context->insertTitle(i18n("Toolbar Menu")); 2102//US context->insertTitle(i18n("Toolbar Menu"));
2101 2103
2102//US KPopupMenu *orient = new KPopupMenu( context, "orient" ); 2104//US KPopupMenu *orient = new KPopupMenu( context, "orient" );
2103 QPopupMenu *orient = new QPopupMenu( context, "orient" ); 2105 QPopupMenu *orient = new QPopupMenu( context, "orient" );
2104 orient->insertItem( i18n("toolbar position string","Top"), CONTEXT_TOP ); 2106 orient->insertItem( i18n("toolbar position string","Top"), CONTEXT_TOP );
2105 orient->insertItem( i18n("toolbar position string","Left"), CONTEXT_LEFT ); 2107 orient->insertItem( i18n("toolbar position string","Left"), CONTEXT_LEFT );
2106 orient->insertItem( i18n("toolbar position string","Right"), CONTEXT_RIGHT ); 2108 orient->insertItem( i18n("toolbar position string","Right"), CONTEXT_RIGHT );
2107 orient->insertItem( i18n("toolbar position string","Bottom"), CONTEXT_BOTTOM ); 2109 orient->insertItem( i18n("toolbar position string","Bottom"), CONTEXT_BOTTOM );
2108 orient->insertSeparator(-1); 2110 orient->insertSeparator(-1);
2109 //orient->insertItem( i18n("toolbar position string","Floating"), CONTEXT_FLOAT ); 2111 //orient->insertItem( i18n("toolbar position string","Floating"), CONTEXT_FLOAT );
2110 orient->insertItem( i18n("min toolbar", "Flat"), CONTEXT_FLAT ); 2112 orient->insertItem( i18n("min toolbar", "Flat"), CONTEXT_FLAT );
2111 2113
2112//US KPopupMenu *mode = new KPopupMenu( context, "mode" ); 2114//US KPopupMenu *mode = new KPopupMenu( context, "mode" );
2113 QPopupMenu *mode = new QPopupMenu( context, "mode" ); 2115 QPopupMenu *mode = new QPopupMenu( context, "mode" );
2114 mode->insertItem( i18n("Icons Only"), CONTEXT_ICONS ); 2116 mode->insertItem( i18n("Icons Only"), CONTEXT_ICONS );
2115 mode->insertItem( i18n("Text Only"), CONTEXT_TEXT ); 2117 mode->insertItem( i18n("Text Only"), CONTEXT_TEXT );
2116 mode->insertItem( i18n("Text Alongside Icons"), CONTEXT_TEXTRIGHT ); 2118 mode->insertItem( i18n("Text Alongside Icons"), CONTEXT_TEXTRIGHT );
2117 mode->insertItem( i18n("Text Under Icons"), CONTEXT_TEXTUNDER ); 2119 mode->insertItem( i18n("Text Under Icons"), CONTEXT_TEXTUNDER );
2118 2120