Changeset View
Changeset View
Standalone View
Standalone View
src/mainwindow.cpp
Show All 32 Lines | |||||
33 | #include <widgets/videomonitorwidget.h> | 33 | #include <widgets/videomonitorwidget.h> | ||
34 | 34 | | |||
35 | 35 | | |||
36 | MainWindow::MainWindow(QWidget *parent) : | 36 | MainWindow::MainWindow(QWidget *parent) : | ||
37 | KXmlGuiWindow(parent), | 37 | KXmlGuiWindow(parent), | ||
38 | m_currEditorView(nullptr), | 38 | m_currEditorView(nullptr), | ||
39 | m_instances(new QTabWidget(this)) | 39 | m_instances(new QTabWidget(this)) | ||
40 | { | 40 | { | ||
41 | m_theme = palette().text().color().value() >= QColor(Qt::lightGray).value() ? QString("dark") : QString("light"); | ||||
42 | | ||||
41 | initWidgets(); | 43 | initWidgets(); | ||
42 | setupActions(); | 44 | setupActions(); | ||
43 | connect(m_instances, &QTabWidget::tabCloseRequested, [this] (int index){ | 45 | connect(m_instances, &QTabWidget::tabCloseRequested, [this] (int index){ | ||
44 | QWidget *tempWidget= m_instances->widget(index); | 46 | QWidget *tempWidget= m_instances->widget(index); | ||
45 | delete tempWidget; | 47 | delete tempWidget; | ||
46 | 48 | | |||
47 | if(m_instances->count() == 1) { | 49 | if(m_instances->count() == 1) { | ||
48 | m_instances->setTabsClosable(false); | 50 | m_instances->setTabsClosable(false); | ||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Line(s) | 96 | { | |||
118 | }; | 120 | }; | ||
119 | 121 | | |||
120 | auto *gcodeEditor = new GCodeEditorWidget(this); | 122 | auto *gcodeEditor = new GCodeEditorWidget(this); | ||
121 | connect(gcodeEditor, &GCodeEditorWidget::updateClientFactory, this, [this](KTextEditor::View* view){ | 123 | connect(gcodeEditor, &GCodeEditorWidget::updateClientFactory, this, [this](KTextEditor::View* view){ | ||
122 | guiFactory()->removeClient(m_currEditorView); | 124 | guiFactory()->removeClient(m_currEditorView); | ||
123 | guiFactory()->addClient(view); | 125 | guiFactory()->addClient(view); | ||
124 | m_currEditorView = view; | 126 | m_currEditorView = view; | ||
125 | }); | 127 | }); | ||
126 | 128 | setupButton("3d", i18n("&3D"), QIcon::fromTheme("draw-cuboid", QIcon(QString(":/%1/3d").arg(m_theme))), new Viewer3D(this)); | |||
127 | setupButton("3d", i18n("&3D"), QIcon::fromTheme("draw-cuboid", QIcon(":/icon/atelier")), new Viewer3D(this)); | 129 | setupButton("gcode", i18n("&GCode"), QIcon::fromTheme("accessories-text-editor", QIcon(":/icon/edit")), gcodeEditor); | ||
128 | setupButton("gcode", i18n("&GCode"), QIcon::fromTheme("accessories-text-editor", QIcon(":/icon/atelier")), gcodeEditor); | 130 | setupButton("video", i18n("&Video"), QIcon::fromTheme("camera-web", QIcon(":/icon/video")), new VideoMonitorWidget(this)); | ||
129 | setupButton("video", i18n("&Video"), QIcon::fromTheme("camera-web", QIcon(":/icon/atelier")), new VideoMonitorWidget(this)); | | |||
130 | buttonLayout->addStretch(); | 131 | buttonLayout->addStretch(); | ||
131 | m_lateral.m_toolBar->setLayout(buttonLayout); | 132 | m_lateral.m_toolBar->setLayout(buttonLayout); | ||
132 | } | 133 | } | ||
133 | 134 | | |||
134 | void MainWindow::setupActions() | 135 | void MainWindow::setupActions() | ||
135 | { | 136 | { | ||
136 | // Actions for the Toolbar | 137 | // Actions for the Toolbar | ||
137 | QAction *action; | 138 | QAction *action; | ||
138 | action = actionCollection()->addAction(QStringLiteral("open_gcode")); | 139 | action = actionCollection()->addAction(QStringLiteral("open")); | ||
139 | action->setIcon(QIcon::fromTheme("document-open", style()->standardIcon(QStyle::SP_DirOpenIcon))); | 140 | action->setIcon(QIcon::fromTheme("document-open", QIcon(QString(":/%1/open").arg(m_theme)))); | ||
140 | action->setText(i18n("&Open GCode")); | 141 | | ||
142 | action->setText(i18n("&Open")); | ||||
141 | actionCollection()->setDefaultShortcut(action, QKeySequence::Open); | 143 | actionCollection()->setDefaultShortcut(action, QKeySequence::Open); | ||
142 | connect(action, &QAction::triggered, this, &MainWindow::openFile); | 144 | connect(action, &QAction::triggered, this, &MainWindow::openFile); | ||
143 | 145 | | |||
144 | action = actionCollection()->addAction(QStringLiteral("new_instance")); | 146 | action = actionCollection()->addAction(QStringLiteral("new_instance")); | ||
145 | action->setIcon(QIcon::fromTheme("list-add", QIcon())); | 147 | action->setIcon(QIcon::fromTheme("list-add", QIcon(QString(":/%1/addTab").arg(m_theme)))); | ||
148 | | ||||
146 | action->setText(i18n("&New Connection")); | 149 | action->setText(i18n("&New Connection")); | ||
147 | actionCollection()->setDefaultShortcut(action, QKeySequence::AddTab); | 150 | actionCollection()->setDefaultShortcut(action, QKeySequence::AddTab); | ||
148 | connect(action, &QAction::triggered, this, &MainWindow::newAtCoreInstance); | 151 | connect(action, &QAction::triggered, this, &MainWindow::newAtCoreInstance); | ||
149 | 152 | | |||
150 | action = actionCollection()->addAction(QStringLiteral("profiles")); | 153 | action = actionCollection()->addAction(QStringLiteral("profiles")); | ||
151 | action->setIcon(QIcon::fromTheme("document-properties", QIcon())); | 154 | action->setIcon(QIcon::fromTheme("document-properties", QIcon(QString(":/%1/configure").arg(m_theme)))); | ||
155 | | ||||
152 | action->setText(i18n("&Profiles")); | 156 | action->setText(i18n("&Profiles")); | ||
153 | connect(action, &QAction::triggered, [this] { | 157 | connect(action, &QAction::triggered, [this] { | ||
154 | std::unique_ptr<ProfilesDialog> pd(new ProfilesDialog); | 158 | std::unique_ptr<ProfilesDialog> pd(new ProfilesDialog); | ||
155 | pd->exec(); | 159 | pd->exec(); | ||
156 | emit(profilesChanged()); | 160 | emit(profilesChanged()); | ||
157 | }); | 161 | }); | ||
158 | 162 | | |||
159 | action = KStandardAction::quit(this, SLOT(close()), actionCollection()); | 163 | action = actionCollection()->addAction(QStringLiteral("quit")); | ||
164 | action->setIcon(QIcon::fromTheme("application-exit", QIcon(":/icon/exit"))); | ||||
165 | | ||||
166 | action->setText(i18n("&Quit")); | ||||
167 | actionCollection()->setDefaultShortcut(action, QKeySequence::Quit); | ||||
168 | connect(action, &QAction::triggered, this, &MainWindow::close); | ||||
160 | 169 | | |||
161 | setupGUI(Default, ":/atelierui"); | 170 | setupGUI(Default, ":/atelierui"); | ||
162 | } | 171 | } | ||
163 | 172 | | |||
164 | void MainWindow::openFile() | 173 | void MainWindow::openFile() | ||
165 | { | 174 | { | ||
166 | QUrl fileName = QFileDialog::getOpenFileUrl(this, i18n("Open GCode"), | 175 | QUrl fileName = QFileDialog::getOpenFileUrl(this, i18n("Open GCode"), | ||
167 | QDir::homePath(), i18n("GCode (*.gco *.gcode)")); | 176 | QDir::homePath(), i18n("GCode (*.gco *.gcode)")); | ||
Show All 20 Lines |