2626#include " maprenderer.h"
2727#include " layer.h"
2828#include " utils.h"
29+ #include " locatorwidget.h"
2930
3031#include < QApplication>
3132#include < QPainter>
3233#include < QRegularExpression>
3334#include < QStyledItemDelegate>
3435#include < QTreeView>
36+ #include < QStaticText>
37+ #include < QTextOption>
3538
3639namespace Tiled {
3740
@@ -121,6 +124,28 @@ class TileMatchDelegate : public QStyledItemDelegate
121124
122125 return QSize (option.rect .width (), height);
123126 }
127+
128+ private:
129+ class Fonts {
130+ public:
131+ Fonts (const QFont &base)
132+ : small(scaledFont(base, 0.9 ))
133+ , big(scaledFont(base, 1.1 ))
134+ {}
135+
136+ const QFont small;
137+ const QFont big;
138+ };
139+
140+ static QFont scaledFont (const QFont &font, qreal scale)
141+ {
142+ QFont scaled (font);
143+ if (font.pixelSize () > 0 )
144+ scaled.setPixelSize (font.pixelSize () * scale);
145+ else
146+ scaled.setPointSizeF (font.pointSizeF () * scale);
147+ return scaled;
148+ }
124149};
125150
126151// /////////////////////////////////////////////////////////////////////////////
@@ -165,7 +190,7 @@ void TileLocatorSource::activate(const QModelIndex &index)
165190 const Match &match = mMatches .at (index.row ());
166191
167192 auto documentManager = DocumentManager::instance ();
168- auto mapDocument = documentManager->currentDocument ();
193+ auto mapDocument = qobject_cast<MapDocument*>( documentManager->currentDocument () );
169194
170195 if (!mapDocument) {
171196 // Try to find any open map document
@@ -181,13 +206,13 @@ void TileLocatorSource::activate(const QModelIndex &index)
181206 if (!mapDocument)
182207 return ;
183208
184- auto renderer = mapDocument->renderer ();
185209 auto mapView = documentManager->viewForDocument (mapDocument);
186210
187211 if (!mapView)
188212 return ;
189213
190214 // Convert tile coordinates to screen coordinates
215+ auto renderer = mapDocument->renderer ();
191216 auto screenPos = renderer->tileToScreenCoords (match.tilePos );
192217
193218 // Center the view on the specified tile position
@@ -211,7 +236,7 @@ QVector<TileLocatorSource::Match> TileLocatorSource::parseCoordinates(const QStr
211236 return result;
212237
213238 // Join all words to handle cases like "10,20" or "x:10 y:20"
214- QString input = words.join (" " );
239+ QString input = words.join (QStringLiteral ( " " ) );
215240
216241 QPoint tilePos;
217242 if (parseCoordinate (input, tilePos)) {
@@ -231,7 +256,7 @@ bool TileLocatorSource::parseCoordinate(const QString &text, QPoint &tilePos)
231256 // Try different coordinate formats
232257
233258 // Format 1: "x,y" (e.g., "10,20")
234- QRegularExpression commaPattern (R"( (\d+)\s*,\s*(\d+))" );
259+ QRegularExpression commaPattern (QStringLiteral ( R"( (\d+)\s*,\s*(\d+))" ) );
235260 auto match = commaPattern.match (text);
236261 if (match.hasMatch ()) {
237262 tilePos.setX (match.captured (1 ).toInt ());
@@ -240,14 +265,14 @@ bool TileLocatorSource::parseCoordinate(const QString &text, QPoint &tilePos)
240265 }
241266
242267 // Format 2: "x:10 y:20" or "x:10, y:20"
243- QRegularExpression xyPattern (R"( x\s*:\s*(\d+)(?:\s*[,\s]\s*y\s*:\s*(\d+))?)" );
268+ QRegularExpression xyPattern (QStringLiteral ( R"( x\s*:\s*(\d+)(?:\s*[,\s]\s*y\s*:\s*(\d+))?)" ) );
244269 match = xyPattern.match (text);
245270 if (match.hasMatch ()) {
246271 tilePos.setX (match.captured (1 ).toInt ());
247272 if (match.captured (2 ).isEmpty ()) {
248273 // Only x coordinate provided, try to find y in the rest of the text
249274 QString remaining = text.mid (match.capturedEnd ());
250- QRegularExpression yPattern (R"( y\s*:\s*(\d+))" );
275+ QRegularExpression yPattern (QStringLiteral ( R"( y\s*:\s*(\d+))" ) );
251276 auto yMatch = yPattern.match (remaining);
252277 if (yMatch.hasMatch ()) {
253278 tilePos.setY (yMatch.captured (1 ).toInt ());
@@ -260,7 +285,7 @@ bool TileLocatorSource::parseCoordinate(const QString &text, QPoint &tilePos)
260285 }
261286
262287 // Format 3: Just two numbers separated by space (e.g., "10 20")
263- QRegularExpression spacePattern (R"( (\d+)\s+(\d+))" );
288+ QRegularExpression spacePattern (QStringLiteral ( R"( (\d+)\s+(\d+))" ) );
264289 match = spacePattern.match (text);
265290 if (match.hasMatch ()) {
266291 tilePos.setX (match.captured (1 ).toInt ());
@@ -269,7 +294,7 @@ bool TileLocatorSource::parseCoordinate(const QString &text, QPoint &tilePos)
269294 }
270295
271296 // Format 4: Single number (assume it's x coordinate)
272- QRegularExpression singlePattern (R"( (\d+))" );
297+ QRegularExpression singlePattern (QStringLiteral ( R"( (\d+))" ) );
273298 match = singlePattern.match (text);
274299 if (match.hasMatch ()) {
275300 tilePos.setX (match.captured (1 ).toInt ());
0 commit comments