[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [ksnapshot/frameworks] /: code style tidies
From:       Aaron Seigo <aseigo () kde ! org>
Date:       2014-11-03 14:39:10
Message-ID: E1XlImk-0003XZ-L3 () scm ! kde ! org
[Download RAW message or body]

Git commit c7e7577184b9437bc491b01d948fdf2b85075c69 by Aaron Seigo.
Committed on 03/11/2014 at 14:35.
Pushed by aseigo into branch 'frameworks'.

code style tidies

M  +1    -2    freeregiongrabber.cpp
M  +3    -3    ksnapshotobject.cpp
M  +21   -14   regiongrabber.cpp

http://commits.kde.org/ksnapshot/c7e7577184b9437bc491b01d948fdf2b85075c69

diff --git a/freeregiongrabber.cpp b/freeregiongrabber.cpp
index 459bc2c..c60b0ca 100644
--- a/freeregiongrabber.cpp
+++ b/freeregiongrabber.cpp
@@ -170,8 +170,7 @@ void FreeRegionGrabber::paintEvent(QPaintEvent *e)
 
     painter.drawText(textRect, txt);
 
-    if ((pol.boundingRect().height() > handleSize * 2 && pol.boundingRect().width() \
>                 handleSize * 2)
-            || !mouseDown) {
+    if (!mouseDown || (pol.boundingRect().height() > handleSize * 2 && \
pol.boundingRect().width() > handleSize * 2)) {  \
painter.setBrush(QBrush(Qt::transparent));  painter.setClipRegion(QRegion(pol));
         painter.drawPolygon(rect());
diff --git a/ksnapshotobject.cpp b/ksnapshotobject.cpp
index adc8a24..df57e00 100644
--- a/ksnapshotobject.cpp
+++ b/ksnapshotobject.cpp
@@ -221,9 +221,9 @@ bool KSnapshotObject::saveImage(QIODevice *device, const \
                QByteArray &format)
     qDebug() << "saving file format" << format << " in quality " << \
imgWriter.quality();  
     // For jpeg and webp use 85% quality not the default
-    if (0 == qstricmp(format.constData(), "jpeg")
-            || 0 == qstricmp(format.constData(), "jpg")
-            || 0 == qstricmp(format.constData(), "webp")) {
+    if (qstricmp(format.constData(), "jpeg") == 0 ||
+        qstricmp(format.constData(), "jpg") == 0 ||
+        qstricmp(format.constData(), "webp") == 0)  {
         imgWriter.setQuality(85);
     }
 
diff --git a/regiongrabber.cpp b/regiongrabber.cpp
index 025649e..97af3fc 100644
--- a/regiongrabber.cpp
+++ b/regiongrabber.cpp
@@ -164,8 +164,7 @@ void RegionGrabber::paintEvent(QPaintEvent *e)
 
     painter.drawText(textRect, txt);
 
-    if ((r.height() > handleSize * 2 && r.width() > handleSize * 2)
-            || !mouseDown) {
+    if (!mouseDown || (r.height() > handleSize * 2 && r.width() > handleSize * 2)) {
         updateHandles();
         painter.setPen(Qt::NoPen);
         painter.setBrush(handleColor);
@@ -225,37 +224,45 @@ void RegionGrabber::mouseMoveEvent(QMouseEvent *e)
 
     if (mouseDown) {
         if (newSelection) {
-            QPoint p = e->pos();
-            QRect r = rect();
+            const QPoint p = e->pos();
+            const QRect r = rect();
             selection = normalizeSelection(QRect(dragStartPoint, limitPointToRect(p, \
r)));  } else if (mouseOverHandle == 0) { // moving the whole selection
             QRect r = rect().normalized(), s = selectionBeforeDrag.normalized();
-            QPoint p = s.topLeft() + e->pos() - dragStartPoint;
+            const QPoint p = s.topLeft() + e->pos() - dragStartPoint;
             r.setBottomRight(r.bottomRight() - QPoint(s.width(), s.height()) + \
QPoint(1, 1));  if (!r.isNull() && r.isValid()) {
                 selection.moveTo(limitPointToRect(p, r));
             }
         } else { // dragging a handle
             QRect r = selectionBeforeDrag;
-            QPoint offset = e->pos() - dragStartPoint;
+            const QPoint offset = e->pos() - dragStartPoint;
 
-            if (mouseOverHandle == &TLHandle || mouseOverHandle == &THandle
-                    || mouseOverHandle == &TRHandle) { // dragging one of the top \
handles +            if (mouseOverHandle == &TLHandle ||
+                mouseOverHandle == &THandle ||
+                mouseOverHandle == &TRHandle) {
+                // dragging one of the top handles
                 r.setTop(r.top() + offset.y());
             }
 
-            if (mouseOverHandle == &TLHandle || mouseOverHandle == &LHandle
-                    || mouseOverHandle == &BLHandle) { // dragging one of the left \
handles +            if (mouseOverHandle == &TLHandle ||
+                mouseOverHandle == &LHandle ||
+                mouseOverHandle == &BLHandle) { 
+                // dragging one of the left handles
                 r.setLeft(r.left() + offset.x());
             }
 
-            if (mouseOverHandle == &BLHandle || mouseOverHandle == &BHandle
-                    || mouseOverHandle == &BRHandle) { // dragging one of the bottom \
handles +            if (mouseOverHandle == &BLHandle ||
+                mouseOverHandle == &BHandle ||
+                mouseOverHandle == &BRHandle) {
+                // dragging one of the bottom handles
                 r.setBottom(r.bottom() + offset.y());
             }
 
-            if (mouseOverHandle == &TRHandle || mouseOverHandle == &RHandle
-                    || mouseOverHandle == &BRHandle) { // dragging one of the right \
handles +            if (mouseOverHandle == &TRHandle ||
+                mouseOverHandle == &RHandle ||
+                mouseOverHandle == &BRHandle) { 
+                // dragging one of the right handles
                 r.setRight(r.right() + offset.x());
             }
             r.setTopLeft(limitPointToRect(r.topLeft(), rect()));


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic