[kde-doc-english] [kdepim] /: Improve the Tab Experience.

Allen Winter winter at kde.org
Tue Feb 14 00:25:09 UTC 2012


Git commit 3f553c1b1f003e21d3aba24388aafb9662bfd074 by Allen Winter.
Committed on 14/02/2012 at 00:45.
Pushed by winterz into branch 'master'.

Improve the Tab Experience.
- add an option for putting the close button on tabs
- allow double-click to open a new empty tab

GUI:
MERGE: none

M  +32   -6    kmail/configuredialog.cpp
M  +1    -0    kmail/configuredialog_p.h
M  +5    -0    messagelist/core/settings.kcfg
M  +17   -7    messagelist/pane.cpp

http://commits.kde.org/kdepim/3f553c1b1f003e21d3aba24388aafb9662bfd074

diff --git a/kmail/configuredialog.cpp b/kmail/configuredialog.cpp
index 3ad20f0..533aa41 100644
--- a/kmail/configuredialog.cpp
+++ b/kmail/configuredialog.cpp
@@ -1268,6 +1268,13 @@ AppearancePageHeadersTab::AppearancePageHeadersTab( QWidget * parent )
   connect( mHideTabBarWithSingleTab, SIGNAL(stateChanged(int)),
            this, SLOT(slotEmitChanged()) );
 
+  mTabsHaveCloseButton = new QCheckBox(
+                 MessageList::Core::Settings::self()->tabsHaveCloseButtonItem()->label(), group );
+  gvlay->addWidget(  mTabsHaveCloseButton );
+
+  connect( mTabsHaveCloseButton, SIGNAL(stateChanged(int)),
+           this, SLOT(slotEmitChanged()) );
+
   // "Aggregation"
   using MessageList::Utils::AggregationComboBox;
   mAggregationComboBox = new AggregationComboBox( group );
@@ -1413,8 +1420,14 @@ void AppearancePage::HeadersTab::slotSelectDefaultTheme()
 void AppearancePage::HeadersTab::doLoadOther()
 {
   // "General Options":
-  mDisplayMessageToolTips->setChecked( MessageList::Core::Settings::self()->messageToolTipEnabled() );
-  mHideTabBarWithSingleTab->setChecked( MessageList::Core::Settings::self()->autoHideTabBarWithSingleTab() );
+  mDisplayMessageToolTips->setChecked(
+    MessageList::Core::Settings::self()->messageToolTipEnabled() );
+
+  mHideTabBarWithSingleTab->setChecked(
+    MessageList::Core::Settings::self()->autoHideTabBarWithSingleTab() );
+
+  mTabsHaveCloseButton->setChecked(
+    MessageList::Core::Settings::self()->tabsHaveCloseButton() );
 
   // "Aggregation":
   slotSelectDefaultAggregation();
@@ -1429,8 +1442,15 @@ void AppearancePage::HeadersTab::doLoadOther()
 
 void AppearancePage::HeadersTab::doLoadFromGlobalSettings()
 {
-  mDisplayMessageToolTips->setChecked( MessageList::Core::Settings::self()->messageToolTipEnabled() );
-  mHideTabBarWithSingleTab->setChecked( MessageList::Core::Settings::self()->autoHideTabBarWithSingleTab() );
+  mDisplayMessageToolTips->setChecked(
+    MessageList::Core::Settings::self()->messageToolTipEnabled() );
+
+  mHideTabBarWithSingleTab->setChecked(
+    MessageList::Core::Settings::self()->autoHideTabBarWithSingleTab() );
+
+  mTabsHaveCloseButton->setChecked(
+    MessageList::Core::Settings::self()->tabsHaveCloseButton() );
+
   // "Aggregation":
   slotSelectDefaultAggregation();
 
@@ -1462,8 +1482,14 @@ void AppearancePage::HeadersTab::setDateDisplay( int num, const QString & format
 
 void AppearancePage::HeadersTab::save()
 {
-  MessageList::Core::Settings::self()->setMessageToolTipEnabled( mDisplayMessageToolTips->isChecked() );
-  MessageList::Core::Settings::self()->setAutoHideTabBarWithSingleTab( mHideTabBarWithSingleTab->isChecked() );
+  MessageList::Core::Settings::self()->
+    setMessageToolTipEnabled( mDisplayMessageToolTips->isChecked() );
+
+  MessageList::Core::Settings::self()->
+    setAutoHideTabBarWithSingleTab( mHideTabBarWithSingleTab->isChecked() );
+
+  MessageList::Core::Settings::self()->
+    setTabsHaveCloseButton( mTabsHaveCloseButton->isChecked() );
 
   // "Aggregation"
   mAggregationComboBox->writeDefaultConfig();
diff --git a/kmail/configuredialog_p.h b/kmail/configuredialog_p.h
index db1d299..f016726 100644
--- a/kmail/configuredialog_p.h
+++ b/kmail/configuredialog_p.h
@@ -329,6 +329,7 @@ private: // methods
 private: // data
   QCheckBox    *mDisplayMessageToolTips;
   QCheckBox    *mHideTabBarWithSingleTab;
+  QCheckBox    *mTabsHaveCloseButton;
   MessageList::Utils::AggregationComboBox *mAggregationComboBox;
   MessageList::Utils::ThemeComboBox *mThemeComboBox;
   KButtonGroup *mDateDisplay;
diff --git a/messagelist/core/settings.kcfg b/messagelist/core/settings.kcfg
index fd90757..f6ac6a8 100644
--- a/messagelist/core/settings.kcfg
+++ b/messagelist/core/settings.kcfg
@@ -15,6 +15,11 @@
       <label>Hide tab bar when only one tab is open</label>
       <whatsthis>With this option enabled the tab bar will be displayed only when there are two or more tabs. With this option disabled the tab bar will be always shown. When the tab bar is hidden you can always open a folder in a new tab by middle-clicking it.</whatsthis>
     </entry>
+    <entry name="TabsHaveCloseButton" type="Bool">
+      <default>false</default>
+      <label>Show close button on each tab</label>
+      <whatsthis>Enable this option if you want to have a close button on each tab.</whatsthis>
+    </entry>
     <entry name="ShowQuickSearch" type="Bool">
       <default>true</default>
     </entry>
diff --git a/messagelist/pane.cpp b/messagelist/pane.cpp
index cbdee24..e9dec7c 100644
--- a/messagelist/pane.cpp
+++ b/messagelist/pane.cpp
@@ -50,10 +50,10 @@ public:
       mXmlGuiClient( 0 ),
       mActionMenu( 0 ),
       mCloseTabAction( 0 ),
-      mActivateNextTabAction( 0 ), 
+      mActivateNextTabAction( 0 ),
       mActivatePreviousTabAction( 0 ),
       mMoveTabLeftAction( 0 ),
-      mMoveTabRightAction( 0 ), 
+      mMoveTabRightAction( 0 ),
       mPreferEmptyTab( false ) { }
 
   void onSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
@@ -162,6 +162,9 @@ Pane::Pane( QAbstractItemModel *model, QItemSelectionModel *selectionModel, QWid
   connect( Core::Settings::self(), SIGNAL(configChanged()),
            this, SLOT(updateTabControls()) );
 
+  connect( this, SIGNAL(mouseDoubleClick()),
+           this, SLOT(createNewTab()) );
+
   connect( this, SIGNAL(mouseMiddleClick(QWidget*)),
            this, SLOT(closeTab(QWidget*)) );
   tabBar()->installEventFilter( this );
@@ -460,12 +463,12 @@ void Pane::Private::moveTabForward()
   const int currentIndex = q->tabBar()->currentIndex();
   if ( currentIndex == q->tabBar()->count()-1 )
     return;
-  q->tabBar()->moveTab( currentIndex, currentIndex+1 );  
+  q->tabBar()->moveTab( currentIndex, currentIndex+1 );
 }
 
 void Pane::Private::moveTabBackward()
 {
-  const int currentIndex = q->tabBar()->currentIndex();  
+  const int currentIndex = q->tabBar()->currentIndex();
   if ( currentIndex == 0 )
     return;
   q->tabBar()->moveTab( currentIndex, currentIndex-1 );
@@ -481,8 +484,8 @@ void Pane::Private::activateNextTab()
 
   if( indexTab == numberOfTab )
     indexTab = 0;
-  
-  q->tabBar()->setCurrentIndex( indexTab );  
+
+  q->tabBar()->setCurrentIndex( indexTab );
 }
 
 void Pane::Private::activatePreviousTab()
@@ -535,6 +538,7 @@ void Pane::Private::onCurrentTabChanged()
   emit q->currentTabChanged();
 
   Widget *w = static_cast<Widget*>( q->currentWidget() );
+
   QItemSelectionModel *s = mWidgetSelectionHash[w];
 
   disconnect( mSelectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
@@ -628,6 +632,10 @@ void Pane::createNewTab()
   w->setXmlGuiClient( d->mXmlGuiClient );
   addTab( w, i18nc( "@title:tab Empty messagelist", "Empty" ) );
 
+  setCloseButtonEnabled( Core::Settings::self()->tabsHaveCloseButton() );
+
+  connect( this, SIGNAL(closeRequest(QWidget*)), SLOT(onCloseTabClicked()) );
+
   QItemSelectionModel *s = new QItemSelectionModel( d->mModel, w );
   MessageList::StorageModel *m = createStorageModel( d->mModel, s, w );
   w->setStorageModel( m );
@@ -690,12 +698,14 @@ void Pane::Private::updateTabControls()
     mMoveTabRightAction->setEnabled( enableAction );
   if ( mMoveTabLeftAction )
     mMoveTabLeftAction->setEnabled( enableAction );
-      
+
   if ( Core::Settings::self()->autoHideTabBarWithSingleTab() ) {
     q->tabBar()->setVisible( enableAction );
   } else {
     q->tabBar()->setVisible( true );
   }
+
+  q->setCloseButtonEnabled( Core::Settings::self()->tabsHaveCloseButton() );
 }
 
 Item Pane::currentItem() const



More information about the kde-doc-english mailing list