Changeset View
Changeset View
Standalone View
Standalone View
src/mainwindow.cpp
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Line(s) | 56 | { | |||
---|---|---|---|---|---|
72 | setCentralWidget(centralWidget); | 72 | setCentralWidget(centralWidget); | ||
73 | } | 73 | } | ||
74 | void MainWindow::newAtCoreInstance() | 74 | void MainWindow::newAtCoreInstance() | ||
75 | { | 75 | { | ||
76 | auto newInstanceWidget = new AtCoreInstanceWidget(); | 76 | auto newInstanceWidget = new AtCoreInstanceWidget(); | ||
77 | QString name = QString::number(m_instances->addTab(newInstanceWidget, i18n("Connect a printer"))); | 77 | QString name = QString::number(m_instances->addTab(newInstanceWidget, i18n("Connect a printer"))); | ||
78 | newInstanceWidget->setObjectName(name); | 78 | newInstanceWidget->setObjectName(name); | ||
79 | connect(this, &MainWindow::profilesChanged, newInstanceWidget, &AtCoreInstanceWidget::updateProfileData); | 79 | connect(this, &MainWindow::profilesChanged, newInstanceWidget, &AtCoreInstanceWidget::updateProfileData); | ||
80 | connect(newInstanceWidget, &AtCoreInstanceWidget::requestProfileDialog, [ this ] { | ||||
81 | std::unique_ptr<ProfilesDialog> pd(new ProfilesDialog); | ||||
82 | pd->exec(); | ||||
83 | emit(profilesChanged()); | ||||
84 | }); | ||||
80 | connect(newInstanceWidget, &AtCoreInstanceWidget::connectionChanged, this, &MainWindow::atCoreInstanceNameChange); | 85 | connect(newInstanceWidget, &AtCoreInstanceWidget::connectionChanged, this, &MainWindow::atCoreInstanceNameChange); | ||
81 | 86 | | |||
82 | if(m_instances->count() > 1) { | 87 | if(m_instances->count() > 1) { | ||
83 | m_instances->setTabsClosable(true); | 88 | m_instances->setTabsClosable(true); | ||
84 | m_instances->setMovable(true); | 89 | m_instances->setMovable(true); | ||
85 | } | 90 | } | ||
86 | } | 91 | } | ||
87 | // Move to LateralArea. | 92 | // Move to LateralArea. | ||
88 | void MainWindow::setupLateralArea() | 93 | void MainWindow::setupLateralArea() | ||
89 | { | 94 | { | ||
90 | m_lateral.m_toolBar = new QWidget(); | 95 | m_lateral.m_toolBar = new QWidget(); | ||
91 | m_lateral.m_stack = new QStackedWidget(); | 96 | m_lateral.m_stack = new QStackedWidget(); | ||
92 | auto buttonLayout = new QVBoxLayout(); | 97 | auto buttonLayout = new QVBoxLayout(); | ||
93 | 98 | | |||
94 | auto setupButton = [this, buttonLayout](const QString& key, const QString& text, const QIcon& icon, QWidget *w) { | 99 | auto setupButton = [this, buttonLayout](const QString& key, const QString& text, const QIcon& icon, QWidget *w) { | ||
95 | auto *btn = new QPushButton(m_lateral.m_toolBar); | 100 | auto *btn = new QPushButton(m_lateral.m_toolBar); | ||
96 | btn->setToolTip(text); | 101 | btn->setToolTip(text); | ||
97 | btn->setAutoExclusive(true); | 102 | btn->setAutoExclusive(true); | ||
98 | btn->setCheckable(true); | 103 | btn->setCheckable(true); | ||
104 | //3d view is on top set it checked so users see its selected. | ||||
105 | btn->setChecked(key == "3d"); | ||||
99 | btn->setIcon(icon); | 106 | btn->setIcon(icon); | ||
107 | btn->setFixedSize(48,48); | ||||
100 | btn->setIconSize(QSize(48,48)); | 108 | btn->setIconSize(QSize(48,48)); | ||
101 | btn->setFlat(true); | 109 | btn->setFlat(true); | ||
102 | m_lateral.m_stack->addWidget(w); | 110 | m_lateral.m_stack->addWidget(w); | ||
103 | m_lateral.m_map[key] = {btn, w}; | 111 | m_lateral.m_map[key] = {btn, w}; | ||
104 | 112 | | |||
105 | buttonLayout->addWidget(btn); | 113 | buttonLayout->addWidget(btn); | ||
106 | connect(btn, &QToolButton::toggled, [this, w](bool checked) { | 114 | connect(btn, &QToolButton::toggled, [this, w](bool checked) { | ||
107 | if (checked) | 115 | if (checked) | ||
patrickelectric: btn->setChecked(key == "3d"); ? | |||||
108 | m_lateral.m_stack->setCurrentWidget(w); | 116 | m_lateral.m_stack->setCurrentWidget(w); | ||
109 | }); | 117 | }); | ||
110 | }; | 118 | }; | ||
111 | 119 | | |||
112 | auto *gcodeEditor = new GCodeEditorWidget(this); | 120 | auto *gcodeEditor = new GCodeEditorWidget(this); | ||
113 | connect(gcodeEditor, &GCodeEditorWidget::updateClientFactory, this, [this](KTextEditor::View* view){ | 121 | connect(gcodeEditor, &GCodeEditorWidget::updateClientFactory, this, [this](KTextEditor::View* view){ | ||
114 | guiFactory()->removeClient(m_currEditorView); | 122 | guiFactory()->removeClient(m_currEditorView); | ||
115 | guiFactory()->addClient(view); | 123 | guiFactory()->addClient(view); | ||
Show All 9 Lines | |||||
125 | 133 | | |||
126 | void MainWindow::setupActions() | 134 | void MainWindow::setupActions() | ||
127 | { | 135 | { | ||
128 | // Actions for the Toolbar | 136 | // Actions for the Toolbar | ||
129 | QAction *action; | 137 | QAction *action; | ||
130 | action = actionCollection()->addAction(QStringLiteral("open_gcode")); | 138 | action = actionCollection()->addAction(QStringLiteral("open_gcode")); | ||
131 | action->setIcon(QIcon::fromTheme("document-open", style()->standardIcon(QStyle::SP_DirOpenIcon))); | 139 | action->setIcon(QIcon::fromTheme("document-open", style()->standardIcon(QStyle::SP_DirOpenIcon))); | ||
132 | action->setText(i18n("&Open GCode")); | 140 | action->setText(i18n("&Open GCode")); | ||
141 | action->setShortcut(QKeySequence::Open); | ||||
133 | connect(action, &QAction::triggered, this, &MainWindow::openFile); | 142 | connect(action, &QAction::triggered, this, &MainWindow::openFile); | ||
134 | 143 | | |||
135 | action = actionCollection()->addAction(QStringLiteral("new_instance")); | 144 | action = actionCollection()->addAction(QStringLiteral("new_instance")); | ||
136 | action->setIcon(QIcon::fromTheme("list-add", QIcon())); | 145 | action->setIcon(QIcon::fromTheme("list-add", QIcon())); | ||
137 | action->setText(i18n("&New Connection")); | 146 | action->setText(i18n("&New Connection")); | ||
147 | action->setShortcut(QKeySequence::AddTab); | ||||
138 | connect(action, &QAction::triggered, this, &MainWindow::newAtCoreInstance); | 148 | connect(action, &QAction::triggered, this, &MainWindow::newAtCoreInstance); | ||
139 | 149 | | |||
140 | action = actionCollection()->addAction(QStringLiteral("profiles")); | 150 | action = actionCollection()->addAction(QStringLiteral("profiles")); | ||
141 | action->setIcon(QIcon::fromTheme("document-properties", QIcon())); | 151 | action->setIcon(QIcon::fromTheme("document-properties", QIcon())); | ||
142 | action->setText(i18n("&Profiles")); | 152 | action->setText(i18n("&Profiles")); | ||
143 | connect(action, &QAction::triggered, [this] { | 153 | connect(action, &QAction::triggered, [this] { | ||
144 | std::unique_ptr<ProfilesDialog> pd(new ProfilesDialog); | 154 | std::unique_ptr<ProfilesDialog> pd(new ProfilesDialog); | ||
145 | pd->exec(); | 155 | pd->exec(); | ||
Show All 32 Lines |
btn->setChecked(key == "3d"); ?