Feature #757

Middle click on Tab

Added by Kud Gray 962 days ago. Updated 269 days ago.

Status:Closed Start:
Priority:Normal Due date:
Assigned to:- % Done:

100%

Category:UserInterface
Target version:0.14
Operating System:

All

Reported in:

0.12-devel


Description

Close the tab when clicking with middle click.


Related issues

blocks Bug #772 bite sized tasks (META TASK) New
blocks Bug #764 Patch review (META TASK) New

Associated revisions

Revision ee056a936620cc190e40d39f89d834d6888714d6
Added by Maciek Niedzielski 269 days ago

Close tab with middle click (closes #757)
Thanks to Moritz Schmidt for the patch posted in redmine.

History

Updated by - duryodhan 921 days ago

I think I might have did the reverse thing , you might have to apply patch with -R :) (sorry)

diff -r psi/src/tabs/tabdlg.cpp psi-dev-snapshot-2008-02-04/src/tabs/tabdlg.cpp
138d137
< connect(tabWidget_, SIGNAL), SLOT));
358,362d356
< void TabDlg::mouseMiddleClickTab(QWidget* widget)
< {
< closeTab(static_cast<TabbableWidget*>(widget));
< }
<
Only in psi/src/tabs: tabdlg.cpp~
diff -r psi/src/tabs/tabdlg.h psi-dev-snapshot-2008-02-04/src/tabs/tabdlg.h
104d103
< void mouseMiddleClickTab(QWidget*);
Only in psi/src/tabs: tabdlg.h~
Only in psi/src/tools/trayicon: trayicon.cpp~
Only in psi/src/unittest/psipopup: testpsipopup.cpp~
Only in psi/src/unittest: textutil
diff -r psi/src/widgets/psitabbar.cpp psi-dev-snapshot-2008-02-04/src/widgets/psitabbar.cpp
80,84d79
< // Enable Middle Click
< if (event->button() == Qt::MidButton) {
< int tabno = findTabUnder(event->pos());
< emit mouseMiddleClickTab(tabno);
< }
Only in psi/src/widgets: psitabbar.cpp~
diff -r psi/src/widgets/psitabbar.h psi-dev-snapshot-2008-02-04/src/widgets/psitabbar.h
42d41
< void mouseMiddleClickTab(int tab);
Only in psi/src/widgets: psitabbar.h~
diff -r psi/src/widgets/psitabwidget.cpp psi-dev-snapshot-2008-02-04/src/widgets/psitabwidget.cpp
79,80d78
<
< connect( tabBar_, SIGNAL), SLOT));
120,123d117
< void PsiTabWidget::mouseMiddleClickTab(int tab) {
< emit mouseMiddleClickTab(widget(tab));
< }
<
Only in psi/src/widgets: psitabwidget.cpp~
diff -r psi/src/widgets/psitabwidget.h psi-dev-snapshot-2008-02-04/src/widgets/psitabwidget.h
72d71
< void mouseMiddleClickTab(QWidget *tab);
82d80
< void mouseMiddleClickTab(int tab);
Only in psi/src/widgets: psitabwidget.h~

Updated by Moritz Schmidt 913 days ago

don't just revert duryodhan's changes... Psi will crash when you middle-click on the tab bar without having the pointer on a tab.

Index: widgets/psitabbar.h ===================================================================
--- widgets/psitabbar.h (Revision 1069)
+++ widgets/psitabbar.h (Arbeitskopie)
@ -39,6 +39,7 @ signals:
void mouseDoubleClickTab(int tab);
+ void mouseMiddleClickTab(int tab);
void tabDropped(int tab, PsiTabBar *source);
// context menu on the blank space will have tab==-1
void contextMenu(QContextMenuEvent *event, int tab);
Index: widgets/psitabwidget.h ===================================================================
--- widgets/psitabwidget.h (Revision 1069)
+++ widgets/psitabwidget.h (Arbeitskopie)
@ -69,6 +69,8 @ signals:
void mouseDoubleClickTab(QWidget *tab);
+ void mouseMiddleClickTab(QWidget *tab);
+
void currentChanged(QWidget *selected);
void closeButtonClicked();
void aboutToShowMenu(QMenu *);
@ -78,6 +80,7 @ private slots:
void mouseDoubleClickTab(int tab);
+ void mouseMiddleClickTab(int tab);
void tab_currentChanged(int tab);
void tab_contextMenu(QContextMenuEvent *event, int tab);
void menu_aboutToShow();
Index: widgets/psitabbar.cpp ===================================================================
--- widgets/psitabbar.cpp (Revision 1069)
+++ widgets/psitabbar.cpp (Arbeitskopie)
@ -69,13 +69,16 @
} void PsiTabBar::mousePressEvent(QMouseEvent *event) {
- if (event->button() == Qt::LeftButton) {
- int tabno = findTabUnder(event->pos());
- dragStartPosition_ = event->pos();
- dragTab_ = tabno;
- if (tabno != -1) {
+ int tabno = findTabUnder(event->pos());
+ if (tabno != -1) {
+ if (event->button() == Qt::LeftButton) {
+ dragStartPosition_ = event->pos();
+ dragTab_ = tabno;
setCurrentIndex(tabno);
}
+ else if (event->button() Qt::MidButton) {
+ emit mouseMiddleClickTab(tabno);
+ }
}
event->accept();
}
Index: widgets/psitabwidget.cpp
=================================================================
--- widgets/psitabwidget.cpp (Revision 1069)
+++ widgets/psitabwidget.cpp (Arbeitskopie)
@ -73,6 +73,7 @
setTabPosition(QTabWidget::Top); connect( tabBar_, SIGNAL), SLOT));
+ connect( tabBar_, SIGNAL), SLOT));
connect( tabBar_, SIGNAL), SLOT));
connect( tabBar_, SIGNAL), SLOT));
connect( closeButton_, SIGNAL), SIGNAL));
@ -115,6 +116,10 @
emit mouseDoubleClickTab(widget(tab));
}

+void PsiTabWidget::mouseMiddleClickTab(int tab) {
+ emit mouseMiddleClickTab(widget(tab));
+}
+
/** * Number of tabs/widgets
*/
Index: tabs/tabdlg.h ===================================================================
--- tabs/tabdlg.h (Revision 1069)
+++ tabs/tabdlg.h (Arbeitskopie)
@ -105,6 +105,7 @ + void mouseMiddleClickTab(QWidget*);
void mouseDoubleClickTab(QWidget*); Index: tabs/tabdlg.cpp ===================================================================
--- tabs/tabdlg.cpp (Revision 1069)
+++ tabs/tabdlg.cpp (Arbeitskopie)
@ -140,6 +140,7 @ + connect(tabWidget_, SIGNAL), SLOT));
connect(tabWidget_, SIGNAL), SLOT));
connect(tabWidget_, SIGNAL), SLOT));
connect(tabWidget_, SIGNAL), SLOT));
@ -369,6 +370,10 @
detachTab(static_cast<TabbableWidget*>(widget));
}

tabWidget_ = new PsiTabWidget(this);
tabWidget_->setCloseIcon(IconsetFactory::icon("psi/closetab").icon());

+void TabDlg::mouseMiddleClickTab(QWidget* widget) {
+ closeTab(static_cast<TabbableWidget*>(widget));
+}
+
void TabDlg::detachTab(TabbableWidget* tab) {
if (tabWidget_->count() == 1 || !tab)

Updated by Anonymous 269 days ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF