Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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 Tvangeste authored
Showing with 16 additions and 3 deletions.
  1. +7 −1 maintabwidget.cc
  2. +6 −2 maintabwidget.hh
  3. +3 −0  mainwindow.cc
View
8 maintabwidget.cc
@@ -2,9 +2,10 @@
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
#include "maintabwidget.hh"
+#include <QDebug>
MainTabWidget::MainTabWidget( QWidget * parent) : QTabWidget( parent ) {
- hideSingleTab = false;
+ hideSingleTab = false;
}
void MainTabWidget::setHideSingleTab(bool hide)
@@ -27,3 +28,8 @@ void MainTabWidget::updateTabBarVisibility()
{
tabBar()->setVisible( !hideSingleTab || tabBar()->count() > 1 );
}
+
+void MainTabWidget::mouseDoubleClickEvent ( QMouseEvent * event )
+{
+ emit doubleClicked();
+}
View
8 maintabwidget.hh
@@ -15,14 +15,18 @@ class MainTabWidget: public QTabWidget
Q_PROPERTY(bool hideSingleTab READ isHideSingleTab WRITE setHideSingleTab)
public:
-
MainTabWidget( QWidget * parent = 0 );
bool isHideSingleTab() const { return hideSingleTab; }
void setHideSingleTab(bool hide);
-private:
+signals:
+ void doubleClicked();
+protected:
+ virtual void mouseDoubleClickEvent ( QMouseEvent * event );
+
+private:
virtual void tabInserted(int index);
virtual void tabRemoved(int index);
void updateTabBarVisibility();
View
3  mainwindow.cc
@@ -361,6 +361,9 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
connect( &addTab, SIGNAL( clicked() ),
this, SLOT( addNewTab() ) );
+ connect( ui.tabWidget, SIGNAL( doubleClicked() ),
+ this, SLOT( addNewTab() ) );
+
connect( ui.tabWidget, SIGNAL( tabCloseRequested( int ) ),
this, SLOT( tabCloseRequested( int ) ) );
Please sign in to comment.
Something went wrong with that request. Please try again.