Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a few toolbar icons #39

Merged
merged 1 commit into from
Jan 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions traffic_editor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ add_executable(traffic-editor
gui/preferences_dialog.cpp
gui/preferences_keys.cpp
gui/vertex.cpp
resources/resource.qrc
)

target_link_libraries(traffic-editor
Expand Down
41 changes: 27 additions & 14 deletions traffic_editor/gui/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,19 +227,19 @@ Editor::Editor(QWidget *parent)
tool_button_group = new QButtonGroup(this);
tool_button_group->setExclusive(true);

create_tool_button(TOOL_SELECT);
create_tool_button(TOOL_SELECT, ":icons/select.svg", "Select (Esc)");

create_tool_button(TOOL_MOVE);
create_tool_button(TOOL_ROTATE);
create_tool_button(TOOL_MOVE, ":icons/move.svg", "Move (M)");
create_tool_button(TOOL_ROTATE, ":icons/rotate.svg", "Rotate (R)");

create_tool_button(TOOL_ADD_VERTEX);
create_tool_button(TOOL_ADD_LANE);
create_tool_button(TOOL_ADD_WALL);
create_tool_button(TOOL_ADD_MEAS);
create_tool_button(TOOL_ADD_DOOR);
create_tool_button(TOOL_ADD_MODEL);
create_tool_button(TOOL_ADD_FLOOR);
create_tool_button(TOOL_EDIT_POLYGON);
create_tool_button(TOOL_ADD_VERTEX, ":icons/add_vertex.svg", "Add Vertex (V)");
create_tool_button(TOOL_ADD_LANE, "", "");
create_tool_button(TOOL_ADD_WALL, "", "");
create_tool_button(TOOL_ADD_MEAS, "", "");
create_tool_button(TOOL_ADD_DOOR, "", "");
create_tool_button(TOOL_ADD_MODEL, "", "");
create_tool_button(TOOL_ADD_FLOOR, "", "");
create_tool_button(TOOL_EDIT_POLYGON, "", "");

connect(
tool_button_group,
Expand Down Expand Up @@ -298,12 +298,25 @@ void Editor::load_model_names()
EditorModel(it->as<std::string>(), model_meters_per_pixel));
}

QToolButton *Editor::create_tool_button(const int id)
QToolButton *Editor::create_tool_button(
const int id,
const QString& icon_filename,
const QString & tooltip)
{
QToolButton *b = new QToolButton(toolbar);
b->setText(tool_id_to_string(id));
b->setCheckable(true);
//b->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);

if (!icon_filename.isEmpty())
{
QIcon icon(icon_filename);
b->setIcon(icon);
b->setToolTip(tooltip);
}
else
{
b->setText(tool_id_to_string(id));
//b->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
}
toolbar->addWidget(b);
tool_button_group->addButton(b, id);
return b;
Expand Down
5 changes: 4 additions & 1 deletion traffic_editor/gui/editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ private slots:
bool is_mouse_event_in_map(QMouseEvent *e, QPointF &p_scene);

QToolBar *toolbar;
QToolButton *create_tool_button(const int id);
QToolButton *create_tool_button(
const int id,
const QString& icon_filename,
const QString &tooltip);
void tool_toggled(int id, bool checked);

/////////////////////////////
Expand Down
64 changes: 64 additions & 0 deletions traffic_editor/resources/icons/add_vertex.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
92 changes: 92 additions & 0 deletions traffic_editor/resources/icons/move.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
99 changes: 99 additions & 0 deletions traffic_editor/resources/icons/rotate.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading