This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository x2godesktopsharing.
commit ef3dfac2eae54c1a4138ff962d44371b9f30a813 Author: Mike Gabriel <mike.gabr...@das-netzwerkteam.de> Date: Mon Nov 12 14:18:12 2018 +0100 Replace QMessageBox based access dialog by a QDialog based access dialog. QMessageBox in Qt5 is not suitable for adding a QCheckBox widget into it anymore. --- accessdialog.cpp | 62 ++++++++++++++ accessdialog.h | 36 ++++++++ debian/changelog | 3 + icons/svg/dialog-question.svg | 185 ++++++++++++++++++++++++++++++++++++++++++ messagebox.cpp | 38 --------- messagebox.h | 31 ------- resources.qrc | 1 + sharetray.cpp | 16 ++-- x2godesktopsharing.pro | 4 +- 9 files changed, 297 insertions(+), 79 deletions(-) diff --git a/accessdialog.cpp b/accessdialog.cpp new file mode 100644 index 0000000..723decb --- /dev/null +++ b/accessdialog.cpp @@ -0,0 +1,62 @@ +// +// C++ Implementation: AccessDialog +// +// Description: +// +// +// Author: Mike Gabriel <mike.gabr...@das-netzwerkteam.de>, (C) 2018 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#include "accessdialog.h" +#include <QCheckBox> +#include <QDialogButtonBox> +#include <QLabel> +#include <QPixmap> +#include <QPushButton> +#include <QHBoxLayout> +#include <QVBoxLayout> + +AccessWindow::AccessWindow(QString uname, QString hname, QWidget *parent) + : QDialog (parent) +{ + setWindowTitle(QString("%1 (%2)").arg(uname).arg(hname)); + + QVBoxLayout *hbox = new QVBoxLayout(this); + + /* question mark and text */ + QHBoxLayout *vtexticonbox = new QHBoxLayout(); + QLabel *icon = new QLabel(); + icon->setPixmap ( QPixmap (":icons/svg/dialog-question.svg") ); + vtexticonbox->addWidget(icon, 1, Qt::AlignLeft); + QLabel *text = new QLabel(); + text->setText(QString(tr("Accept %1 from %2 ?")).arg(uname).arg(hname)); + vtexticonbox->addWidget(text, 1, Qt::AlignLeft); + hbox->addLayout(vtexticonbox); + + /* the check box (remember this setting for user X) */ + checkBox=new QCheckBox(QString(tr("Save selection for %1")).arg(uname),this); + hbox->addWidget(checkBox, 1, Qt::AlignLeft); + + /* dialog buttons */ + QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Grant access")); + connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Deny access")); + buttonBox->button(QDialogButtonBox::Cancel)->setDefault(true); + connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + hbox->addWidget(buttonBox, 1, Qt::AlignRight | Qt::AlignBottom); + + /* modality */ + setWindowModality(Qt::WindowModal); +} + +AccessWindow::~AccessWindow() +{ +} + +bool AccessWindow::isChecked() +{ + return checkBox->isChecked(); +} diff --git a/accessdialog.h b/accessdialog.h new file mode 100644 index 0000000..1dd01c8 --- /dev/null +++ b/accessdialog.h @@ -0,0 +1,36 @@ +// +// C++ Interface: AccessDialog +// +// Description: +// +// +// Author: Mike Gabriel <mike.gabr...@das-netzwerkteam.de>, (C) 2018 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#ifndef ACCESSDIALOG_H +#define ACCESSDIALOG_H + +/** + @author Mike Gabriel <mike.gabr...@das-netzwerkteam.de> +*/ + +#include <QDialog> +#include <QCheckBox> + +/** + @author Mike Gabriel <mike.gabr...@das-netzwerkteam.de> +*/ +class AccessWindow : public QDialog +{ + Q_OBJECT +public: + AccessWindow(QString uname, QString hname, QWidget *parent = NULL); + ~AccessWindow(); + bool isChecked(); +private: + QCheckBox* checkBox; +}; + +#endif diff --git a/debian/changelog b/debian/changelog index b55c7d7..057d4b3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -20,6 +20,9 @@ x2godesktopsharing (3.1.1.5-0x2go1) UNRELEASED; urgency=medium - Make the desktop sharing group configurable system-wide and by the user. - man/man8/x2goterminate-desktopsharing.8: Grammar fix. - resources.qrc: Rename file from resources.rcc. + - Replace QMessageBox based access dialog by a QDialog based access dialog. + QMessageBox in Qt5 is not suitable for adding a QCheckBox widget into it + anymore. * debian/*: + Convert to DH packaging style. Build against Qt5. * debian/control: diff --git a/icons/svg/dialog-question.svg b/icons/svg/dialog-question.svg new file mode 100644 index 0000000..50123ac --- /dev/null +++ b/icons/svg/dialog-question.svg @@ -0,0 +1,185 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="48px" + height="48px" + id="svg7220" + sodipodi:version="0.32" + inkscape:version="0.46" + sodipodi:docname="dialog-question.svg" + inkscape:output_extension="org.inkscape.output.svg.inkscape"> + <defs + id="defs7222"> + <linearGradient + inkscape:collect="always" + id="linearGradient4873"> + <stop + style="stop-color:#ffffff;stop-opacity:1;" + offset="0" + id="stop4875" /> + <stop + style="stop-color:#ffffff;stop-opacity:0;" + offset="1" + id="stop4877" /> + </linearGradient> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient4873" + id="linearGradient2704" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(2.3440063,0,0,2.3440063,-121.79862,31.22942)" + x1="62.745731" + y1="-13.444987" + x2="62.608765" + y2="7.1072145" /> + <linearGradient + id="linearGradient3811"> + <stop + id="stop3813" + offset="0" + style="stop-color:#204a87;stop-opacity:1" /> + <stop + id="stop3815" + offset="1" + style="stop-color:#3465a4;stop-opacity:1" /> + </linearGradient> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3811" + id="linearGradient3927" + x1="15.046636" + y1="44.787998" + x2="15.046636" + y2="3.8851264" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(1.0805272,0,0,1.0805026,-1.5082857,-3.3507604)" /> + <linearGradient + id="linearGradient5106"> + <stop + style="stop-color:#8fb3d9;stop-opacity:1" + offset="0" + id="stop5108" /> + <stop + id="stop8208" + offset="0.25288007" + style="stop-color:#729fcf;stop-opacity:1" /> + <stop + style="stop-color:#3465a4;stop-opacity:1" + offset="0.68271071" + id="stop8210" /> + <stop + style="stop-color:#204a87;stop-opacity:1" + offset="1" + id="stop5110" /> + </linearGradient> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient5106" + id="radialGradient2707" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(-7.565785,-6.219707e-7,3.9644633e-7,-4.8230546,494.60904,-26.555114)" + cx="62.202274" + cy="-5.7132163" + fx="62.202274" + fy="-5.7132163" + r="9.7552835" /> + <linearGradient + id="linearGradient10691" + inkscape:collect="always"> + <stop + id="stop10693" + offset="0" + style="stop-color:#000000;stop-opacity:1;" /> + <stop + id="stop10695" + offset="1" + style="stop-color:#000000;stop-opacity:0;" /> + </linearGradient> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient10691" + id="radialGradient3080" + gradientUnits="userSpaceOnUse" + gradientTransform="scale(1.902215,0.525703)" + cx="6.702713" + cy="73.615715" + fx="6.702713" + fy="73.615715" + r="7.228416" /> + </defs> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="7" + inkscape:cx="24" + inkscape:cy="24" + inkscape:current-layer="layer1" + showgrid="true" + inkscape:grid-bbox="true" + inkscape:document-units="px" + inkscape:window-width="1680" + inkscape:window-height="1000" + inkscape:window-x="0" + inkscape:window-y="25" /> + <metadata + id="metadata7225"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + </cc:Work> + </rdf:RDF> + </metadata> + <g + id="layer1" + inkscape:label="Layer 1" + inkscape:groupmode="layer"> + <path + transform="matrix(1.6,0,0,1.8421053,3.6000003,-30.289476)" + d="M 26.5,38.700001 A 13.75,3.8 0 1 1 -1,38.700001 A 13.75,3.8 0 1 1 26.5,38.700001 z" + sodipodi:ry="3.8" + sodipodi:rx="13.75" + sodipodi:cy="38.700001" + sodipodi:cx="12.75" + id="path2625" + style="opacity:0.5;fill:url(#radialGradient3080);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.80000001;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" + sodipodi:type="arc" /> + <path + style="fill:url(#radialGradient2707);fill-opacity:1;fill-rule:nonzero;stroke:url(#linearGradient3927);stroke-width:1.00004065;stroke-miterlimit:4;stroke-dasharray:none" + d="M 45.499979,22.999239 C 45.499979,34.87373 35.873401,44.49998 24.000271,44.49998 C 12.126053,44.49998 2.5000203,34.873621 2.5000203,22.999239 C 2.5000203,11.12529 12.126053,1.5000193 24.000271,1.5000193 C 35.873401,1.5000193 45.499979,11.12529 45.499979,22.999239 L 45.499979,22.999239 z" + id="path6495" /> + <path + id="path8655" + d="M 44.49904,22.999272 C 44.49904,34.321462 35.320423,43.499975 23.999791,43.499975 C 12.678124,43.499975 3.5000253,34.321356 3.5000253,22.999272 C 3.5000253,11.677606 12.678124,2.5000243 23.999791,2.5000243 C 35.320423,2.5000243 44.49904,11.677606 44.49904,22.999272 L 44.49904,22.999272 z" + style="opacity:0.6;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:url(#linearGradient2704);stroke-width:1.00004995;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + <path + id="path9053" + style="font-size:72px;font-style:normal;font-weight:bold;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.75;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;font-family:Standard Symbols L" + d="M 25.499549,29.000001 C 25.500288,27.000001 24.999549,24.022899 27.499549,22.000001 C 29.987045,20.009725 32.016392,18.017155 31.999549,15.000001 C 32.036328,12.012312 28.999549,10.023333 25.999549,9.7499987 C 22.008774,9.4823727 17.999549,10.031438 15.999549,14.000001 C 15.707504,15.711192 15.898252,18.000001 17.999549,18.000001 C 18.983603,18.000001 19.999549,17.038081 19.999549,16.000001 L 19.999549,15.000001 C 19.999549,14.500001 20.028884,14.041648 20.999549,13.500001 C 22 [...] + sodipodi:nodetypes="cccccsssssssscc" /> + <path + sodipodi:type="arc" + style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="path8287" + sodipodi:cx="18.4417" + sodipodi:cy="34.547359" + sodipodi:rx="2.2272584" + sodipodi:ry="2.4054391" + d="M 20.668958,34.547359 A 2.2272584,2.4054391 0 1 1 16.214442,34.547359 A 2.2272584,2.4054391 0 1 1 20.668958,34.547359 z" + transform="matrix(0.8979649,0,0,0.831449,7.4395493,5.2756317)" /> + </g> +</svg> diff --git a/messagebox.cpp b/messagebox.cpp deleted file mode 100644 index 60e0075..0000000 --- a/messagebox.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// -// C++ Implementation: messagebox -// -// Description: -// -// -// Author: Oleksandr Shneyder <oleksandr.shney...@obviously-nice.de>, (C) 2009-2015 -// -// Copyright: See COPYING file that comes with this distribution -// -// -#include "messagebox.h" -#include <QCheckBox> -#include <QGridLayout> - -MessageBox::MessageBox(QString uname, QString hname, QWidget *parent) - : QMessageBox(parent) -{ - checkBox=new QCheckBox( - QString(tr("Save selection for %1")).arg(uname),this); - ((QGridLayout*)layout())->addWidget(checkBox,1,1); - setIcon(Question); - setWindowModality(Qt::WindowModal); - setText(QString(tr("Accept %1 from %2 ?")).arg(uname).arg(hname)); - setStandardButtons(Yes|No); - setWindowTitle(QString("%1(%2)").arg(uname).arg(hname)); -} - - -MessageBox::~MessageBox() -{ -} - -bool MessageBox::isChecked() -{ - return checkBox->isChecked(); -} - diff --git a/messagebox.h b/messagebox.h deleted file mode 100644 index a77ad1f..0000000 --- a/messagebox.h +++ /dev/null @@ -1,31 +0,0 @@ -// -// C++ Interface: messagebox -// -// Description: -// -// -// Author: Oleksandr Shneyder <oleksandr.shney...@obviously-nice.de>, (C) 2009-2015 -// -// Copyright: See COPYING file that comes with this distribution -// -// -#ifndef MESSAGEBOX_H -#define MESSAGEBOX_H - -#include <QMessageBox> -/** - @author Oleksandr Shneyder <oleksandr.shney...@obviously-nice.de> -*/ -class QCheckBox; -class MessageBox : public QMessageBox -{ - Q_OBJECT -public: - MessageBox(QString uname, QString hname, QWidget *parent = 0); - ~MessageBox(); - bool isChecked(); -private: - QCheckBox* checkBox; -}; - -#endif diff --git a/resources.qrc b/resources.qrc index 5e5a232..7cd4c6e 100644 --- a/resources.qrc +++ b/resources.qrc @@ -18,6 +18,7 @@ <file>icons/32x32/wlist.png</file> <file>icons/32x32/x2godesktopsharing.png</file> <file>icons/128x128/x2godesktopsharing.png</file> + <file>icons/svg/dialog-question.svg</file> <file>x2godesktopsharing_da.qm</file> <file>x2godesktopsharing_de.qm</file> <file>x2godesktopsharing_es.qm</file> diff --git a/sharetray.cpp b/sharetray.cpp index c7e96bb..a975004 100644 --- a/sharetray.cpp +++ b/sharetray.cpp @@ -18,18 +18,19 @@ #include <QDir> #include <QtDebug> #include <QMessageBox> +#include <QDialog> #include <QSocketNotifier> #include <sys/socket.h> #include <sys/unistd.h> #include "simplelocalsocket.h" #include "accessaction.h" +#include "accessdialog.h" #include <sys/types.h> #include <csignal> #include <errno.h> #include <QToolTip> #include <QTimer> #include <QSettings> -#include "messagebox.h" #include <QSystemTrayIcon> #include <QCloseEvent> #include <QDateTime> @@ -404,7 +405,7 @@ QString ShareTray::getSocketAnswer ( QString message ) QString client=lst[0]; QString user=params[1]; QString remote_user=lst[10]; - if ( getAccess ( remote_user, client ) ==QMessageBox::Yes ) + if ( getAccess ( remote_user, client ) ==QDialog::Accepted ) { trayMessage ( tr ( "Access granted" ),QString ( tr ( "%1(%2): access granted" ) ).arg (remote_user ).arg ( client ) ); //start agent @@ -486,13 +487,12 @@ int ShareTray::getAccess ( QString remote_user, QString host ) if ( systemwideBlackList.contains ( remote_user ) ) return QMessageBox::Yes; - MessageBox m ( remote_user, host, this ); - m.activateWindow(); - m.raise(); - int res=m.exec(); - if ( m.isChecked() &&res==QMessageBox::Yes ) + AccessWindow ad ( remote_user, host, this ); + ad.raise(); + int res=ad.exec(); + if ( ad.isChecked() &&res==QDialog::Accepted ) userWhiteList<<remote_user; - if ( m.isChecked() &&res==QMessageBox::No ) + if ( ad.isChecked() &&res==QDialog::Rejected ) userBlackList<<remote_user; actBlack->setEnabled ( userBlackList.size() >0 ); actWhite->setEnabled ( userWhiteList.size() >0 ); diff --git a/x2godesktopsharing.pro b/x2godesktopsharing.pro index 530e3ed..75a9556 100644 --- a/x2godesktopsharing.pro +++ b/x2godesktopsharing.pro @@ -44,11 +44,11 @@ SOURCES += main.cpp \ sharetray.cpp \ simplelocalsocket.cpp \ accessaction.cpp \ - messagebox.cpp + accessdialog.cpp HEADERS += sharetray.h \ simplelocalsocket.h \ accessaction.h \ - messagebox.h + accessdialog.h RESOURCES += resources.qrc FORMS = dlg.ui -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2godesktopsharing.git _______________________________________________ x2go-commits mailing list x2go-commits@lists.x2go.org https://lists.x2go.org/listinfo/x2go-commits