[X2Go-Commits] [x2goclient] 03/05: non_modal_messagebox.{cpp, h}: add new Non_Modal_MessageBox class for non-modal message boxes.
git-admin at x2go.org
git-admin at x2go.org
Mon Mar 9 23:26:56 CET 2015
This is an automated email from the git hooks/post-receive script.
x2go pushed a commit to branch bugfix/general
in repository x2goclient.
commit 18677da6be9955198fa1b6f83b57ca5468dba7df
Author: Mihai Moldovan <ionic at ionic.de>
Date: Mon Mar 9 22:49:25 2015 +0100
non_modal_messagebox.{cpp,h}: add new Non_Modal_MessageBox class for non-modal message boxes.
---
debian/changelog | 2 ++
src/non_modal_messagebox.cpp | 43 ++++++++++++++++++++++++++++++++++++++++++
src/non_modal_messagebox.h | 33 ++++++++++++++++++++++++++++++++
src/onmainwindow.h | 2 +-
x2goclient.pro | 6 ++++--
5 files changed, 83 insertions(+), 3 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index a63847c..393f57e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -186,6 +186,8 @@ x2goclient (4.0.4.0-0x2go1) UNRELEASED; urgency=low
Fixes: #804.
- onmainwindow.cpp: clarify message regarding missing SSH daemon host
keys. Fixes: #793.
+ - non_modal_messagebox.{cpp,h}: Add new Non_Modal_MessageBox class for
+ non-modal message boxes.
-- X2Go Release Manager <git-admin at x2go.org> Thu, 19 Feb 2015 13:25:28 +0100
diff --git a/src/non_modal_messagebox.cpp b/src/non_modal_messagebox.cpp
new file mode 100644
index 0000000..68ff7ac
--- /dev/null
+++ b/src/non_modal_messagebox.cpp
@@ -0,0 +1,43 @@
+/**************************************************************************
+* Copyright (C) 2015 by Mihai Moldovan <ionic at ionic.de> *
+* *
+* 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 2 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 "non_modal_messagebox.h"
+#include <QGridLayout>
+#include <QSpacerItem>
+
+// Please look up the documentation in the header file!
+void Non_Modal_MessageBox::critical (QWidget *parent, const QString &title,
+ const QString &text,
+ QMessageBox::StandardButtons buttons,
+ QMessageBox::StandardButton defaultButton) {
+ QMessageBox *msg_box = new QMessageBox (QMessageBox::Critical, title, text, buttons, parent);
+
+ msg_box->setAttribute (Qt::WA_DeleteOnClose);
+ msg_box->setDefaultButton (defaultButton);
+
+ // Set to minimum width of 300px.
+ QSpacerItem *horizontal_spacer = new QSpacerItem (500, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
+ QGridLayout *grid_layout = (QGridLayout*) (msg_box->layout ());
+ grid_layout->addItem (horizontal_spacer, grid_layout->rowCount (), 0, 1, grid_layout->columnCount ());
+
+ // Here's the real magic.
+ msg_box->setModal (false);
+
+ msg_box->show ();
+ msg_box->raise ();
+ msg_box->activateWindow ();
+}
+
diff --git a/src/non_modal_messagebox.h b/src/non_modal_messagebox.h
new file mode 100644
index 0000000..ab7505e
--- /dev/null
+++ b/src/non_modal_messagebox.h
@@ -0,0 +1,33 @@
+/**************************************************************************
+* Copyright (C) 2015 by Mihai Moldovan <ionic at ionic.de> *
+* *
+* 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 2 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 NON_MODAL_MESSAGEBOX_H
+#define NON_MODAL_MESSAGEBOX_H
+
+#include <QMessageBox>
+
+class Non_Modal_MessageBox {
+ public:
+ // Use this instead QMessageBox::critical for a non-modal variant.
+ // Caveat: this function does return immediately and will NOT return the clicked button.
+ static void critical (QWidget *parent, const QString &title,
+ const QString &text,
+ QMessageBox::StandardButtons buttons = QMessageBox::Ok,
+ QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
+
+};
+
+#endif /* !defined (NON_MODAL_MESSAGEBOX_H) */
diff --git a/src/onmainwindow.h b/src/onmainwindow.h
index 57ad65b..e1b68dc 100644
--- a/src/onmainwindow.h
+++ b/src/onmainwindow.h
@@ -42,7 +42,7 @@
#include <QToolBar>
#include <QSystemTrayIcon>
#include "sshmasterconnection.h"
-
+#include "non_modal_messagebox.h"
#ifdef Q_OS_WIN
diff --git a/x2goclient.pro b/x2goclient.pro
index e790d5e..d41b07e 100644
--- a/x2goclient.pro
+++ b/x2goclient.pro
@@ -75,7 +75,8 @@ HEADERS += src/configdialog.h \
src/helpdialog.h \
src/sessionexplorer.h \
src/folderbutton.h \
- src/folderexplorer.h
+ src/folderexplorer.h \
+ src/non_modal_messagebox.h
SOURCES += src/sharewidget.cpp \
src/settingswidget.cpp \
@@ -116,7 +117,8 @@ SOURCES += src/sharewidget.cpp \
src/helpdialog.cpp \
src/sessionexplorer.cpp \
src/folderbutton.cpp \
- src/folderexplorer.cpp
+ src/folderexplorer.cpp \
+ src/non_modal_messagebox.cpp
LIBS += -lssh
win32:LIBS += -lAdvAPI32 -lshell32 -lUser32
--
Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
More information about the x2go-commits
mailing list