Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/atcoreinstancewidget.cpp
Show All 12 Lines | 1 | /* Atelier KDE Printer Host for 3D Printing | |||
---|---|---|---|---|---|
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. | ||
14 | 14 | | |||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | 17 | */ | ||
18 | 18 | | |||
19 | #include "atcoreinstancewidget.h" | 19 | #include "atcoreinstancewidget.h" | ||
20 | #include "ui_atcoreinstancewidget.h" | 20 | #include "ui_atcoreinstancewidget.h" | ||
21 | #include <QMenu> | ||||
21 | #include <QToolBar> | 22 | #include <QToolBar> | ||
23 | #include <QToolButton> | ||||
22 | #include <AtCore/SerialLayer> | 24 | #include <AtCore/SerialLayer> | ||
23 | #include <AtCore/GCodeCommands> | 25 | #include <AtCore/GCodeCommands> | ||
24 | #include <KLocalizedString> | 26 | #include <KLocalizedString> | ||
25 | #include "choosefiledialog.h" | 27 | #include "choosefiledialog.h" | ||
26 | 28 | | |||
27 | AtCoreInstanceWidget::AtCoreInstanceWidget(QWidget *parent): | 29 | AtCoreInstanceWidget::AtCoreInstanceWidget(QWidget *parent): | ||
28 | QWidget(parent), | 30 | QWidget(parent), | ||
29 | m_mainToolBar(nullptr), | 31 | m_mainToolBar(nullptr), | ||
Show All 18 Lines | |||||
48 | { | 50 | { | ||
49 | m_core.closeConnection(); | 51 | m_core.closeConnection(); | ||
50 | delete ui; | 52 | delete ui; | ||
51 | } | 53 | } | ||
52 | 54 | | |||
53 | void AtCoreInstanceWidget::buildToolbar() | 55 | void AtCoreInstanceWidget::buildToolbar() | ||
54 | { | 56 | { | ||
55 | m_toolBar = new QToolBar(); | 57 | m_toolBar = new QToolBar(); | ||
58 | m_toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); | ||||
59 | auto homeMenu = new QMenu(); | ||||
56 | 60 | | |||
57 | auto lb = new QAction; | 61 | for(auto homes : std::map<QString, int>{{i18n("Home X"), AtCore::X}, {i18n("Home Y"), AtCore::Y}, {i18n("Home Z"), AtCore::Z}}) { | ||
58 | lb->setIcon(QIcon::fromTheme("go-home", QIcon(QString(":/%1/home").arg(m_theme)))); | | |||
59 | | ||||
60 | lb->setDisabled(true); | | |||
61 | m_toolBar->addAction(lb); | | |||
62 | | ||||
63 | auto homeAll = new QAction("All"); | | |||
64 | connect(homeAll, &QAction::triggered, [this]{ | | |||
65 | m_core.home(); | | |||
66 | }); | | |||
67 | m_toolBar->addAction(homeAll); | | |||
68 | | ||||
69 | for(auto homes : std::map<QString, int>{{"X", AtCore::X}, {"Y", AtCore::Y}, {"Z", AtCore::Z}}) { | | |||
70 | auto home = new QAction(homes.first); | 62 | auto home = new QAction(homes.first); | ||
63 | home->setIcon(QIcon::fromTheme("go-home", QIcon(QString(":/%1/home").arg(m_theme)))); | ||||
71 | connect(home, &QAction::triggered, [this, homes] { | 64 | connect(home, &QAction::triggered, [this, homes] { | ||
72 | m_core.home(homes.second); | 65 | m_core.home(homes.second); | ||
73 | }); | 66 | }); | ||
74 | m_toolBar->addAction(home); | 67 | homeMenu->addAction(home); | ||
75 | } | 68 | } | ||
76 | 69 | | |||
70 | auto action = new QAction(i18n("Home All")); | ||||
71 | action->setIcon(QIcon::fromTheme("go-home", QIcon(QString(":/%1/home").arg(m_theme)))); | ||||
72 | action->setMenu(homeMenu); | ||||
73 | connect(action,&QAction::triggered,[this]{ | ||||
74 | m_core.home(); | ||||
75 | }); | ||||
76 | | ||||
77 | m_toolBar->addAction(action); | ||||
77 | m_toolBar->addSeparator(); | 78 | m_toolBar->addSeparator(); | ||
78 | 79 | | |||
79 | auto *axis = new QAction("Axis"); | 80 | auto *axis = new QAction("Axis"); | ||
80 | axis->setCheckable(true); | 81 | axis->setCheckable(true); | ||
81 | axis->setChecked(true); | 82 | axis->setChecked(true); | ||
82 | connect(axis, &QAction::toggled, ui->axisViewWidget, &AxisControl::setVisible); | 83 | connect(axis, &QAction::toggled, ui->axisViewWidget, &AxisControl::setVisible); | ||
83 | 84 | | |||
84 | auto controls = new QAction("Controls"); | 85 | auto controls = new QAction("Controls"); | ||
▲ Show 20 Lines • Show All 383 Lines • Show Last 20 Lines |