From kde-pim Mon Feb 04 20:27:25 2008 From: "Mischael Schill" Date: Mon, 04 Feb 2008 20:27:25 +0000 To: kde-pim Subject: Re: [Kde-pim] New Sidebar for kontact Message-Id: <200802042127.26352.me () mschill ! ch> X-MARC-Message: https://marc.info/?l=kde-pim&m=120215675508613 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--===============1561357302==" --===============1561357302== Content-Type: multipart/signed; boundary="nextPart4559877.siK5HZ1TaV"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit --nextPart4559877.siK5HZ1TaV Content-Type: multipart/mixed; boundary="Boundary-01=_uU3pHe0ZtJqU8tU" Content-Transfer-Encoding: 7bit Content-Disposition: inline --Boundary-01=_uU3pHe0ZtJqU8tU Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline So, i've done all my corrections. Here is the patch, if the new "style" is acceptable :). It's=20 pretty much a total rewrite using KToolBar instead of a List,=20 because of my lack of qt-skills. I tried to make my coding style better and learned a lot.=20 Cheers, Mischa --Boundary-01=_uU3pHe0ZtJqU8tU Content-Type: text/x-diff; charset="utf-8"; name="newsidepane.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="newsidepane.diff" Index: mainwindow.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- mainwindow.cpp (Revision 770947) +++ mainwindow.cpp (Arbeitskopie) @@ -285,7 +285,7 @@ sizes << 0; mSplitter->setSizes(sizes); */ =2D mSidePane->setActionCollection( actionCollection() ); + //mSidePane->setActionCollection( actionCollection() ); =20 connect( mSidePane, SIGNAL( pluginSelected( Kontact::Plugin * ) ), SLOT( selectPlugin( Kontact::Plugin * ) ) ); @@ -638,7 +638,7 @@ =20 if ( plugin->isRunningStandalone() ) { statusBar()->showMessage( i18n( "Application is running standalone. Fo= regrounding..." ), 1000 ); =2D mSidePane->indicateForegrunding( plugin ); + mSidePane->indicateForegrounding( plugin ); plugin->bringToForeground(); return; } Index: iconsidepane.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- iconsidepane.h (Revision 770947) +++ iconsidepane.h (Arbeitskopie) @@ -31,8 +31,8 @@ #include #include =20 =2D#include =2D +#include +#include #include "sidepanebase.h" #include "prefs.h" =20 @@ -48,138 +48,33 @@ class Plugin; class Navigator; =20 =2Denum IconViewMode { LargeIcons =3D 48, NormalIcons =3D 32, SmallIcons = =3D 22, ShowText =3D 3, ShowIcons =3D 5 }; =2D =2D /** =2D A QListBoxPixmap Square Box with an optional icon and a text =2D underneath. =2D*/ =2Dclass EntryItem : public Q3ListBoxItem =2D{ =2D public: =2D EntryItem( Navigator *, Kontact::Plugin * ); =2D ~EntryItem(); =2D =2D Kontact::Plugin *plugin() const { return mPlugin; } =2D =2D const QPixmap *pixmap() const { return &mPixmap; } =2D =2D Navigator* navigator() const; =2D =2D void setHover( bool ); =2D void setPaintActive( bool ); =2D bool paintActive() const { return mPaintActive; } =2D /** =2D returns the width of this item. =2D */ =2D virtual int width( const Q3ListBox * ) const; =2D /** =2D returns the height of this item. =2D */ =2D virtual int height( const Q3ListBox * ) const; =2D =2D protected: =2D void reloadPixmap(); =2D =2D virtual void paint( QPainter *p ); =2D =2D private: =2D Kontact::Plugin *mPlugin; =2D QPixmap mPixmap; =2D bool mHasHover; =2D bool mPaintActive; =2D}; =2D =2D/** =2D * Tooltip that changes text depending on the item it is above. =2D * Compliments of "Practical Qt" by Dalheimer, Petersen et al. =2D */ =2D#ifdef __GNUC__ =2D#warning Port me! =2D#endif =2D#if 0 =2Dclass EntryItemToolTip : public QToolTip =2D{ =2D public: =2D EntryItemToolTip( Q3ListBox* parent ) =2D : QToolTip( parent->viewport() ), mListBox( parent ) =2D {} =2D protected: =2D void maybeTip( const QPoint& p ) { =2D // We only show tooltips when there are no texts shown =2D if ( Prefs::self()->sidePaneShowText() ) return; =2D if ( !mListBox ) return; =2D Q3ListBoxItem* item =3D mListBox->itemAt( p ); =2D if ( !item ) return; =2D const QRect itemRect =3D mListBox->itemRect( item ); =2D if ( !itemRect.isValid() ) return; =2D =2D const EntryItem *entryItem =3D static_cast( item ); =2D QString tipStr =3D entryItem->text(); =2D tip( itemRect, tipStr ); =2D } =2D private: =2D Q3ListBox* mListBox; =2D}; =2D#endif =2D =2D/** Navigation pane showing all parts relevant to the user */ =2Dclass Navigator : public K3ListBox +class Navigator : public KToolBar { Q_OBJECT public: =2D Navigator( SidePaneBase *parent =3D 0, const char *name =3D 0 ); + Navigator( SidePaneBase *parent =3D 0 ); + ~Navigator(); =20 =2D virtual void setSelected( Q3ListBoxItem *, bool ); =2D void updatePlugins( QList plugins ); + void selectPlugin( Kontact::Plugin* plugin ); + void selectPlugin( const QString &name ); + void disablePlugin( Kontact::Plugin *plugin ); + void enablePlugin( Kontact::Plugin *plugin ); =20 =2D QSize sizeHint() const; =2D =2D void highlightItem( EntryItem* item ); =2D =2D IconViewMode viewMode() { return mViewMode; } =2D IconViewMode sizeIntToEnum(int size) const; =2D const QList & actions() { return mActions; } =2D bool showIcons() const { return mShowIcons; } =2D bool showText() const { return mShowText; } signals: void pluginActivated( Kontact::Plugin * ); =20 =2D protected: =2D void dragEnterEvent( QDragEnterEvent * ); =2D void dragMoveEvent ( QDragMoveEvent * ); =2D void dropEvent( QDropEvent * ); =2D void resizeEvent( QResizeEvent * ); =2D void enterEvent( QEvent* ); =2D void leaveEvent( QEvent* ); =2D =2D void setHoverItem( Q3ListBoxItem*, bool ); =2D void setPaintActiveItem( Q3ListBoxItem*, bool ); =2D =2D protected slots: =2D void slotExecuted( Q3ListBoxItem * ); =2D void slotMouseOn( Q3ListBoxItem *item ); =2D void slotMouseOff(); =2D void slotShowRMBMenu( Q3ListBoxItem *, const QPoint& ); =2D void shortCutSelected( int ); =2D void slotStopHighlight(); =2D + private slots: + void slotExecuted( QAction* action ); + void slotShowRMBMenu( const QPoint& ); private: SidePaneBase *mSidePane; =2D IconViewMode mViewMode; =2D =2D Q3ListBoxItem* mMouseOn; =2D =2D EntryItem* mHighlightItem; =2D =2D QSignalMapper *mMapper; =2D QList mActions; =2D bool mShowIcons; =2D bool mShowText; + QList mPlugins; + QAction* mLastAction; + void restorePreferences(); }; =20 class IconSidePane : public SidePaneBase @@ -189,13 +84,12 @@ IconSidePane( Core *core, QWidget *parent ); ~IconSidePane(); =20 =2D virtual void indicateForegrunding( Kontact::Plugin* ); + virtual void indicateForegrounding( Kontact::Plugin* ); =20 public slots: virtual void updatePlugins(); virtual void selectPlugin( Kontact::Plugin* ); virtual void selectPlugin( const QString &name ); =2D const QList & actions() { return mNavigator->actions(); } =20 private: Navigator *mNavigator; Index: iconsidepane.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- iconsidepane.cpp (Revision 770947) +++ iconsidepane.cpp (Arbeitskopie) @@ -42,11 +42,13 @@ #include #include =20 +#include +#include + #include #include #include #include =2D#include =20 #include #include @@ -61,7 +63,8 @@ { =20 //ugly wrapper class for adding an operator< to the Plugin class =2D +//currently unused, no sorting +/* class PluginProxy { public: @@ -92,401 +95,180 @@ private: Plugin *mPlugin; }; =2D +*/ } //namespace =20 using namespace Kontact; =20 =2DEntryItem::EntryItem( Navigator *parent, Kontact::Plugin *plugin ) =2D : Q3ListBoxItem( parent ), =2D mPlugin( plugin ), =2D mHasHover( false ), =2D mPaintActive( false ) +Navigator::Navigator( SidePaneBase *parent ) + : KToolBar( parent ) { =2D reloadPixmap(); =2D setCustomHighlighting( true ); =2D setText( plugin->title() ); =2D} + mSidePane =3D parent; + mLastAction =3D 0; =20 =2DEntryItem::~EntryItem() =2D{ =2D} + setOrientation ( Qt::Vertical ); + setContextMenuPolicy( Qt::CustomContextMenu ); + restorePreferences(); =20 =2Dvoid EntryItem::reloadPixmap() =2D{ =2D int size =3D (int)navigator()->viewMode(); =2D if ( size !=3D 0 ) =2D mPixmap =3D KIconLoader::global()->loadIcon( mPlugin->icon(), =2D KIconLoader::Desktop, si= ze, =2D mPlugin->disabled() ? =2D KIconLoader::DisabledS= tate =2D : KIconLoader::DefaultSt= ate); =2D else =2D mPixmap =3D QPixmap(); + connect( this, SIGNAL( actionTriggered ( QAction * ) ),=20 + this, SLOT( slotExecuted( QAction* ) ) ); + connect( this, SIGNAL( customContextMenuRequested( const QPoint & ) ),=20 + this, SLOT( slotShowRMBMenu( const QPoint & ) ) ); } =20 =2DNavigator* EntryItem::navigator() const +Navigator::~Navigator() { =2D return static_cast( listBox() ); } =20 =2Dint EntryItem::width( const Q3ListBox *listbox ) const +void Navigator::restorePreferences() { =2D int w =3D 0; =2D if( navigator()->showIcons() ) { =2D w =3D navigator()->viewMode(); =2D if ( navigator()->viewMode() =3D=3D SmallIcons ) =2D w +=3D 4; + if(Prefs::self()->sidePaneShowIcons()){ + if(Prefs::self()->sidePaneShowText()){ + setToolButtonStyle( Qt::ToolButtonTextUnderIcon ); =20 + }else{ + setToolButtonStyle( Qt::ToolButtonIconOnly ); =20 + } + }else{ + setToolButtonStyle( Qt::ToolButtonTextOnly ); =20 } =2D if( navigator()->showText() ) { =2D if ( navigator()->viewMode() =3D=3D SmallIcons ) =2D w +=3D listbox->fontMetrics().width( text() ); =2D else =2D w =3D qMax( w, listbox->fontMetrics().width( text() ) ); =2D } =2D return w + ( KDialog::marginHint() * 2 ); + + setIconDimensions( Prefs::self()->sidePaneIconSize() ); + parentWidget()->setMaximumWidth( sizeHint().width() ); } =20 =2Dint EntryItem::height( const Q3ListBox *listbox ) const +void Navigator::selectPlugin( Kontact::Plugin *plugin ) { =2D int h =3D 0; =2D if ( navigator()->showIcons() ) =2D h =3D (int)navigator()->viewMode() + 4; =2D if ( navigator()->showText() ) { =2D if ( navigator()->viewMode() =3D=3D SmallIcons || !navigator()->show= Icons() ) =2D h =3D qMax( h, listbox->fontMetrics().lineSpacing() ) + KDialog::s= pacingHint() * 2; =2D else =2D h =3D (int)navigator()->viewMode() + listbox->fontMetrics().lineSp= acing() + 4; + int index =3D mPlugins.indexOf( plugin ); + QList actlist =3D actions(); + for( QList::ConstIterator it =3D actlist.begin(); + it !=3D actlist.end(); it++ ){ + if( (*it)->data() =3D=3D index ){ + if( mLastAction !=3D 0 ) + mLastAction->setChecked( false ); + (*it)->setChecked( true ); + mLastAction =3D (*it); + return; + } } =2D return h; } =20 =2Dvoid EntryItem::paint( QPainter *p ) +void Navigator::selectPlugin( const QString &name ) { =2D reloadPixmap(); =2D =2D Q3ListBox *box =3D listBox(); =2D bool iconAboveText =3D ( navigator()->viewMode() > SmallIcons ) =2D && navigator()->showIcons(); =2D int w =3D box->viewport()->width(); =2D int y =3D iconAboveText ? 2 : =2D ( ( height( box ) - mPixmap.height() ) / 2 ); =2D =2D // draw selected =2D if ( isCurrent() || isSelected() || mHasHover || mPaintActive ) { =2D int h =3D height( box ); =2D =2D QBrush brush; =2D if ( isCurrent() || isSelected() || mPaintActive ) =2D brush =3D box->palette().color( QPalette::Highlight ); =2D else =2D brush =3D QBrush( box->palette().color( QPalette::Highlight ).ligh= t( 115 ) ); =2D p->fillRect( 1, 0, w - 2, h - 1, brush ); =2D QPen pen =3D p->pen(); =2D QPen oldPen =3D pen; =2D pen.setColor( box->palette().color( QPalette::Mid ) ); =2D p->setPen( pen ); =2D =2D p->drawPoint( 1, 0 ); =2D p->drawPoint( 1, h - 2 ); =2D p->drawPoint( w - 2, 0 ); =2D p->drawPoint( w - 2, h - 2 ); =2D =2D p->setPen( oldPen ); =2D } =2D =2D if ( !mPixmap.isNull() && navigator()->showIcons() ) { =2D int x =3D iconAboveText ? ( ( w - mPixmap.width() ) / 2 ) : =2D KDialog::marginHint(); =2D p->drawPixmap( x, y, mPixmap ); =2D } =2D =2D QColor shadowColor =3D listBox()->palette().color( QPalette::Backgroun= d ).dark(115); =2D if ( isCurrent() || isSelected() ) { =2D p->setPen( box->palette().color( QPalette::HighlightedText ) ); =2D } =2D =2D if ( !text().isEmpty() && navigator()->showText() ) { =2D QFontMetrics fm =3D p->fontMetrics(); =2D =2D int x =3D 0; =2D if ( iconAboveText ) { =2D x =3D ( w - fm.width( text() ) ) / 2; =2D y +=3D fm.height() - fm.descent(); =2D if ( navigator()->showIcons() ) =2D y +=3D mPixmap.height(); =2D } else { =2D x =3D KDialog::marginHint() + 4; =2D if( navigator()->showIcons() ) { =2D x +=3D mPixmap.width(); =2D } =2D =2D if ( !navigator()->showIcons() || mPixmap.height() < fm.height() ) =2D y =3D height( box )/2 - fm.height()/2 + fm.ascent(); =2D else =2D y +=3D mPixmap.height()/2 - fm.height()/2 + fm.ascent(); + for( QList::ConstIterator it =3D mPlugins.begin(); + it !=3D mPlugins.end(); it++ ){ + if( (*it)->title() =3D=3D name){ + selectPlugin( *it ); + return; } =2D =2D if ( plugin()->disabled() ) { =2D p->setPen( box->palette().disabled().text( ) ); =2D } else if ( isCurrent() || isSelected() || mHasHover ) { =2D p->setPen( box->palette().color( QPalette::Highlight ).dark(115) ); =2D p->drawText( x + ( QApplication::isRightToLeft() ? -1 : 1), =2D y + 1, text() ); =2D p->setPen( box->palette().color( QPalette::HighlightedText ) ); =2D } =2D else =2D p->setPen( box->palette().color( QPalette::Text ) ); =2D =2D p->drawText( x, y, text() ); } =2D =2D // ensure that we don't have a stale flag around =2D if ( isCurrent() || isSelected() ) mHasHover =3D false; } =20 =2Dvoid EntryItem::setHover( bool hasHover ) +void Navigator::disablePlugin( Kontact::Plugin *plugin ) { =2D mHasHover =3D hasHover; + int index =3D mPlugins.indexOf( plugin ); + QList actlist =3D actions(); + for( QList::ConstIterator it =3D actlist.begin(); + it !=3D actlist.end(); it++ ){ + if( (*it) ->data() =3D=3D index){ + (*it)->setEnabled( false ); + return; + } + } } =20 =2Dvoid EntryItem::setPaintActive( bool paintActive ) +void Navigator::enablePlugin( Kontact::Plugin *plugin ) { =2D mPaintActive =3D paintActive; + int index =3D mPlugins.indexOf( plugin ); + QList actlist =3D actions(); + for( QList::ConstIterator it =3D actlist.begin(); + it !=3D actlist.end(); it++ ){ + if( (*it)->data() =3D=3D index){ + (*it)->setEnabled( true ); + return; + } + } } =20 =2DNavigator::Navigator( SidePaneBase *parent, const char *name ) =2D : K3ListBox( parent, name ), mSidePane( parent ), =2D mShowIcons( true ), mShowText( true ) +void Navigator::updatePlugins( QList plugins ) { =2D mMouseOn =3D 0; =2D mHighlightItem =3D 0; =2D mViewMode =3D sizeIntToEnum( Prefs::self()->sidePaneIconSize() ); =2D mShowIcons =3D Prefs::self()->sidePaneShowIcons(); =2D mShowText =3D Prefs::self()->sidePaneShowText(); =2D setSelectionMode( K3ListBox::Single ); =2D viewport()->setBackgroundRole( QPalette::Background ); =2D setHScrollBarMode( Q3ScrollView::AlwaysOff ); =2D setAcceptDrops( true ); =2D =2D setFocusPolicy( Qt::NoFocus ); =2D =2D connect( this, SIGNAL( selectionChanged( Q3ListBoxItem* ) ), =2D SLOT( slotExecuted( Q3ListBoxItem* ) ) ); =2D connect( this, SIGNAL( rightButtonPressed( Q3ListBoxItem*, const QPoin= t& ) ), =2D SLOT( slotShowRMBMenu( Q3ListBoxItem*, const QPoint& ) ) ); =2D connect( this, SIGNAL( onItem( Q3ListBoxItem * ) ), =2D SLOT( slotMouseOn( Q3ListBoxItem * ) ) ); =2D connect( this, SIGNAL( onViewport() ), SLOT( slotMouseOff() ) ); =2D =2D mMapper =3D new QSignalMapper( this ); =2D connect( mMapper, SIGNAL( mapped( int ) ), SLOT( shortCutSelected( int= ) ) ); =2D =2D this->setToolTip(""); =2D#ifdef __GNUC__ =2D#warning Port me! =2D#endif =2D// if ( !mShowText ) =2D// new EntryItemToolTip( this ); =2D =2D} =2D =2DQSize Navigator::sizeHint() const =2D{ =2D return QSize( 100, 100 ); =2D} =2D =2Dvoid Navigator::highlightItem( EntryItem * item ) =2D{ =2D mHighlightItem =3D item; =2D =2D setPaintActiveItem( mHighlightItem, true ); =2D =2D QTimer::singleShot( 2000, this, SLOT( slotStopHighlight() ) ); =2D} =2D =2Dvoid Navigator::slotStopHighlight() =2D{ =2D setPaintActiveItem( mHighlightItem, false ); =2D} =2D =2Dvoid Navigator::setSelected( Q3ListBoxItem *item, bool selected ) =2D{ =2D // Reimplemented to avoid the immediate activation of =2D // the item. might turn out it doesn't work, we check that =2D // an confirm from MainWindow::selectPlugin() =2D if ( selected ) { =2D EntryItem *entry =3D static_cast( item ); =2D emit pluginActivated( entry->plugin() ); + QList actlist =3D actions(); + for( QList::ConstIterator it =3D actlist.begin(); + it !=3D actlist.end(); it++ ){ + delete *it; } =2D} =20 =2Dvoid Navigator::updatePlugins( QList plugins_ ) =2D{ =2D QList plugins; =2D QList::ConstIterator end_ =3D plugins_.end(); =2D QList::ConstIterator it_ =3D plugins_.begin(); =2D for ( ; it_ !=3D end_; ++it_ ) =2D plugins +=3D PluginProxy( *it_ ); =2D clear(); =2D =2D qDeleteAll( mActions ); =2D mActions.clear(); =2D =2D int counter =3D 0; =2D int minWidth =3D 0; =2D#ifdef __GNUC__ =2D#warning Port me! =2D#endif =2D// qSort( plugins ); =2D QList::ConstIterator end =3D plugins.end(); =2D QList::ConstIterator it =3D plugins.begin(); =2D for ( ; it !=3D end; ++it ) { =2D Kontact::Plugin *plugin =3D ( *it ).plugin(); =2D if ( !plugin->showInSideBar() ) + mPlugins.clear(); + QList::ConstIterator end =3D plugins.end(); + QList::ConstIterator it =3D plugins.begin(); + int counter =3D 0; //Counts added items + int index =3D -1; //Counts iterated plugins + for ( ; it !=3D end; ++it ){ + index++; + Kontact::Plugin *plugin =3D *it; + mPlugins +=3D plugin; + if ( !plugin->showInSideBar() ){ continue; + } + QAction* action =3D new QAction( KIcon( plugin->icon() ), + i18n( (char *)plugin->title().toUtf8().data() ), this); + action->setEnabled( !plugin->disabled() ); + action->setCheckable( true ); + action->setData( index ); + if( counter < 9 ){ + QString shortcut =3D QString( "Ctrl+%1" ).arg( counter + 1 ); + action->setShortcut( QKeySequence( shortcut ) ); + action->setToolTip( shortcut ); + } =20 =2D EntryItem *item =3D new EntryItem( this, plugin ); =2D item->setSelectable( !plugin->disabled() ); + kDebug(5600) << "action added, title: " << plugin->title() << ", icon:= " << plugin->icon(); =20 =2D if ( item->width( this ) > minWidth ) =2D minWidth =3D item->width( this ); =2D =2D QString name =3D QString( "CTRL+%1" ).arg( counter + 1 ); =2D KAction *action =3D new KAction(KIcon(plugin->icon()), plugin->titl= e(), this); =2D mSidePane->actionCollection()->addAction(name.toLatin1(), action); =2D connect(action, SIGNAL(triggered(bool) ), mMapper, SLOT( map() )); =2D action->setShortcut(KShortcut( name )); =2D mActions.append( action ); =2D mMapper->setMapping( action, counter ); + addAction(action); counter++; } =20 =2D parentWidget()->setFixedWidth( minWidth ); + restorePreferences(); } =20 =2Dvoid Navigator::dragEnterEvent( QDragEnterEvent *event ) +void Navigator::slotExecuted( QAction* action ) { =2D kDebug(5600) <<"Navigator::dragEnterEvent()"; + int index =3D action->data().toInt(); =20 =2D dragMoveEvent( event ); =2D} =2D =2Dvoid Navigator::dragMoveEvent( QDragMoveEvent *event ) =2D{ =2D kDebug(5600) <<"Navigator::dragEnterEvent()"; =2D =2D kDebug(5600) <<" Format:" << event->format(); =2D =2D Q3ListBoxItem *item =3D itemAt( event->pos() ); =2D =2D if ( !item ) { =2D event->setAccepted( false ); =2D return; + if( index < mPlugins.size() ){ + if( mLastAction !=3D 0 ) + mLastAction->setChecked( false ); + emit pluginActivated( mPlugins.value(index) ); + mLastAction =3D action; } =2D =2D EntryItem *entry =3D static_cast( item ); =2D =2D kDebug(5600) <<" PLUGIN:" << entry->plugin()->identifier(); =2D =2D event->setAccepted( entry->plugin()->canDecodeMimeData( event->mimeDat= a() ) ); } =20 =2Dvoid Navigator::dropEvent( QDropEvent *event ) +void Navigator::slotShowRMBMenu( const QPoint& pos ) { =2D kDebug(5600) <<"Navigator::dropEvent()"; =2D =2D Q3ListBoxItem *item =3D itemAt( event->pos() ); =2D =2D if ( !item ) { =2D return; =2D } =2D =2D EntryItem *entry =3D static_cast( item ); =2D =2D kDebug(5600) <<" PLUGIN:" << entry->plugin()->identifier(); =2D =2D entry->plugin()->processDropEvent( event ); =2D} =2D =2Dvoid Navigator::resizeEvent( QResizeEvent *event ) =2D{ =2D Q3ListBox::resizeEvent( event ); =2D triggerUpdate( true ); =2D} =2D =2Dvoid Navigator::enterEvent( QEvent *event ) =2D{ =2D // work around Qt behaviour: onItem is not emmitted in enterEvent() =2D K3ListBox::enterEvent( event ); =2D emit onItem( itemAt( mapFromGlobal( QCursor::pos() ) ) ); =2D} =2D =2Dvoid Navigator::leaveEvent( QEvent *event ) =2D{ =2D K3ListBox::leaveEvent( event ); =2D slotMouseOn( 0 ); =2D mMouseOn =3D 0; =2D} =2D =2Dvoid Navigator::slotExecuted( Q3ListBoxItem *item ) =2D{ =2D if ( !item ) =2D return; =2D =2D EntryItem *entry =3D static_cast( item ); =2D =2D emit pluginActivated( entry->plugin() ); =2D} =2D =2DIconViewMode Navigator::sizeIntToEnum(int size) const =2D{ =2D switch ( size ) { =2D case int(LargeIcons): =2D return LargeIcons; =2D break; =2D case int(NormalIcons): =2D return NormalIcons; =2D break; =2D case int(SmallIcons): =2D return SmallIcons; =2D break; =2D default: =2D // Stick with sane values =2D return NormalIcons; =2D kDebug() <<"View mode not implemented!"; =2D break; =2D } =2D} =2D =2Dvoid Navigator::slotShowRMBMenu( Q3ListBoxItem *, const QPoint &pos ) =2D{ KMenu menu( i18n( "Icon Size" ) ); =20 QAction *large =3D menu.addAction( i18n( "Large" ) ); =2D large->setEnabled( mShowIcons ); + large->setEnabled( Prefs::self()->sidePaneShowIcons() ); large->setCheckable( true ); =2D large->setChecked( mViewMode =3D=3D LargeIcons ); + large->setChecked( Prefs::self()->sidePaneIconSize() =3D=3D KIconLoader:= :SizeLarge ); QAction *normal =3D menu.addAction( i18n( "Normal" ) ); =2D normal->setEnabled( mShowIcons ); + normal->setEnabled( Prefs::self()->sidePaneShowIcons() ); normal->setCheckable( true ); =2D normal->setChecked( mViewMode =3D=3D NormalIcons ); + normal->setChecked( Prefs::self()->sidePaneIconSize() =3D=3D KIconLoader= ::SizeMedium ); QAction *small =3D menu.addAction( i18n( "Small" ) ); =2D small->setEnabled( mShowIcons ); + small->setEnabled( Prefs::self()->sidePaneShowIcons() ); small->setCheckable( true ); =2D small->setChecked( mViewMode =3D=3D SmallIcons ); + small->setChecked( Prefs::self()->sidePaneIconSize() =3D=3D KIconLoader:= :SizeSmallMedium ); =20 menu.addSeparator(); =20 QAction *showIcons =3D menu.addAction( i18n( "Show Icons" ) ); showIcons->setCheckable( true ); =2D showIcons->setChecked( mShowIcons ); =2D showIcons->setEnabled( mShowText ); + showIcons->setChecked( Prefs::self()->sidePaneShowIcons() ); + showIcons->setEnabled( Prefs::self()->sidePaneShowText() ); QAction *showText =3D menu.addAction( i18n( "Show Text" ) ); showText->setCheckable( true ); =2D showText->setChecked( mShowText ); =2D showText->setEnabled( mShowIcons ); + showText->setChecked( Prefs::self()->sidePaneShowText() ); + showText->setEnabled( Prefs::self()->sidePaneShowIcons() ); =20 QAction *choice =3D menu.exec( pos ); =20 @@ -494,82 +276,25 @@ return; =20 if ( choice =3D=3D large ) { =2D mViewMode =3D sizeIntToEnum( LargeIcons ); =2D Prefs::self()->setSidePaneIconSize( LargeIcons ); + Prefs::self()->setSidePaneIconSize( KIconLoader::SizeLarge ); } else if ( choice =3D=3D normal ) { =2D mViewMode =3D sizeIntToEnum( NormalIcons ); =2D Prefs::self()->setSidePaneIconSize( NormalIcons ); + Prefs::self()->setSidePaneIconSize( KIconLoader::SizeMedium ); } else if ( choice =3D=3D small ) { =2D mViewMode =3D sizeIntToEnum( SmallIcons ); =2D Prefs::self()->setSidePaneIconSize( SmallIcons ); + Prefs::self()->setSidePaneIconSize( KIconLoader::SizeSmallMedium ); } else if ( choice =3D=3D showIcons ) { =2D mShowIcons =3D !mShowIcons; =2D Prefs::self()->setSidePaneShowIcons( mShowIcons ); + Prefs::self()->setSidePaneShowIcons( !Prefs::self()->sidePaneShowIcons= () ); } else if ( choice =3D=3D showText ) { =2D mShowText =3D !mShowText; =2D Prefs::self()->setSidePaneShowText( mShowText ); + Prefs::self()->setSidePaneShowText( !Prefs::self()->sidePaneShowText()= ); } =2D =2D int maxWidth =3D 0; =2D Q3ListBoxItem* it =3D 0; =2D for (int i =3D 0; (it =3D item(i)) !=3D 0; ++i) =2D { =2D int width =3D it->width(this); =2D if (width > maxWidth) =2D maxWidth =3D width; =2D } =2D parentWidget()->setFixedWidth( maxWidth ); =2D =2D triggerUpdate( true ); + restorePreferences(); } =20 =2Dvoid Navigator::shortCutSelected( int pos ) =2D{ =2D setCurrentItem( pos ); =2D} =2D =2Dvoid Navigator::setHoverItem( Q3ListBoxItem* item, bool hover ) =2D{ =2D static_cast( item )->setHover( hover ); =2D updateItem( item ); =2D} =2D =2Dvoid Navigator::setPaintActiveItem( Q3ListBoxItem* item, bool paintActiv= e ) =2D{ =2D static_cast( item )->setPaintActive( paintActive ); =2D updateItem( item ); =2D} =2D =2Dvoid Navigator::slotMouseOn( Q3ListBoxItem* newItem ) =2D{ =2D Q3ListBoxItem* oldItem =3D mMouseOn; =2D if ( oldItem =3D=3D newItem ) return; =2D =2D if ( oldItem && !oldItem->isCurrent() && !oldItem->isSelected() ) =2D { =2D setHoverItem( oldItem, false ); =2D } =2D =2D if ( newItem && !newItem->isCurrent() && !newItem->isSelected() ) =2D { =2D setHoverItem( newItem, true ); =2D } =2D mMouseOn =3D newItem; =2D} =2D =2Dvoid Navigator::slotMouseOff() =2D{ =2D slotMouseOn( 0 ); =2D} =2D IconSidePane::IconSidePane( Core *core, QWidget *parent ) : SidePaneBase( core, parent ) { mNavigator =3D new Navigator( this ); connect( mNavigator, SIGNAL( pluginActivated( Kontact::Plugin* ) ), SIGNAL( pluginSelected( Kontact::Plugin* ) ) ); =2D =2D setAcceptDrops( true ); } =20 IconSidePane::~IconSidePane() @@ -583,47 +308,17 @@ =20 void IconSidePane::selectPlugin( Kontact::Plugin *plugin ) { =2D bool blocked =3D signalsBlocked(); =2D blockSignals( true ); =2D =2D for ( uint i =3D 0; i < mNavigator->count(); ++i ) { =2D EntryItem *item =3D static_cast( mNavigator->item( i ) ); =2D if ( item->plugin() =3D=3D plugin ) { =2D mNavigator->setCurrentItem( i ); =2D break; =2D } =2D } =2D =2D blockSignals( blocked ); + mNavigator->selectPlugin( plugin ); } =20 void IconSidePane::selectPlugin( const QString &name ) { =2D bool blocked =3D signalsBlocked(); =2D blockSignals( true ); =2D =2D for ( uint i =3D 0; i < mNavigator->count(); ++i ) { =2D EntryItem *item =3D static_cast( mNavigator->item( i ) ); =2D if ( item->plugin()->identifier() =3D=3D name ) { =2D mNavigator->setCurrentItem( i ); =2D break; =2D } =2D } =2D =2D blockSignals( blocked ); + mNavigator->selectPlugin( name ); } =20 =2Dvoid IconSidePane::indicateForegrunding( Kontact::Plugin *plugin ) +void IconSidePane::indicateForegrounding( Kontact::Plugin *plugin ) { =2D for ( uint i =3D 0; i < mNavigator->count(); ++i ) { =2D EntryItem *item =3D static_cast( mNavigator->item( i ) ); =2D if ( item->plugin() =3D=3D plugin ) { =2D mNavigator->highlightItem( item ); =2D break; =2D } =2D } =2D =2D + mNavigator->disablePlugin( plugin ); } #include "iconsidepane.moc" =20 Index: sidepanebase.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- sidepanebase.h (Revision 770947) +++ sidepanebase.h (Arbeitskopie) @@ -40,11 +40,6 @@ SidePaneBase( Core *core, QWidget *parent ); virtual ~SidePaneBase(); =20 =2D void setActionCollection( KActionCollection *actionCollection ); =2D KActionCollection *actionCollection() const; =2D =2D virtual const QList & actions() =3D 0; =2D signals: void pluginSelected( Kontact::Plugin* ); =20 @@ -67,13 +62,12 @@ */ virtual void selectPlugin( const QString &name ) =3D 0; =20 =2D virtual void indicateForegrunding( Kontact::Plugin* ) =3D 0; + virtual void indicateForegrounding( Kontact::Plugin* ) =3D 0; protected: Core* core() const; =20 private: Core* mCore; =2D KActionCollection *mActionCollection; }; =20 } Index: sidepanebase.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- sidepanebase.cpp (Revision 770947) +++ sidepanebase.cpp (Arbeitskopie) @@ -39,14 +39,4 @@ return mCore; } =20 =2Dvoid SidePaneBase::setActionCollection( KActionCollection *actionCollect= ion ) =2D{ =2D mActionCollection =3D actionCollection; =2D} =2D =2DKActionCollection *SidePaneBase::actionCollection() const =2D{ =2D return mActionCollection; =2D} =2D #include "sidepanebase.moc" --Boundary-01=_uU3pHe0ZtJqU8tU-- --nextPart4559877.siK5HZ1TaV Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4-svn0 (GNU/Linux) iD8DBQBHp3Uuwrpm7jsVp+YRAgZRAJ9T6Mej12rhQmyEQSjyZlc0YayXQwCgjqN6 +v76WPsDW2kZJi4qgn7PJYM= =ynZC -----END PGP SIGNATURE----- --nextPart4559877.siK5HZ1TaV-- --===============1561357302== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ KDE PIM mailing list kde-pim@kde.org https://mail.kde.org/mailman/listinfo/kde-pim KDE PIM home page at http://pim.kde.org/ --===============1561357302==--