Changeset 561 for trunk/src/gui/util


Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
23 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/util/qcompleter.cpp

    r172 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    159159QCompletionModel::QCompletionModel(QCompleterPrivate *c, QObject *parent)
    160160    : QAbstractProxyModel(*new QCompletionModelPrivate, parent),
    161       c(c), engine(0), showAll(false)
     161      c(c), showAll(false)
    162162{
    163163    createEngine();
     
    209209    }
    210210
    211     delete engine;
    212211    if (sortedEngine)
    213         engine = new QSortedModelEngine(c);
     212        engine.reset(new QSortedModelEngine(c));
    214213    else
    215         engine = new QUnsortedModelEngine(c);
     214        engine.reset(new QUnsortedModelEngine(c));
    216215}
    217216
     
    483482        QString str = source->index(i, c->column).data().toString();
    484483        if (str.startsWith(c->prefix, c->cs)
    485 #if !defined(Q_OS_OS2) && (!defined(Q_OS_WIN) || defined(Q_OS_WINCE))
     484#if (!defined(Q_OS_WIN) || defined(Q_OS_WINCE)) && !defined(Q_OS_SYMBIAN) && !defined(Q_OS_OS2)
    486485            && (!dirModel || QDir::toNativeSeparators(str) != QDir::separator())
    487486#endif
     
    773772QCompleterPrivate::QCompleterPrivate()
    774773: widget(0), proxy(0), popup(0), cs(Qt::CaseSensitive), role(Qt::EditRole), column(0),
    775   sorting(QCompleter::UnsortedModel), wrap(true), eatFocusOut(true)
     774  maxVisibleItems(7), sorting(QCompleter::UnsortedModel), wrap(true), eatFocusOut(true)
    776775{
    777776}
     
    825824    QString completion;
    826825
    827     if (!index.isValid() || (index.row() >= proxy->engine->matchCount())) {
     826    if (!index.isValid() || (!proxy->showAll && (index.row() >= proxy->engine->matchCount()))) {
    828827        completion = prefix;
    829828    } else {
     829        if (!(index.flags() & Qt::ItemIsEnabled))
     830            return;
    830831        QModelIndex si = proxy->mapToSource(index);
    831832        si = si.sibling(si.row(), column); // for clicked()
     
    862863    QPoint pos;
    863864    int rw, rh, w;
    864     int h = (popup->sizeHintForRow(0) * qMin(7, popup->model()->rowCount()) + 3) + 3;
     865    int h = (popup->sizeHintForRow(0) * qMin(maxVisibleItems, popup->model()->rowCount()) + 3) + 3;
    865866    QScrollBar *hsb = popup->horizontalScrollBar();
    866867    if (hsb && hsb->isVisible())
     
    988989#ifndef QT_NO_DIRMODEL
    989990    if (qobject_cast<QDirModel *>(model)) {
    990 #if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_OS2)
     991#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN) || defined(Q_OS_OS2)
    991992        setCaseSensitivity(Qt::CaseInsensitive);
    992993#else
     
    10781079    if (popup->model() != d->proxy)
    10791080        popup->setModel(d->proxy);
    1080     popup->hide();
    1081     popup->setParent(0, Qt::Popup);
    1082 
    1083     Qt::FocusPolicy origPolicy;
     1081#ifdef Q_OS_MAC
     1082     popup->show();
     1083#else
     1084     popup->hide();
     1085#endif
     1086
     1087    Qt::FocusPolicy origPolicy = Qt::NoFocus;
    10841088    if (d->widget)
    10851089        origPolicy = d->widget->focusPolicy();
     1090    popup->setParent(0, Qt::Popup);
    10861091    popup->setFocusPolicy(Qt::NoFocus);
    10871092    if (d->widget)
     
    10991104    QObject::connect(popup, SIGNAL(clicked(QModelIndex)),
    11001105                     this, SLOT(_q_complete(QModelIndex)));
    1101     QObject::connect(popup, SIGNAL(clicked(QModelIndex)), popup, SLOT(hide()));
     1106    QObject::connect(this, SIGNAL(activated(QModelIndex)),
     1107                     popup, SLOT(hide()));
    11021108
    11031109    QObject::connect(popup->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
     
    11791185            if (!curIndex.isValid()) {
    11801186                int rowCount = d->proxy->rowCount();
    1181                 QModelIndex lastIndex = d->proxy->index(rowCount - 1, 0);
     1187                QModelIndex lastIndex = d->proxy->index(rowCount - 1, d->column);
    11821188                d->setCurrentIndex(lastIndex);
    11831189                return true;
     
    11911197        case Qt::Key_Down:
    11921198            if (!curIndex.isValid()) {
    1193                 QModelIndex firstIndex = d->proxy->index(0, 0);
     1199                QModelIndex firstIndex = d->proxy->index(0, d->column);
    11941200                d->setCurrentIndex(firstIndex);
    11951201                return true;
     
    15071513
    15081514/*!
     1515    \property QCompleter::maxVisibleItems
     1516    \brief the maximum allowed size on screen of the completer, measured in items
     1517    \since 4.6
     1518
     1519    By default, this property has a value of 7.
     1520*/
     1521int QCompleter::maxVisibleItems() const
     1522{
     1523    Q_D(const QCompleter);
     1524    return d->maxVisibleItems;
     1525}
     1526
     1527void QCompleter::setMaxVisibleItems(int maxItems)
     1528{
     1529    Q_D(QCompleter);
     1530    if (maxItems < 0) {
     1531        qWarning("QCompleter::setMaxVisibleItems: "
     1532                 "Invalid max visible items (%d) must be >= 0", maxItems);
     1533        return;
     1534    }
     1535    d->maxVisibleItems = maxItems;
     1536}
     1537
     1538/*!
    15091539    \property QCompleter::caseSensitivity
    15101540    \brief the case sensitivity of the matching
     
    15781608    that contains all the possible matches for the current completion prefix.
    15791609    The completion model is auto-updated to reflect the current completions.
     1610
     1611    \note The return value of this function is defined to be an QAbstractItemModel
     1612    purely for generality. This actual kind of model returned is an instance of an
     1613    QAbstractProxyModel subclass.
    15801614
    15811615    \sa completionPrefix, model()
     
    16211655    } while (idx.isValid());
    16221656
    1623 #if !defined(Q_OS_OS2) && (!defined(Q_OS_WIN) || defined(Q_OS_WINCE))
     1657#if (!defined(Q_OS_WIN) || defined(Q_OS_WINCE)) && !defined(Q_OS_SYMBIAN) && !defined(Q_OS_OS2)
    16241658    if (list.count() == 1) // only the separator or some other text
    16251659        return list[0];
     
    16551689    QString pathCopy = QDir::toNativeSeparators(path);
    16561690    QString sep = QDir::separator();
    1657 #if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_OS2)
     1691#if defined(Q_OS_SYMBIAN)
     1692    if (pathCopy == QLatin1String("\\"))
     1693        return QStringList(pathCopy);
     1694#elif (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_OS2)
    16581695    if (pathCopy == QLatin1String("\\") || pathCopy == QLatin1String("\\\\"))
    16591696        return QStringList(pathCopy);
     
    16651702#endif
    16661703
    1667     QRegExp re(QLatin1String("[") + QRegExp::escape(sep) + QLatin1String("]"));
     1704    QRegExp re(QLatin1Char('[') + QRegExp::escape(sep) + QLatin1Char(']'));
    16681705    QStringList parts = pathCopy.split(re);
    16691706
    1670 #if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_OS2)
     1707#if defined(Q_OS_SYMBIAN)
     1708    // Do nothing
     1709#elif (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_OS2)
    16711710    if (!doubleSlash.isEmpty())
    16721711        parts[0].prepend(doubleSlash);
  • trunk/src/gui/util/qcompleter.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    7070    Q_PROPERTY(int completionColumn READ completionColumn WRITE setCompletionColumn)
    7171    Q_PROPERTY(int completionRole READ completionRole WRITE setCompletionRole)
     72    Q_PROPERTY(int maxVisibleItems READ maxVisibleItems WRITE setMaxVisibleItems)
    7273    Q_PROPERTY(Qt::CaseSensitivity caseSensitivity READ caseSensitivity WRITE setCaseSensitivity)
    7374    Q_PROPERTY(bool wrapAround READ wrapAround WRITE setWrapAround)
     
    119120    bool wrapAround() const;
    120121
     122    int maxVisibleItems() const;
     123    void setMaxVisibleItems(int maxItems);
     124
    121125    int completionCount() const;
    122126    bool setCurrentRow(int row);
  • trunk/src/gui/util/qcompleter_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    8888    int role;
    8989    int column;
     90    int maxVisibleItems;
    9091    QCompleter::ModelSorting sorting;
    9192    bool wrap;
     
    214215public:
    215216    QCompletionModel(QCompleterPrivate *c, QObject *parent);
    216     ~QCompletionModel() { delete engine; }
    217217
    218218    void createEngine();
     
    237237
    238238    QCompleterPrivate *c;
    239     QCompletionEngine *engine;
     239    QScopedPointer<QCompletionEngine> engine;
    240240    bool showAll;
    241241
  • trunk/src/gui/util/qdesktopservices.cpp

    r132 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5656#elif defined(Q_WS_MAC)
    5757#include "qdesktopservices_mac.cpp"
     58#elif defined(Q_OS_SYMBIAN)
     59#include "qdesktopservices_s60.cpp"
    5860#endif
    5961
     
    289291    may need to be created by the system or the user.
    290292
    291     \note On Mac OS X, DataLocation does not include QCoreApplication::organizationName.
    292     Use code like this to add it:
    293 
    294     \code
    295     QString location = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
    296     #ifdef Q_WS_MAC
    297         location.insert(location.count() - QCoreApplication::applicationName().count(),
    298             QCoreApplication::organizationName() + "/");
    299     #endif
    300     \endcode
     293    \note On Symbian OS, ApplicationsLocation always point /sys/bin folder on the same drive
     294    with executable. FontsLocation always points to folder on ROM drive. Symbian OS does not
     295    have desktop concept, DesktopLocation returns same path as DocumentsLocation.
     296    Rest of the standard locations point to folder on same drive with executable, except
     297    that if executable is in ROM the folder from C drive is returned.
    301298*/
    302299
  • trunk/src/gui/util/qdesktopservices.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/gui/util/qdesktopservices_mac.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    9797static bool lsOpen(const QUrl &url)
    9898{
    99     if (!url.isValid())
     99    if (!url.isValid() || url.scheme().isEmpty())
    100100        return false;
    101101
     
    135135QString QDesktopServices::storageLocation(StandardLocation type)
    136136{
    137      if (QDesktopServices::HomeLocation == type)
     137     if (type == HomeLocation)
    138138        return QDir::homePath();
     139
     140     if (type == TempLocation)
     141         return QDir::tempPath();
    139142
    140143    short domain = kOnAppropriateDisk;
    141144
    142     if (QDesktopServices::DataLocation == type
    143         || QDesktopServices::CacheLocation == type)
     145    if (type == DataLocation || type == CacheLocation)
    144146        domain = kUserDomain;
    145147
     
    152154    QString path = getFullPath(ref);
    153155
    154     QString appName = QCoreApplication::applicationName();
    155     if (!appName.isEmpty() &&
    156         (QDesktopServices::DataLocation == type || QDesktopServices::CacheLocation == type))
    157         path += QLatin1String("/") + appName;
     156    if (type == DataLocation || type == CacheLocation) {
     157        if (QCoreApplication::organizationName().isEmpty() == false)
     158            path += QLatin1Char('/') + QCoreApplication::organizationName();
     159        if (QCoreApplication::applicationName().isEmpty() == false)
     160            path += QLatin1Char('/') + QCoreApplication::applicationName();
     161    }
    158162
    159163    return path;
  • trunk/src/gui/util/qdesktopservices_win.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4242#include <qsettings.h>
    4343#include <qdir.h>
     44#include <qlibrary.h>
    4445#include <qurl.h>
    4546#include <qstringlist.h>
     
    4849#include <qcoreapplication.h>
    4950
    50 #include <windows.h>
     51#include <qt_windows.h>
    5152#include <shlobj.h>
    5253#if !defined(Q_OS_WINCE)
     
    5960#endif
    6061
     62#if defined(Q_CC_MINGW) && !defined(CSIDL_MYMUSIC)
     63#define CSIDL_MYMUSIC   13
     64#define CSIDL_MYVIDEO   14
     65#endif
     66
    6167#ifndef QT_NO_DESKTOPSERVICES
    6268
    6369QT_BEGIN_NAMESPACE
    64 
    65 //#undef UNICODE
    6670
    6771static bool openDocument(const QUrl &file)
     
    6973    if (!file.isValid())
    7074        return false;
    71 
    72     quintptr returnValue;
    73     QT_WA({
    74                 returnValue = (quintptr)ShellExecute(0, 0, (TCHAR *)file.toString().utf16(), 0, 0, SW_SHOWNORMAL);
    75             } , {
    76                 returnValue = (quintptr)ShellExecuteA(0, 0, file.toString().toLocal8Bit().constData(), 0, 0, SW_SHOWNORMAL);
    77             });
     75    QString filePath = file.toLocalFile();
     76    if (filePath.isEmpty())
     77        filePath = file.toString();
     78    quintptr returnValue = (quintptr)ShellExecute(0, 0, (wchar_t*)filePath.utf16(), 0, 0, SW_SHOWNORMAL);
    7879    return (returnValue > 32); //ShellExecute returns a value greater than 32 if successful
    7980}
     
    8182static QString expandEnvStrings(const QString &command)
    8283{
    83 
    8484#if defined(Q_OS_WINCE)
    8585    return command;
    8686#else
    87     QByteArray path = command.toLocal8Bit();
    88     char commandValue[2 * MAX_PATH] = {0};
    89     DWORD returnValue = ExpandEnvironmentStringsA(path.data(), commandValue, MAX_PATH);
    90     if (returnValue)
    91         return QString::fromLocal8Bit(commandValue);
     87    wchar_t buffer[MAX_PATH];
     88    if (ExpandEnvironmentStrings((wchar_t*)command.utf16(), buffer, MAX_PATH))
     89        return QString::fromWCharArray(buffer);
    9290    else
    9391        return command;
     
    9997    if (url.scheme() == QLatin1String("mailto")) {
    10098        //Retrieve the commandline for the default mail client
    101         //the key used below is the command line for the mailto: shell command
     99        //the default key used below is the command line for the mailto: shell command
    102100        DWORD  bufferSize = 2 * MAX_PATH;
    103101        long  returnValue =  -1;
     
    106104        HKEY handle;
    107105        LONG res;
    108         QT_WA ({
    109             res = RegOpenKeyExW(HKEY_CLASSES_ROOT, L"mailto\\Shell\\Open\\Command", 0, KEY_READ, &handle);
    110             if (res != ERROR_SUCCESS)
    111                 return false;
    112 
    113             wchar_t keyValue[2 * MAX_PATH] = {0};
    114             returnValue = RegQueryValueExW(handle, L"", 0, 0, reinterpret_cast<unsigned char*>(keyValue), &bufferSize);
     106        wchar_t keyValue[2 * MAX_PATH] = {0};
     107        QString keyName(QLatin1String("mailto"));
     108
     109        //Check if user has set preference, otherwise use default.
     110        res = RegOpenKeyExW(HKEY_CURRENT_USER,
     111                            L"Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\mailto\\UserChoice",
     112                            0, KEY_READ, &handle);
     113        if (res == ERROR_SUCCESS) {
     114            returnValue = RegQueryValueEx(handle, L"Progid", 0, 0, reinterpret_cast<unsigned char*>(keyValue), &bufferSize);
    115115            if (!returnValue)
    116                 command = QString::fromRawData((QChar*)keyValue, bufferSize);
    117         }, {
    118             res = RegOpenKeyExA(HKEY_CLASSES_ROOT, "mailto\\Shell\\Open\\Command", 0, KEY_READ, &handle);
    119             if (res != ERROR_SUCCESS)
    120                 return false;
    121 
    122             char keyValue[2 * MAX_PATH] = {0};
    123             returnValue = RegQueryValueExA(handle, "", 0, 0, reinterpret_cast<unsigned char*>(keyValue), &bufferSize);
    124             if (!returnValue)
    125                 command = QString::fromLocal8Bit(keyValue);
    126         });
     116                keyName = QString::fromUtf16((const ushort*)keyValue);
     117            RegCloseKey(handle);
     118        }
     119        keyName += QLatin1String("\\Shell\\Open\\Command");
     120        res = RegOpenKeyExW(HKEY_CLASSES_ROOT, (const wchar_t*)keyName.utf16(), 0, KEY_READ, &handle);
     121        if (res != ERROR_SUCCESS)
     122            return false;
     123
     124        bufferSize = 2 * MAX_PATH;
     125        returnValue = RegQueryValueExW(handle, L"", 0, 0, reinterpret_cast<unsigned char*>(keyValue), &bufferSize);
     126        if (!returnValue)
     127            command = QString::fromRawData((QChar*)keyValue, bufferSize);
    127128        RegCloseKey(handle);
    128129
    129         if(returnValue)
     130        if (returnValue)
    130131            return false;
     132
    131133        command = expandEnvStrings(command);
    132134        command = command.trimmed();
     
    146148        PROCESS_INFORMATION pi;
    147149        ZeroMemory(&pi, sizeof(pi));
    148         QT_WA ({
    149             STARTUPINFO si;
    150             ZeroMemory(&si, sizeof(si));
    151             si.cb = sizeof(si);
    152 
    153             returnValue = CreateProcess(NULL, (TCHAR*)command.utf16(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
    154         }, {
    155             STARTUPINFOA si;
    156             ZeroMemory(&si, sizeof(si));
    157             si.cb = sizeof(si);
    158 
    159             returnValue = CreateProcessA(NULL, command.toLocal8Bit().data(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
    160         });
     150        STARTUPINFO si;
     151        ZeroMemory(&si, sizeof(si));
     152        si.cb = sizeof(si);
     153
     154        returnValue = CreateProcess(NULL, (wchar_t*)command.utf16(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
    161155
    162156        if (!returnValue)
     
    171165        return false;
    172166
    173     quintptr returnValue;
    174      QT_WA ({
    175          returnValue = (quintptr)ShellExecute(0, 0, (TCHAR *) QString::fromUtf8(url.toEncoded().constData()).utf16(), 0, 0, SW_SHOWNORMAL);
    176             } , {
    177                 returnValue = (quintptr)ShellExecuteA(0, 0, url.toEncoded().constData(), 0, 0, SW_SHOWNORMAL);
    178             });
     167    if (url.scheme().isEmpty())
     168        return openDocument(url);
     169
     170    quintptr returnValue = (quintptr)ShellExecute(0, 0, (wchar_t *)QString::fromUtf8(url.toEncoded().constData()).utf16(),
     171                                                  0, 0, SW_SHOWNORMAL);
    179172    return (returnValue > 32);
    180173}
     
    182175QString QDesktopServices::storageLocation(StandardLocation type)
    183176{
    184 #if !defined(QT_NO_SETTINGS)   
    185     QSettings settings(QSettings::UserScope, QLatin1String("Microsoft"), QLatin1String("Windows"));
    186     settings.beginGroup(QLatin1String("CurrentVersion/Explorer/Shell Folders"));
     177    QString result;
     178
     179#ifndef Q_OS_WINCE
     180        QLibrary library(QLatin1String("shell32"));
     181#else
     182        QLibrary library(QLatin1String("coredll"));
     183#endif // Q_OS_WINCE
     184    typedef BOOL (WINAPI*GetSpecialFolderPath)(HWND, LPWSTR, int, BOOL);
     185    static GetSpecialFolderPath SHGetSpecialFolderPath =
     186            (GetSpecialFolderPath)library.resolve("SHGetSpecialFolderPathW");
     187    if (!SHGetSpecialFolderPath)
     188        return QString();
     189
     190    wchar_t path[MAX_PATH];
     191
    187192    switch (type) {
     193    case DataLocation:
     194#if defined Q_WS_WINCE
     195        if (SHGetSpecialFolderPath(0, path, CSIDL_APPDATA, FALSE))
     196#else
     197        if (SHGetSpecialFolderPath(0, path, CSIDL_LOCAL_APPDATA, FALSE))
     198#endif
     199            result = QString::fromWCharArray(path);
     200        if (!QCoreApplication::organizationName().isEmpty())
     201            result = result + QLatin1String("\\") + QCoreApplication::organizationName();
     202        if (!QCoreApplication::applicationName().isEmpty())
     203            result = result + QLatin1String("\\") + QCoreApplication::applicationName();
     204        break;
     205
     206    case DesktopLocation:
     207        if (SHGetSpecialFolderPath(0, path, CSIDL_DESKTOPDIRECTORY, FALSE))
     208            result = QString::fromWCharArray(path);
     209        break;
     210
     211    case DocumentsLocation:
     212        if (SHGetSpecialFolderPath(0, path, CSIDL_PERSONAL, FALSE))
     213            result = QString::fromWCharArray(path);
     214        break;
     215
     216    case FontsLocation:
     217        if (SHGetSpecialFolderPath(0, path, CSIDL_FONTS, FALSE))
     218            result = QString::fromWCharArray(path);
     219        break;
     220
     221    case ApplicationsLocation:
     222        if (SHGetSpecialFolderPath(0, path, CSIDL_PROGRAMS, FALSE))
     223            result = QString::fromWCharArray(path);
     224        break;
     225
     226    case MusicLocation:
     227        if (SHGetSpecialFolderPath(0, path, CSIDL_MYMUSIC, FALSE))
     228            result = QString::fromWCharArray(path);
     229        break;
     230
     231    case MoviesLocation:
     232        if (SHGetSpecialFolderPath(0, path, CSIDL_MYVIDEO, FALSE))
     233            result = QString::fromWCharArray(path);
     234        break;
     235
     236    case PicturesLocation:
     237        if (SHGetSpecialFolderPath(0, path, CSIDL_MYPICTURES, FALSE))
     238            result = QString::fromWCharArray(path);
     239        break;
     240
    188241    case CacheLocation:
    189242        // Although Microsoft has a Cache key it is a pointer to IE's cache, not a cache
     
    191244        // cache directory located in their AppData directory
    192245        return storageLocation(DataLocation) + QLatin1String("\\cache");
    193     case DataLocation:
    194         if (!settings.contains(QLatin1String("Local AppData")))
    195             break;
    196         return settings.value(QLatin1String("Local AppData")).toString()
    197             + QLatin1String("\\") + QCoreApplication::organizationName()
    198             + QLatin1String("\\") + QCoreApplication::applicationName();
    199         break;
    200     case DesktopLocation:
    201         return settings.value(QLatin1String("Desktop")).toString();
    202         break;
    203 
    204     case DocumentsLocation:
    205         return settings.value(QLatin1String("Personal")).toString();
    206         break;
    207 
    208     case FontsLocation:
    209         return settings.value(QLatin1String("Fonts")).toString();
    210         break;
    211 
    212     case ApplicationsLocation:
    213         return settings.value(QLatin1String("Programs")).toString();
    214         break;
    215 
    216     case MusicLocation:
    217         return settings.value(QLatin1String("My Music")).toString();
    218         break;
    219 
    220     case MoviesLocation:
    221         return settings.value(QLatin1String("My Video")).toString();
    222         break;
    223 
    224     case PicturesLocation:
    225         return settings.value(QLatin1String("My Pictures")).toString();
    226         break;
    227246
    228247    case QDesktopServices::HomeLocation:
     
    235254        break;
    236255    }
    237 #endif
    238     return QString();
     256    return result;
    239257}
    240258
  • trunk/src/gui/util/qdesktopservices_x11.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5757inline static bool launch(const QUrl &url, const QString &client)
    5858{
     59#if !defined(QT_NO_PROCESS)
    5960    return (QProcess::startDetached(client + QLatin1Char(' ') + QString::fromLatin1(url.toEncoded().constData())));
     61#else
     62    return (::system((client + QLatin1Char(' ') + QString::fromLatin1(url.toEncoded().constData())).toLocal8Bit().constData()) != -1);
     63#endif
    6064}
    6165
     
    165169                QString value = lst.at(2);
    166170                if (value.length() > 2
    167                     && value.startsWith(QLatin1String("\""))
    168                     && value.endsWith(QLatin1String("\"")))
     171                    && value.startsWith(QLatin1Char('\"'))
     172                    && value.endsWith(QLatin1Char('\"')))
    169173                    value = value.mid(1, value.length() - 2);
    170174                // Store the key and value: "DESKTOP", "$HOME/Desktop"
  • trunk/src/gui/util/qsystemtrayicon.cpp

    r290 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    6666    \brief The QSystemTrayIcon class provides an icon for an application in the system tray.
    6767    \since 4.2
    68     \ingroup application
    6968    \ingroup desktop
    7069
     
    382381    when the application has focus.
    383382
     383    On Mac OS X, the Growl notification system must be installed for this function to
     384    display messages.
     385 
    384386    \sa show() supportsMessages()
    385387  */
     
    435437    QFont f = titleLabel->font();
    436438    f.setBold(true);
    437 #ifdef Q_OS_WINCE
     439#ifdef Q_WS_WINCE
    438440    f.setPointSize(f.pointSize() - 2);
    439441#endif
     
    441443    titleLabel->setTextFormat(Qt::PlainText); // to maintain compat with windows
    442444
    443 #ifdef Q_OS_WINCE
     445#ifdef Q_WS_WINCE
    444446    const int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize);
    445447    const int closeButtonSize = style()->pixelMetric(QStyle::PM_SmallIconSize) - 2;
     
    457459
    458460    QLabel *msgLabel = new QLabel;
    459 #ifdef Q_OS_WINCE
     461#ifdef Q_WS_WINCE
    460462    f.setBold(false);
    461463    msgLabel->setFont(f);
     
    467469
    468470    // smart size for the message label
    469 #ifdef Q_OS_WINCE
     471#ifdef Q_WS_WINCE
    470472    int limit = QApplication::desktop()->availableGeometry(msgLabel).size().width() / 2;
    471473#else
     
    482484            }
    483485        }
    484 #ifdef Q_OS_WINCE
     486#ifdef Q_WS_WINCE
    485487        // Make sure that the text isn't wrapped "somewhere" in the balloon widget
    486488        // in the case that we have a long title label.
  • trunk/src/gui/util/qsystemtrayicon.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/gui/util/qsystemtrayicon_mac.mm

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    125125@end
    126126
    127 @interface QNSMenu : NSMenu {
     127
     128#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5
     129
     130@protocol NSMenuDelegate <NSObject>
     131-(void)menuNeedsUpdate:(NSMenu*)menu;
     132@end
     133#endif
     134
     135
     136@interface QNSMenu : NSMenu <NSMenuDelegate> {
    128137    QMenu *qmenu;
    129138}
    130139-(QMenu*)menu;
    131140-(id)initWithQMenu:(QMenu*)qmenu;
    132 -(void)menuNeedsUpdate:(QNSMenu*)menu;
    133141-(void)selectedAction:(id)item;
    134142@end
     
    307315    Q_UNUSED(notification);
    308316    down = NO;
     317
     318    if( ![self icon]->icon().isNull() ) {
     319#ifndef QT_MAC_USE_COCOA
     320        const short scale = GetMBarHeight()-4;
     321#else
     322        CGFloat hgt = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
     323        const short scale = hgt - 4;
     324#endif
     325        NSImage *nsimage = static_cast<NSImage *>(qt_mac_create_nsimage([self icon]->icon().pixmap(QSize(scale, scale))));
     326        [self setImage: nsimage];
     327        [nsimage release];
     328    }
     329
    309330    if([self icon]->contextMenu())
    310331        [self icon]->contextMenu()->hide();
     332
    311333    [self setNeedsDisplay:YES];
    312334}
     
    319341        [self icon]->contextMenu()->hide();
    320342    [self setNeedsDisplay:YES];
     343
     344#ifndef QT_MAC_USE_COCOA
     345    const short scale = GetMBarHeight()-4;
     346#else
     347    CGFloat hgt = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
     348    const short scale = hgt - 4;
     349#endif
     350
     351    if( down && ![self icon]->icon().isNull() ) {
     352        NSImage *nsaltimage = static_cast<NSImage *>(qt_mac_create_nsimage([self icon]->icon().pixmap(QSize(scale, scale), QIcon::Selected)));
     353        [self setImage: nsaltimage];
     354        [nsaltimage release];
     355    }
     356
    321357
    322358    if (down)
     
    456492    return self;
    457493}
    458 -(QMenu*)menu {
    459     return qmenu;
    460 }
    461 -(void)menuNeedsUpdate:(QNSMenu*)menu {
     494-(QMenu*)menu {
     495    return qmenu;
     496}
     497-(void)menuNeedsUpdate:(NSMenu*)nsmenu {
     498    QNSMenu *menu = static_cast<QNSMenu *>(nsmenu);
    462499    emit static_cast<QSystemTrayIconQMenu*>(menu->qmenu)->doAboutToShow();
    463500    for(int i = [menu numberOfItems]-1; i >= 0; --i)
  • trunk/src/gui/util/qsystemtrayicon_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    9595class QBalloonTip : public QWidget
    9696{
     97    Q_OBJECT
    9798public:
    9899    static void showBalloon(QSystemTrayIcon::MessageIcon icon, const QString& title,
  • trunk/src/gui/util/qsystemtrayicon_win.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4242#include "qsystemtrayicon_p.h"
    4343#ifndef QT_NO_SYSTEMTRAYICON
    44 //#define _WIN32_IE 0x0500
    45 #define _WIN32_IE 0x0600 //required for NOTIFYICONDATAW_V2_SIZE
     44#define _WIN32_IE 0x0600 //required for NOTIFYICONDATA_V2_SIZE
    4645
    4746//missing defines for MINGW :
     
    6362#include <QSettings>
    6463
    65 #if defined(Q_OS_WINCE) && !defined(STANDARDSHELL_UI_MODEL)
     64#if defined(Q_WS_WINCE) && !defined(STANDARDSHELL_UI_MODEL)
    6665#   include <streams.h>
    6766#endif
     
    6968QT_BEGIN_NAMESPACE
    7069
    71 #if defined(Q_OS_WINCE)
     70#if defined(Q_WS_WINCE)
    7271static const UINT q_uNOTIFYICONID = 13;     // IDs from 0 to 12 are reserved on WinCE.
    7372#else
     
    7877#define MYWM_NOTIFYICON (WM_APP+101)
    7978
    80 typedef BOOL (WINAPI *PtrShell_NotifyIcon)(DWORD,PNOTIFYICONDATA);
    81 static PtrShell_NotifyIcon ptrShell_NotifyIcon = 0;
    82 
    83 static void resolveLibs()
    84 {
    85     static bool triedResolve = false;
    86 #if defined Q_OS_WINCE
    87     QString libName(QLatin1String("coredll"));
    88     const char* funcName = "Shell_NotifyIcon";
    89 #else
    90     QString libName(QLatin1String("shell32"));
    91     const char* funcName = "Shell_NotifyIconW";
    92 #endif
    93     if (!triedResolve) {
    94         QLibrary lib(libName);
    95             triedResolve = true;
    96             ptrShell_NotifyIcon = (PtrShell_NotifyIcon) lib.resolve(funcName);
    97     }
    98 }
     79struct Q_NOTIFYICONIDENTIFIER {
     80    DWORD cbSize;
     81    HWND hWnd;
     82    UINT uID;
     83    GUID guidItem;
     84};
     85
     86#define Q_MSGFLT_ALLOW 1
     87
     88typedef HRESULT (WINAPI *PtrShell_NotifyIconGetRect)(const Q_NOTIFYICONIDENTIFIER* identifier, RECT* iconLocation);
     89typedef BOOL (WINAPI *PtrChangeWindowMessageFilter)(UINT message, DWORD dwFlag);
     90typedef BOOL (WINAPI *PtrChangeWindowMessageFilterEx)(HWND hWnd, UINT message, DWORD action, void* pChangeFilterStruct);
    9991
    10092class QSystemTrayIconSys : QWidget
     
    10496    ~QSystemTrayIconSys();
    10597    bool winEvent( MSG *m, long *result );
    106     bool trayMessageA(DWORD msg);
    107     bool trayMessageW(DWORD msg);
    10898    bool trayMessage(DWORD msg);
    10999    bool iconDrawItem(LPDRAWITEMSTRUCT lpdi);
    110     void setIconContentsW(NOTIFYICONDATAW &data);
    111     void setIconContentsA(NOTIFYICONDATAA &data);
    112     bool showMessageW(const QString &title, const QString &message, QSystemTrayIcon::MessageIcon type, uint uSecs);
    113     bool showMessageA(const QString &title, const QString &message, QSystemTrayIcon::MessageIcon type, uint uSecs);
     100    void setIconContents(NOTIFYICONDATA &data);
     101    bool showMessage(const QString &title, const QString &message, QSystemTrayIcon::MessageIcon type, uint uSecs);
    114102    bool allowsMessages();
    115103    bool supportsMessages();
    116104    QRect findIconGeometry(const int a_iButtonID);
    117     QRect findTrayGeometry();
    118     HBITMAP createIconMask(const QBitmap &bitmap);
    119105    void createIcon();
    120     int detectShellVersion() const;
    121106    HICON hIcon;
    122107    QPoint globalPos;
    123108    QSystemTrayIcon *q;
    124109private:
    125     uint notifyIconSizeW;
    126     uint notifyIconSizeA;
    127     int currentShellVersion;
     110    uint notifyIconSize;
    128111    int maxTipLength;
     112    bool ignoreNextMouseRelease;
    129113};
    130114
    131 // Checks for the shell32 dll version number, since only version
    132 // 5 or later of supports ballon messages
    133115bool QSystemTrayIconSys::allowsMessages()
    134116{
    135117#ifndef QT_NO_SETTINGS
    136 
    137118    QSettings settings(QLatin1String("HKEY_CURRENT_USER\\Software\\Microsoft"
    138119                                      "\\Windows\\CurrentVersion\\Explorer\\Advanced"), QSettings::NativeFormat);
     
    143124}
    144125
    145 // Checks for the shell32 dll version number, since only version
    146 // 5 or later of supports ballon messages
    147126bool QSystemTrayIconSys::supportsMessages()
    148127{
    149 #if NOTIFYICON_VERSION >= 3
    150     if (currentShellVersion >= 5)
    151         return allowsMessages();
    152     else
    153 #endif
    154         return false;
    155 }
    156 
    157 //Returns the runtime major version of the shell32 dll
    158 int QSystemTrayIconSys::detectShellVersion() const
    159 {
    160128#ifndef Q_OS_WINCE
    161     int shellVersion = 4; //NT 4.0 and W95
    162     DLLGETVERSIONPROC pDllGetVersion = (DLLGETVERSIONPROC)QLibrary::resolve(
    163             QLatin1String("shell32"), "DllGetVersion");
    164     if (pDllGetVersion)
    165     {
    166         DLLVERSIONINFO dvi;
    167         HRESULT hr;
    168         ZeroMemory(&dvi, sizeof(dvi));
    169         dvi.cbSize = sizeof(dvi);
    170         hr = (*pDllGetVersion)(&dvi);
    171         if (SUCCEEDED(hr)) {
    172             if (dvi.dwMajorVersion >= 5)
    173             {
    174                 shellVersion = dvi.dwMajorVersion;
    175             }
    176         }
    177     }
    178     return shellVersion;
    179 #endif
    180     return 4; //No ballonMessages and MaxTipLength = 64 for WindowsCE
     129    return allowsMessages();
     130#endif
     131    return false;
    181132}
    182133
    183134QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *object)
    184     : hIcon(0), q(object)
    185 {
    186     currentShellVersion = detectShellVersion();
    187     notifyIconSizeA = FIELD_OFFSET(NOTIFYICONDATAA, szTip[64]); // NOTIFYICONDATAA_V1_SIZE
    188     notifyIconSizeW = FIELD_OFFSET(NOTIFYICONDATAW, szTip[64]); // NOTIFYICONDATAW_V1_SIZE;
     135    : hIcon(0), q(object), ignoreNextMouseRelease(false)
     136
     137{
     138#ifndef Q_OS_WINCE
     139    notifyIconSize = FIELD_OFFSET(NOTIFYICONDATA, guidItem); // NOTIFYICONDATAW_V2_SIZE;
     140    maxTipLength = 128;
     141#else
     142    notifyIconSize = FIELD_OFFSET(NOTIFYICONDATA, szTip[64]); // NOTIFYICONDATAW_V1_SIZE;
    189143    maxTipLength = 64;
    190 
    191 #if NOTIFYICON_VERSION >= 3
    192     if (currentShellVersion >=5) {
    193         notifyIconSizeA = FIELD_OFFSET(NOTIFYICONDATAA, guidItem); // NOTIFYICONDATAA_V2_SIZE
    194         notifyIconSizeW = FIELD_OFFSET(NOTIFYICONDATAW, guidItem); // NOTIFYICONDATAW_V2_SIZE;
    195         maxTipLength = 128;
    196     }
    197144#endif
    198145
    199146    // For restoring the tray icon after explorer crashes
    200147    if (!MYWM_TASKBARCREATED) {
    201         MYWM_TASKBARCREATED = QT_WA_INLINE(RegisterWindowMessageW(L"TaskbarCreated"),RegisterWindowMessageA("TaskbarCreated"));
     148        MYWM_TASKBARCREATED = RegisterWindowMessage(L"TaskbarCreated");
     149    }
     150
     151    // Allow the WM_TASKBARCREATED message through the UIPI filter on Windows Vista and higher
     152    static PtrChangeWindowMessageFilterEx pChangeWindowMessageFilterEx =
     153        (PtrChangeWindowMessageFilterEx)QLibrary::resolve(QLatin1String("user32"), "ChangeWindowMessageFilterEx");
     154
     155    if (pChangeWindowMessageFilterEx) {
     156        // Call the safer ChangeWindowMessageFilterEx API if available
     157        pChangeWindowMessageFilterEx(winId(), MYWM_TASKBARCREATED, Q_MSGFLT_ALLOW, 0);
     158    } else {
     159        static PtrChangeWindowMessageFilter pChangeWindowMessageFilter =
     160            (PtrChangeWindowMessageFilter)QLibrary::resolve(QLatin1String("user32"), "ChangeWindowMessageFilter");
     161
     162        if (pChangeWindowMessageFilter) {
     163            // Call the deprecated ChangeWindowMessageFilter API otherwise
     164            pChangeWindowMessageFilter(MYWM_TASKBARCREATED, Q_MSGFLT_ALLOW);
     165        }
    202166    }
    203167}
     
    209173}
    210174
    211 void QSystemTrayIconSys::setIconContentsW(NOTIFYICONDATAW &tnd)
    212 {
    213     tnd.uFlags = NIF_MESSAGE|NIF_ICON|NIF_TIP;
     175void QSystemTrayIconSys::setIconContents(NOTIFYICONDATA &tnd)
     176{
     177    tnd.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
    214178    tnd.uCallbackMessage = MYWM_NOTIFYICON;
    215179    tnd.hIcon = hIcon;
     
    217181
    218182    if (!tip.isNull()) {
    219         // Tip is limited to maxTipLength - NULL; lstrcpyn appends a NULL terminator.
    220183        tip = tip.left(maxTipLength - 1) + QChar();
    221 #if defined(Q_OS_WINCE)
    222         wcsncpy(tnd.szTip, reinterpret_cast<const wchar_t *> (tip.utf16()), qMin(tip.length()+1, maxTipLength));
    223 #else
    224         lstrcpynW(tnd.szTip, (TCHAR*)tip.utf16(), qMin(tip.length()+1, maxTipLength));
    225 #endif
    226     }
    227 }
    228 
    229 void QSystemTrayIconSys::setIconContentsA(NOTIFYICONDATAA &tnd)
    230 {
    231     tnd.uFlags = NIF_MESSAGE|NIF_ICON|NIF_TIP;
    232     tnd.uCallbackMessage = MYWM_NOTIFYICON;
    233     tnd.hIcon = hIcon;
    234     QString tip = q->toolTip();
    235 
    236     if (!tip.isNull()) {
    237         // Tip is limited to maxTipLength - NULL; lstrcpyn appends a NULL terminator.
    238         tip = tip.left(maxTipLength - 1) + QChar();
    239 #if defined(Q_OS_WINCE)
    240         strncpy(tnd.szTip, tip.toLocal8Bit().constData(), qMin(tip.length()+1, maxTipLength));
    241 #else
    242         lstrcpynA(tnd.szTip, tip.toLocal8Bit().constData(), qMin(tip.length()+1, maxTipLength));
    243 #endif
    244     }
    245 }
    246 
    247 int iconFlag( QSystemTrayIcon::MessageIcon icon )
    248 {
    249     int flag = 0;
     184        memcpy(tnd.szTip, tip.utf16(), qMin(tip.length() + 1, maxTipLength) * sizeof(wchar_t));
     185    }
     186}
     187
     188static int iconFlag( QSystemTrayIcon::MessageIcon icon )
     189{
    250190#if NOTIFYICON_VERSION >= 3
    251191    switch (icon) {
     192        case QSystemTrayIcon::Information:
     193            return NIIF_INFO;
     194        case QSystemTrayIcon::Warning:
     195            return NIIF_WARNING;
     196        case QSystemTrayIcon::Critical:
     197            return NIIF_ERROR;
    252198        case QSystemTrayIcon::NoIcon:
    253             break;
    254         case QSystemTrayIcon::Critical:
    255             flag = NIIF_ERROR;
    256             break;
    257         case QSystemTrayIcon::Warning:
    258             flag = NIIF_WARNING;
    259             break;
    260         case QSystemTrayIcon::Information:
    261         default : // fall through
    262             flag = NIIF_INFO;
     199            return NIIF_NONE;
     200        default:
     201            Q_ASSERT_X(false, "QSystemTrayIconSys::showMessage", "Invalid QSystemTrayIcon::MessageIcon value");
     202            return NIIF_NONE;
    263203    }
    264204#else
    265205    Q_UNUSED(icon);
    266 #endif
    267     return flag;
    268 }
    269 
    270 bool QSystemTrayIconSys::showMessageW(const QString &title, const QString &message, QSystemTrayIcon::MessageIcon type, uint uSecs)
    271 {
    272 #if NOTIFYICON_VERSION>=3
     206    return 0;
     207#endif
     208}
     209
     210bool QSystemTrayIconSys::showMessage(const QString &title, const QString &message, QSystemTrayIcon::MessageIcon type, uint uSecs)
     211{
     212#if NOTIFYICON_VERSION >= 3
    273213    NOTIFYICONDATA tnd;
    274     memset(&tnd, 0, notifyIconSizeW);
     214    memset(&tnd, 0, notifyIconSize);
    275215    Q_ASSERT(testAttribute(Qt::WA_WState_Created));
    276216
    277     setIconContentsW(tnd);
    278 #if defined(Q_OS_WINCE)
    279     wcsncpy(tnd.szInfo, message.utf16(), qMin(message.length() + 1, 256));
    280     wcsncpy(tnd.szInfoTitle, title.utf16(), qMin(title.length()+1, 64));
    281 #else
    282     lstrcpynW(tnd.szInfo, (TCHAR*)message.utf16(), qMin(message.length() + 1, 256));
    283     lstrcpynW(tnd.szInfoTitle, (TCHAR*)title.utf16(), qMin(title.length() + 1, 64));
    284 #endif
     217    setIconContents(tnd);
     218    memcpy(tnd.szInfo, message.utf16(), qMin(message.length() + 1, 256) * sizeof(wchar_t));
     219    memcpy(tnd.szInfoTitle, title.utf16(), qMin(title.length() + 1, 64) * sizeof(wchar_t));
     220
    285221    tnd.uID = q_uNOTIFYICONID;
    286222    tnd.dwInfoFlags = iconFlag(type);
    287     tnd.cbSize = notifyIconSizeW;
     223    tnd.cbSize = notifyIconSize;
    288224    tnd.hWnd = winId();
    289225    tnd.uTimeout = uSecs;
    290226    tnd.uFlags = NIF_INFO;
    291     return ptrShell_NotifyIcon(NIM_MODIFY, &tnd);
     227
     228    return Shell_NotifyIcon(NIM_MODIFY, &tnd);
    292229#else
    293230    Q_UNUSED(title);
     
    299236}
    300237
    301 bool QSystemTrayIconSys::showMessageA(const QString &title, const QString &message, QSystemTrayIcon::MessageIcon type, uint uSecs)
    302 {
    303 #if NOTIFYICON_VERSION>=3
    304     NOTIFYICONDATAA tnd;
    305     memset(&tnd, 0, notifyIconSizeA);
     238bool QSystemTrayIconSys::trayMessage(DWORD msg)
     239{
     240    NOTIFYICONDATA tnd;
     241    memset(&tnd, 0, notifyIconSize);
     242    tnd.uID = q_uNOTIFYICONID;
     243    tnd.cbSize = notifyIconSize;
     244    tnd.hWnd = winId();
     245
    306246    Q_ASSERT(testAttribute(Qt::WA_WState_Created));
    307247
    308     setIconContentsA(tnd);
    309 #if defined(Q_OS_WINCE)
    310     strncpy(tnd.szInfo, message.toLocal8Bit().constData(), qMin(message.length() + 1, 256));
    311     strncpy(tnd.szInfoTitle, title.toLocal8Bit().constData(), qMin(title.length()+1, 64));
    312 #else
    313     lstrcpynA(tnd.szInfo, message.toLocal8Bit().constData(), qMin(message.length() + 1, 256));
    314     lstrcpynA(tnd.szInfoTitle, title.toLocal8Bit().constData(), qMin(title.length() + 1, 64));
    315 #endif
    316     tnd.uID = q_uNOTIFYICONID;
    317     tnd.dwInfoFlags = iconFlag(type);
    318     tnd.cbSize = notifyIconSizeA;
    319     tnd.hWnd = winId();
    320     tnd.uTimeout = uSecs;
    321     tnd.uFlags = NIF_INFO;
    322     return Shell_NotifyIconA(NIM_MODIFY, &tnd);
    323 #else
    324     Q_UNUSED(title);
    325     Q_UNUSED(message);
    326     Q_UNUSED(type);
    327     Q_UNUSED(uSecs);
    328     return false;
    329 #endif
    330 }
    331 
    332 bool QSystemTrayIconSys::trayMessageA(DWORD msg)
    333 {
    334 #if !defined(Q_OS_WINCE)
    335     NOTIFYICONDATAA tnd;
    336     memset(&tnd, 0, notifyIconSizeA);
    337     tnd.uID = q_uNOTIFYICONID;
    338     tnd.cbSize = notifyIconSizeA;
    339     tnd.hWnd = winId();
    340     Q_ASSERT(testAttribute(Qt::WA_WState_Created));
    341 
    342248    if (msg != NIM_DELETE) {
    343         setIconContentsA(tnd);
    344     }
    345     return Shell_NotifyIconA(msg, &tnd);
    346 #else
    347     Q_UNUSED(msg);
    348     return false;
    349 #endif
    350 }
    351 
    352 bool QSystemTrayIconSys::trayMessageW(DWORD msg)
    353 {
    354     NOTIFYICONDATAW tnd;
    355     memset(&tnd, 0, notifyIconSizeW);
    356     tnd.uID = q_uNOTIFYICONID;
    357     tnd.cbSize = notifyIconSizeW;
    358     tnd.hWnd = winId();
    359     Q_ASSERT(testAttribute(Qt::WA_WState_Created));
    360 
    361     if (msg != NIM_DELETE) {
    362         setIconContentsW(tnd);
    363     }
    364     return ptrShell_NotifyIcon(msg, &tnd);
    365 }
    366 
    367 bool QSystemTrayIconSys::trayMessage(DWORD msg)
    368 {
    369     resolveLibs();
    370     if (!(ptrShell_NotifyIcon))
    371         return false;
    372 
    373     QT_WA({
    374         return trayMessageW(msg);
    375     },
    376     {
    377         return trayMessageA(msg);
    378     });
     249        setIconContents(tnd);
     250    }
     251
     252    return Shell_NotifyIcon(msg, &tnd);
    379253}
    380254
     
    386260    DrawIconEx(lpdi->hDC, lpdi->rcItem.left, lpdi->rcItem.top, hIcon, 0, 0, 0, 0, DI_NORMAL);
    387261    return true;
    388 }
    389 
    390 HBITMAP QSystemTrayIconSys::createIconMask(const QBitmap &bitmap)
    391 {
    392     QImage bm = bitmap.toImage().convertToFormat(QImage::Format_Mono);
    393     int w = bm.width();
    394     int h = bm.height();
    395     int bpl = ((w+15)/16)*2;                        // bpl, 16 bit alignment
    396     uchar *bits = new uchar[bpl*h];
    397     bm.invertPixels();
    398     for (int y=0; y<h; y++)
    399         memcpy(bits+y*bpl, bm.scanLine(y), bpl);
    400     HBITMAP hbm = CreateBitmap(w, h, 1, 1, bits);
    401     delete [] bits;
    402     return hbm;
    403262}
    404263
     
    417276        return;
    418277
    419     QBitmap mask = pm.mask();
    420     if (mask.isNull()) {
    421         mask = QBitmap(pm.size());
    422         mask.fill(Qt::color1);
    423     }
    424 
    425     HBITMAP im = createIconMask(mask);
    426     ICONINFO ii;
    427     ii.fIcon    = true;
    428     ii.hbmMask  = im;
    429     ii.hbmColor = pm.toWinHBITMAP(QPixmap::Alpha);
    430     ii.xHotspot = 0;
    431     ii.yHotspot = 0;
    432     hIcon = CreateIconIndirect(&ii);
    433 
    434     DeleteObject(ii.hbmColor);
    435     DeleteObject(im);
     278    hIcon = pm.toWinHICON();
    436279}
    437280
     
    460303            switch (m->lParam) {
    461304            case WM_LBUTTONUP:
    462                 emit q->activated(QSystemTrayIcon::Trigger);
     305                if (ignoreNextMouseRelease)
     306                    ignoreNextMouseRelease = false;
     307                else
     308                    emit q->activated(QSystemTrayIcon::Trigger);
    463309                break;
    464310
    465 #if !defined(Q_OS_WINCE)
    466311            case WM_LBUTTONDBLCLK:
     312                ignoreNextMouseRelease = true; // Since DBLCLICK Generates a second mouse
     313                                               // release we must ignore it
    467314                emit q->activated(QSystemTrayIcon::DoubleClick);
    468315                break;
     
    471318                if (q->contextMenu()) {
    472319                    q->contextMenu()->popup(gpos);
     320#if defined(Q_WS_WINCE)
     321                    // We must ensure that the popup menu doesn't show up behind the task bar.
     322                    QRect desktopRect = qApp->desktop()->availableGeometry();
     323                    int maxY = desktopRect.y() + desktopRect.height() - q->contextMenu()->height();
     324                    if (gpos.y() > maxY) {
     325                        gpos.ry() = maxY;
     326                        q->contextMenu()->move(gpos);
     327                    }
     328#endif
    473329                    q->contextMenu()->activateWindow();
    474330                    //Must be activated for proper keyboardfocus and menu closing on windows:
     
    477333                break;
    478334
     335#if !defined(Q_WS_WINCE)
    479336            case NIN_BALLOONUSERCLICK:
    480337                emit q->messageClicked();
    481338                break;
     339#endif
    482340
    483341            case WM_MBUTTONUP:
    484342                emit q->activated(QSystemTrayIcon::MiddleClick);
    485343                break;
    486 #endif
    487344            default:
    488345                        break;
     
    515372}
    516373
    517 //fallback on win 95/98
    518 QRect QSystemTrayIconSys::findTrayGeometry()
    519 {
    520     //Use lower right corner as fallback
    521     QPoint brCorner = qApp->desktop()->screenGeometry().bottomRight();
    522     QRect ret(brCorner.x() - 10, brCorner.y() - 10, 10, 10);
    523 #if defined(Q_OS_WINCE)
    524     HWND trayHandle = FindWindowW(L"Shell_TrayWnd", NULL);
    525 #else
    526     HWND trayHandle = FindWindowA("Shell_TrayWnd", NULL);
    527 #endif
    528     if (trayHandle) {
    529 #if defined(Q_OS_WINCE)
    530         trayHandle = FindWindowW(L"TrayNotifyWnd", NULL);
    531 #else
    532         trayHandle = FindWindowExA(trayHandle, NULL, "TrayNotifyWnd", NULL);
    533 #endif
    534         if (trayHandle) {
    535             RECT r;
    536             if (GetWindowRect(trayHandle, &r)) {
    537                 ret = QRect(r.left, r.top, r.right- r.left, r.bottom - r.top);
    538             }
    539         }
    540     }
    541     return ret;
    542 }
    543 
    544374/*
    545375* This function tries to determine the icon geometry from the tray
     
    549379QRect QSystemTrayIconSys::findIconGeometry(const int iconId)
    550380{
     381    static PtrShell_NotifyIconGetRect Shell_NotifyIconGetRect =
     382        (PtrShell_NotifyIconGetRect)QLibrary::resolve(QLatin1String("shell32"), "Shell_NotifyIconGetRect");
     383
     384    if (Shell_NotifyIconGetRect) {
     385        Q_NOTIFYICONIDENTIFIER nid;
     386        memset(&nid, 0, sizeof(nid));
     387        nid.cbSize = sizeof(nid);
     388        nid.hWnd = winId();
     389        nid.uID = iconId;
     390
     391        RECT rect;
     392        HRESULT hr = Shell_NotifyIconGetRect(&nid, &rect);
     393        if (SUCCEEDED(hr)) {
     394            return QRect(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
     395        }
     396    }
     397
    551398    QRect ret;
    552399
    553400    TBBUTTON buttonData;
    554401    DWORD processID = 0;
    555 #if defined(Q_OS_WINCE)
    556     HWND trayHandle = FindWindowW(L"Shell_TrayWnd", NULL);
    557 #else
    558     HWND trayHandle = FindWindowA("Shell_TrayWnd", NULL);
    559 #endif
     402    HWND trayHandle = FindWindow(L"Shell_TrayWnd", NULL);
    560403
    561404    //find the toolbar used in the notification area
    562405    if (trayHandle) {
    563406#if defined(Q_OS_WINCE)
    564         trayHandle = FindWindowW(L"TrayNotifyWnd", NULL);
    565 #else
    566         trayHandle = FindWindowExA(trayHandle, NULL, "TrayNotifyWnd", NULL);
     407        trayHandle = FindWindow(L"TrayNotifyWnd", NULL);
     408#else
     409        trayHandle = FindWindowEx(trayHandle, NULL, L"TrayNotifyWnd", NULL);
    567410#endif
    568411        if (trayHandle) {
    569412#if defined(Q_OS_WINCE)
    570             HWND hwnd = FindWindowW(L"SysPager", NULL);
     413            HWND hwnd = FindWindow(L"SysPager", NULL);
    571414#else
    572415            HWND hwnd = FindWindowEx(trayHandle, NULL, L"SysPager", NULL);
     
    613456        SendMessage(trayHandle, TB_GETBUTTON, toolbarButton , (LPARAM)data);
    614457
    615         if(!ReadProcessMemory(trayProcess, data, &buttonData, sizeof(TBBUTTON), &numBytes))
     458        if (!ReadProcessMemory(trayProcess, data, &buttonData, sizeof(TBBUTTON), &numBytes))
    616459            continue;
    617460
    618         if(!ReadProcessMemory(trayProcess, (LPVOID) buttonData.dwData, appData, sizeof(appData), &numBytes))
     461        if (!ReadProcessMemory(trayProcess, (LPVOID) buttonData.dwData, appData, sizeof(appData), &numBytes))
    619462            continue;
    620463
     
    647490}
    648491
    649 
    650492void QSystemTrayIconPrivate::showMessage_sys(const QString &title, const QString &message, QSystemTrayIcon::MessageIcon type, int timeOut)
    651493{
     
    658500    else uSecs = (int)timeOut;
    659501
    660     resolveLibs();
    661 
    662502    //message is limited to 255 chars + NULL
    663503    QString messageString;
    664504    if (message.isEmpty() && !title.isEmpty())
    665         messageString = QLatin1String(" "); //ensures that the message shows when only title is set
     505        messageString = QLatin1Char(' '); //ensures that the message shows when only title is set
    666506    else
    667507        messageString = message.left(255) + QChar();
     
    671511
    672512    if (sys->supportsMessages()) {
    673         QT_WA({
    674             sys->showMessageW(titleString, messageString, type, (unsigned int)uSecs);
    675         }, {
    676             sys->showMessageA(titleString, messageString, type, (unsigned int)uSecs);
    677         });
     513        sys->showMessage(titleString, messageString, type, (unsigned int)uSecs);
    678514    } else {
    679         //use fallbacks
    680         QRect iconPos = sys->findIconGeometry(0);
     515        //use fallback
     516        QRect iconPos = sys->findIconGeometry(q_uNOTIFYICONID);
    681517        if (iconPos.isValid()) {
    682518            QBalloonTip::showBalloon(type, title, message, sys->q, iconPos.center(), uSecs, true);
    683         } else {
    684             QRect trayRect = sys->findTrayGeometry();
    685             QBalloonTip::showBalloon(type, title, message, sys->q, QPoint(trayRect.left(),
    686                                      trayRect.center().y()), uSecs, false);
    687519        }
    688520    }
     
    693525    if (!sys)
    694526        return QRect();
    695     return sys->findIconGeometry(0);
     527    return sys->findIconGeometry(q_uNOTIFYICONID);
    696528}
    697529
     
    727559void QSystemTrayIconPrivate::updateToolTip_sys()
    728560{
    729 #ifdef Q_OS_WINCE
     561#ifdef Q_WS_WINCE
    730562    // Calling sys->trayMessage(NIM_MODIFY) on an existing icon is broken on Windows CE.
    731563    // So we need to call updateIcon_sys() which creates a new icon handle.
  • trunk/src/gui/util/qsystemtrayicon_x11.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/gui/util/qundogroup.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    6262    \brief The QUndoGroup class is a group of QUndoStack objects.
    6363    \since 4.2
    64     \ingroup misc
    6564
    6665    For an overview of the Qt's undo framework, see the
  • trunk/src/gui/util/qundogroup.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/gui/util/qundostack.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5353    \brief The QUndoCommand class is the base class of all commands stored on a QUndoStack.
    5454    \since 4.2
    55     \ingroup misc
    5655
    5756    For an overview of Qt's Undo Framework, see the
     
    293292    \brief The QUndoStack class is a stack of QUndoCommand objects.
    294293    \since 4.2
    295     \ingroup misc
    296294
    297295    For an overview of Qt's Undo Framework, see the
     
    716714
    717715/*!
    718     Repeatedly calls undo() or redo() until the the current command index reaches
     716    Repeatedly calls undo() or redo() until the current command index reaches
    719717    \a idx. This function can be used to roll the state of the document forwards
    720718    of backwards. indexChanged() is emitted only once.
  • trunk/src/gui/util/qundostack.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/gui/util/qundostack_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/gui/util/qundoview.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    254254    \brief The QUndoView class displays the contents of a QUndoStack.
    255255    \since 4.2
    256     \ingroup misc
     256
    257257    \ingroup advanced
    258258
  • trunk/src/gui/util/qundoview.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/gui/util/util.pri

    r255 r561  
    4747                OBJECTIVE_SOURCES += util/qsystemtrayicon_mac.mm
    4848}
     49
     50symbian {
     51    LIBS += -lsendas2 -letext -lapmime
     52    contains(QT_CONFIG, s60): LIBS += -lplatformenv -lcommonui
     53}
Note: See TracChangeset for help on using the changeset viewer.