Changeset View
Changeset View
Standalone View
Standalone View
src/mainwindow.cpp
Show First 20 Lines • Show All 77 Lines • ▼ Show 20 Line(s) | 64 | { | |||
---|---|---|---|---|---|
78 | ui->centralwidget->setLayout(centralLayout); | 78 | ui->centralwidget->setLayout(centralLayout); | ||
79 | } | 79 | } | ||
80 | void MainWindow::newAtCoreInstance() | 80 | void MainWindow::newAtCoreInstance() | ||
81 | { | 81 | { | ||
82 | auto newInstanceWidget = new AtCoreInstanceWidget(); | 82 | auto newInstanceWidget = new AtCoreInstanceWidget(); | ||
83 | QString name = QString::number(m_instances->addTab(newInstanceWidget, i18n("Connect a printer"))); | 83 | QString name = QString::number(m_instances->addTab(newInstanceWidget, i18n("Connect a printer"))); | ||
84 | newInstanceWidget->setObjectName(name); | 84 | newInstanceWidget->setObjectName(name); | ||
85 | connect(this, &MainWindow::profilesChanged, newInstanceWidget, &AtCoreInstanceWidget::updateProfileData); | 85 | connect(this, &MainWindow::profilesChanged, newInstanceWidget, &AtCoreInstanceWidget::updateProfileData); | ||
86 | connect(newInstanceWidget, &AtCoreInstanceWidget::requestProfileDialog, [ this ] { | ||||
87 | std::unique_ptr<ProfilesDialog> pd(new ProfilesDialog); | ||||
88 | pd->exec(); | ||||
89 | emit(profilesChanged()); | ||||
90 | }); | ||||
86 | connect(newInstanceWidget, &AtCoreInstanceWidget::connectionChanged, this, &MainWindow::atCoreInstanceNameChange); | 91 | connect(newInstanceWidget, &AtCoreInstanceWidget::connectionChanged, this, &MainWindow::atCoreInstanceNameChange); | ||
87 | 92 | | |||
88 | if(m_instances->count() > 1) { | 93 | if(m_instances->count() > 1) { | ||
89 | m_instances->setTabsClosable(true); | 94 | m_instances->setTabsClosable(true); | ||
90 | m_instances->setMovable(true); | 95 | m_instances->setMovable(true); | ||
91 | } | 96 | } | ||
92 | } | 97 | } | ||
93 | // Move to LateralArea. | 98 | // Move to LateralArea. | ||
Show All 11 Lines | 105 | auto setupButton = [this, buttonLayout](const QString& key, const QString& text, const QIcon& icon, QWidget *w) { | |||
105 | btn->setIcon(icon); | 110 | btn->setIcon(icon); | ||
106 | btn->setIconSize(QSize(64,64)); | 111 | btn->setIconSize(QSize(64,64)); | ||
107 | btn->setFlat(true); | 112 | btn->setFlat(true); | ||
108 | m_lateral.m_stack->addWidget(w); | 113 | m_lateral.m_stack->addWidget(w); | ||
109 | m_lateral.m_map[key] = {btn, w}; | 114 | m_lateral.m_map[key] = {btn, w}; | ||
110 | 115 | | |||
111 | buttonLayout->addWidget(btn); | 116 | buttonLayout->addWidget(btn); | ||
112 | connect(btn, &QToolButton::toggled, [this, w](bool checked) { | 117 | connect(btn, &QToolButton::toggled, [this, w](bool checked) { | ||
113 | if (checked) | 118 | if (checked) | ||
patrickelectric: btn->setChecked(key == "3d"); ? | |||||
114 | m_lateral.m_stack->setCurrentWidget(w); | 119 | m_lateral.m_stack->setCurrentWidget(w); | ||
115 | }); | 120 | }); | ||
116 | }; | 121 | }; | ||
117 | 122 | | |||
118 | auto *gcodeEditor = new GCodeEditorWidget(this); | 123 | auto *gcodeEditor = new GCodeEditorWidget(this); | ||
119 | connect(gcodeEditor, &GCodeEditorWidget::updateClientFactory, this, [this](KTextEditor::View* view){ | 124 | connect(gcodeEditor, &GCodeEditorWidget::updateClientFactory, this, [this](KTextEditor::View* view){ | ||
120 | guiFactory()->removeClient(m_currEditorView); | 125 | guiFactory()->removeClient(m_currEditorView); | ||
121 | guiFactory()->addClient(view); | 126 | guiFactory()->addClient(view); | ||
122 | m_currEditorView = view; | 127 | m_currEditorView = view; | ||
123 | }); | 128 | }); | ||
124 | 129 | | |||
125 | setupButton("3d", i18n("&3D"), QIcon(":/icon/atelier"), new Viewer3D(this)); | 130 | setupButton("3d", i18n("&3D"), QIcon(":/icon/atelier"), new Viewer3D(this)); | ||
126 | setupButton("gcode", i18n("&GCode"), QIcon(":/icon/atelier"), gcodeEditor); | 131 | setupButton("gcode", i18n("&GCode"), QIcon(":/icon/atelier"), gcodeEditor); | ||
127 | setupButton("video", i18n("&Video"), QIcon(":/icon/atelier"), new VideoMonitorWidget(this)); | 132 | setupButton("video", i18n("&Video"), QIcon(":/icon/atelier"), new VideoMonitorWidget(this)); | ||
128 | buttonLayout->addStretch(); | 133 | buttonLayout->addStretch(); | ||
129 | m_lateral.m_toolBar->setLayout(buttonLayout); | 134 | m_lateral.m_toolBar->setLayout(buttonLayout); | ||
130 | } | 135 | } | ||
131 | 136 | | |||
132 | void MainWindow::setupActions() | 137 | void MainWindow::setupActions() | ||
133 | { | 138 | { | ||
134 | // Actions for the Toolbar | 139 | // Actions for the Toolbar | ||
135 | QAction *action; | 140 | QAction *action; | ||
136 | action = actionCollection()->addAction(QStringLiteral("open_gcode")); | 141 | action = actionCollection()->addAction(QStringLiteral("open_gcode")); | ||
137 | action->setText(i18n("&Open GCode")); | 142 | action->setText(i18n("&Open GCode")); | ||
143 | action->setShortcut(QKeySequence::Open); | ||||
138 | connect(action, &QAction::triggered, this, &MainWindow::openFile); | 144 | connect(action, &QAction::triggered, this, &MainWindow::openFile); | ||
139 | 145 | | |||
140 | action = actionCollection()->addAction(QStringLiteral("new_instance")); | 146 | action = actionCollection()->addAction(QStringLiteral("new_instance")); | ||
141 | action->setText(i18n("&New Connection")); | 147 | action->setText(i18n("&New Connection")); | ||
148 | action->setShortcut(QKeySequence::AddTab); | ||||
142 | connect(action, &QAction::triggered, this, &MainWindow::newAtCoreInstance); | 149 | connect(action, &QAction::triggered, this, &MainWindow::newAtCoreInstance); | ||
143 | 150 | | |||
144 | action = actionCollection()->addAction(QStringLiteral("profiles")); | 151 | action = actionCollection()->addAction(QStringLiteral("profiles")); | ||
145 | action->setText(i18n("&Profiles")); | 152 | action->setText(i18n("&Profiles")); | ||
146 | connect(action, &QAction::triggered, [this] { | 153 | connect(action, &QAction::triggered, [this] { | ||
147 | std::unique_ptr<ProfilesDialog> pd(new ProfilesDialog); | 154 | std::unique_ptr<ProfilesDialog> pd(new ProfilesDialog); | ||
148 | pd->exec(); | 155 | pd->exec(); | ||
149 | emit(profilesChanged()); | 156 | emit(profilesChanged()); | ||
Show All 38 Lines |
btn->setChecked(key == "3d"); ?