summaryrefslogtreecommitdiffstats
path: root/src/gui/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/util')
-rw-r--r--src/gui/util/qcompleter.cpp2
-rw-r--r--src/gui/util/qdesktopservices_mac.cpp15
-rw-r--r--src/gui/util/qdesktopservices_win.cpp67
-rw-r--r--src/gui/util/qdesktopservices_x11.cpp4
-rw-r--r--src/gui/util/qsystemtrayicon.cpp10
-rw-r--r--src/gui/util/qsystemtrayicon_win.cpp14
6 files changed, 54 insertions, 58 deletions
diff --git a/src/gui/util/qcompleter.cpp b/src/gui/util/qcompleter.cpp
index 8410a69..aba0245 100644
--- a/src/gui/util/qcompleter.cpp
+++ b/src/gui/util/qcompleter.cpp
@@ -1667,7 +1667,7 @@ QStringList QCompleter::splitPath(const QString& path) const
doubleSlash.clear();
#endif
- QRegExp re(QLatin1String("[") + QRegExp::escape(sep) + QLatin1String("]"));
+ QRegExp re(QLatin1Char('[') + QRegExp::escape(sep) + QLatin1Char(']'));
QStringList parts = pathCopy.split(re);
#if defined(Q_OS_SYMBIAN)
diff --git a/src/gui/util/qdesktopservices_mac.cpp b/src/gui/util/qdesktopservices_mac.cpp
index 5124068..4f730b7 100644
--- a/src/gui/util/qdesktopservices_mac.cpp
+++ b/src/gui/util/qdesktopservices_mac.cpp
@@ -96,7 +96,7 @@ OSType translateLocation(QDesktopServices::StandardLocation type)
static bool lsOpen(const QUrl &url)
{
- if (!url.isValid())
+ if (!url.isValid() || url.scheme().isEmpty())
return false;
QCFType<CFURLRef> cfUrl = CFURLCreateWithString(0, QCFString(QString::fromLatin1(url.toEncoded())), 0);
@@ -134,13 +134,15 @@ static QString getFullPath(const FSRef &ref)
QString QDesktopServices::storageLocation(StandardLocation type)
{
- if (QDesktopServices::HomeLocation == type)
+ if (type == HomeLocation)
return QDir::homePath();
+ if (type == TempLocation)
+ return QDir::tempPath();
+
short domain = kOnAppropriateDisk;
- if (QDesktopServices::DataLocation == type
- || QDesktopServices::CacheLocation == type)
+ if (type == DataLocation || type == CacheLocation)
domain = kUserDomain;
// http://developer.apple.com/documentation/Carbon/Reference/Folder_Manager/Reference/reference.html
@@ -152,9 +154,8 @@ QString QDesktopServices::storageLocation(StandardLocation type)
QString path = getFullPath(ref);
QString appName = QCoreApplication::applicationName();
- if (!appName.isEmpty() &&
- (QDesktopServices::DataLocation == type || QDesktopServices::CacheLocation == type))
- path += QLatin1String("/") + appName;
+ if (!appName.isEmpty() && (type == DataLocation || type == CacheLocation))
+ path += QLatin1Char('/') + appName;
return path;
}
diff --git a/src/gui/util/qdesktopservices_win.cpp b/src/gui/util/qdesktopservices_win.cpp
index 0449cba..a8aa11c 100644
--- a/src/gui/util/qdesktopservices_win.cpp
+++ b/src/gui/util/qdesktopservices_win.cpp
@@ -98,32 +98,35 @@ static bool launchWebBrowser(const QUrl &url)
{
if (url.scheme() == QLatin1String("mailto")) {
//Retrieve the commandline for the default mail client
- //the key used below is the command line for the mailto: shell command
+ //the default key used below is the command line for the mailto: shell command
DWORD bufferSize = 2 * MAX_PATH;
long returnValue = -1;
QString command;
HKEY handle;
LONG res;
- QT_WA ({
- res = RegOpenKeyExW(HKEY_CLASSES_ROOT, L"mailto\\Shell\\Open\\Command", 0, KEY_READ, &handle);
- if (res != ERROR_SUCCESS)
- return false;
-
- wchar_t keyValue[2 * MAX_PATH] = {0};
- returnValue = RegQueryValueExW(handle, L"", 0, 0, reinterpret_cast<unsigned char*>(keyValue), &bufferSize);
- if (!returnValue)
- command = QString::fromRawData((QChar*)keyValue, bufferSize);
- }, {
- res = RegOpenKeyExA(HKEY_CLASSES_ROOT, "mailto\\Shell\\Open\\Command", 0, KEY_READ, &handle);
- if (res != ERROR_SUCCESS)
- return false;
-
- char keyValue[2 * MAX_PATH] = {0};
- returnValue = RegQueryValueExA(handle, "", 0, 0, reinterpret_cast<unsigned char*>(keyValue), &bufferSize);
+ wchar_t keyValue[2 * MAX_PATH] = {0};
+ QString keyName(QLatin1String("mailto"));
+
+ //Check if user has set preference, otherwise use default.
+ res = RegOpenKeyExW(HKEY_CURRENT_USER,
+ L"Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\mailto\\UserChoice",
+ 0, KEY_READ, &handle);
+ if (res == ERROR_SUCCESS) {
+ returnValue = RegQueryValueEx(handle, L"Progid", 0, 0, reinterpret_cast<unsigned char*>(keyValue), &bufferSize);
if (!returnValue)
- command = QString::fromLocal8Bit(keyValue);
- });
+ keyName = QString::fromUtf16((const ushort*)keyValue);
+ RegCloseKey(handle);
+ }
+ keyName += QLatin1String("\\Shell\\Open\\Command");
+ res = RegOpenKeyExW(HKEY_CLASSES_ROOT, (const wchar_t*)keyName.utf16(), 0, KEY_READ, &handle);
+ if (res != ERROR_SUCCESS)
+ return false;
+
+ bufferSize = 2 * MAX_PATH;
+ returnValue = RegQueryValueExW(handle, L"", 0, 0, reinterpret_cast<unsigned char*>(keyValue), &bufferSize);
+ if (!returnValue)
+ command = QString::fromRawData((QChar*)keyValue, bufferSize);
RegCloseKey(handle);
if(returnValue)
@@ -145,19 +148,11 @@ static bool launchWebBrowser(const QUrl &url)
//start the process
PROCESS_INFORMATION pi;
ZeroMemory(&pi, sizeof(pi));
- QT_WA ({
- STARTUPINFO si;
- ZeroMemory(&si, sizeof(si));
- si.cb = sizeof(si);
-
- returnValue = CreateProcess(NULL, (TCHAR*)command.utf16(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
- }, {
- STARTUPINFOA si;
- ZeroMemory(&si, sizeof(si));
- si.cb = sizeof(si);
+ STARTUPINFO si;
+ ZeroMemory(&si, sizeof(si));
+ si.cb = sizeof(si);
- returnValue = CreateProcessA(NULL, command.toLocal8Bit().data(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
- });
+ returnValue = CreateProcess(NULL, (TCHAR*)command.utf16(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
if (!returnValue)
return false;
@@ -170,12 +165,12 @@ static bool launchWebBrowser(const QUrl &url)
if (!url.isValid())
return false;
+ if (url.scheme().isEmpty())
+ return openDocument(url);
+
quintptr returnValue;
- QT_WA ({
- returnValue = (quintptr)ShellExecute(0, 0, (TCHAR *) QString::fromUtf8(url.toEncoded().constData()).utf16(), 0, 0, SW_SHOWNORMAL);
- } , {
- returnValue = (quintptr)ShellExecuteA(0, 0, url.toEncoded().constData(), 0, 0, SW_SHOWNORMAL);
- });
+ returnValue = (quintptr)ShellExecute(0, 0, (TCHAR *) QString::fromUtf8(url.toEncoded().constData()).utf16(),
+ 0, 0, SW_SHOWNORMAL);
return (returnValue > 32);
}
diff --git a/src/gui/util/qdesktopservices_x11.cpp b/src/gui/util/qdesktopservices_x11.cpp
index b3486e8..8c4a597 100644
--- a/src/gui/util/qdesktopservices_x11.cpp
+++ b/src/gui/util/qdesktopservices_x11.cpp
@@ -164,8 +164,8 @@ QString QDesktopServices::storageLocation(StandardLocation type)
QString key = lst.at(1);
QString value = lst.at(2);
if (value.length() > 2
- && value.startsWith(QLatin1String("\""))
- && value.endsWith(QLatin1String("\"")))
+ && value.startsWith(QLatin1Char('\"'))
+ && value.endsWith(QLatin1Char('\"')))
value = value.mid(1, value.length() - 2);
// Store the key and value: "DESKTOP", "$HOME/Desktop"
lines[key] = value;
diff --git a/src/gui/util/qsystemtrayicon.cpp b/src/gui/util/qsystemtrayicon.cpp
index 2e072c5..bfafe44 100644
--- a/src/gui/util/qsystemtrayicon.cpp
+++ b/src/gui/util/qsystemtrayicon.cpp
@@ -434,13 +434,13 @@ QBalloonTip::QBalloonTip(QSystemTrayIcon::MessageIcon icon, const QString& title
titleLabel->setText(title);
QFont f = titleLabel->font();
f.setBold(true);
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
f.setPointSize(f.pointSize() - 2);
#endif
titleLabel->setFont(f);
titleLabel->setTextFormat(Qt::PlainText); // to maintain compat with windows
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
const int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize);
const int closeButtonSize = style()->pixelMetric(QStyle::PM_SmallIconSize) - 2;
#else
@@ -456,7 +456,7 @@ QBalloonTip::QBalloonTip(QSystemTrayIcon::MessageIcon icon, const QString& title
QObject::connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
QLabel *msgLabel = new QLabel;
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
f.setBold(false);
msgLabel->setFont(f);
#endif
@@ -466,7 +466,7 @@ QBalloonTip::QBalloonTip(QSystemTrayIcon::MessageIcon icon, const QString& title
msgLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);
// smart size for the message label
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
int limit = QApplication::desktop()->availableGeometry(msgLabel).size().width() / 2;
#else
int limit = QApplication::desktop()->availableGeometry(msgLabel).size().width() / 3;
@@ -481,7 +481,7 @@ QBalloonTip::QBalloonTip(QSystemTrayIcon::MessageIcon icon, const QString& title
control->document()->setDefaultTextOption(opt);
}
}
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
// Make sure that the text isn't wrapped "somewhere" in the balloon widget
// in the case that we have a long title label.
setMaximumWidth(limit);
diff --git a/src/gui/util/qsystemtrayicon_win.cpp b/src/gui/util/qsystemtrayicon_win.cpp
index 84f9de4..f79f135 100644
--- a/src/gui/util/qsystemtrayicon_win.cpp
+++ b/src/gui/util/qsystemtrayicon_win.cpp
@@ -62,13 +62,13 @@
#include <QDesktopWidget>
#include <QSettings>
-#if defined(Q_OS_WINCE) && !defined(STANDARDSHELL_UI_MODEL)
+#if defined(Q_WS_WINCE) && !defined(STANDARDSHELL_UI_MODEL)
# include <streams.h>
#endif
QT_BEGIN_NAMESPACE
-#if defined(Q_OS_WINCE)
+#if defined(Q_WS_WINCE)
static const UINT q_uNOTIFYICONID = 13; // IDs from 0 to 12 are reserved on WinCE.
#else
static const UINT q_uNOTIFYICONID = 0;
@@ -331,7 +331,7 @@ bool QSystemTrayIconSys::showMessageA(const QString &title, const QString &messa
bool QSystemTrayIconSys::trayMessageA(DWORD msg)
{
-#if !defined(Q_OS_WINCE)
+#if !defined(Q_WS_WINCE)
NOTIFYICONDATAA tnd;
memset(&tnd, 0, notifyIconSizeA);
tnd.uID = q_uNOTIFYICONID;
@@ -462,7 +462,7 @@ bool QSystemTrayIconSys::winEvent( MSG *m, long *result )
emit q->activated(QSystemTrayIcon::Trigger);
break;
-#if !defined(Q_OS_WINCE)
+#if !defined(Q_WS_WINCE)
case WM_LBUTTONDBLCLK:
emit q->activated(QSystemTrayIcon::DoubleClick);
break;
@@ -518,7 +518,7 @@ void QSystemTrayIconPrivate::install_sys()
QRect QSystemTrayIconSys::findTrayGeometry()
{
//Use lower right corner as fallback
- QPoint brCorner = qApp->desktop()->screenGeometry().bottomRight();
+ QPoint brCorner = QApplication::desktop()->screenGeometry().bottomRight();
QRect ret(brCorner.x() - 10, brCorner.y() - 10, 10, 10);
#if defined(Q_OS_WINCE)
HWND trayHandle = FindWindowW(L"Shell_TrayWnd", NULL);
@@ -662,7 +662,7 @@ void QSystemTrayIconPrivate::showMessage_sys(const QString &title, const QString
//message is limited to 255 chars + NULL
QString messageString;
if (message.isEmpty() && !title.isEmpty())
- messageString = QLatin1String(" "); //ensures that the message shows when only title is set
+ messageString = QLatin1Char(' '); //ensures that the message shows when only title is set
else
messageString = message.left(255) + QChar();
@@ -726,7 +726,7 @@ void QSystemTrayIconPrivate::updateMenu_sys()
void QSystemTrayIconPrivate::updateToolTip_sys()
{
-#ifdef Q_OS_WINCE
+#ifdef Q_WS_WINCE
// Calling sys->trayMessage(NIM_MODIFY) on an existing icon is broken on Windows CE.
// So we need to call updateIcon_sys() which creates a new icon handle.
updateIcon_sys();