@@ -12,6 +12,21 @@ def __init__(self, parent=None):
1212
1313 self .setTabBar (self .tabBar )
1414
15+ self .btn = QPushButton (self )
16+ self .btn .setEnabled (True )
17+ #self.btn.setMinimumSize(64, 40)
18+ #self.btn.setIconSize(QSize(38, 38))
19+ self .btn .setIcon (QIcon (':/qt-project.org/styles/commonstyle/images/up-32.png' ))
20+ self .btn .clicked .connect (self .invokeDetachTab )
21+ self .setCornerWidget (self .btn )
22+
23+ self ._lastgeometry = None
24+
25+ @pyqtSlot (bool )
26+ def invokeDetachTab (self , ** args ):
27+ x = self .btn .geometry ().x ()
28+ y = self .btn .geometry ().y ()
29+ self .detachTab (self .currentIndex (), QPoint (x ,y ))
1530
1631 ##
1732 # The default movable functionality of QTabWidget must remain disabled
@@ -58,62 +73,14 @@ def detachTab(self, index, point):
5873 detachedTab .setWindowTitle (name + ' - Close to reattach' )
5974 detachedTab .setWindowIcon (icon )
6075 detachedTab .setObjectName (name )
61- detachedTab .setGeometry (contentWidgetRect )
62- detachedTab .onCloseSignal .connect (self .attachTab )
63- detachedTab .move (point )
64- detachedTab .show ()
65-
66- def attachTab1 (self , contentWidget , name , icon ):
67-
68- # Make the content widget a child of this widget
69- contentWidget .setParent (self )
70-
71-
72- # Create an image from the given icon
73- if not icon .isNull ():
74- tabIconPixmap = icon .pixmap (icon .availableSizes ()[0 ])
75- tabIconImage = tabIconPixmap .toImage ()
76- else :
77- tabIconImage = None
78-
79-
80- # Create an image of the main window icon
81- if not icon .isNull ():
82- windowIconPixmap = self .window ().windowIcon ().pixmap (icon .availableSizes ()[0 ])
83- windowIconImage = windowIconPixmap .toImage ()
84- else :
85- windowIconImage = None
86-
87-
88- # Determine if the given image and the main window icon are the same.
89- # If they are, then do not add the icon to the tab
90- if name == 'Model Selection' :
91- index = 0
92- elif name == "Model' Parameters" :
93- index = 1
94- elif name == 'Stim settings' :
95- index = 2
96- elif name == 'Parameter evolution settings' :
97- index = 3
98- elif name == 'LambdaE' :
99- index = 4
100- elif name == 'Simulation settings' :
101- index = 5
102- elif name == 'LFP + PPS + Pulse Results' :
103- index = 6
104- if tabIconImage == windowIconImage :
105- index = self .insertTab (index ,contentWidget , name )
106- # index = self.addTab(contentWidget, name)
76+ if self ._lastgeometry is None :
77+ detachedTab .setGeometry (contentWidgetRect )
78+ detachedTab .move (point )
10779 else :
108- # index = self.addTab(contentWidget, icon, name)
109- index = self .insertTab (index ,contentWidget , icon , name )
110-
111-
112-
113- # Make this tab the current tab
114- if index > - 1 :
115- self .setCurrentIndex (index )
80+ detachedTab .setGeometry (self ._lastgeometry )
11681
82+ detachedTab .onCloseSignal .connect (self .attachTab )
83+ detachedTab .show ()
11784
11885 ##
11986 # Re-attach the tab by removing the content from the DetachedTab dialog,
@@ -122,8 +89,10 @@ def attachTab1(self, contentWidget, name, icon):
12289 # @param contentWidget the content widget from the DetachedTab dialog
12390 # @param name the name of the detached tab
12491 # @param icon the window icon for the detached tab
125- @pyqtSlot (QWidget , type ('' ), QIcon )
126- def attachTab (self , contentWidget , name , icon ):
92+ @pyqtSlot (QWidget , type ('' ), QIcon , QRect )
93+ def attachTab (self , contentWidget , name , icon , geometry ):
94+
95+ self ._lastgeometry = geometry
12796
12897 # Make the content widget a child of this widget
12998 contentWidget .setParent (self )
@@ -163,7 +132,7 @@ def attachTab(self, contentWidget, name, icon):
163132 # can be re-attached by closing the dialog or by double clicking on its
164133 # window frame.
165134 class DetachedTab (QDialog ):
166- onCloseSignal = pyqtSignal (QWidget ,type ('' ), QIcon )
135+ onCloseSignal = pyqtSignal (QWidget ,type ('' ), QIcon , QRect )
167136
168137 def __init__ (self , contentWidget , parent = None ):
169138 QDialog .__init__ (self , parent )
@@ -198,7 +167,7 @@ def event(self, event):
198167 #
199168 # @param event a close event
200169 def closeEvent (self , event ):
201- self .onCloseSignal .emit (self .contentWidget , self .objectName (), self .windowIcon ())
170+ self .onCloseSignal .emit (self .contentWidget , self .objectName (), self .windowIcon (), self . geometry () )
202171
203172
204173 ##
@@ -326,8 +295,8 @@ def __init__(self, parent=None):
326295 self .parent = parent
327296 self .centralTabs = DetachTabWidget ()
328297 self .setCentralWidget (self .centralTabs )
329- self .setFixedWidth (200 )
330- self .setFixedHeight (200 )
298+ # self.setFixedWidth(200)
299+ # self.setFixedHeight(200)
331300
332301 #tab 1
333302 self .tab_1 = QWidget ()
0 commit comments