]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt/GuiSetBorder.cpp
Fix readability
[lyx.git] / src / frontends / qt / GuiSetBorder.cpp
index 30e25743fb99709a9f07e0c8a538fc4ec5436261..dfe494851b492e481b58a213706aa77e933eb3d9 100644 (file)
@@ -80,19 +80,32 @@ void GuiSetBorder::init()
 
 void GuiSetBorder::mousePressEvent(QMouseEvent * e)
 {
+#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
+       if (e->position().y() > e->position().x()) {
+               if (e->position().y() < height() - e->position().x()) {
+#else
        if (e->y() > e->x()) {
                if (e->y() < height() - e->x()) {
+#endif
                        if (left_.enabled) {
                                setLeft(left_.set == LINE_SET ? LINE_UNSET : LINE_SET);
                                // emit signal
                                leftSet();
                        }
                } else {
+#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
+                       if (bottom_trim_left_.enabled && e->position().x() < margin + 4 + 2 * corner_length) {
+#else
                        if (bottom_trim_left_.enabled && e->x() < margin + 4 + 2 * corner_length) {
+#endif
                                setBottomLeftTrim(bottom_trim_left_.set == LINE_SET ? LINE_UNSET : LINE_SET);
                                // emit signal
                                bottomLTSet();
+#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
+                       } else if (bottom_trim_right_.enabled && e->position().x() > bwidth - margin - 2 * corner_length - 4) {
+#else
                        } else if (bottom_trim_right_.enabled && e->x() > bwidth - margin - 2 * corner_length - 4) {
+#endif
                                        setBottomRightTrim(bottom_trim_right_.set == LINE_SET ? LINE_UNSET : LINE_SET);
                                        // emit signal
                                        bottomRTSet();
@@ -103,12 +116,21 @@ void GuiSetBorder::mousePressEvent(QMouseEvent * e)
                        }
                }
        } else {
+#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
+               if (e->position().y() < height() - e->position().x()) {
+                       if (top_trim_left_.enabled && e->position().x() < margin + 4 + 2 * corner_length) {
+#else
                if (e->y() < height() - e->x()) {
                        if (top_trim_left_.enabled && e->x() < margin + 4 + 2 * corner_length) {
+#endif
                                setTopLeftTrim(top_trim_left_.set == LINE_SET ? LINE_UNSET : LINE_SET);
                                // emit signal
                                topLTSet();
+#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
+                       } else if (top_trim_right_.enabled && e->position().x() > bwidth - margin - 2 * corner_length - 4) {
+#else
                        } else if (top_trim_right_.enabled && e->x() > bwidth - margin - 2 * corner_length - 4) {
+#endif
                                        setTopRightTrim(top_trim_right_.set == LINE_SET ? LINE_UNSET : LINE_SET);
                                        // emit signal
                                        topRTSet();
@@ -213,14 +235,18 @@ void GuiSetBorder::drawTop(BorderState draw)
 }
 
 
-void GuiSetBorder::undrawWideTopLine()
+void GuiSetBorder::undrawWideTopLine(bool const right)
 {
-       if (!top_drawn_wide_)
+       if (!top_drawn_wide_ && !right)
                return;
 
        // Overpaint previous lines white
-       drawLine(Qt::white, margin + corner_length + 2, margin + corner_length,
-                bwidth - margin - corner_length - 1, margin + corner_length);
+       if (right)
+               drawLine(Qt::white, margin + 2 * (corner_length + 2), margin + corner_length,
+                       bwidth - margin - corner_length - 1, margin + corner_length);
+       else
+               drawLine(Qt::white, margin + corner_length + 2, margin + corner_length,
+                        bwidth - margin - corner_length - 1, margin + corner_length);
        top_drawn_wide_ = false;
 }
 
@@ -300,14 +326,18 @@ void GuiSetBorder::drawBottom(BorderState draw)
 }
 
 
-void GuiSetBorder::undrawWideBottomLine()
+void GuiSetBorder::undrawWideBottomLine(bool const right)
 {
-       if (!bottom_drawn_wide_)
+       if (!bottom_drawn_wide_ && !right)
                return;
 
-       //Overpaint previous lines white
-       drawLine(Qt::white, margin + corner_length + 2, bwidth - margin - corner_length + 1,
-                bwidth - margin - corner_length - 1, bwidth - margin - corner_length + 1);
+       // Overpaint previous lines white
+       if (right)
+               drawLine(Qt::white, margin + 2 * (corner_length + 2), bwidth - margin - corner_length + 1,
+                       bwidth - margin - corner_length - 1, bwidth - margin - corner_length + 1);
+       else
+               drawLine(Qt::white, margin + corner_length + 2, bwidth - margin - corner_length + 1,
+                        bwidth - margin - corner_length - 1, bwidth - margin - corner_length + 1);
        bottom_drawn_wide_ = false;
 }
 
@@ -401,10 +431,10 @@ void GuiSetBorder::setTopLeftTrimEnabled(bool enabled)
 void GuiSetBorder::setTopRightTrimEnabled(bool enabled)
 {
        top_trim_right_.enabled = enabled;
-       undrawWideTopLine();
+       undrawWideTopLine(enabled);
        drawTopRightTrim(top_trim_right_.set);
        drawTop(top_.set);
-       top_drawn_wide_ = !enabled;;
+       top_drawn_wide_ = !enabled;
 }
 
 
@@ -414,17 +444,17 @@ void GuiSetBorder::setBottomLeftTrimEnabled(bool enabled)
        undrawWideBottomLine();
        drawBottomLeftTrim(bottom_trim_left_.set);
        drawBottom(bottom_.set);
-       bottom_drawn_wide_ = !enabled;;
+       bottom_drawn_wide_ = !enabled;
 }
 
 
 void GuiSetBorder::setBottomRightTrimEnabled(bool enabled)
 {
        bottom_trim_right_.enabled = enabled;
-       undrawWideBottomLine();
+       undrawWideBottomLine(enabled);
        drawBottomRightTrim(bottom_trim_right_.set);
        drawBottom(bottom_.set);
-       bottom_drawn_wide_ = !enabled;;
+       bottom_drawn_wide_ = !enabled;
 }