携带bug的功能实现版本
This commit is contained in:
parent
108d307ccd
commit
f7223984aa
|
@ -4,9 +4,8 @@
|
|||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="55c45e43-6fd9-4244-902d-86f83a348f5b" name="Changes" comment="">
|
||||
<list default="true" id="55c45e43-6fd9-4244-902d-86f83a348f5b" name="Changes" comment="删除冗余打印代码">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/DockPanel.py" beforeDir="false" afterPath="$PROJECT_DIR$/DockPanel.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Manager.py" beforeDir="false" afterPath="$PROJECT_DIR$/Manager.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/SplitPanel.py" beforeDir="false" afterPath="$PROJECT_DIR$/SplitPanel.py" afterDir="false" />
|
||||
</list>
|
||||
|
@ -23,8 +22,28 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="PUSH_TAGS">
|
||||
<GitPushTagMode>
|
||||
<option name="argument" value="--tags" />
|
||||
<option name="title" value="All" />
|
||||
</GitPushTagMode>
|
||||
</option>
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="GitHubPullRequestSearchHistory"><![CDATA[{
|
||||
"lastFilter": {
|
||||
"state": "OPEN",
|
||||
"assignee": "heisehuanyin"
|
||||
}
|
||||
}]]></component>
|
||||
<component name="GithubPullRequestsUISettings">
|
||||
<option name="selectedUrlAndAccountId">
|
||||
<UrlAndAccount>
|
||||
<option name="accountId" value="e2cefb47-a99c-4e4b-bae0-586cfe078ae3" />
|
||||
<option name="url" value="https://github.com/heisehuanyin/QDragsView.git" />
|
||||
</UrlAndAccount>
|
||||
</option>
|
||||
</component>
|
||||
<component name="HierarchyBrowserManager">
|
||||
<option name="IS_AUTOSCROLL_TO_SOURCE" value="true" />
|
||||
</component>
|
||||
|
@ -39,20 +58,20 @@
|
|||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"Python.DockPanel.executor": "Debug",
|
||||
"Python.Manager.executor": "Run",
|
||||
"Python.SplitPanel.executor": "Run",
|
||||
"Python.Widget.executor": "Run",
|
||||
"Python.test.executor": "Run",
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"git-widget-placeholder": "main",
|
||||
"settings.editor.selected.configurable": "preferences.sourceCode"
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"Python.DockPanel.executor": "Debug",
|
||||
"Python.Manager.executor": "Run",
|
||||
"Python.SplitPanel.executor": "Run",
|
||||
"Python.Widget.executor": "Run",
|
||||
"Python.test.executor": "Run",
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"git-widget-placeholder": "main",
|
||||
"settings.editor.selected.configurable": "preferences.sourceCode"
|
||||
}
|
||||
}</component>
|
||||
}]]></component>
|
||||
<component name="RunManager" selected="Python.SplitPanel">
|
||||
<configuration name="DockPanel" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||
<module name="SimpleIDE" />
|
||||
|
@ -167,6 +186,30 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1703843144486</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="删除冗余打印代码">
|
||||
<option name="closed" value="true" />
|
||||
<created>1703944526835</created>
|
||||
<option name="number" value="00001" />
|
||||
<option name="presentableId" value="LOCAL-00001" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1703944526835</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="2" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="删除冗余打印代码" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="删除冗余打印代码" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
<breakpoints>
|
||||
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
|
||||
<url>file://$PROJECT_DIR$/Manager.py</url>
|
||||
<line>126</line>
|
||||
<option name="timeStamp" value="9" />
|
||||
</line-breakpoint>
|
||||
</breakpoints>
|
||||
</breakpoint-manager>
|
||||
</component>
|
||||
</project>
|
58
Manager.py
58
Manager.py
|
@ -1,9 +1,19 @@
|
|||
from PyQt5.QtWidgets import QWidget, QApplication, QMainWindow
|
||||
from PyQt5.QtCore import QObject, QEvent, QRect, QMargins, Qt, QMimeData
|
||||
from PyQt5.QtGui import QPainter, QColor, QDragEnterEvent, QDropEvent
|
||||
from enum import Enum
|
||||
import re
|
||||
|
||||
|
||||
class PLACE_AREA(Enum):
|
||||
LEFT_AREA = 0,
|
||||
RIGHT_AREA = 1,
|
||||
TOP_AREA = 2,
|
||||
BOTTOM_AREA = 3,
|
||||
CENTER_AREA = 4,
|
||||
UNDEFINE_AREA = 5,
|
||||
|
||||
|
||||
class AcceptPanel(QWidget):
|
||||
|
||||
def __init__(self, mgr):
|
||||
|
@ -19,11 +29,13 @@ class AcceptPanel(QWidget):
|
|||
|
||||
self.mgr_inst = mgr
|
||||
self.target_anchor :QWidget = None
|
||||
self.target_area = PLACE_AREA.UNDEFINE_AREA
|
||||
|
||||
def resizeEvent(self, a0):
|
||||
total_rect = self.rect()
|
||||
total_rect = total_rect - QMargins(5, 5, 5, 5)
|
||||
anchor_width = 30
|
||||
self.target_area = PLACE_AREA.UNDEFINE_AREA
|
||||
|
||||
self.left_rect = QRect(int(total_rect.left()), int(total_rect.center().y() - anchor_width / 2), int(anchor_width), int(anchor_width))
|
||||
self.right_rect = QRect(int(total_rect.right() - anchor_width), int(total_rect.center().y() - anchor_width / 2), int(anchor_width), int(anchor_width))
|
||||
|
@ -47,24 +59,29 @@ class AcceptPanel(QWidget):
|
|||
painter.fillRect(self.right_rect, Qt.green)
|
||||
painter.fillRect(self.center_rect, Qt.green)
|
||||
|
||||
def mouseMoveEvent(self, a0):
|
||||
def dragMoveEvent(self, a0):
|
||||
self.hover_rect = self.rect()
|
||||
print(a0.pos())
|
||||
|
||||
if self.left_rect.contains(a0.pos()):
|
||||
self.hover_rect.setWidth(int(self.hover_rect.width() / 3))
|
||||
self.target_area = PLACE_AREA.LEFT_AREA
|
||||
elif self.right_rect.contains(a0.pos()):
|
||||
self.target_area = PLACE_AREA.RIGHT_AREA
|
||||
self.hover_rect.setWidth(int(self.hover_rect.width() / 3))
|
||||
self.hover_rect.moveLeft(int(self.rect().right() - self.hover_rect.width()))
|
||||
elif self.top_rect.contains(a0.pos()):
|
||||
self.target_area = PLACE_AREA.TOP_AREA
|
||||
self.hover_rect.setHeight(int(self.hover_rect.height() / 3))
|
||||
elif self.center_rect.contains(a0.pos()):
|
||||
self.target_area = PLACE_AREA.CENTER_AREA
|
||||
pass
|
||||
elif self.bottom_rect.contains(a0.pos()):
|
||||
self.target_area = PLACE_AREA.BOTTOM_AREA
|
||||
self.hover_rect.setHeight(int(self.hover_rect.height() / 3))
|
||||
self.hover_rect.moveTop(int(self.rect().bottom() - self.hover_rect.height()))
|
||||
else:
|
||||
self.hover_rect = QRect()
|
||||
self.target_area = PLACE_AREA.UNDEFINE_AREA
|
||||
|
||||
self.update()
|
||||
|
||||
|
@ -79,9 +96,18 @@ class AcceptPanel(QWidget):
|
|||
regex = re.compile("view-drags\\(([^\\(\\)]+)\\)")
|
||||
result = regex.match(a0.mimeData().text())
|
||||
if result:
|
||||
from SplitPanel import SplitPanel, SplitType
|
||||
from DockPanel import DockPanel
|
||||
view_id = result.group(1)
|
||||
adjust_view = self.mgr_inst.get_dockpanel(view_id)
|
||||
target_view = self.target_anchor
|
||||
adjust_view: DockPanel = self.mgr_inst.get_dockpanel(view_id)
|
||||
target_view: DockPanel = self.target_anchor
|
||||
|
||||
if self.target_area == PLACE_AREA.CENTER_AREA and not target_view.can_replace:
|
||||
self.setVisible(False)
|
||||
return
|
||||
if self.target_area == PLACE_AREA.UNDEFINE_AREA:
|
||||
self.setVisible(False)
|
||||
return
|
||||
|
||||
# 移除源视图
|
||||
parent_frame_rm = adjust_view.parent_res
|
||||
|
@ -98,6 +124,30 @@ class AcceptPanel(QWidget):
|
|||
else:
|
||||
pparent_frame.replace_view(self_siblings[0], parent_frame_rm)
|
||||
|
||||
place_frame = target_view.parent_res
|
||||
split_group:DockPanel = None # 声明类型
|
||||
if self.target_area == PLACE_AREA.LEFT_AREA:
|
||||
split_group = SplitPanel(adjust_view, target_view, SplitType.SPLIT_H)
|
||||
split_group.set_split_info(SplitType.SPLIT_H, 1/3)
|
||||
elif self.target_area == PLACE_AREA.RIGHT_AREA:
|
||||
split_group = SplitPanel(target_view, adjust_view, SplitType.SPLIT_H)
|
||||
split_group.set_split_info(SplitType.SPLIT_H, 2/3)
|
||||
elif self.target_area == PLACE_AREA.TOP_AREA:
|
||||
split_group = SplitPanel(adjust_view, target_view, SplitType.SPLIT_V)
|
||||
split_group.set_split_info(SplitType.SPLIT_V, 1/3)
|
||||
elif self.target_area == PLACE_AREA.BOTTOM_AREA:
|
||||
split_group = SplitPanel(target_view, adjust_view, SplitType.SPLIT_V)
|
||||
split_group.set_split_info(SplitType.SPLIT_V, 2/3)
|
||||
elif self.target_area == PLACE_AREA.CENTER_AREA:
|
||||
split_group = adjust_view
|
||||
|
||||
if place_frame is None:
|
||||
main_window = target_view.parent()
|
||||
target_view.setVisible(False)
|
||||
main_window.setCentralWidget(split_group)
|
||||
else:
|
||||
place_frame.replace_view(split_group, target_view)
|
||||
|
||||
self.setVisible(False)
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import Manager
|
||||
from Manager import DragManager
|
||||
from DockPanel import DockPanel
|
||||
from PyQt5.QtWidgets import QApplication, QWidget, QFrame
|
||||
from enum import Enum
|
||||
|
@ -113,9 +113,9 @@ class SplitPanel(QWidget):
|
|||
self.split_member = (new, self.split_member[1])
|
||||
else:
|
||||
self.split_member = (self.split_member[0], new)
|
||||
|
||||
new.parent_res = self
|
||||
new.setParent(self)
|
||||
old.setParent(None)
|
||||
self.sync_status()
|
||||
self.update()
|
||||
pass
|
||||
|
@ -124,7 +124,7 @@ class SplitPanel(QWidget):
|
|||
if __name__ == "__main__":
|
||||
app = QApplication([])
|
||||
ow = QMainWindow()
|
||||
app.installEventFilter(Manager.DragManager.instance())
|
||||
app.installEventFilter(DragManager.instance())
|
||||
|
||||
a = DockPanel("docka", None, None)
|
||||
b = DockPanel("dockb", None, None)
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue