mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2026-06-01 21:45:00 -04:00
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:
@@ -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"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user