Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

645 lines
23KB

  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # PatchBay Canvas engine using QGraphicsView/Scene
  4. # Copyright (C) 2010-2019 Filipe Coelho <falktx@falktx.com>
  5. #
  6. # This program is free software; you can redistribute it and/or
  7. # modify it under the terms of the GNU General Public License as
  8. # published by the Free Software Foundation; either version 2 of
  9. # the License, or any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # For a full copy of the GNU General Public License see the doc/GPL.txt file.
  17. # ------------------------------------------------------------------------------------------------------------
  18. # Imports (Global)
  19. from PyQt5.QtCore import qCritical, Qt, QPointF, QRectF, QTimer
  20. from PyQt5.QtGui import QCursor, QFont, QFontMetrics, QLinearGradient, QPainter, QPen
  21. from PyQt5.QtWidgets import QGraphicsItem, QMenu
  22. # ------------------------------------------------------------------------------------------------------------
  23. # Imports (Custom)
  24. from . import (
  25. canvas,
  26. features,
  27. options,
  28. port_dict_t,
  29. CanvasBoxType,
  30. ANTIALIASING_FULL,
  31. ACTION_PLUGIN_EDIT,
  32. ACTION_PLUGIN_SHOW_UI,
  33. ACTION_PLUGIN_CLONE,
  34. ACTION_PLUGIN_REMOVE,
  35. ACTION_PLUGIN_RENAME,
  36. ACTION_PLUGIN_REPLACE,
  37. ACTION_GROUP_INFO,
  38. ACTION_GROUP_JOIN,
  39. ACTION_GROUP_SPLIT,
  40. ACTION_GROUP_RENAME,
  41. ACTION_PORTS_DISCONNECT,
  42. EYECANDY_FULL,
  43. PORT_MODE_NULL,
  44. PORT_MODE_INPUT,
  45. PORT_MODE_OUTPUT,
  46. PORT_TYPE_NULL,
  47. PORT_TYPE_AUDIO_JACK,
  48. PORT_TYPE_MIDI_ALSA,
  49. PORT_TYPE_MIDI_JACK,
  50. PORT_TYPE_PARAMETER,
  51. MAX_PLUGIN_ID_ALLOWED,
  52. )
  53. from .canvasboxshadow import CanvasBoxShadow
  54. from .canvasicon import CanvasIcon
  55. from .canvasport import CanvasPort
  56. from .theme import Theme
  57. from .utils import CanvasItemFX, CanvasGetFullPortName, CanvasGetPortConnectionList
  58. # ------------------------------------------------------------------------------------------------------------
  59. class cb_line_t(object):
  60. def __init__(self, line, connection_id):
  61. self.line = line
  62. self.connection_id = connection_id
  63. # ------------------------------------------------------------------------------------------------------------
  64. class CanvasBox(QGraphicsItem):
  65. def __init__(self, group_id, group_name, icon, parent=None):
  66. QGraphicsItem.__init__(self)
  67. self.setParentItem(parent)
  68. # Save Variables, useful for later
  69. self.m_group_id = group_id
  70. self.m_group_name = group_name
  71. # plugin Id, < 0 if invalid
  72. self.m_plugin_id = -1
  73. self.m_plugin_ui = False
  74. # Base Variables
  75. self.p_width = 50
  76. self.p_height = canvas.theme.box_header_height + canvas.theme.box_header_spacing + 1
  77. self.m_last_pos = QPointF()
  78. self.m_splitted = False
  79. self.m_splitted_mode = PORT_MODE_NULL
  80. self.m_cursor_moving = False
  81. self.m_forced_split = False
  82. self.m_mouse_down = False
  83. self.m_port_list_ids = []
  84. self.m_connection_lines = []
  85. # Set Font
  86. self.m_font_name = QFont()
  87. self.m_font_name.setFamily(canvas.theme.box_font_name)
  88. self.m_font_name.setPixelSize(canvas.theme.box_font_size)
  89. self.m_font_name.setWeight(canvas.theme.box_font_state)
  90. self.m_font_port = QFont()
  91. self.m_font_port.setFamily(canvas.theme.port_font_name)
  92. self.m_font_port.setPixelSize(canvas.theme.port_font_size)
  93. self.m_font_port.setWeight(canvas.theme.port_font_state)
  94. # Icon
  95. if canvas.theme.box_use_icon:
  96. self.icon_svg = CanvasIcon(icon, self.m_group_name, self)
  97. else:
  98. self.icon_svg = None
  99. # Shadow
  100. if options.eyecandy:
  101. self.shadow = CanvasBoxShadow(self.toGraphicsObject())
  102. self.shadow.setFakeParent(self)
  103. self.setGraphicsEffect(self.shadow)
  104. else:
  105. self.shadow = None
  106. # Final touches
  107. self.setFlags(QGraphicsItem.ItemIsFocusable | QGraphicsItem.ItemIsMovable | QGraphicsItem.ItemIsSelectable)
  108. # Wait for at least 1 port
  109. if options.auto_hide_groups:
  110. self.setVisible(False)
  111. if options.auto_select_items:
  112. self.setAcceptHoverEvents(True)
  113. self.updatePositions()
  114. canvas.scene.addItem(self)
  115. QTimer.singleShot(0, self.fixPos)
  116. def getGroupId(self):
  117. return self.m_group_id
  118. def getGroupName(self):
  119. return self.m_group_name
  120. def isSplitted(self):
  121. return self.m_splitted
  122. def getSplittedMode(self):
  123. return self.m_splitted_mode
  124. def getPortCount(self):
  125. return len(self.m_port_list_ids)
  126. def getPortList(self):
  127. return self.m_port_list_ids
  128. def setAsPlugin(self, plugin_id, hasUi):
  129. self.m_plugin_id = plugin_id
  130. self.m_plugin_ui = hasUi
  131. def setIcon(self, icon):
  132. if self.icon_svg is not None:
  133. self.icon_svg.setIcon(icon, self.m_group_name)
  134. def setSplit(self, split, mode=PORT_MODE_NULL):
  135. self.m_splitted = split
  136. self.m_splitted_mode = mode
  137. def setGroupName(self, group_name):
  138. self.m_group_name = group_name
  139. self.updatePositions()
  140. def setShadowOpacity(self, opacity):
  141. if self.shadow:
  142. self.shadow.setOpacity(opacity)
  143. def addPortFromGroup(self, port_id, port_mode, port_type, port_name, is_alternate):
  144. if len(self.m_port_list_ids) == 0:
  145. if options.auto_hide_groups:
  146. if options.eyecandy == EYECANDY_FULL:
  147. CanvasItemFX(self, True, False)
  148. self.setVisible(True)
  149. new_widget = CanvasPort(self.m_group_id, port_id, port_name, port_mode, port_type, is_alternate, self)
  150. port_dict = port_dict_t()
  151. port_dict.group_id = self.m_group_id
  152. port_dict.port_id = port_id
  153. port_dict.port_name = port_name
  154. port_dict.port_mode = port_mode
  155. port_dict.port_type = port_type
  156. port_dict.is_alternate = is_alternate
  157. port_dict.widget = new_widget
  158. self.m_port_list_ids.append(port_id)
  159. return new_widget
  160. def removePortFromGroup(self, port_id):
  161. if port_id in self.m_port_list_ids:
  162. self.m_port_list_ids.remove(port_id)
  163. else:
  164. qCritical("PatchCanvas::CanvasBox.removePort(%i) - unable to find port to remove" % port_id)
  165. return
  166. if len(self.m_port_list_ids) > 0:
  167. self.updatePositions()
  168. elif self.isVisible():
  169. if options.auto_hide_groups:
  170. if options.eyecandy == EYECANDY_FULL:
  171. CanvasItemFX(self, False, False)
  172. else:
  173. self.setVisible(False)
  174. def addLineFromGroup(self, line, connection_id):
  175. new_cbline = cb_line_t(line, connection_id)
  176. self.m_connection_lines.append(new_cbline)
  177. def removeLineFromGroup(self, connection_id):
  178. for connection in self.m_connection_lines:
  179. if connection.connection_id == connection_id:
  180. self.m_connection_lines.remove(connection)
  181. return
  182. qCritical("PatchCanvas::CanvasBox.removeLineFromGroup(%i) - unable to find line to remove" % connection_id)
  183. def checkItemPos(self):
  184. if not canvas.size_rect.isNull():
  185. pos = self.scenePos()
  186. if not (canvas.size_rect.contains(pos) and
  187. canvas.size_rect.contains(pos + QPointF(self.p_width, self.p_height))):
  188. if pos.x() < canvas.size_rect.x():
  189. self.setPos(canvas.size_rect.x(), pos.y())
  190. elif pos.x() + self.p_width > canvas.size_rect.width():
  191. self.setPos(canvas.size_rect.width() - self.p_width, pos.y())
  192. pos = self.scenePos()
  193. if pos.y() < canvas.size_rect.y():
  194. self.setPos(pos.x(), canvas.size_rect.y())
  195. elif pos.y() + self.p_height > canvas.size_rect.height():
  196. self.setPos(pos.x(), canvas.size_rect.height() - self.p_height)
  197. def removeIconFromScene(self):
  198. if self.icon_svg is None:
  199. return
  200. item = self.icon_svg
  201. self.icon_svg = None
  202. canvas.scene.removeItem(item)
  203. del item
  204. def updatePositions(self):
  205. self.prepareGeometryChange()
  206. # Check Text Name size
  207. app_name_size = QFontMetrics(self.m_font_name).width(self.m_group_name) + 30
  208. self.p_width = max(50, app_name_size)
  209. # Get Port List
  210. port_list = []
  211. for port in canvas.port_list:
  212. if port.group_id == self.m_group_id and port.port_id in self.m_port_list_ids:
  213. port_list.append(port)
  214. if len(port_list) == 0:
  215. self.p_height = canvas.theme.box_header_height
  216. else:
  217. max_in_width = max_out_width = 0
  218. port_spacing = canvas.theme.port_height + canvas.theme.port_spacing
  219. # Get Max Box Width, vertical ports re-positioning
  220. port_types = [PORT_TYPE_AUDIO_JACK, PORT_TYPE_MIDI_JACK, PORT_TYPE_MIDI_ALSA, PORT_TYPE_PARAMETER]
  221. last_in_type = last_out_type = PORT_TYPE_NULL
  222. last_in_pos = last_out_pos = canvas.theme.box_header_height + canvas.theme.box_header_spacing
  223. for port_type in port_types:
  224. for port in port_list:
  225. if port.port_type != port_type:
  226. continue
  227. size = QFontMetrics(self.m_font_port).width(port.port_name)
  228. if port.port_mode == PORT_MODE_INPUT:
  229. max_in_width = max(max_in_width, size)
  230. if port.port_type != last_in_type:
  231. if last_in_type != PORT_TYPE_NULL:
  232. last_in_pos += canvas.theme.port_spacingT
  233. last_in_type = port.port_type
  234. port.widget.setY(last_in_pos)
  235. last_in_pos += port_spacing
  236. elif port.port_mode == PORT_MODE_OUTPUT:
  237. max_out_width = max(max_out_width, size)
  238. if port.port_type != last_out_type:
  239. if last_out_type != PORT_TYPE_NULL:
  240. last_out_pos += canvas.theme.port_spacingT
  241. last_out_type = port.port_type
  242. port.widget.setY(last_out_pos)
  243. last_out_pos += port_spacing
  244. self.p_width = max(self.p_width, 30 + max_in_width + max_out_width)
  245. # Horizontal ports re-positioning
  246. inX = canvas.theme.port_offset
  247. outX = self.p_width - max_out_width - canvas.theme.port_offset - 12
  248. for port_type in port_types:
  249. for port in port_list:
  250. if port.port_mode == PORT_MODE_INPUT:
  251. port.widget.setX(inX)
  252. port.widget.setPortWidth(max_in_width)
  253. elif port.port_mode == PORT_MODE_OUTPUT:
  254. port.widget.setX(outX)
  255. port.widget.setPortWidth(max_out_width)
  256. self.p_height = max(last_in_pos, last_out_pos)
  257. self.p_height += max(canvas.theme.port_spacing, canvas.theme.port_spacingT) - canvas.theme.port_spacing
  258. self.p_height += canvas.theme.box_pen.widthF()
  259. self.repaintLines(True)
  260. self.update()
  261. def repaintLines(self, forced=False):
  262. if self.pos() != self.m_last_pos or forced:
  263. for connection in self.m_connection_lines:
  264. connection.line.updateLinePos()
  265. self.m_last_pos = self.pos()
  266. def resetLinesZValue(self):
  267. for connection in canvas.connection_list:
  268. if connection.port_out_id in self.m_port_list_ids and connection.port_in_id in self.m_port_list_ids:
  269. z_value = canvas.last_z_value
  270. else:
  271. z_value = canvas.last_z_value - 1
  272. connection.widget.setZValue(z_value)
  273. def type(self):
  274. return CanvasBoxType
  275. def contextMenuEvent(self, event):
  276. event.accept()
  277. menu = QMenu()
  278. # Conenct menu stuff
  279. connMenu = QMenu("Connect", menu)
  280. our_port_types = []
  281. our_port_outs = {
  282. PORT_TYPE_AUDIO_JACK: [],
  283. PORT_TYPE_MIDI_JACK: [],
  284. PORT_TYPE_MIDI_ALSA: [],
  285. }
  286. for port in canvas.port_list:
  287. if port.group_id != self.m_group_id:
  288. continue
  289. if port.port_mode != PORT_MODE_OUTPUT:
  290. continue
  291. if port.port_id not in self.m_port_list_ids:
  292. continue
  293. if port.port_type not in our_port_types:
  294. our_port_types.append(port.port_type)
  295. our_port_outs[port.port_type].append((port.group_id, port.port_id))
  296. if len(our_port_types) != 0:
  297. act_x_conn = None
  298. for group in canvas.group_list:
  299. if self.m_group_id == group.group_id:
  300. continue
  301. has_ports = False
  302. target_ports = {
  303. PORT_TYPE_AUDIO_JACK: [],
  304. PORT_TYPE_MIDI_JACK: [],
  305. PORT_TYPE_MIDI_ALSA: [],
  306. }
  307. for port in canvas.port_list:
  308. if port.group_id != group.group_id:
  309. continue
  310. if port.port_mode != PORT_MODE_INPUT:
  311. continue
  312. if port.port_type not in our_port_types:
  313. continue
  314. has_ports = True
  315. target_ports[port.port_type].append((port.group_id, port.port_id))
  316. if not has_ports:
  317. continue
  318. act_x_conn = connMenu.addAction(group.group_name)
  319. act_x_conn.setData((our_port_outs, target_ports))
  320. act_x_conn.triggered.connect(canvas.qobject.PortContextMenuConnect)
  321. if act_x_conn is None:
  322. act_x_disc = connMenu.addAction("Nothing to connect to")
  323. act_x_disc.setEnabled(False)
  324. else:
  325. act_x_disc = connMenu.addAction("No output ports")
  326. act_x_disc.setEnabled(False)
  327. # Disconnect menu stuff
  328. discMenu = QMenu("Disconnect", menu)
  329. conn_list = []
  330. conn_list_ids = []
  331. for port_id in self.m_port_list_ids:
  332. tmp_conn_list = CanvasGetPortConnectionList(self.m_group_id, port_id)
  333. for tmp_conn_id, tmp_group_id, tmp_port_id in tmp_conn_list:
  334. if tmp_conn_id not in conn_list_ids:
  335. conn_list.append((tmp_conn_id, tmp_group_id, tmp_port_id))
  336. conn_list_ids.append(tmp_conn_id)
  337. if len(conn_list) > 0:
  338. for conn_id, group_id, port_id in conn_list:
  339. act_x_disc = discMenu.addAction(CanvasGetFullPortName(group_id, port_id))
  340. act_x_disc.setData(conn_id)
  341. act_x_disc.triggered.connect(canvas.qobject.PortContextMenuDisconnect)
  342. else:
  343. act_x_disc = discMenu.addAction("No connections")
  344. act_x_disc.setEnabled(False)
  345. menu.addMenu(connMenu)
  346. menu.addMenu(discMenu)
  347. act_x_disc_all = menu.addAction("Disconnect &All")
  348. act_x_sep1 = menu.addSeparator()
  349. act_x_info = menu.addAction("Info")
  350. act_x_rename = menu.addAction("Rename")
  351. act_x_sep2 = menu.addSeparator()
  352. act_x_split_join = menu.addAction("Join" if self.m_splitted else "Split")
  353. if not features.group_info:
  354. act_x_info.setVisible(False)
  355. if not features.group_rename:
  356. act_x_rename.setVisible(False)
  357. if not (features.group_info and features.group_rename):
  358. act_x_sep1.setVisible(False)
  359. if self.m_plugin_id >= 0 and self.m_plugin_id <= MAX_PLUGIN_ID_ALLOWED:
  360. menu.addSeparator()
  361. act_p_edit = menu.addAction("Edit")
  362. act_p_ui = menu.addAction("Show Custom UI")
  363. menu.addSeparator()
  364. act_p_clone = menu.addAction("Clone")
  365. act_p_rename = menu.addAction("Rename...")
  366. act_p_replace = menu.addAction("Replace...")
  367. act_p_remove = menu.addAction("Remove")
  368. if not self.m_plugin_ui:
  369. act_p_ui.setVisible(False)
  370. else:
  371. act_p_edit = act_p_ui = None
  372. act_p_clone = act_p_rename = None
  373. act_p_replace = act_p_remove = None
  374. haveIns = haveOuts = False
  375. for port in canvas.port_list:
  376. if port.group_id == self.m_group_id and port.port_id in self.m_port_list_ids:
  377. if port.port_mode == PORT_MODE_INPUT:
  378. haveIns = True
  379. elif port.port_mode == PORT_MODE_OUTPUT:
  380. haveOuts = True
  381. if not (self.m_splitted or bool(haveIns and haveOuts)):
  382. act_x_sep2.setVisible(False)
  383. act_x_split_join.setVisible(False)
  384. act_selected = menu.exec_(event.screenPos())
  385. if act_selected is None:
  386. pass
  387. elif act_selected == act_x_disc_all:
  388. for conn_id in conn_list_ids:
  389. canvas.callback(ACTION_PORTS_DISCONNECT, conn_id, 0, "")
  390. elif act_selected == act_x_info:
  391. canvas.callback(ACTION_GROUP_INFO, self.m_group_id, 0, "")
  392. elif act_selected == act_x_rename:
  393. canvas.callback(ACTION_GROUP_RENAME, self.m_group_id, 0, "")
  394. elif act_selected == act_x_split_join:
  395. if self.m_splitted:
  396. canvas.callback(ACTION_GROUP_JOIN, self.m_group_id, 0, "")
  397. else:
  398. canvas.callback(ACTION_GROUP_SPLIT, self.m_group_id, 0, "")
  399. elif act_selected == act_p_edit:
  400. canvas.callback(ACTION_PLUGIN_EDIT, self.m_plugin_id, 0, "")
  401. elif act_selected == act_p_ui:
  402. canvas.callback(ACTION_PLUGIN_SHOW_UI, self.m_plugin_id, 0, "")
  403. elif act_selected == act_p_clone:
  404. canvas.callback(ACTION_PLUGIN_CLONE, self.m_plugin_id, 0, "")
  405. elif act_selected == act_p_rename:
  406. canvas.callback(ACTION_PLUGIN_RENAME, self.m_plugin_id, 0, "")
  407. elif act_selected == act_p_replace:
  408. canvas.callback(ACTION_PLUGIN_REPLACE, self.m_plugin_id, 0, "")
  409. elif act_selected == act_p_remove:
  410. canvas.callback(ACTION_PLUGIN_REMOVE, self.m_plugin_id, 0, "")
  411. def keyPressEvent(self, event):
  412. if self.m_plugin_id >= 0 and event.key() == Qt.Key_Delete:
  413. event.accept()
  414. canvas.callback(ACTION_PLUGIN_REMOVE, self.m_plugin_id, 0, "")
  415. return
  416. QGraphicsItem.keyPressEvent(self, event)
  417. def hoverEnterEvent(self, event):
  418. if options.auto_select_items:
  419. if len(canvas.scene.selectedItems()) > 0:
  420. canvas.scene.clearSelection()
  421. self.setSelected(True)
  422. QGraphicsItem.hoverEnterEvent(self, event)
  423. def mouseDoubleClickEvent(self, event):
  424. if self.m_plugin_id >= 0:
  425. event.accept()
  426. canvas.callback(ACTION_PLUGIN_SHOW_UI if self.m_plugin_ui else ACTION_PLUGIN_EDIT, self.m_plugin_id, 0, "")
  427. return
  428. QGraphicsItem.mouseDoubleClickEvent(self, event)
  429. def mousePressEvent(self, event):
  430. canvas.last_z_value += 1
  431. self.setZValue(canvas.last_z_value)
  432. self.resetLinesZValue()
  433. self.m_cursor_moving = False
  434. if event.button() == Qt.RightButton:
  435. event.accept()
  436. canvas.scene.clearSelection()
  437. self.setSelected(True)
  438. self.m_mouse_down = False
  439. return
  440. elif event.button() == Qt.LeftButton:
  441. if self.sceneBoundingRect().contains(event.scenePos()):
  442. self.m_mouse_down = True
  443. else:
  444. # FIXME: Check if still valid: Fix a weird Qt behaviour with right-click mouseMove
  445. self.m_mouse_down = False
  446. event.ignore()
  447. return
  448. else:
  449. self.m_mouse_down = False
  450. QGraphicsItem.mousePressEvent(self, event)
  451. def mouseMoveEvent(self, event):
  452. if self.m_mouse_down:
  453. if not self.m_cursor_moving:
  454. self.setCursor(QCursor(Qt.SizeAllCursor))
  455. self.m_cursor_moving = True
  456. self.repaintLines()
  457. QGraphicsItem.mouseMoveEvent(self, event)
  458. def mouseReleaseEvent(self, event):
  459. if self.m_cursor_moving:
  460. self.unsetCursor()
  461. QTimer.singleShot(0, self.fixPos)
  462. self.m_mouse_down = False
  463. self.m_cursor_moving = False
  464. QGraphicsItem.mouseReleaseEvent(self, event)
  465. def fixPos(self):
  466. self.setX(round(self.x()))
  467. self.setY(round(self.y()))
  468. def boundingRect(self):
  469. return QRectF(0, 0, self.p_width, self.p_height)
  470. def paint(self, painter, option, widget):
  471. painter.save()
  472. painter.setRenderHint(QPainter.Antialiasing, bool(options.antialiasing == ANTIALIASING_FULL))
  473. rect = QRectF(0, 0, self.p_width, self.p_height)
  474. # Draw rectangle
  475. pen = QPen(canvas.theme.box_pen_sel if self.isSelected() else canvas.theme.box_pen)
  476. pen.setWidthF(pen.widthF() + 0.00001)
  477. painter.setPen(pen)
  478. lineHinting = pen.widthF() / 2
  479. if canvas.theme.box_bg_type == Theme.THEME_BG_GRADIENT:
  480. box_gradient = QLinearGradient(0, 0, 0, self.p_height)
  481. box_gradient.setColorAt(0, canvas.theme.box_bg_1)
  482. box_gradient.setColorAt(1, canvas.theme.box_bg_2)
  483. painter.setBrush(box_gradient)
  484. else:
  485. painter.setBrush(canvas.theme.box_bg_1)
  486. rect.adjust(lineHinting, lineHinting, -lineHinting, -lineHinting)
  487. painter.drawRect(rect)
  488. # Draw pixmap header
  489. rect.setHeight(canvas.theme.box_header_height)
  490. if canvas.theme.box_header_pixmap:
  491. painter.setPen(Qt.NoPen)
  492. painter.setBrush(canvas.theme.box_bg_2)
  493. # outline
  494. rect.adjust(lineHinting, lineHinting, -lineHinting, -lineHinting)
  495. painter.drawRect(rect)
  496. rect.adjust(1, 1, -1, 0)
  497. painter.drawTiledPixmap(rect, canvas.theme.box_header_pixmap, rect.topLeft())
  498. # Draw text
  499. painter.setFont(self.m_font_name)
  500. if self.isSelected():
  501. painter.setPen(canvas.theme.box_text_sel)
  502. else:
  503. painter.setPen(canvas.theme.box_text)
  504. if canvas.theme.box_use_icon:
  505. textPos = QPointF(25, canvas.theme.box_text_ypos)
  506. else:
  507. appNameSize = QFontMetrics(self.m_font_name).width(self.m_group_name)
  508. rem = self.p_width - appNameSize
  509. textPos = QPointF(rem/2, canvas.theme.box_text_ypos)
  510. painter.drawText(textPos, self.m_group_name)
  511. self.repaintLines()
  512. painter.restore()
  513. # ------------------------------------------------------------------------------------------------------------