blob: b5150b84aafd3354b59d418fcc6f978f6ec5ebee (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
//===========================================
// Lumina-DE source code
// Copyright (c) 2017, Ken Moore
// Available under the 3-clause BSD license
// See the LICENSE file for full details
//===========================================
// This is a drag and drop capable version of the QTabBar
//===========================================
#ifndef _LUMINA_TEXT_EDITOR_DND_TABWIDGET_H
#define _LUMINA_TEXT_EDITOR_DND_TABWIDGET_H
#include <QTabBar>
#include <QTabWidget>
#include <QMouseEvent>
#include <QDebug>
#include <QDrag>
#include <QMimeData>
#include <QMenu>
#include <QAction>
class DnDTabBar : public QTabBar{
Q_OBJECT
signals:
/*void DetachTab(int); //
void DroppedIn(QString); //The "whatsThis()" field on some other DnDTabBar tab
void DraggedOut(QString); //The "whatsThis()" field on *this* DnDTabBar tab*/
private:
//QMenu *tabMenu;
//int selTab;
private slots:
/*void slotDetachTab(){
qDebug() << "Detach Tab:" << selTab;
if(selTab>=0){ emit DetachTab(selTab); }
}*/
public:
DnDTabBar(QWidget *parent) : QTabBar(parent){
//this->setAcceptDrops(true);
//selTab = -1;
//tabMenu = new QMenu(this);
//tabMenu->addAction(tr("Detach Tab"), this, SLOT(slotDetachTab()) );
}
~DnDTabBar(){
}
protected:
/*virtual void mousePressEvent(QMouseEvent *ev){
if(ev->button() == Qt::RightButton){
int tab = this->tabAt(ev->pos());
if(tab>=0){
selTab = tab;
tabMenu->popup(ev->globalPos());
}
QTabBar::mousePressEvent(ev);
}else if(ev->button() == Qt::MiddleButton){
int tab = this->tabAt(ev->pos());
if(tab>=0){
QDrag *drag = new QDrag(this);
QMimeData *mimeData = new QMimeData;
mimeData->setUrls(QList<QUrl>() << QUrl::fromLocalFile(this->tabWhatsThis(tab)));
drag->setMimeData(mimeData);
Qt::DropAction dropAction = drag->exec();
}else{
QTabBar::mousePressEvent(ev);
}
}else{
QTabBar::mousePressEvent(ev);
}
}
virtual void mouseReleaseEvent(QMouseEvent *ev){
}
virtual void mouseMoveEvent(QMouseEvent *ev){
}*/
};
class DnDTabWidget : public QTabWidget{
Q_OBJECT
private:
DnDTabBar *TB;
public:
DnDTabWidget(QWidget *parent) : QTabWidget(parent){
TB = new DnDTabBar(this);
this->setTabBar(TB);
}
~DnDTabWidget(){}
DnDTabBar* dndTabBar(){ return TB; }
};
#endif
|