From 6a484c615ae3f04873fe41a415277ef6c2c37573 Mon Sep 17 00:00:00 2001 From: jaseg Date: Thu, 17 Dec 2020 15:43:37 +0100 Subject: WIP --- numberator.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'numberator.cpp') diff --git a/numberator.cpp b/numberator.cpp index 3161ee8..3fe6497 100644 --- a/numberator.cpp +++ b/numberator.cpp @@ -3,6 +3,7 @@ #include "ui_TagListDock.h" #include +#include Numberator::Numberator(QWidget *parent) : QMainWindow(parent) @@ -88,6 +89,30 @@ Numberator::Numberator(QWidget *parent) } }); + QToolBar *tools_tb = new QToolBar("Tools", this); + struct tool_def { + ToolType type; + QString filename; + QString name; + }; + + std::initializer_list tool_defs = { + {SELECTION_TOOL, ":/icons/selection_tool.png", "Select"}, + {TAG_TOOL, ":/icons/tag.png", "Add Tag"}, + {MOVE_TOOL, ":/icons/move_tool.png", "Move Tag"}, + {EDIT_TOOL, ":/icons/edit_tool.png", "Edit Tag"}, + }; + QActionGroup toolsActionGroup(this); + for (auto tool : tool_defs) { + auto action = tools_tb->addAction(QIcon(tool.filename), tool.name, [=](){ + setTool(tool.type); + }); + action->setCheckable(true); + toolsActionGroup.addAction(action); + } + toolsActionGroup.actions().first()->setChecked(true); + this->addToolBar(Qt::TopToolBarArea, tools_tb); + ui->menuView->addAction(dock->toggleViewAction()); connect(ui->actionReload_Image, &QAction::triggered, &proj, &SQLiteSaveFile::reloadImageFromDisk); @@ -151,6 +176,11 @@ Numberator::~Numberator() delete ui; } +void Numberator::setTool(Numberator::ToolType tool) +{ + ui->graphicsView->scene()->setTool(tool); +} + bool Numberator::showConfirmDiscardDialog() { if (!proj.isMemory() || !proj.isDirty()) -- cgit