[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/work/kwin-tabbing
From:       Jorge Emilio Mata <matamax123 () gmail ! com>
Date:       2009-07-02 23:03:11
Message-ID: 1246575791.101730.28822.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 990674 by mata:

- Added slot to show the window menu of any Client in the group.
- tabtest decoration can show tabs in a QTabBar and display a button for
  the window menu and it's title.



 M  +5 -0      bridge.cpp  
 M  +1 -0      bridge.h  
 M  +6 -0      clientgroup.cpp  
 M  +3 -0      clientgroup.h  
 M  +12 -2     clients/tabtest/tabtestbutton.cpp  
 M  +4 -1      clients/tabtest/tabtestbutton.h  
 M  +42 -10    clients/tabtest/tabtestdecoration.cpp  
 M  +2 -0      clients/tabtest/tabtestdecoration.h  
 M  +4 -0      kcmkwin/kwindecoration/preview.cpp  
 M  +1 -0      kcmkwin/kwindecoration/preview.h  
 M  +5 -0      lib/kcommondecoration.cpp  
 M  +3 -0      lib/kcommondecoration.h  
 M  +5 -0      lib/kdecoration.cpp  
 M  +1 -0      lib/kdecoration.h  
 M  +1 -0      lib/kdecorationbridge.h  
 M  +1 -1      useractions.cpp  


--- branches/work/kwin-tabbing/bridge.cpp #990673:990674
@@ -253,4 +253,9 @@
     c->closeTab( index );
     }
 
+void Bridge::showClientWindowMenu( int index, const QPoint &point )
+    {
+    c->clientGroup()->showClientWindowMenu( index, point );
+    }
+
 } // namespace
--- branches/work/kwin-tabbing/bridge.h #990673:990674
@@ -87,6 +87,7 @@
         virtual void changeTabOrder( int from, int to );
         virtual void closeGroup();
         virtual void closeTab( int index );
+        virtual void showClientWindowMenu( int index, const QPoint &point );
     private:
         Client* c;
     };
--- branches/work/kwin-tabbing/clientgroup.cpp #990673:990674
@@ -269,6 +269,12 @@
     tab->closeWindow();
     }
 
+void ClientGroup::showClientWindowMenu( int index, const QPoint &point )
+    {
+    if( index >= 0 && index < members.count() )
+        work->showWindowMenu( point, members[ index ] );
+    }
+
 void ClientGroup::updateTitleIcons()
     {
     ClientList::const_iterator i;
--- branches/work/kwin-tabbing/clientgroup.h #990673:990674
@@ -115,6 +115,9 @@
         *   of the clients in the group.
         */
         QList< TitleIcon > groupTitleIcons() const;
+        /// Show the window menu for the Client members[ index ].
+        void showClientWindowMenu( int index, const QPoint &point );
+        /// Fill the list with the titles and icons.
         void updateTitleIcons();
         /**
         *   Updates all the settings of the client_id
--- branches/work/kwin-tabbing/clients/tabtest/tabtestbutton.cpp #990673:990674
@@ -30,7 +30,7 @@
 #include <QPixmap>
 #include <QRect>
 
-tabtestButton::tabtestButton( ButtonType type, tabtestDecoration *parent, QString \
tip ) +tabtestButton::tabtestButton( ButtonType type, tabtestDecoration *parent, \
QString tip, QIcon *tabIcon, int id )  : KCommonDecorationButton( type, parent )
     {
     setAutoFillBackground( false );
@@ -38,6 +38,8 @@
     setCursor( Qt::ArrowCursor );
     client = parent;
     btype = type;
+    icon = tabIcon;
+    index_ = id;
     setToolTip( tip );
     }
 
@@ -88,7 +90,10 @@
             p.drawText( QRect( 0, 0, 16, 16 ), Qt::AlignVCenter | Qt::AlignHCenter, \
"X" );  break;
         case MenuButton:
-            p.drawPixmap( 0, 0, client->icon().pixmap( 16 ));
+            if( icon == NULL )
+                p.drawPixmap( 0, 0, client->icon().pixmap( 16 ));
+            else
+                p.drawPixmap( 0, 0, icon->pixmap( 16 ) );
             break;
         case OnAllDesktopsButton:
             p.drawText( QRect( 0, 0, 16, 16 ), Qt::AlignVCenter | Qt::AlignHCenter, \
"O" ); @@ -128,3 +133,8 @@
     {
     KCommonDecorationButton::mouseReleaseEvent( e );
     }
+
+int tabtestButton::index()
+    {
+    return index_;
+    }
--- branches/work/kwin-tabbing/clients/tabtest/tabtestbutton.h #990673:990674
@@ -33,10 +33,11 @@
     : public KCommonDecorationButton
     {
     public:
-        tabtestButton( ButtonType type, tabtestDecoration *parent, QString tip );
+        tabtestButton( ButtonType type, tabtestDecoration *parent, QString tip, \
QIcon *tabIcon = NULL, int id = -1 );  ~tabtestButton();
         void reset( unsigned long changed );
         QSize sizeHint() const;
+        int index();
     private:
         void paintEvent( QPaintEvent *e );
         void leaveEvent( QEvent *e );
@@ -45,6 +46,8 @@
         void mouseReleaseEvent( QMouseEvent *e );
         tabtestDecoration *client;
         ButtonType btype;
+        QIcon *icon;
+        int index_;
     };
 
 #endif
--- branches/work/kwin-tabbing/clients/tabtest/tabtestdecoration.cpp #990673:990674
@@ -34,6 +34,7 @@
 #include <QString>
 #include <QComboBox>
 #include <QTabBar>
+#include <QPushButton>
 
 tabtestDecoration::tabtestDecoration( KDecorationBridge *bridge, KDecorationFactory \
*factory )  : KCommonDecorationUnstable( bridge, factory )
@@ -139,28 +140,42 @@
         if( tabBar == NULL )
             {
             tabBar = new QTabBar( widget() );
+            tabBar->installEventFilter( this );
             connect( tabBar, SIGNAL( currentChanged( int ) ), this, SLOT( \
                moveToClientId( int ) ) );
             connect( tabBar, SIGNAL( tabCloseRequested( int ) ), this, SLOT( \
                closeTab( int ) ) );
             connect( tabBar, SIGNAL( tabMoved( int, int ) ), this, SLOT( \
changeTabOrder( int, int ) ) );  }
         QList< TitleIcon > list = groupTitleIcons();
         int tabsCount = tabBar->count();
-        int titlesCount = list.count(), i = 0;
-        for( i = 0; i < tabsCount && i < titlesCount; i++)
+        int titlesCount = list.count(), i;
+        buttons.clear();
+
+        for( i = 0; i < titlesCount; ++i )
             {
-            tabBar->setTabIcon( i, list[i].icon() );
-            tabBar->setTabText( i, list[i].title() );
+            buttons.append( new tabtestButton( MenuButton, this, "Menu", new QIcon( \
list[i].icon() ), i ) ); +            buttons[i]->installEventFilter( this );
             }
+
+        for( i = 0; i < tabsCount && i < titlesCount; ++i )
+            if( list[i].title() != tabBar->tabText( i ) )
+                {
+                tabBar->setTabText( i, list[i].title() );
+                tabBar->setTabButton( i, QTabBar::LeftSide, buttons[i] );
+                }
+
         while( i < titlesCount )
             {
-            tabBar->insertTab( i, list[i].icon(), list[i].title() );
-            i++;
+            tabBar->insertTab( i, list[i].title() );
+            tabBar->setTabButton( i, QTabBar::LeftSide, buttons[i] );
+            ++i;
             }
+
         while( tabsCount > titlesCount )
             {
             tabsCount--;
             tabBar->removeTab( tabsCount );
             }
+
         tabBar->move( titleR.x(), titleR.y() );
         tabBar->resize( titleR.width(), titleR.height() );
         tabBar->setExpanding( true );
@@ -347,11 +362,28 @@
 bool tabtestDecoration::eventFilter( QObject* o, QEvent* e )
     {
     bool state = false;
+    if( tabtestFactory::tabPositions() == tabtestFactory::Title && tabBar != NULL && \
tabBar == o ) +        {
+        if( e->type() == QEvent::MouseButtonPress && static_cast< QMouseEvent* >( e \
)->button() != Qt::MidButton ) +            {
+            if( static_cast< QMouseEvent* >( e )->button() == Qt::LeftButton )
+                return eventFilter( widget(), e );
+            else
+                return true;
+            }
+        return tabBar->eventFilter( o, e );
+        }
 
-//    kDebug() << "\n--Mata-error: evento: " << e->type() << "\n";
-
-    if( widget() != o )
+    else if( tabtestFactory::tabPositions() == tabtestFactory::Title && \
dynamic_cast< tabtestButton* >( o ) ) +        { // click in a menu button
+        tabtestButton* btn = dynamic_cast< tabtestButton* >( o );
+        if( e->type() == QEvent::MouseButtonPress )
+            {
+            showClientWindowMenu( btn->index(), btn->mapToGlobal( \
static_cast<QMouseEvent*>( e )->pos() ) ); +            return true;
+            }
         return false;
+        }
 
     else if( e->type() == QEvent::Drop && widget() == o ) // Drop
         state = dropEvent( static_cast< QDropEvent* >( e ) );
@@ -440,12 +472,12 @@
     {
     if( mouseClickTab && ( e->pos() - dragP ).manhattanLength() >= 4 )
         {
+        mouseClickTab = false;
         QDrag *drag = new QDrag( widget() );
         QMimeData *group_data = new QMimeData();
         group_data->setText( QString().setNum( listIndex() ) );
         drag->setMimeData( group_data );
         drag->exec( Qt::CopyAction | Qt::MoveAction );
-        mouseClickTab = false;
         return true;
         }
     return false;
--- branches/work/kwin-tabbing/clients/tabtest/tabtestdecoration.h #990673:990674
@@ -29,6 +29,7 @@
 class tabtestButton;
 class QComboBox;
 class QTabBar;
+class QPushButton;
 
 class tabtestDecoration
     : public KCommonDecorationUnstable
@@ -63,6 +64,7 @@
         QPoint dragP;
         QComboBox *box;
         QTabBar* tabBar;
+        QList< tabtestButton* > buttons;
         bool mouseClickTab;
     };
 
--- branches/work/kwin-tabbing/kcmkwin/kwindecoration/preview.cpp #990673:990674
@@ -503,6 +503,10 @@
     {
     }
 
+void KDecorationPreviewBridge::showClientWindowMenu( int index, const QPoint &point \
) +    {
+    }
+
 KDecorationPreviewOptions::KDecorationPreviewOptions()
     {
     customBorderSize = BordersCount; // invalid
--- branches/work/kwin-tabbing/kcmkwin/kwindecoration/preview.h #990673:990674
@@ -126,6 +126,7 @@
         virtual void changeTabOrder( int, int );
         virtual void closeGroup();
         virtual void closeTab( int index );
+        virtual void showClientWindowMenu( int index, const QPoint &point );
     private:
         KDecorationPreview* preview;
         bool active;
--- branches/work/kwin-tabbing/lib/kcommondecoration.cpp #990673:990674
@@ -1307,5 +1307,10 @@
     static_cast<const KDecorationUnstable*>( decoration() )->closeTab( index );
     }
 
+void KCommonDecorationUnstable::showClientWindowMenu( int index, const QPoint &point \
) +    {
+    static_cast<const KDecorationUnstable*>( decoration() )->showClientWindowMenu( \
index, point ); +    }
+
 // kate: space-indent on; indent-width 4; mixedindent off; indent-mode cstyle;
 
--- branches/work/kwin-tabbing/lib/kcommondecoration.h #990673:990674
@@ -408,7 +408,10 @@
         *   closes all the clients.
         */
         void closeGroup();
+        /// Close the tab at position index
         void closeTab( int index );
+        /// Show the window menu
+        void showClientWindowMenu( int index, const QPoint &point );
     };
 
 /**
--- branches/work/kwin-tabbing/lib/kdecoration.cpp #990673:990674
@@ -449,6 +449,11 @@
     static_cast< KDecorationBridgeUnstable* >( bridge_ )->closeTab( index );
     }
 
+void KDecorationUnstable::showClientWindowMenu( int index, const QPoint &point )
+    {
+    static_cast< KDecorationBridgeUnstable* >( bridge_ )->showClientWindowMenu( \
index, point ); +    }
+
 KDecorationOptions::KDecorationOptions()
     : d( new KDecorationOptionsPrivate )
     {
--- branches/work/kwin-tabbing/lib/kdecoration.h #990673:990674
@@ -941,6 +941,7 @@
         */
         void closeGroup();
         void closeTab( int index );
+        void showClientWindowMenu( int index, const QPoint &point );
     };
 
 inline
--- branches/work/kwin-tabbing/lib/kdecorationbridge.h #990673:990674
@@ -105,6 +105,7 @@
         virtual void changeTabOrder( int from, int to ) = 0;
         virtual void closeGroup() = 0;
         virtual void closeTab( int index ) = 0;
+        virtual void showClientWindowMenu( int index, const QPoint &point ) = 0;
     };
 
 /** @} */
--- branches/work/kwin-tabbing/useractions.cpp #990673:990674
@@ -257,7 +257,7 @@
     else
         initMoveToTab();
 
-    if( !decorationSupportsTabs() || tabGroupize < 2 )
+    if( !decorationSupportsTabs() || tabGroupList.count() < 2 )
         {
         delete add_tabs_popup;
         add_tabs_popup = 0;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic