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 17 Lines | |||||
47 | { | 49 | { | ||
48 | m_core.closeConnection(); | 50 | m_core.closeConnection(); | ||
49 | delete ui; | 51 | delete ui; | ||
50 | } | 52 | } | ||
51 | 53 | | |||
52 | void AtCoreInstanceWidget::buildToolbar() | 54 | void AtCoreInstanceWidget::buildToolbar() | ||
53 | { | 55 | { | ||
54 | m_toolBar = new QToolBar(); | 56 | m_toolBar = new QToolBar(); | ||
57 | m_toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); | ||||
55 | 58 | | |||
56 | auto lb = new QAction; | 59 | auto homeAll = new QAction(QIcon::fromTheme("go-home", style()->standardIcon(QStyle::SP_DirHomeIcon)),i18n("All")); | ||
57 | lb->setIcon(QIcon::fromTheme("go-home", style()->standardIcon(QStyle::SP_DirHomeIcon))); | 60 | homeAll->setToolTip(i18n("Home All")); | ||
58 | lb->setDisabled(true); | | |||
59 | m_toolBar->addAction(lb); | | |||
60 | | ||||
61 | auto homeAll = new QAction("All"); | | |||
62 | connect(homeAll, &QAction::triggered, [this]{ | 61 | connect(homeAll, &QAction::triggered, [this]{ | ||
63 | m_core.home(); | 62 | m_core.home(); | ||
64 | }); | 63 | }); | ||
65 | m_toolBar->addAction(homeAll); | | |||
66 | 64 | | |||
67 | for(auto homes : std::map<QString, int>{{"X", AtCore::X}, {"Y", AtCore::Y}, {"Z", AtCore::Z}}) { | 65 | auto homeMenu = new QMenu(); | ||
66 | | ||||
67 | for(auto homes : std::map<QString, int>{{i18n("Home: X"), AtCore::X}, {i18n("Home: Y"), AtCore::Y}, {i18n("Home: Z"), AtCore::Z}}) { | ||||
68 | auto home = new QAction(homes.first); | 68 | auto home = new QAction(homes.first); | ||
69 | home->setIcon(QIcon::fromTheme("go-home", style()->standardIcon(QStyle::SP_DirHomeIcon))); | ||||
69 | connect(home, &QAction::triggered, [this, homes] { | 70 | connect(home, &QAction::triggered, [this, homes] { | ||
70 | m_core.home(homes.second); | 71 | m_core.home(homes.second); | ||
71 | }); | 72 | }); | ||
72 | m_toolBar->addAction(home); | 73 | homeMenu->addAction(home); | ||
73 | } | 74 | } | ||
74 | 75 | | |||
76 | auto homeBtn = new QToolButton(); | ||||
77 | homeBtn->setIcon(QIcon::fromTheme("go-home", style()->standardIcon(QStyle::SP_DirHomeIcon))); | ||||
78 | homeBtn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); | ||||
79 | homeBtn->setText(i18n("All")); | ||||
80 | homeBtn->setMenu(homeMenu); | ||||
81 | connect(homeBtn, &QToolButton::clicked, [this]{ | ||||
82 | m_core.home(); | ||||
83 | }); | ||||
84 | | ||||
85 | m_toolBar->addWidget(homeBtn); | ||||
86 | | ||||
75 | m_toolBar->addSeparator(); | 87 | m_toolBar->addSeparator(); | ||
76 | 88 | | |||
77 | auto *axis = new QAction("Axis"); | 89 | auto *axis = new QAction("Axis"); | ||
78 | axis->setCheckable(true); | 90 | axis->setCheckable(true); | ||
79 | axis->setChecked(true); | 91 | axis->setChecked(true); | ||
80 | connect(axis, &QAction::toggled, ui->axisViewWidget, &AxisControl::setVisible); | 92 | connect(axis, &QAction::toggled, ui->axisViewWidget, &AxisControl::setVisible); | ||
81 | 93 | | |||
82 | auto controls = new QAction("Controls"); | 94 | auto controls = new QAction("Controls"); | ||
▲ Show 20 Lines • Show All 382 Lines • Show Last 20 Lines |