Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #28: Allow adding a new tab by double-clicking the large empty …

…space right to it
  • Loading branch information...
commit 202914653fe4777232034c13453192a0c28b2769 1 parent a03d4d2
Tvangeste authored July 19, 2011
8  maintabwidget.cc
@@ -2,9 +2,10 @@
2 2
  * Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
3 3
 
4 4
 #include "maintabwidget.hh"
  5
+#include <QDebug>
5 6
 
6 7
 MainTabWidget::MainTabWidget( QWidget * parent) : QTabWidget( parent ) {
7  
-    hideSingleTab = false;
  8
+  hideSingleTab = false;
8 9
 }
9 10
 
10 11
 void MainTabWidget::setHideSingleTab(bool hide)
@@ -27,3 +28,8 @@ void MainTabWidget::updateTabBarVisibility()
27 28
 {
28 29
   tabBar()->setVisible( !hideSingleTab || tabBar()->count() > 1 );
29 30
 }
  31
+
  32
+void MainTabWidget::mouseDoubleClickEvent ( QMouseEvent * event )
  33
+{
  34
+  emit doubleClicked();
  35
+}
8  maintabwidget.hh
@@ -15,14 +15,18 @@ class MainTabWidget: public QTabWidget
15 15
   Q_PROPERTY(bool hideSingleTab READ isHideSingleTab WRITE setHideSingleTab)
16 16
 
17 17
 public:
18  
-
19 18
   MainTabWidget( QWidget * parent = 0 );
20 19
 
21 20
   bool isHideSingleTab() const { return hideSingleTab; }
22 21
   void setHideSingleTab(bool hide);
23 22
 
24  
-private:
  23
+signals:
  24
+  void doubleClicked();
25 25
 
  26
+protected:
  27
+  virtual void mouseDoubleClickEvent ( QMouseEvent * event );
  28
+
  29
+private:
26 30
   virtual void tabInserted(int index);
27 31
   virtual void tabRemoved(int index);
28 32
   void updateTabBarVisibility();
3  mainwindow.cc
@@ -361,6 +361,9 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
361 361
   connect( &addTab, SIGNAL( clicked() ),
362 362
            this, SLOT( addNewTab() ) );
363 363
 
  364
+  connect( ui.tabWidget, SIGNAL( doubleClicked() ),
  365
+           this, SLOT( addNewTab() ) );
  366
+
364 367
   connect( ui.tabWidget, SIGNAL( tabCloseRequested( int ) ),
365 368
            this, SLOT( tabCloseRequested( int ) ) );
366 369
 

0 notes on commit 2029146

Please sign in to comment.
Something went wrong with that request. Please try again.