15 #include <QVBoxLayout>
17 #include <QKeySequence>
23 SettingsItemDropdown* GraphTabWidget::sSettingGridType;
24 SettingsItemDropdown* GraphTabWidget::sSettingDragModifier;
25 SettingsItemDropdown* GraphTabWidget::sSettingPanModifier;
27 SettingsItemKeybind* GraphTabWidget::sSettingZoomIn;
28 SettingsItemKeybind* GraphTabWidget::sSettingZoomOut;
29 SettingsItemKeybind* GraphTabWidget::sSettingFoldModule;
30 SettingsItemKeybind* GraphTabWidget::sSettingUnfoldModule;
31 SettingsItemKeybind* GraphTabWidget::sSettingRemoveNode;
33 bool GraphTabWidget::sSettingsInitialized = initSettings();
35 bool GraphTabWidget::initSettings()
37 sSettingGridType =
new SettingsItemDropdown(
39 "graph_view/grid_type",
40 GraphicsScene::GridType::None,
41 "Appearance:Graph View",
42 "Specifies the grid pattern in the background of the Graph View scene"
46 sSettingDragModifier =
new SettingsItemDropdown(
48 "graph_view/drag_mode_modifier",
49 KeyboardModifier::Alt,
51 "Specifies the key which can be pressed to switch the position of two Module/Gates in the Graph View while dragging."
55 sSettingPanModifier =
new SettingsItemDropdown(
57 "graph_view/move_modifier",
58 KeyboardModifier::Shift,
60 "Specifies the key which can be pressed to pan the scene in the Graph View while left clicking."
64 sSettingZoomIn =
new SettingsItemKeybind(
66 "keybinds/graph_view_zoom_in",
69 "Keybind for zooming in in the Graph View."
72 sSettingZoomOut =
new SettingsItemKeybind(
73 "Graph View Zoom Out",
74 "keybinds/graph_view_zoom_out",
77 "Keybind for zooming out in the Graph View."
80 sSettingFoldModule =
new SettingsItemKeybind(
82 "keybinds/fold_module",
85 "Keybind to fold the parent module of selected node in current view."
88 sSettingUnfoldModule =
new SettingsItemKeybind(
90 "keybinds/unfold_module",
93 "Keybind to unfold the selected module."
96 sSettingRemoveNode =
new SettingsItemKeybind(
97 "Remove Node from View",
98 "keybinds/remove_node",
101 "Keybind to remove the selected node from view."
109 mSelectCursor(Select)
127 mKeyModifierMap.
insert(KeyboardModifier::Alt, Qt::KeyboardModifier::AltModifier);
128 mKeyModifierMap.
insert(KeyboardModifier::Ctrl, Qt::KeyboardModifier::ControlModifier);
129 mKeyModifierMap.
insert(KeyboardModifier::Shift, Qt::KeyboardModifier::ShiftModifier);
153 list.
append(zoomInShortcut);
154 list.
append(zoomOutShortcut);
155 list.
append(foldModuleShortcut);
156 list.
append(unfoldModuleShortcut);
157 list.
append(removeNodeShortcut);
164 int tab_index = mTabWidget->
addTab(tab,
name);
181 if(currentGraphWidget)
197 auto index = getContextTabIndex(context);
205 addGraphWidgetTab(context);
210 addGraphWidgetTab(context);
215 mTabWidget->
setTabText(getContextTabIndex(context), context->
name());
226 if(currentGraphWidget)
233 if(currentGraphWidget)
234 currentGraphWidget->
focusNet(netId);
240 if(currentGraphWidget)
244 void GraphTabWidget::addGraphWidgetTab(
GraphContext* context)
266 int tab_index =
addTab(new_graph_widget, context->
name());
272 void GraphTabWidget::handleZoomInShortcut()
274 GraphWidget* w =
dynamic_cast<GraphWidget*
>(mTabWidget->
currentWidget());
276 w->view()->viewportCenterZoom(mZoomFactor);
279 void GraphTabWidget::handleZoomOutShortcut()
281 GraphWidget* w =
dynamic_cast<GraphWidget*
>(mTabWidget->
currentWidget());
283 w->view()->viewportCenterZoom(1.0 / mZoomFactor);
287 void GraphTabWidget::handleFoldModuleShortcut()
289 GraphWidget* currentGraphWidget =
dynamic_cast<GraphWidget*
>(mTabWidget->
currentWidget());
290 if (!currentGraphWidget)
return;
291 currentGraphWidget->view()->handleFoldModuleShortcut();
294 void GraphTabWidget::handleUnfoldModuleShortcut()
296 GraphWidget* currentGraphWidget =
dynamic_cast<GraphWidget*
>(mTabWidget->
currentWidget());
297 if (!currentGraphWidget)
return;
298 currentGraphWidget->view()->handleUnfoldModuleShortcut();
301 void GraphTabWidget::handleRemoveNodeShortcut()
303 GraphWidget* currentGraphWidget =
dynamic_cast<GraphWidget*
>(mTabWidget->
currentWidget());
304 if (!currentGraphWidget)
return;
305 currentGraphWidget->view()->handleRemoveFromView();
310 for (
int i = 0; i < mTabWidget->
count(); i++)
314 if (p->getContext() == ctx)
325 int GraphTabWidget::getContextTabIndex(
const GraphContext* context)
const
327 for (
int i = 0; i < mTabWidget->
count(); i++)
331 if (p->getContext() == context)
347 QMenu contextMenu(
"Context menu",
this);
349 contextMenu.
addAction(
"Close", [
this, index](){
355 contextMenu.
addAction(
"Close all", [
this](){
359 contextMenu.
addAction(
"Close all others", [
this, index](){
364 contextMenu.
addAction(
"Close all right", [
this, index](){
368 contextMenu.
addAction(
"Close all left", [
this, index](){
379 while (index != mTabWidget->
count()-1)
395 int count = mTabWidget->
count();
396 for (
int i = 0; i < count; i++)
405 int n = mTabWidget->
count();
406 if (mSelectCursor ==
Select)
408 for (
int i=0; i<
n; i++)
414 ?
QPixmap(
":/icons/module_cursor",
"PNG")
415 :
QPixmap(
":/icons/gate_cursor",
"PNG"));
416 for (
int i=0; i<
n; i++)
421 void GraphTabWidget::emitTerminatePicker()
const
ContextManagerWidget * getContextManagerWidget()
Abstract class for Widgets within HAL's ContentArea.
QVBoxLayout * mContentLayout
void selectViewContext(GraphContext *context)
Logical container for modules, gates, and nets.
void scheduleSceneUpdate()
void contextRenamed(GraphContext *context)
void contextCreated(GraphContext *context)
void deletingContext(GraphContext *context)
void setGridType(GraphicsScene::GridType gridType)
void setPanModifier(Qt::KeyboardModifier panModifier)
void setDragModifier(Qt::KeyboardModifier dragModifier)
void navigationRequested()
virtual QVariant value() const override
void intChanged(int value)
void keySequenceChanged(QKeySequence value)
virtual QVariant value() const override
ContentManager * gContentManager
GraphContextManager * gGraphContextManager
void append(const T &value)
QMap::iterator insert(const Key &key, const T &value)
const T value(const Key &key, const T &defaultValue) const const
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void setKey(const QKeySequence &key)
int tabAt(const QPoint &position) const const
void setTabText(int index, const QString &label)
int toInt(bool *ok) const const
QString toString() const const