src/main.cpp

changeset 232
8efa3a33172e
parent 231
a9bf6bab5ea2
child 233
5509bec02c81
--- a/src/main.cpp	Wed Jun 15 19:47:02 2022 +0300
+++ b/src/main.cpp	Mon Jun 20 02:04:51 2022 +0300
@@ -14,6 +14,7 @@
 #include "settingseditor/settingseditor.h"
 #include "widgets/colorselectdialog.h"
 #include "settings.h"
+#include "ui/circletooloptions.h"
 
 static const QDir LOCALE_DIR {":/locale"};
 
@@ -269,8 +270,9 @@
 	};
 }
 
-void initializeTools(Ui_MainWindow* ui, QWidget* parent)
+void initializeTools(Ui_MainWindow* ui, DocumentManager* documents, QWidget* parent)
 {
+	CircleToolOptionsWidget* circleToolOptions = new CircleToolOptionsWidget{parent};
 	const struct
 	{
 		QString name, tooltip;
@@ -289,6 +291,12 @@
 			.icon = {":/icons/pencil-outline.png"},
 			.widget = nullptr,
 		},
+		{
+			.name = QObject::tr("Circle"),
+			.tooltip = QObject::tr("Draw circular primitives."),
+			.icon = {":/icons/linetype-circularprimitive.png"},
+			.widget = circleToolOptions,
+		},
 	};
 	for (int i = 0; i < countof(editingModesInfo); ++i) {
 		const auto& editingModeInfo = editingModesInfo[i];
@@ -304,7 +312,18 @@
 			widget = new QWidget{parent};
 		}
 		ui->toolWidgetStack->addWidget(widget);
+		QObject::connect(action, &QAction::triggered, [ui, i]{
+			ui->toolWidgetStack->setCurrentIndex(i);
+		});
 	}
+	QObject::connect(
+		circleToolOptions,
+		&CircleToolOptionsWidget::optionsChanged,
+		[ui, documents](const CircleToolOptions& options) {
+			if (ModelData* data = currentModelData(ui, documents)) {
+				data->tools->setCircleToolOptions(options);
+			}
+		});
 }
 
 constexpr bool sortModelIndexesByRow(const QModelIndex& a, const QModelIndex& b)
@@ -583,7 +602,7 @@
 			action->setChecked(action->data().value<EditingMode>() == mode);
 		}
 	};
-	initializeTools(&ui, &mainWindow);
+	initializeTools(&ui, &documents, &mainWindow);
 	for (QAction* action : ui.editingModesToolBar->actions()) {
 		QObject::connect(action, &QAction::triggered, [&, action]{
 			if (ModelData* data = currentModelData(&ui, &documents)) {

mercurial