[X2Go-Commits] [x2goclient] 01/07: src/sessionbutton.cpp: make button non-sensitive in bottom right part if it's editable. Fixes: #1214.
git-admin at x2go.org
git-admin at x2go.org
Thu Jan 25 14:53:23 CET 2018
This is an automated email from the git hooks/post-receive script.
x2go pushed a commit to branch master
in repository x2goclient.
commit 0da3f0a0d2d1f9331c92f5bd68418852cf826761
Author: Mihai Moldovan <ionic at ionic.de>
Date: Thu Jan 25 11:30:19 2018 +0100
src/sessionbutton.cpp: make button non-sensitive in bottom right part if it's editable. Fixes: #1214.
---
debian/changelog | 2 ++
src/sessionbutton.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 53 insertions(+), 4 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index aaf1979..9a04dbb 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -54,6 +54,8 @@ x2goclient (4.1.1.1-0x2go1) UNRELEASED; urgency=medium
X2GO_XINERAMA in accordance with server changes.
- src/onmainwindow.cpp: supply xinerama option as another parameter to
x2goresume-session on session resume.
+ - src/sessionbutton.cpp: make button non-sensitive in bottom right part if
+ it's editable. Fixes: #1214.
[ Oleksandr Shneyder ]
* New upstream version (4.1.1.1):
diff --git a/src/sessionbutton.cpp b/src/sessionbutton.cpp
index 2f6fb95..c3d9e25 100644
--- a/src/sessionbutton.cpp
+++ b/src/sessionbutton.cpp
@@ -37,6 +37,7 @@
#include <QPainter>
#include <QImage>
#include <QPixmap>
+#include <QPolygon>
#include "sessionexplorer.h"
@@ -602,11 +603,57 @@ void SessionButton::mousePressEvent ( QMouseEvent * event )
void SessionButton::mouseReleaseEvent ( QMouseEvent * event )
{
SVGFrame::mouseReleaseEvent ( event );
- int x=event->x();
- int y=event->y();
loadBg ( ":/img/svg/sessionbut.svg" );
- if ( x>=0 && x< width() && y>=0 && y<height() )
- emit clicked();
+
+ QPoint click_pos (event->x (), event->y ());
+
+ QRect sensitive_area (0, 0, width (), height ());
+
+ bool recognized_click = false;
+
+ /*
+ * If button is editable, let only the top "half"
+ * of the button be clickable to trigger an event.
+ *
+ * Actually, the area will look something like that:
+ * ----------------------------
+ * | |
+ * | -----------------------
+ * | |
+ * | |
+ * | |
+ * ------
+ *
+ */
+ if (editable) {
+ bool mini_mode = par->retMiniMode ();
+
+ QRect sensitive_area2;
+
+ if (!mini_mode) {
+ sensitive_area.setHeight (84);
+ sensitive_area2 = QRect (0, 83, 58, height () - 84);
+ }
+ else {
+ sensitive_area.setHeight (44);
+ sensitive_area2 = QRect (0, 43, 66, height () - 44);
+ }
+
+ QPolygon real_sensitive_area;
+ real_sensitive_area << sensitive_area.topLeft () << sensitive_area.topRight ()
+ << sensitive_area.bottomRight () << sensitive_area2.topRight ()
+ << sensitive_area2.bottomRight () << sensitive_area2.bottomLeft ()
+ << sensitive_area.topLeft ();
+
+ recognized_click = real_sensitive_area.containsPoint (click_pos, Qt::WindingFill);
+ }
+ else {
+ recognized_click = sensitive_area.contains (click_pos);
+ }
+
+ if (recognized_click) {
+ emit clicked ();
+ }
}
void SessionButton::mouseMoveEvent ( QMouseEvent * event )
--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
More information about the x2go-commits
mailing list