Changeset View
Changeset View
Standalone View
Standalone View
src/mainwindow.cpp
Show First 20 Lines • Show All 97 Lines • ▼ Show 20 Line(s) | 95 | { | |||
---|---|---|---|---|---|
98 | auto buttonLayout = new QVBoxLayout(); | 98 | auto buttonLayout = new QVBoxLayout(); | ||
99 | 99 | | |||
100 | auto setupButton = [this, buttonLayout](const QString& key, const QString& text, const QIcon& icon, QWidget *w) { | 100 | auto setupButton = [this, buttonLayout](const QString& key, const QString& text, const QIcon& icon, QWidget *w) { | ||
101 | auto *btn = new QPushButton(m_lateral.m_toolBar); | 101 | auto *btn = new QPushButton(m_lateral.m_toolBar); | ||
102 | btn->setToolTip(text); | 102 | btn->setToolTip(text); | ||
103 | btn->setAutoExclusive(true); | 103 | btn->setAutoExclusive(true); | ||
104 | btn->setCheckable(true); | 104 | btn->setCheckable(true); | ||
105 | btn->setIcon(icon); | 105 | btn->setIcon(icon); | ||
106 | btn->setIconSize(QSize(64,64)); | 106 | btn->setIconSize(QSize(48,48)); | ||
107 | btn->setFlat(true); | 107 | btn->setFlat(true); | ||
108 | m_lateral.m_stack->addWidget(w); | 108 | m_lateral.m_stack->addWidget(w); | ||
109 | m_lateral.m_map[key] = {btn, w}; | 109 | m_lateral.m_map[key] = {btn, w}; | ||
110 | 110 | | |||
111 | buttonLayout->addWidget(btn); | 111 | buttonLayout->addWidget(btn); | ||
112 | connect(btn, &QToolButton::toggled, [this, w](bool checked) { | 112 | connect(btn, &QToolButton::toggled, [this, w](bool checked) { | ||
113 | if (checked) | 113 | if (checked) | ||
114 | m_lateral.m_stack->setCurrentWidget(w); | 114 | m_lateral.m_stack->setCurrentWidget(w); | ||
115 | }); | 115 | }); | ||
116 | }; | 116 | }; | ||
117 | 117 | | |||
118 | auto *gcodeEditor = new GCodeEditorWidget(this); | 118 | auto *gcodeEditor = new GCodeEditorWidget(this); | ||
119 | connect(gcodeEditor, &GCodeEditorWidget::updateClientFactory, this, [this](KTextEditor::View* view){ | 119 | connect(gcodeEditor, &GCodeEditorWidget::updateClientFactory, this, [this](KTextEditor::View* view){ | ||
120 | guiFactory()->removeClient(m_currEditorView); | 120 | guiFactory()->removeClient(m_currEditorView); | ||
121 | guiFactory()->addClient(view); | 121 | guiFactory()->addClient(view); | ||
122 | m_currEditorView = view; | 122 | m_currEditorView = view; | ||
123 | }); | 123 | }); | ||
124 | 124 | | |||
125 | setupButton("3d", i18n("&3D"), QIcon(":/icon/atelier"), new Viewer3D(this)); | 125 | setupButton("3d", i18n("&3D"), QIcon::fromTheme("draw-cuboid", QIcon(":/icon/atelier")), new Viewer3D(this)); | ||
126 | setupButton("gcode", i18n("&GCode"), QIcon(":/icon/atelier"), gcodeEditor); | 126 | setupButton("gcode", i18n("&GCode"), QIcon::fromTheme("accessories-text-editor", QIcon(":/icon/atelier")), gcodeEditor); | ||
127 | setupButton("video", i18n("&Video"), QIcon(":/icon/atelier"), new VideoMonitorWidget(this)); | 127 | setupButton("video", i18n("&Video"), QIcon::fromTheme("camera-web", QIcon(":/icon/atelier")), new VideoMonitorWidget(this)); | ||
128 | buttonLayout->addStretch(); | 128 | buttonLayout->addStretch(); | ||
129 | m_lateral.m_toolBar->setLayout(buttonLayout); | 129 | m_lateral.m_toolBar->setLayout(buttonLayout); | ||
130 | } | 130 | } | ||
131 | 131 | | |||
132 | void MainWindow::setupActions() | 132 | void MainWindow::setupActions() | ||
133 | { | 133 | { | ||
134 | // Actions for the Toolbar | 134 | // Actions for the Toolbar | ||
135 | QAction *action; | 135 | QAction *action; | ||
136 | action = actionCollection()->addAction(QStringLiteral("open_gcode")); | 136 | action = actionCollection()->addAction(QStringLiteral("open_gcode")); | ||
137 | action->setIcon(QIcon::fromTheme("document-open", style()->standardIcon(QStyle::SP_DirOpenIcon))); | ||||
137 | action->setText(i18n("&Open GCode")); | 138 | action->setText(i18n("&Open GCode")); | ||
138 | connect(action, &QAction::triggered, this, &MainWindow::openFile); | 139 | connect(action, &QAction::triggered, this, &MainWindow::openFile); | ||
139 | 140 | | |||
140 | action = actionCollection()->addAction(QStringLiteral("new_instance")); | 141 | action = actionCollection()->addAction(QStringLiteral("new_instance")); | ||
142 | action->setIcon(QIcon::fromTheme("list-add", QIcon())); | ||||
141 | action->setText(i18n("&New Connection")); | 143 | action->setText(i18n("&New Connection")); | ||
142 | connect(action, &QAction::triggered, this, &MainWindow::newAtCoreInstance); | 144 | connect(action, &QAction::triggered, this, &MainWindow::newAtCoreInstance); | ||
143 | 145 | | |||
144 | action = actionCollection()->addAction(QStringLiteral("profiles")); | 146 | action = actionCollection()->addAction(QStringLiteral("profiles")); | ||
147 | action->setIcon(QIcon::fromTheme("document-properties", QIcon())); | ||||
145 | action->setText(i18n("&Profiles")); | 148 | action->setText(i18n("&Profiles")); | ||
146 | connect(action, &QAction::triggered, [this] { | 149 | connect(action, &QAction::triggered, [this] { | ||
147 | std::unique_ptr<ProfilesDialog> pd(new ProfilesDialog); | 150 | std::unique_ptr<ProfilesDialog> pd(new ProfilesDialog); | ||
148 | pd->exec(); | 151 | pd->exec(); | ||
149 | emit(profilesChanged()); | 152 | emit(profilesChanged()); | ||
150 | }); | 153 | }); | ||
151 | 154 | | |||
152 | #ifdef Q_OS_LINUX | | |||
153 | //only set icons from theme on linux | | |||
154 | actionCollection()->action(QStringLiteral("profiles"))->setIcon(QIcon::fromTheme("emblem-favorite")); | | |||
155 | #endif | | |||
156 | //use style's standardIcon for the icons we can. | | |||
157 | actionCollection()->action(QStringLiteral("open_gcode"))->setIcon(style()->standardIcon(QStyle::SP_DirOpenIcon)); | | |||
158 | | ||||
159 | action = KStandardAction::quit(qApp, SLOT(quit()), actionCollection()); | 155 | action = KStandardAction::quit(qApp, SLOT(quit()), actionCollection()); | ||
160 | 156 | | |||
161 | setupGUI(Default, ":/atelierui"); | 157 | setupGUI(Default, ":/atelierui"); | ||
162 | } | 158 | } | ||
163 | 159 | | |||
164 | void MainWindow::openFile() | 160 | void MainWindow::openFile() | ||
165 | { | 161 | { | ||
166 | QUrl fileName = QFileDialog::getOpenFileUrl(this, i18n("Open GCode"), | 162 | QUrl fileName = QFileDialog::getOpenFileUrl(this, i18n("Open GCode"), | ||
Show All 21 Lines |