Sfoglia il codice sorgente

Take content margins into account when calculating icon rectangles.

Sascha Zelzer 13 anni fa
parent
commit
cf48bbfaca
1 ha cambiato i file con 5 aggiunte e 6 eliminazioni
  1. 5 6
      Libs/Widgets/ctkSearchBox.cpp

+ 5 - 6
Libs/Widgets/ctkSearchBox.cpp

@@ -94,21 +94,20 @@ QRect ctkSearchBoxPrivate::clearRect()const
 QRect ctkSearchBoxPrivate::searchRect()const
 {
   Q_Q(const ctkSearchBox);
-  QRect sRect;
+  QRect sRect = q->contentsRect();
   // If the QLineEdit has a frame, the icon must be shifted from
   // the frame line width
   if (q->hasFrame())
     {
     QStyleOptionFrameV2 opt;
     q->initStyleOption(&opt);
-    sRect.moveTopLeft(QPoint(opt.lineWidth, opt.lineWidth));
+    sRect.adjust(opt.lineWidth, opt.lineWidth, -opt.lineWidth, -opt.lineWidth);
     }
-  // Hardcoded: shift by 1 pixel because some styles have a focus frame inside
+  // Hardcoded: shrink by 1 pixel because some styles have a focus frame inside
   // the line edit frame.
-  sRect.translate(QPoint(1,1));
+  sRect.adjust(1, 1, -1, -1);
   // Square size
-  sRect.setSize(QSize(q->height(),q->height()) -
-                2*QSize(sRect.left(), sRect.top()));
+  sRect.setWidth(sRect.height());
   return sRect;
 }