summaryrefslogtreecommitdiff
path: root/tikzit/src/gui/toolpalette.cpp
blob: 3c08bce21d418b0ad81863f00c163c062027bb06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "toolpalette.h"

#include <QVector>
#include <QLayout>
#include <QVBoxLayout>
#include <QDebug>

ToolPalette::ToolPalette(QWidget *parent) :
    QToolBar(parent)
{
    setWindowFlags(Qt::Window
                   | Qt::CustomizeWindowHint
                   | Qt::WindowDoesNotAcceptFocus);
    setOrientation(Qt::Vertical);
    setFocusPolicy(Qt::NoFocus);
    setGeometry(100,200,30,195);

    tools  = new QActionGroup(this);

    select = new QAction(QIcon(":/images/select-rectangular.png"), "Select");
    vertex = new QAction(QIcon(":/images/draw-ellipse.png"), "Add Vertex");
    edge   = new QAction(QIcon(":/images/draw-path.png"), "Add Edge");
    crop   = new QAction(QIcon(":/images/transform-crop-and-resize.png"), "Bounding Box");

    tools->addAction(select);
    tools->addAction(vertex);
    tools->addAction(edge);
    tools->addAction(crop);

    select->setCheckable(true);
    vertex->setCheckable(true);
    edge->setCheckable(true);
    crop->setCheckable(true);
    select->setChecked(true);

    addAction(select);
    addAction(vertex);
    addAction(edge);
    addAction(crop);
}

ToolPalette::Tool ToolPalette::currentTool() const
{
    QAction *a = tools->checkedAction();
    if (a == vertex) return VERTEX;
    else if (a == edge) return EDGE;
    else if (a == crop) return CROP;
    else return SELECT;
}