added icons for circular primitives and enhanced some existing ones

Sat, 23 Jun 2018 13:57:04 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Sat, 23 Jun 2018 13:57:04 +0300
changeset 1425
5354313b9958
parent 1424
737df8e904af
child 1426
e5a2ddfe2ba5

added icons for circular primitives and enhanced some existing ones

icons/chord.png file | annotate | diff | comparison | revisions
icons/circle.png file | annotate | diff | comparison | revisions
icons/closed-cylinder.png file | annotate | diff | comparison | revisions
icons/condline.png file | annotate | diff | comparison | revisions
icons/cone.png file | annotate | diff | comparison | revisions
icons/cylinder.png file | annotate | diff | comparison | revisions
icons/disc-negative.png file | annotate | diff | comparison | revisions
icons/disc.png file | annotate | diff | comparison | revisions
icons/line.png file | annotate | diff | comparison | revisions
icons/quad.png file | annotate | diff | comparison | revisions
icons/ring.png file | annotate | diff | comparison | revisions
icons/subfilereference.png file | annotate | diff | comparison | revisions
icons/triangle.png file | annotate | diff | comparison | revisions
ldforge.qrc file | annotate | diff | comparison | revisions
src/linetypes/circularprimitive.cpp file | annotate | diff | comparison | revisions
src/model.cpp file | annotate | diff | comparison | revisions
Binary file icons/chord.png has changed
Binary file icons/circle.png has changed
Binary file icons/closed-cylinder.png has changed
Binary file icons/condline.png has changed
Binary file icons/cone.png has changed
Binary file icons/cylinder.png has changed
Binary file icons/disc-negative.png has changed
Binary file icons/disc.png has changed
Binary file icons/line.png has changed
Binary file icons/quad.png has changed
Binary file icons/ring.png has changed
Binary file icons/subfilereference.png has changed
Binary file icons/triangle.png has changed
--- a/ldforge.qrc	Fri Jun 22 15:03:50 2018 +0300
+++ b/ldforge.qrc	Sat Jun 23 13:57:04 2018 +0300
@@ -29,16 +29,23 @@
 	<file>./icons/camera-right.png</file>
 	<file>./icons/camera-top.png</file>
 	<file>./icons/checkerboard.png</file>
+	<file>./icons/chord.png</file>
+	<file>./icons/circle.png</file>
+	<file>./icons/closed-cylinder.png</file>
 	<file>./icons/colorcursor.png</file>
 	<file>./icons/colorselect.png</file>
 	<file>./icons/colors.txt</file>
 	<file>./icons/comment.png</file>
 	<file>./icons/condline.png</file>
+	<file>./icons/cone.png</file>
 	<file>./icons/copy.png</file>
 	<file>./icons/coverer.png</file>
 	<file>./icons/cut.png</file>
+	<file>./icons/cylinder.png</file>
 	<file>./icons/delete.png</file>
 	<file>./icons/del-line.png</file>
+	<file>./icons/disc-negative.png</file>
+	<file>./icons/disc.png</file>
 	<file>./icons/empty.png</file>
 	<file>./icons/error.png</file>
 	<file>./icons/exit.png</file>
@@ -91,6 +98,7 @@
 	<file>./icons/rectifier.png</file>
 	<file>./icons/redo.png</file>
 	<file>./icons/replace-coords.png</file>
+	<file>./icons/ring.png</file>
 	<file>./icons/round-coords.png</file>
 	<file>./icons/screencap.png</file>
 	<file>./icons/select-all.png</file>
--- a/src/linetypes/circularprimitive.cpp	Fri Jun 22 15:03:50 2018 +0300
+++ b/src/linetypes/circularprimitive.cpp	Sat Jun 23 13:57:04 2018 +0300
@@ -282,6 +282,7 @@
 		break;
 
 	case PrimitiveModel::Cylinder:
+	case PrimitiveModel::CylinderOpen:
 		return "cylinder";
 
 	case PrimitiveModel::Disc:
@@ -294,10 +295,7 @@
 		return "circle";
 
 	case PrimitiveModel::CylinderClosed:
-		return "cylinder-closed";
-
-	case PrimitiveModel::CylinderOpen:
-		return "cylinder-open";
+		return "closed-cylinder";
 
 	case PrimitiveModel::Chord:
 		return "chord";
--- a/src/model.cpp	Fri Jun 22 15:03:50 2018 +0300
+++ b/src/model.cpp	Sat Jun 23 13:57:04 2018 +0300
@@ -311,6 +311,8 @@
 
 QVariant Model::data(const QModelIndex& index, int role) const
 {
+	static QMap<QString, QPixmap> scaledIcons;
+
 	if (index.row() < 0 or index.row() >= size())
 		return {};
 
@@ -337,7 +339,17 @@
 		}
 
 	case Qt::DecorationRole:
-		return MainWindow::getIcon(object->iconName());
+		{
+			QString iconName = object->iconName();
+			auto it = scaledIcons.find(iconName);
+			if (it == scaledIcons.end())
+			{
+				QPixmap pixmap = MainWindow::getIcon(object->iconName())
+					.scaled({24, 24}, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+				it = scaledIcons.insert(iconName, pixmap);
+			}
+			return *it;
+		}
 
 	case Qt::BackgroundColorRole:
 		if (object->type() == LDObjectType::Error)

mercurial