[X2Go-Commits] [x2gokdriveclient] 01/01: identify screen, when user hovering the action in the multiple monitors menu.

git-admin at x2go.org git-admin at x2go.org
Thu Jan 23 11:23:34 CET 2020


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository x2gokdriveclient.

commit 04caf8775388742bc08d5c7ac7c6aeec07a083fd
Author: Oleksandr Shneyder <o.shneyder at phoca-gmbh.de>
Date:   Thu Jan 23 11:20:42 2020 +0100

    identify screen, when user hovering the action in the multiple monitors menu.
---
 client.cpp           | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 client.h             |  7 ++++--
 debian/changelog     |  1 +
 screenidentifier.cpp | 38 +++++++++++++++++++++++++++++++++
 screenidentifier.h   | 37 ++++++++++++++++++++++++++++++++
 x2gokdriveclient.pro |  4 ++--
 6 files changed, 143 insertions(+), 4 deletions(-)

diff --git a/client.cpp b/client.cpp
index ceb5e03..e016ef6 100644
--- a/client.cpp
+++ b/client.cpp
@@ -51,6 +51,7 @@
 #include <QToolButton>
 #include <QMenu>
 #include <QClipboard>
+#include "screenidentifier.h"
 
 
 
@@ -166,7 +167,10 @@ Client::Client()
     actRandr->setCheckable(true);
     menu->addSeparator();
     for(int i=0;i<4;++i)
+    {
         actDisp[i]=menu->addAction(QIcon(":res/view-fullscreen.svg"), tr("Monitor ")+QString::number(i+1) ,this, SLOT(slotDisplayFS()));
+        connect(actDisp[i], SIGNAL(hovered()), this, SLOT (slotIdentifyScreen()));
+    }
 
     actFS=menu->addAction(QIcon(":res/view-fullscreen.svg"), tr("All monitors"),this, SLOT(slotFS()));
     menu->addSeparator();
@@ -197,6 +201,62 @@ Client::~Client()
         delete currentCursor;
 }
 
+void Client::slotIdentifyScreen()
+{
+    if(!menu->isVisible() || !menu->underMouse())
+    {
+        if(screenIdentifier)
+            screenIdentifier->hide();
+        return;
+    }
+
+    QAction* hoveredAction=menu->actionAt( menu->mapFromGlobal(QCursor::pos()));
+    if(!hoveredAction)
+    {
+        if(screenIdentifier)
+            screenIdentifier->hide();
+        return;
+    }
+
+    int number=-1;
+
+    for(int i=0;i<4;++i)
+    {
+        if(hoveredAction == actDisp[i])
+        {
+            number=i;
+            break;
+        }
+    }
+    if(number<0)
+    {
+        if(screenIdentifier)
+            screenIdentifier->hide();
+        return;
+    }
+
+    if(number >= QGuiApplication::screens().size())
+    {
+        qDebug()<<"screen not connected";
+        if(screenIdentifier)
+            screenIdentifier->hide();
+        return;
+    }
+    QRect geom=QGuiApplication::screens()[number]->geometry();
+    if(!screenIdentifier)
+    {
+        screenIdentifier=new ScreenIdentifier(this, Qt::FramelessWindowHint|Qt::X11BypassWindowManagerHint|Qt::WindowStaysOnTopHint);
+    }
+    screenIdentifier->setText(tr("Monitor")+" "+QString::number(number+1));
+    int x_pos=geom.width()/2-300;
+    int y_pos=geom.height()/2-150;
+    screenIdentifier->setFixedSize(600,300);
+    screenIdentifier ->move(geom.x()+x_pos, geom.y()+y_pos);
+    screenIdentifier->show();
+    menu->show();
+    //hide the identifier, when no screen actions are hovered
+    QTimer::singleShot(100,this, SLOT(slotIdentifyScreen()));
+}
 
 void Client::editWindowTitle()
 {
diff --git a/client.h b/client.h
index 04a1b3b..9211384 100644
--- a/client.h
+++ b/client.h
@@ -111,7 +111,8 @@ class QTimer;
 class MenuFrame;
 class QMenu;
 class QAction;
-
+class QLabel;
+class ScreenIdentifier;
 
 class Client : public QMainWindow
 {
@@ -128,7 +129,7 @@ public:
     bool isDisplayPointer(QMouseEvent* event);
 
 private slots:
-
+    void slotIdentifyScreen();
     void connectToServer();
     void socketConnected();
     void socketDisconnected();
@@ -239,6 +240,8 @@ private:
     QRect ephyrScreens[4];
     int primaryScreenIndex=0;
     int cacheSize=0;
+    ScreenIdentifier *screenIdentifier=0l;
+    QLabel* fr;
 
 protected:
     void resizeEvent(QResizeEvent*);
diff --git a/debian/changelog b/debian/changelog
index cd71b3e..d5ec6d2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -19,5 +19,6 @@ x2gokdriveclient (0.0.0.1-0x2go1) UNRELEASED; urgency=medium
     - set default window geometry to 800x600.
     - force client to send geometry event if the size of the display area is not changed after intiation
       for server to send initial image.
+    - identify screen, when user hovering the action in the multiple monitors menu.
 
  -- Mike Gabriel <mike.gabriel at das-netzwerkteam.de>  Tue, 04 Jun 2019 11:10:43 +0200
diff --git a/screenidentifier.cpp b/screenidentifier.cpp
new file mode 100644
index 0000000..3a3ab13
--- /dev/null
+++ b/screenidentifier.cpp
@@ -0,0 +1,38 @@
+/*
+ * QT Client for X2GoKDrive
+ * Copyright (C) 2018  Oleksandr Shneyder <o.shneyder at phoca-gmbh.de>
+ * Copyright (C) 2018  phoca-GmbH
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+#include <QLabel>
+#include "screenidentifier.h"
+
+ScreenIdentifier::ScreenIdentifier(QWidget* parent,  Qt::WindowFlags flags):QMainWindow(parent, flags)
+{
+    label=new QLabel("", this);
+    QFont f=label->font();
+    f.setBold(true);
+    f.setPointSize(56);
+    label->setFont(f);
+    label->setAlignment(Qt::AlignCenter);
+    setCentralWidget(label);
+    label->setFrameStyle(QFrame::Box);
+}
+
+void ScreenIdentifier::setText(const QString& text)
+{
+    label->setText(text);
+}
diff --git a/screenidentifier.h b/screenidentifier.h
new file mode 100644
index 0000000..fbb7f46
--- /dev/null
+++ b/screenidentifier.h
@@ -0,0 +1,37 @@
+/*
+ * QT Client for X2GoKDrive
+ * Copyright (C) 2018  Oleksandr Shneyder <o.shneyder at phoca-gmbh.de>
+ * Copyright (C) 2018  phoca-GmbH
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef SCREENIDENTIFIER_H
+#define SCREENIDENTIFIER_H
+#include <QMainWindow>
+
+class QLabel;
+
+class ScreenIdentifier: public QMainWindow
+{
+    Q_OBJECT
+public:
+    explicit ScreenIdentifier(QWidget *parent, Qt::WindowFlags flags);
+    void setText(const QString& text);
+private:
+    QLabel* label;
+};
+
+#endif // SCREENIDENTIFIER_H
diff --git a/x2gokdriveclient.pro b/x2gokdriveclient.pro
index fab1ed2..339627c 100644
--- a/x2gokdriveclient.pro
+++ b/x2gokdriveclient.pro
@@ -20,5 +20,5 @@ RESOURCES += resources.qrc
 
 
 # Input
-SOURCES += main.cpp client.cpp displayarea.cpp menuframe.cpp
-HEADERS += client.h displayarea.h menuframe.h
+SOURCES += main.cpp client.cpp displayarea.cpp menuframe.cpp screenidentifier.cpp
+HEADERS += client.h displayarea.h menuframe.h screenidentifier.h

--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2gokdriveclient.git


More information about the x2go-commits mailing list