#include <QClipboard>
#include <QApplication>
#include <QDesktopServices>
+#include <QLoggingCategory>
#include <QMessageBox>
using namespace OCC;
+Q_LOGGING_CATEGORY(lcUtility, "gui.utility", QtInfoMsg)
+
bool Utility::openBrowser(const QUrl &url, QWidget *errorWidgetParent)
{
- if (!QDesktopServices::openUrl(url) && errorWidgetParent) {
- QMessageBox::warning(
- errorWidgetParent,
- QCoreApplication::translate("utility", "Could not open browser"),
- QCoreApplication::translate("utility",
- "There was an error when launching the browser to go to "
- "URL %1. Maybe no default browser is configured?")
- .arg(url.toString()));
+ if (!QDesktopServices::openUrl(url)) {
+ if (errorWidgetParent) {
+ QMessageBox::warning(
+ errorWidgetParent,
+ QCoreApplication::translate("utility", "Could not open browser"),
+ QCoreApplication::translate("utility",
+ "There was an error when launching the browser to go to "
+ "URL %1. Maybe no default browser is configured?")
+ .arg(url.toString()));
+ }
+ qCWarning(lcUtility) << "QDesktopServices::openUrl failed for" << url;
return false;
}
return true;
url.setQueryItems({ { QLatin1String("subject"), subject },
{ QLatin1String("body"), body } });
- if (!QDesktopServices::openUrl(url) && errorWidgetParent) {
- QMessageBox::warning(
- errorWidgetParent,
- QCoreApplication::translate("utility", "Could not open email client"),
- QCoreApplication::translate("utility",
- "There was an error when launching the email client to "
- "create a new message. Maybe no default email client is "
- "configured?"));
+ if (!QDesktopServices::openUrl(url)) {
+ if (errorWidgetParent) {
+ QMessageBox::warning(
+ errorWidgetParent,
+ QCoreApplication::translate("utility", "Could not open email client"),
+ QCoreApplication::translate("utility",
+ "There was an error when launching the email client to "
+ "create a new message. Maybe no default email client is "
+ "configured?"));
+ }
+ qCWarning(lcUtility) << "QDesktopServices::openUrl failed for" << url;
return false;
}
return true;
void sendMessage(const QString &message, bool doWait = false) const
{
- qCInfo(lcSocketApi) << "Sending SocketAPI message: " << message << "to" << socket;
+ qCInfo(lcSocketApi) << "Sending SocketAPI message -->" << message << "to" << socket;
QString localMessage = message;
if (!localMessage.endsWith(QLatin1Char('\n'))) {
localMessage.append(QLatin1Char('\n'));
// make sure that the path will match, especially on OS X.
QString line = QString::fromUtf8(socket->readLine()).normalized(QString::NormalizationForm_C);
line.chop(1); // remove the '\n'
+ qCInfo(lcSocketApi) << "Received SocketAPI message <--" << line << "from" << socket;
QByteArray command = line.split(":").value(0).toAscii();
QByteArray functionWithArguments = "command_" + command + "(QString,SocketListener*)";
int indexOfMethod = staticMetaObject.indexOfMethod(functionWithArguments);
void SocketApi::command_RETRIEVE_FILE_STATUS(const QString &argument, SocketListener *listener)
{
- qCDebug(lcSocketApi) << argument;
-
QString statusString;
Folder *syncFolder = FolderMan::instance()->folderForPath(argument);
void SocketApi::command_SHARE(const QString &localFile, SocketListener *listener)
{
- qCDebug(lcSocketApi) << localFile;
-
auto theme = Theme::instance();
Folder *shareFolder = FolderMan::instance()->folderForPath(localFile);
void SocketApi::command_SHARE_STATUS(const QString &localFile, SocketListener *listener)
{
- qCDebug(lcSocketApi) << localFile;
-
Folder *shareFolder = FolderMan::instance()->folderForPath(localFile);
if (!shareFolder) {