Show
Ignore:
Timestamp:
03/14/08 05:19:15 (9 months ago)
Author:
flynd
Message:

Added (ugly) workaround for tab shortcuts in kde4-gui.

Location:
trunk/qt4-gui/src/widgets
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/qt4-gui/src/widgets/tabwidget.cpp

    r6082 r6092  
    133133} 
    134134 
     135#ifdef USE_KDE 
     136void TabWidget::restoreShortcuts() 
     137{ 
     138  // KTabWidget destroys any shortcuts so we have the following options: 
     139  // 1) Don't specify any shortcuts. This is bad since it means qt-gui won't 
     140  //    have any shortcuts. 
     141  // 2) Remove shortcuts from strings when compiling for kde. This will result 
     142  //    in different shortcuts for qt-gui and kde-gui. 
     143  // 3) Don't use KTabWidget. We want the rest of the function and look of kde 
     144  //    so using KTabWidget is preferred. 
     145  // 4) Restore our shortcuts every time KTabWidget has messed with them. 
     146  //    This is an ugly workaround but it'll work as a compromise. 
     147 
     148  for (int i = 0; i < count(); ++i) 
     149    QTabWidget::setTabText(i, tabText(i).replace("&&", "&")); 
     150} 
     151 
     152void TabWidget::setTabText(int index, const QString& label) 
     153{ 
     154  TABWIDGET_BASE::setTabText(index, label); 
     155  restoreShortcuts(); 
     156} 
     157 
     158void TabWidget::resizeEvent(QResizeEvent* event) 
     159{ 
     160  TABWIDGET_BASE::resizeEvent(event); 
     161  restoreShortcuts(); 
     162} 
     163#endif 
     164 
    135165#ifndef USE_KDE 
    136166void TabWidget::wheelEvent(QWheelEvent* e) 
  • trunk/qt4-gui/src/widgets/tabwidget.h

    r6082 r6092  
    7070  void setNextPage(); 
    7171 
    72 #ifndef USE_KDE 
     72#ifdef USE_KDE 
     73  /** 
     74   * Overloaded to fix tab shortcuts 
     75   */ 
     76  void setTabText(int index, const QString& label); 
     77 
     78protected: 
     79  /** 
     80   * Overloaded to fix tab shortcuts 
     81   */ 
     82  virtual void resizeEvent(QResizeEvent* event); 
     83 
     84private: 
     85  /** 
     86   * Restore tab shortcuts after KTabWidget has broken them 
     87   */ 
     88  void restoreShortcuts(); 
     89#else 
    7390signals: 
    7491  void mouseMiddleClick(QWidget* p);