Make message boxes more platform independent with a wrapper

Instead  of  using the  Qt  QMessageBox  class  directly a  new  class
MessageBox  (MessageBox.hpp)  has been  added  to  deal with  platform
independence issues like the title not being shown on Mac OS X.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6861 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Bill Somerville
2016-07-03 20:31:19 +00:00
parent d375f0c874
commit 3f1ea9d10c
17 changed files with 393 additions and 218 deletions
+33 -33
View File
@@ -11,7 +11,6 @@
#include <QNetworkReply>
#include <QTreeWidgetItem>
#include <QTreeWidgetItemIterator>
#include <QMessageBox>
#include <QJsonDocument>
#include <QJsonParseError>
#include <QJsonArray>
@@ -22,6 +21,7 @@
#include "DirectoryNode.hpp"
#include "FileNode.hpp"
#include "revision_utils.hpp"
#include "MessageBox.hpp"
#include "moc_Directory.cpp"
@@ -89,7 +89,7 @@ bool Directory::url_root (QUrl root)
void Directory::error (QString const& title, QString const& message)
{
QMessageBox::warning (this, title, message);
MessageBox::warning_message (this, title, message);
}
bool Directory::refresh ()
@@ -107,10 +107,10 @@ bool Directory::refresh ()
}
else
{
QMessageBox::warning (this
, tr ("URL Error")
, tr ("Invalid URL:\n\"%1\"")
.arg (url.toDisplayString ()));
MessageBox::warning_message (this
, tr ("URL Error")
, tr ("Invalid URL:\n\"%1\"")
.arg (url.toDisplayString ()));
}
return false;
}
@@ -126,16 +126,16 @@ void Directory::download_finished (bool success)
auto content = QJsonDocument::fromJson (contents.readAll (), &json_status);
if (json_status.error)
{
QMessageBox::warning (this
, tr ("JSON Error")
, tr ("Contents file syntax error %1 at character offset %2")
.arg (json_status.errorString ()).arg (json_status.offset));
MessageBox::warning_message (this
, tr ("JSON Error")
, tr ("Contents file syntax error %1 at character offset %2")
.arg (json_status.errorString ()).arg (json_status.offset));
return;
}
if (!content.isArray ())
{
QMessageBox::warning (this, tr ("JSON Error")
, tr ("Contents file top level must be a JSON array"));
MessageBox::warning_message (this, tr ("JSON Error")
, tr ("Contents file top level must be a JSON array"));
return;
}
QTreeWidgetItem * parent {invisibleRootItem ()};
@@ -146,11 +146,11 @@ void Directory::download_finished (bool success)
}
else
{
QMessageBox::warning (this, tr ("File System Error")
, tr ("Failed to open \"%1\"\nError: %2 - %3")
.arg (contents.fileName ())
.arg (contents.error ())
.arg (contents.errorString ()));
MessageBox::warning_message (this, tr ("File System Error")
, tr ("Failed to open \"%1\"\nError: %2 - %3")
.arg (contents.fileName ())
.arg (contents.error ())
.arg (contents.errorString ()));
}
}
}
@@ -183,10 +183,10 @@ void Directory::parse_entries (QJsonArray const& entries, QDir const& dir, QTree
}
else
{
QMessageBox::warning (this
, tr ("URL Error")
, tr ("Invalid URL:\n\"%1\"")
.arg (url.toDisplayString ()));
MessageBox::warning_message (this
, tr ("URL Error")
, tr ("Invalid URL:\n\"%1\"")
.arg (url.toDisplayString ()));
}
}
else if ("directory" == type)
@@ -202,34 +202,34 @@ void Directory::parse_entries (QJsonArray const& entries, QDir const& dir, QTree
}
else
{
QMessageBox::warning (this, tr ("JSON Error")
, tr ("Contents entries must be a JSON array"));
MessageBox::warning_message (this, tr ("JSON Error")
, tr ("Contents entries must be a JSON array"));
}
}
else
{
QMessageBox::warning (this, tr ("JSON Error")
, tr ("Contents entries must have a valid type"));
MessageBox::warning_message (this, tr ("JSON Error")
, tr ("Contents entries must have a valid type"));
}
}
else
{
QMessageBox::warning (this, tr ("JSON Error")
, tr ("Contents entries must have a valid name"));
MessageBox::warning_message (this, tr ("JSON Error")
, tr ("Contents entries must have a valid name"));
}
}
else
{
QMessageBox::warning (this, tr ("JSON Error")
, tr ("Contents entries must be JSON objects"));
MessageBox::warning_message (this, tr ("JSON Error")
, tr ("Contents entries must be JSON objects"));
}
}
}
else
{
QMessageBox::warning (this, tr ("JSON Error")
, tr ("Contents directories must be relative and within \"%1\"")
.arg (samples_dir_name));
MessageBox::warning_message (this, tr ("JSON Error")
, tr ("Contents directories must be relative and within \"%1\"")
.arg (samples_dir_name));
}
}
@@ -295,5 +295,5 @@ void Directory::update (QTreeWidgetItem * item)
void Directory::authentication (QNetworkReply * /* reply */
, QAuthenticator * /* authenticator */)
{
QMessageBox::warning (this, "Network Error", "Authentication required");
MessageBox::warning_message (this, tr ("Network Error"), tr ("Authentication required"));
}