예제 #1
0
 def __init__(self, db_editor):
     super().__init__(db_editor)
     self.setObjectName("spine_db_editor_url_toolbar")
     self._db_editor = db_editor
     self._history = []
     self._history_index = -1
     self._project_urls = {}
     self._go_back_action = self.addAction(QIcon(CharIconEngine("\uf060")),
                                           "Go back",
                                           db_editor.load_previous_urls)
     self._go_forward_action = self.addAction(
         QIcon(CharIconEngine("\uf061")), "Go forward",
         db_editor.load_next_urls)
     self.reload_action = self.addAction(QIcon(CharIconEngine("\uf021")),
                                         "Reload",
                                         db_editor.refresh_session)
     self.reload_action.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_R))
     self._go_back_action.setEnabled(False)
     self._go_forward_action.setEnabled(False)
     self.reload_action.setEnabled(False)
     self._open_project_url_menu = self._add_open_project_url_menu()
     self._line_edit = QLineEdit(self)
     self._line_edit.setPlaceholderText("Type the URL of a Spine DB")
     self._line_edit.returnPressed.connect(
         self._handle_line_edit_return_pressed)
     self.addWidget(self._line_edit)
     self.setMovable(False)
     self.setIconSize(QSize(20, 20))
예제 #2
0
 def _create_context_menu(self):
     """Creates a context menu for this view."""
     self._menu.addAction(self._spine_db_editor.ui.actionCopy)
     self._menu.addSeparator()
     self._add_middle_actions()
     self._menu.addSeparator()
     self._show_entity_metadata_action = self._menu.addAction(
         QIcon(CharIconEngine("\uf4ad")), "View metadata",
         self.show_entity_metadata)
     self._menu.addSeparator()
     self._edit_action = self._menu.addAction(self._cube_pen_icon,
                                              "Edit...", self.edit_selected)
     self._remove_action = self._menu.addAction(self._cube_minus_icon,
                                                "Remove...",
                                                self.remove_selected)
     self._menu.addSeparator()
     self._export_action = self._menu.addAction(
         QIcon(":/icons/menu_icons/database-export.svg"), "Export",
         self.export_selected)
     self._menu.addSeparator()
     self._fully_expand_action = self._menu.addAction(
         QIcon(CharIconEngine("\uf101")), "Fully expand", self.fully_expand)
     self._fully_collapse_action = self._menu.addAction(
         QIcon(CharIconEngine("\uf100")), "Fully collapse",
         self.fully_collapse)
예제 #3
0
 def set_icon(self, unicode, color=0):
     """Refreshes the icon."""
     if (unicode, color) == self._current_icon:
         return
     pixmap = CharIconEngine(unicode,
                             color).pixmap(QSize(self._extent,
                                                 self._extent))
     self.setPixmap(pixmap)
     self._current_icon = (unicode, color)
예제 #4
0
 def add_main_menu(self, menu):
     menu_action = self.addAction(QIcon(CharIconEngine("\uf0c9")), "")
     menu_action.setMenu(menu)
     menu_button = self.widgetForAction(menu_action)
     menu_button.setPopupMode(menu_button.InstantPopup)
     action = QAction(self)
     action.triggered.connect(menu_button.showMenu)
     keys = [
         QKeySequence(Qt.ALT + Qt.Key_F),
         QKeySequence(Qt.ALT + Qt.Key_E)
     ]
     action.setShortcuts(keys)
     keys_str = ", ".join([key.toString() for key in keys])
     menu_button.setToolTip(
         f"<p>Customize and control Spine DB Editor ({keys_str})</p>")
     return action
예제 #5
0
 def _add_main_menu(self):
     menu = QMenu(self)
     menu.addMenu(self._db_editor.ui.menuSession)
     menu.addMenu(self._db_editor.ui.menuFile)
     menu.addMenu(self._db_editor.ui.menuEdit)
     menu.addMenu(self._db_editor.ui.menuView)
     menu.addMenu(self._db_editor.ui.menuPivot_table)
     menu.addMenu(self._db_editor.ui.menuGraph)
     menu.addSeparator()
     menu.addAction(self._db_editor.ui.actionUser_guide)
     menu.addAction(self._db_editor.ui.actionSettings)
     menu_action = self.addAction(QIcon(CharIconEngine("\uf0c9")), "")
     menu_action.setMenu(menu)
     menu_button = self.widgetForAction(menu_action)
     menu_button.setPopupMode(menu_button.InstantPopup)
     menu_button.setToolTip("<p>Customize and control Spine DB Editor</p>")
예제 #6
0
 def _add_open_project_url_menu(self):
     toolbox = self._db_editor.toolbox
     if toolbox is None:
         return None
     menu = QMenu(self)
     menu_action = self.addAction(QIcon(CharIconEngine("\uf1c0")), "")
     menu_action.setMenu(menu)
     menu_button = self.widgetForAction(menu_action)
     menu_button.setPopupMode(menu_button.InstantPopup)
     menu_button.setToolTip("<p>Open URL from project</p>")
     menu.aboutToShow.connect(self._update_open_project_url_menu)
     menu.triggered.connect(self._open_ds_url)
     slot = lambda *args: self._update_ds_url_menu_enabled()
     self._connect_project_item_model_signals(slot)
     self.destroyed.connect(lambda obj=None, slot=slot: self.
                            _disconnect_project_item_model_signals(slot))
     return menu
예제 #7
0
 def _add_middle_actions(self):
     self._add_object_classes_action = self._menu.addAction(
         self._cube_plus_icon, "Add objects classes", self.add_object_classes
     )
     self._add_objects_action = self._menu.addAction(self._cube_plus_icon, "Add objects", self.add_objects)
     self._add_relationship_actions()
     self._menu.addSeparator()
     self._find_next_action = self._menu.addAction(
         QIcon(CharIconEngine("\uf141")), "Find next relationship", self.find_next_relationship
     )
     self._add_object_group_action = self._menu.addAction(
         self._cube_plus_icon, "Add object group", self.add_object_group
     )
     self._manage_members_action = self._menu.addAction(self._cube_pen_icon, "Manage members", self.manage_members)
     self._duplicate_object_action = self._menu.addAction(
         self._cube_plus_icon, "Duplicate object", self.duplicate_object
     )
예제 #8
0
 def __init__(self, parent):
     """
     Args:
         parent (MultiSpineDBEditor)
     """
     super().__init__(parent)
     self._parent = parent
     self._plus_button = QToolButton(self)
     self._plus_button.setIcon(QIcon(CharIconEngine("\uf067")))
     self._plus_button.clicked.connect(lambda _=False: self.plus_clicked.emit())
     self._move_plus_button()
     self.setShape(QTabBar.RoundedNorth)
     self.setTabsClosable(True)
     self.setMovable(True)
     self.setElideMode(Qt.ElideLeft)
     self.drag_index = None
     self._tab_hot_spot_x = None
     self._hot_spot_y = None
예제 #9
0
 def contextMenuEvent(self, event):
     index = self.tabAt(event.pos())
     if self._plus_button.underMouse():
         self._show_plus_button_context_menu(event.globalPos())
         return
     if self.tabButton(index, QTabBar.RightSide).underMouse():
         return
     db_editor = self._parent.tab_widget.widget(index)
     if db_editor is None:
         return
     menu = QMenu(self)
     others = self._parent.others()
     if others:
         move_tab_menu = menu.addMenu("Move tab to another window")
         move_tab_to_new_window = move_tab_menu.addAction(
             "New window",
             lambda _=False, index=index: self._parent.move_tab(
                 index, None))
         for other in others:
             move_tab_menu.addAction(
                 other.name(),
                 lambda _=False, index=index, other=other: self._parent.
                 move_tab(index, other))
     else:
         move_tab_to_new_window = menu.addAction(
             "Move tab to new window",
             lambda _=False, index=index: self._parent.move_tab(
                 index, None))
     move_tab_to_new_window.setEnabled(self.count() > 1)
     menu.addSeparator()
     menu.addAction(db_editor.url_toolbar.reload_action)
     db_url_codenames = db_editor.db_url_codenames
     menu.addAction(
         QIcon(CharIconEngine("\uf24d")),
         "Duplicate",
         lambda _=False, index=index + 1, db_url_codenames=db_url_codenames:
         self._parent.insert_new_tab(index, db_url_codenames),
     )
     menu.popup(event.globalPos())
     menu.aboutToHide.connect(menu.deleteLater)
     event.accept()
예제 #10
0
 def refresh_icon(self):
     pixmap = CharIconEngine("\uf05b",
                             0).pixmap(QSize(self._extent, self._extent))
     self.setPixmap(pixmap)
예제 #11
0
 def display_icon(self):
     if self.icon_code is None:
         return None
     engine = CharIconEngine(self.icon_code, 0)
     return QIcon(engine.pixmap())