Changeset 846 for trunk/src/gui/util


Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • trunk

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

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6363    \snippet doc/src/snippets/code/src_gui_util_qcompleter.cpp 0
    6464
    65     A QDirModel can be used to provide auto completion of file names.
     65    A QFileSystemModel can be used to provide auto completion of file names.
    6666    For example:
    6767
     
    121121
    122122    Let's take the example of a user typing in a file system path.
    123     The model is a (hierarchical) QDirModel. The completion
     123    The model is a (hierarchical) QFileSystemModel. The completion
    124124    occurs for every element in the path. For example, if the current
    125125    text is \c C:\Wind, QCompleter might suggest \c Windows to
     
    131131    For \c C:\Windows\Sy, it needs to be split as "C:", "Windows" and "Sy".
    132132    The default implementation of splitPath(), splits the completionPrefix
    133     using QDir::separator() if the model is a QDirModel.
     133    using QDir::separator() if the model is a QFileSystemModel.
    134134
    135135    To provide completions, QCompleter needs to know the path from an index.
    136136    This is provided by pathFromIndex(). The default implementation of
    137137    pathFromIndex(), returns the data for the \l{Qt::EditRole}{edit role}
    138     for list models and the absolute file path if the mode is a QDirModel.
     138    for list models and the absolute file path if the mode is a QFileSystemModel.
    139139
    140140    \sa QAbstractItemModel, QLineEdit, QComboBox, {Completer Example}
     
    148148#include "QtGui/qstringlistmodel.h"
    149149#include "QtGui/qdirmodel.h"
     150#include "QtGui/qfilesystemmodel.h"
    150151#include "QtGui/qheaderview.h"
    151152#include "QtGui/qlistview.h"
     
    154155#include "QtGui/qheaderview.h"
    155156#include "QtGui/qdesktopwidget.h"
     157#include "QtGui/qlineedit.h"
    156158
    157159QT_BEGIN_NAMESPACE
     
    471473    if (curParts.count() <= 1 || c->proxy->showAll || !source)
    472474        return QMatchData();
    473     bool dirModel = false;
     475    bool isDirModel = false;
     476    bool isFsModel = false;
    474477#ifndef QT_NO_DIRMODEL
    475     dirModel = (qobject_cast<QDirModel *>(source) != 0);
     478    isDirModel = (qobject_cast<QDirModel *>(source) != 0);
     479#endif
     480#ifndef QT_NO_FILESYSTEMMODEL
     481    isFsModel = (qobject_cast<QFileSystemModel *>(source) != 0);
    476482#endif
    477483    QVector<int> v;
     
    483489        if (str.startsWith(c->prefix, c->cs)
    484490#if (!defined(Q_OS_WIN) || defined(Q_OS_WINCE)) && !defined(Q_OS_SYMBIAN) && !defined(Q_OS_OS2)
    485             && (!dirModel || QDir::toNativeSeparators(str) != QDir::separator())
     491            && ((!isFsModel && !isDirModel) || QDir::toNativeSeparators(str) != QDir::separator())
    486492#endif
    487493            )
     
    777783QCompleterPrivate::QCompleterPrivate()
    778784: widget(0), proxy(0), popup(0), cs(Qt::CaseSensitive), role(Qt::EditRole), column(0),
    779   maxVisibleItems(7), sorting(QCompleter::UnsortedModel), wrap(true), eatFocusOut(true)
     785  maxVisibleItems(7), sorting(QCompleter::UnsortedModel), wrap(true), eatFocusOut(true),
     786  hiddenBecauseNoMatch(false)
    780787{
    781788}
     
    844851        }
    845852#endif
     853#ifndef QT_NO_FILESYSTEMMODEL
     854        // add a trailing separator in inline
     855        if (mode == QCompleter::InlineCompletion) {
     856            if (qobject_cast<QFileSystemModel *>(proxy->sourceModel()) && QFileInfo(completion).isDir())
     857                completion += QDir::separator();
     858        }
     859#endif
    846860    }
    847861
     
    867881    Qt::LayoutDirection dir = widget->layoutDirection();
    868882    QPoint pos;
    869     int rw, rh, w;
     883    int rh, w;
    870884    int h = (popup->sizeHintForRow(0) * qMin(maxVisibleItems, popup->model()->rowCount()) + 3) + 3;
    871885    QScrollBar *hsb = popup->horizontalScrollBar();
     
    875889    if (rect.isValid()) {
    876890        rh = rect.height();
    877         w = rw = rect.width();
     891        w = rect.width();
    878892        pos = widget->mapToGlobal(dir == Qt::RightToLeft ? rect.bottomRight() : rect.bottomLeft());
    879893    } else {
    880894        rh = widget->height();
    881         rw = widget->width();
    882895        pos = widget->mapToGlobal(QPoint(0, widget->height() - 2));
    883896        w = widget->width();
    884897    }
    885898
    886     if ((pos.x() + rw) > (screen.x() + screen.width()))
     899    if (w > screen.width())
     900        w = screen.width();
     901    if ((pos.x() + w) > (screen.x() + screen.width()))
    887902        pos.setX(screen.x() + screen.width() - w);
    888903    if (pos.x() < screen.x())
    889904        pos.setX(screen.x());
    890     if (((pos.y() + rh) > (screen.y() + screen.height())) && ((pos.y() - h - rh) >= 0))
    891         pos.setY(pos.y() - qMax(h, popup->minimumHeight()) - rh + 2);
     905
     906    int top = pos.y() - rh - screen.top() + 2;
     907    int bottom = screen.bottom() - pos.y();
     908    h = qMax(h, popup->minimumHeight());
     909    if (h > bottom) {
     910        h = qMin(qMax(top, bottom), h);
     911
     912        if (top > bottom)
     913            pos.setY(pos.y() - h - rh + 2);
     914    }
    892915
    893916    popup->setGeometry(pos.x(), pos.y(), w, h);
     
    895918    if (!popup->isVisible())
    896919        popup->show();
     920}
     921
     922void QCompleterPrivate::_q_fileSystemModelDirectoryLoaded(const QString &path)
     923{
     924    Q_Q(QCompleter);
     925    // Slot called when QFileSystemModel has finished loading.
     926    // If we hide the popup because there was no match because the model was not loaded yet,
     927    // we re-start the completion when we get the results
     928    if (hiddenBecauseNoMatch
     929        && prefix.startsWith(path) && prefix != (path + '/')
     930        && widget) {
     931        q->complete();
     932    }
    897933}
    898934
     
    9771013    and it has the QCompleter as its parent, it is deleted.
    9781014
    979     For convenience, if \a model is a QDirModel, QCompleter switches its
     1015    For convenience, if \a model is a QFileSystemModel, QCompleter switches its
    9801016    caseSensitivity to Qt::CaseInsensitive on Windows and Qt::CaseSensitive
    9811017    on other platforms.
     
    10011037    }
    10021038#endif // QT_NO_DIRMODEL
     1039#ifndef QT_NO_FILESYSTEMMODEL
     1040    QFileSystemModel *fsModel = qobject_cast<QFileSystemModel *>(model);
     1041    if (fsModel) {
     1042#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN)
     1043        setCaseSensitivity(Qt::CaseInsensitive);
     1044#else
     1045        setCaseSensitivity(Qt::CaseSensitive);
     1046#endif
     1047        setCompletionRole(QFileSystemModel::FileNameRole);
     1048        connect(fsModel, SIGNAL(directoryLoaded(QString)), this, SLOT(_q_fileSystemModelDirectoryLoaded(QString)));
     1049    }
     1050#endif // QT_NO_FILESYSTEMMODEL
    10031051}
    10041052
     
    10841132    if (popup->model() != d->proxy)
    10851133        popup->setModel(d->proxy);
    1086 #ifdef Q_OS_MAC
     1134#if defined(Q_OS_MAC) && !defined(QT_MAC_USE_COCOA)
    10871135     popup->show();
    10881136#else
     
    11561204
    11571205    if (d->eatFocusOut && o == d->widget && e->type() == QEvent::FocusOut) {
     1206        d->hiddenBecauseNoMatch = false;
    11581207        if (d->popup && d->popup->isVisible())
    11591208            return true;
     
    13341383    Q_D(QCompleter);
    13351384    QModelIndex idx = d->proxy->currentIndex(false);
     1385    d->hiddenBecauseNoMatch = false;
    13361386    if (d->mode == QCompleter::InlineCompletion) {
    13371387        if (idx.isValid())
     
    13451395        if (d->popup)
    13461396            d->popup->hide(); // no suggestion, hide
     1397        d->hiddenBecauseNoMatch = true;
    13471398        return;
    13481399    }
     
    16321683    The default implementation returns the \l{Qt::EditRole}{edit role} of the
    16331684    item for list models. It returns the absolute file path if the model is a
    1634     QDirModel.
     1685    QFileSystemModel.
    16351686
    16361687    \sa splitPath()
    16371688*/
     1689
    16381690QString QCompleter::pathFromIndex(const QModelIndex& index) const
    16391691{
     
    16451697    if (!sourceModel)
    16461698        return QString();
     1699    bool isDirModel = false;
     1700    bool isFsModel = false;
    16471701#ifndef QT_NO_DIRMODEL
    1648     QDirModel *dirModel = qobject_cast<QDirModel *>(sourceModel);
    1649     if (!dirModel)
    1650 #endif
     1702    isDirModel = qobject_cast<QDirModel *>(d->proxy->sourceModel()) != 0;
     1703#endif
     1704#ifndef QT_NO_FILESYSTEMMODEL
     1705    isFsModel = qobject_cast<QFileSystemModel *>(d->proxy->sourceModel()) != 0;
     1706#endif
     1707    if (!isDirModel && !isFsModel)
    16511708        return sourceModel->data(index, d->role).toString();
    16521709
     
    16541711    QStringList list;
    16551712    do {
    1656         QString t = sourceModel->data(idx, Qt::EditRole).toString();
     1713        QString t;
     1714        if (isDirModel)
     1715            t = sourceModel->data(idx, Qt::EditRole).toString();
     1716#ifndef QT_NO_FILESYSTEMMODEL
     1717        else
     1718            t = sourceModel->data(idx, QFileSystemModel::FileNameRole).toString();
     1719#endif
    16571720        list.prepend(t);
    16581721        QModelIndex parent = idx.parent();
     
    16741737
    16751738    The default implementation of splitPath() splits a file system path based on
    1676     QDir::separator() when the sourceModel() is a QDirModel.
     1739    QDir::separator() when the sourceModel() is a QFileSystemModel.
    16771740
    16781741    When used with list models, the first item in the returned list is used for
     
    16841747{
    16851748    bool isDirModel = false;
     1749    bool isFsModel = false;
    16861750#ifndef QT_NO_DIRMODEL
    16871751    Q_D(const QCompleter);
    16881752    isDirModel = qobject_cast<QDirModel *>(d->proxy->sourceModel()) != 0;
    16891753#endif
    1690 
    1691     if (!isDirModel || path.isEmpty())
     1754#ifndef QT_NO_FILESYSTEMMODEL
     1755#ifdef QT_NO_DIRMODEL
     1756    Q_D(const QCompleter);
     1757#endif
     1758    isFsModel = qobject_cast<QFileSystemModel *>(d->proxy->sourceModel()) != 0;
     1759#endif
     1760
     1761    if ((!isDirModel && !isFsModel) || path.isEmpty())
    16921762        return QStringList(completionPrefix());
    16931763
  • trunk/src/gui/util/qcompleter.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    160160    Q_PRIVATE_SLOT(d_func(), void _q_completionSelected(const QItemSelection&))
    161161    Q_PRIVATE_SLOT(d_func(), void _q_autoResizePopup())
     162    Q_PRIVATE_SLOT(d_func(), void _q_fileSystemModelDirectoryLoaded(const QString&))
    162163};
    163164
  • trunk/src/gui/util/qcompleter_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    9494    bool eatFocusOut;
    9595    QRect popupRect;
     96    bool hiddenBecauseNoMatch;
    9697
    9798    void showPopup(const QRect&);
     
    99100    void _q_completionSelected(const QItemSelection&);
    100101    void _q_autoResizePopup();
     102    void _q_fileSystemModelDirectoryLoaded(const QString &path);
    101103    void setCurrentIndex(QModelIndex, bool = true);
    102104};
  • trunk/src/gui/util/qdesktopservices.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/util/qdesktopservices.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/util/qdesktopservices_mac.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/util/qdesktopservices_qws.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/util/qdesktopservices_s60.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4040****************************************************************************/
    4141
    42 // This flag changes the implementation to use S60 CDcoumentHandler
    43 // instead of apparch when opening the files
    44 #define USE_DOCUMENTHANDLER
    4542
    4643#include <qcoreapplication.h>
     
    4946#include <private/qcore_symbian_p.h>
    5047
     48#include <f32file.h>                // TDriveUnit etc
     49#include <pathinfo.h>               // PathInfo
     50
     51#ifndef USE_SCHEMEHANDLER
     52#ifdef Q_WS_S60
     53// This flag changes the implementation to use S60 CDcoumentHandler
     54// instead of apparc when opening the files
     55#define USE_DOCUMENTHANDLER
     56#endif
     57
    5158#include <txtrich.h>                // CRichText
    52 #include <f32file.h>                // TDriveUnit etc
    5359#include <eikenv.h>                 // CEikonEnv
    5460#include <apgcli.h>                 // RApaLsSession
     
    5763#include <rsendasmessage.h>         // RSendAsMessage
    5864
    59 // copied from miutset.h, so we don't get a dependency into the app layer
    60 const TUid KUidMsgTypeSMTP                      = {0x10001028}; // 268439592
    61 
    62 #ifdef Q_WS_S60
    63 #  include <pathinfo.h>             // PathInfo
    64 #  ifdef USE_DOCUMENTHANDLER
    65 #    include <DocumentHandler.h>    // CDocumentHandler
    66 #    include <AknServerApp.h>
    67 #  endif
    68 #else
    69 #  warning CDocumentHandler requires support for S60
    70 #  undef USE_DOCUMENTHANDLER        // Fallback to RApaLsSession based implementation
     65#ifdef USE_DOCUMENTHANDLER
     66#include <DocumentHandler.h>        // CDocumentHandler
     67#include <AknServerApp.h>
     68#endif
     69#else // USE_SCHEMEHANDLER
     70#include <schemehandler.h>
    7171#endif
    7272
     
    7777_LIT(KBrowserPrefix, "4 " );
    7878_LIT(KFontsDir, "z:\\resource\\Fonts\\");
     79
     80#ifndef USE_SCHEMEHANDLER
     81// copied from miutset.h, so we don't get a dependency into the app layer
     82const TUid KUidMsgTypeSMTP = {0x10001028}; // 268439592
    7983const TUid KUidBrowser = { 0x10008D39 };
    8084
     
    135139#endif
    136140
    137 
    138141static void handleMailtoSchemeLX(const QUrl &url)
    139142{
     
    153156    QStringList bccs = bcc.split(QLatin1String(","), QString::SkipEmptyParts);
    154157
    155 
    156158    RSendAs sendAs;
    157159    User::LeaveIfError(sendAs.Connect());
    158160    QAutoClose<RSendAs> sendAsCleanup(sendAs);
    159 
    160161
    161162    CSendAsAccounts* accounts = CSendAsAccounts::NewL();
     
    221222    if (task.Exists()){
    222223        // Switch to existing browser instance
     224        task.BringToForeground();
    223225        HBufC8* param8 = HBufC8::NewLC(buf16->Length());
    224226        param8->Des().Append(buf16->Des());
     
    246248}
    247249
    248 static TDriveUnit exeDrive()
    249 {
    250     RProcess me;
    251     TFileName processFileName = me.FileName();
    252     TDriveUnit drive(processFileName);
    253     return drive;
    254 }
    255 
    256 static TDriveUnit writableExeDrive()
    257 {
    258     TDriveUnit drive = exeDrive();
    259     if(drive.operator TInt() == EDriveZ)
    260         return TDriveUnit(EDriveC);
    261     return drive;
    262 }
    263 
    264 static TPtrC writableDataRoot()
    265 {
    266     TDriveUnit drive = exeDrive();
    267 #ifdef Q_WS_S60
    268     switch(drive.operator TInt()){
    269         case EDriveC:
    270             return PathInfo::PhoneMemoryRootPath();
    271             break;
    272         case EDriveE:
    273             return PathInfo::MemoryCardRootPath();
    274             break;
    275         case EDriveZ:
    276             // It is not possible to write on ROM drive ->
    277             // return phone mem root path instead
    278             return PathInfo::PhoneMemoryRootPath();
    279             break;
    280         default:
    281             return PathInfo::PhoneMemoryRootPath();
    282             break;
    283     }
    284 #else
    285 #warning No fallback implementation of writableDataRoot()
    286     return 0;
    287 #endif
    288 }
    289250
    290251static void openDocumentL(const TDesC& aUrl)
     
    311272}
    312273
    313 #ifdef USE_SCHEMEHANDLER
    314 // The schemehandler component only exist in private SDK. This implementation
    315 // exist here just for convenience in case that we need to use it later on
    316 // The schemehandle based implementation is not yet tested.
    317 
    318 // The biggest advantage of schemehandler is that it can handle
    319 // wide range of schemes and is extensible by plugins
    320 static bool handleUrl(const QUrl &url)
    321 {
    322     if (!url.isValid())
    323         return false;
    324 
    325     QString urlString(url.toString());
    326     TPtrC urlPtr(qt_QString2TPtrC(urlString));
    327     TRAPD( err, handleUrlL(urlPtr));
    328     return err ? false : true;
    329 }
    330 
    331 static void handleUrlL(const TDesC& aUrl)
    332 {
    333     CSchemeHandler* schemeHandler = CSchemeHandler::NewL(aUrl);
    334     CleanupStack::PushL(schemeHandler);
    335     schemeHandler->HandleUrlStandaloneL(); // Process the Url in standalone mode
    336     CleanupStack::PopAndDestroy();
    337 }
    338 static bool launchWebBrowser(const QUrl &url)
    339 {
    340     return handleUrl(url);
    341 }
    342 
    343 static bool openDocument(const QUrl &file)
    344 {
    345     return handleUrl(url);
    346 }
    347 #endif
    348 
    349274static bool launchWebBrowser(const QUrl &url)
    350275{
     
    370295}
    371296
     297#else //USE_SCHEMEHANDLER
     298// The schemehandler component only exist in private SDK. This implementation
     299// exist here just for convenience in case that we need to use it later on
     300// The schemehandle based implementation is not yet tested.
     301
     302// The biggest advantage of schemehandler is that it can handle
     303// wide range of schemes and is extensible by plugins
     304static void handleUrlL(const TDesC& aUrl)
     305{
     306    CSchemeHandler* schemeHandler = CSchemeHandler::NewL(aUrl);
     307    CleanupStack::PushL(schemeHandler);
     308    schemeHandler->HandleUrlStandaloneL(); // Process the Url in standalone mode
     309    CleanupStack::PopAndDestroy();
     310}
     311
     312static bool handleUrl(const QUrl &url)
     313{
     314    if (!url.isValid())
     315        return false;
     316
     317    QString urlString(url.toString());
     318    TPtrC urlPtr(qt_QString2TPtrC(urlString));
     319    TRAPD( err, handleUrlL(urlPtr));
     320    return err ? false : true;
     321}
     322
     323static bool launchWebBrowser(const QUrl &url)
     324{
     325    return handleUrl(url);
     326}
     327
     328static bool openDocument(const QUrl &file)
     329{
     330    return handleUrl(file);
     331}
     332
     333#endif //USE_SCHEMEHANDLER
     334
     335// Common functions to all implementations
     336
     337static TDriveUnit exeDrive()
     338{
     339    RProcess me;
     340    TFileName processFileName = me.FileName();
     341    TDriveUnit drive(processFileName);
     342    return drive;
     343}
     344
     345static TDriveUnit writableExeDrive()
     346{
     347    TDriveUnit drive = exeDrive();
     348    if (drive.operator TInt() == EDriveZ)
     349        return TDriveUnit(EDriveC);
     350    return drive;
     351}
     352
     353static TPtrC writableDataRoot()
     354{
     355    TDriveUnit drive = exeDrive();
     356    switch (drive.operator TInt()){
     357        case EDriveC:
     358            return PathInfo::PhoneMemoryRootPath();
     359            break;
     360        case EDriveE:
     361            return PathInfo::MemoryCardRootPath();
     362            break;
     363        case EDriveZ:
     364            // It is not possible to write on ROM drive ->
     365            // return phone mem root path instead
     366            return PathInfo::PhoneMemoryRootPath();
     367            break;
     368        default:
     369            return PathInfo::PhoneMemoryRootPath();
     370            break;
     371    }
     372}
     373
    372374QString QDesktopServices::storageLocation(StandardLocation type)
    373375{
     
    392394    case MusicLocation:
    393395        path.Append(writableDataRoot());
    394 #ifdef Q_WS_S60
    395396        path.Append(PathInfo::SoundsPath());
    396 #endif
    397397        break;
    398398    case MoviesLocation:
    399399        path.Append(writableDataRoot());
    400 #ifdef Q_WS_S60
    401400        path.Append(PathInfo::VideosPath());
    402 #endif
    403401        break;
    404402    case PicturesLocation:
    405403        path.Append(writableDataRoot());
    406 #ifdef Q_WS_S60
    407404        path.Append(PathInfo::ImagesPath());
    408 #endif
    409405        break;
    410406    case TempLocation:
     
    416412        break;
    417413    case DataLocation:
    418         CEikonEnv::Static()->FsSession().PrivatePath(path);
     414        qt_s60GetRFs().PrivatePath(path);
    419415        path.Insert(0, writableExeDrive().Name());
    420416        break;
    421417    case CacheLocation:
    422         CEikonEnv::Static()->FsSession().PrivatePath(path);
     418        qt_s60GetRFs().PrivatePath(path);
    423419        path.Insert(0, writableExeDrive().Name());
    424420        path.Append(KCacheSubDir);
  • trunk/src/gui/util/qdesktopservices_win.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4242#include <qsettings.h>
    4343#include <qdir.h>
    44 #include <qlibrary.h>
     44#include <private/qsystemlibrary_p.h>
    4545#include <qurl.h>
    4646#include <qstringlist.h>
     
    6060#endif
    6161
    62 #if defined(Q_CC_MINGW) && !defined(CSIDL_MYMUSIC)
     62#ifndef CSIDL_MYMUSIC
    6363#define CSIDL_MYMUSIC   13
    6464#define CSIDL_MYVIDEO   14
     
    9898        //Retrieve the commandline for the default mail client
    9999        //the default key used below is the command line for the mailto: shell command
    100         DWORD  bufferSize = 2 * MAX_PATH;
     100        DWORD  bufferSize = sizeof(wchar_t) * MAX_PATH;
    101101        long  returnValue =  -1;
    102102        QString command;
     
    104104        HKEY handle;
    105105        LONG res;
    106         wchar_t keyValue[2 * MAX_PATH] = {0};
     106        wchar_t keyValue[MAX_PATH] = {0};
    107107        QString keyName(QLatin1String("mailto"));
    108108
    109109        //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);
     110        res = RegOpenKeyEx(HKEY_CURRENT_USER,
     111                           L"Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\mailto\\UserChoice",
     112                           0, KEY_READ, &handle);
    113113        if (res == ERROR_SUCCESS) {
    114114            returnValue = RegQueryValueEx(handle, L"Progid", 0, 0, reinterpret_cast<unsigned char*>(keyValue), &bufferSize);
     
    122122            return false;
    123123
    124         bufferSize = 2 * MAX_PATH;
    125         returnValue = RegQueryValueExW(handle, L"", 0, 0, reinterpret_cast<unsigned char*>(keyValue), &bufferSize);
     124        bufferSize = sizeof(wchar_t) * MAX_PATH;
     125        returnValue = RegQueryValueEx(handle, L"", 0, 0, reinterpret_cast<unsigned char*>(keyValue), &bufferSize);
    126126        if (!returnValue)
    127127            command = QString::fromRawData((QChar*)keyValue, bufferSize);
     
    178178
    179179#ifndef Q_OS_WINCE
    180         QLibrary library(QLatin1String("shell32"));
    181 #else
    182         QLibrary library(QLatin1String("coredll"));
     180        QSystemLibrary library(QLatin1String("shell32"));
     181#else
     182        QSystemLibrary library(QLatin1String("coredll"));
    183183#endif // Q_OS_WINCE
    184184    typedef BOOL (WINAPI*GetSpecialFolderPath)(HWND, LPWSTR, int, BOOL);
  • trunk/src/gui/util/qdesktopservices_x11.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    7272        return true;
    7373
    74     if (X11->desktopEnvironment == DE_GNOME && launch(url, QLatin1String("gnome-open"))) {
     74    // Use the X11->desktopEnvironment value if X11 is non-NULL,
     75    //  otherwise just attempt to launch command regardless of the desktop environment
     76    if ((!X11 || (X11 && X11->desktopEnvironment == DE_GNOME)) && launch(url, QLatin1String("gnome-open"))) {
    7577        return true;
    7678    } else {
    77         if (X11->desktopEnvironment == DE_KDE && launch(url, QLatin1String("kfmclient exec")))
     79        if ((!X11 || (X11 && X11->desktopEnvironment == DE_KDE)) && launch(url, QLatin1String("kfmclient exec")))
    7880            return true;
    7981    }
     
    105107        return true;
    106108
    107     if (X11->desktopEnvironment == DE_GNOME && launch(url, QLatin1String("gnome-open"))) {
     109    // Use the X11->desktopEnvironment value if X11 is non-NULL,
     110    //  otherwise just attempt to launch command regardless of the desktop environment
     111    if ((!X11 || (X11 && X11->desktopEnvironment == DE_GNOME)) && launch(url, QLatin1String("gnome-open"))) {
    108112        return true;
    109113    } else {
    110         if (X11->desktopEnvironment == DE_KDE && launch(url, QLatin1String("kfmclient openURL")))
     114        if ((!X11 || (X11 && X11->desktopEnvironment == DE_KDE)) && launch(url, QLatin1String("kfmclient openURL")))
    111115            return true;
    112116    }
  • trunk/src/gui/util/qsystemtrayicon.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    357357bool QSystemTrayIcon::supportsMessages()
    358358{
    359 #if defined(Q_WS_QWS)
    360     return false;
    361 #endif
    362     return true;
     359    return QSystemTrayIconPrivate::supportsMessages_sys();
    363360}
    364361
  • trunk/src/gui/util/qsystemtrayicon.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/util/qsystemtrayicon_mac.mm

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    7676#define QT_MAC_SYSTEMTRAY_USE_GROWL
    7777
    78 @class QNSMenu;
    79 
    8078#include <private/qt_cocoa_helpers_mac_p.h>
    8179#include <private/qsystemtrayicon_p.h>
     
    9492extern NSString *keySequenceToKeyEqivalent(const QKeySequence &accel); // qmenu_mac.mm
    9593extern NSUInteger keySequenceModifierMask(const QKeySequence &accel);  // qmenu_mac.mm
     94extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum);
    9695QT_END_NAMESPACE
    9796
    9897QT_USE_NAMESPACE
    9998
    100 @class QNSImageView;
    101 
    102 @interface QNSStatusItem : NSObject {
     99@class QT_MANGLE_NAMESPACE(QNSMenu);
     100@class QT_MANGLE_NAMESPACE(QNSImageView);
     101
     102@interface QT_MANGLE_NAMESPACE(QNSStatusItem) : NSObject {
    103103    NSStatusItem *item;
    104104    QSystemTrayIcon *icon;
    105105    QSystemTrayIconPrivate *iconPrivate;
    106     QNSImageView *imageCell;
     106    QT_MANGLE_NAMESPACE(QNSImageView) *imageCell;
    107107}
    108108-(id)initWithIcon:(QSystemTrayIcon*)icon iconPrivate:(QSystemTrayIconPrivate *)iprivate;
     
    111111-(NSStatusItem*)item;
    112112-(QRectF)geometry;
    113 - (void)triggerSelector:(id)sender;
     113- (void)triggerSelector:(id)sender button:(Qt::MouseButton)mouseButton;
    114114- (void)doubleClickSelector:(id)sender;
    115115@end
    116116
    117 @interface QNSImageView : NSImageView {
     117@interface QT_MANGLE_NAMESPACE(QNSImageView) : NSImageView {
    118118    BOOL down;
    119     QNSStatusItem *parent;
    120 }
    121 -(id)initWithParent:(QNSStatusItem*)myParent;
     119    QT_MANGLE_NAMESPACE(QNSStatusItem) *parent;
     120}
     121-(id)initWithParent:(QT_MANGLE_NAMESPACE(QNSStatusItem)*)myParent;
    122122-(QSystemTrayIcon*)icon;
    123123-(void)menuTrackingDone:(NSNotification*)notification;
    124 -(void)mousePressed:(NSEvent *)mouseEvent;
     124-(void)mousePressed:(NSEvent *)mouseEvent button:(Qt::MouseButton)mouseButton;
    125125@end
    126126
     
    134134
    135135
    136 @interface QNSMenu : NSMenu <NSMenuDelegate> {
     136@interface QT_MANGLE_NAMESPACE(QNSMenu) : NSMenu <NSMenuDelegate> {
    137137    QMenu *qmenu;
    138138}
     
    148148    QSystemTrayIconSys(QSystemTrayIcon *icon, QSystemTrayIconPrivate *d) {
    149149        QMacCocoaAutoReleasePool pool;
    150         item = [[QNSStatusItem alloc] initWithIcon:icon iconPrivate:d];
     150        item = [[QT_MANGLE_NAMESPACE(QNSStatusItem) alloc] initWithIcon:icon iconPrivate:d];
    151151    }
    152152    ~QSystemTrayIconSys() {
     
    155155        [item release];
    156156    }
    157     QNSStatusItem *item;
     157    QT_MANGLE_NAMESPACE(QNSStatusItem) *item;
    158158};
    159159
     
    223223
    224224bool QSystemTrayIconPrivate::isSystemTrayAvailable_sys()
     225{
     226    return true;
     227}
     228
     229bool QSystemTrayIconPrivate::supportsMessages_sys()
    225230{
    226231    return true;
     
    299304@end
    300305
    301 @implementation QNSImageView
    302 -(id)initWithParent:(QNSStatusItem*)myParent {
     306@implementation QT_MANGLE_NAMESPACE(QNSImageView)
     307-(id)initWithParent:(QT_MANGLE_NAMESPACE(QNSStatusItem)*)myParent {
    303308    self = [super init];
    304309    parent = myParent;
     
    334339}
    335340
    336 -(void)mousePressed:(NSEvent *)mouseEvent
    337 {
    338     int clickCount = [mouseEvent clickCount];
    339     down = !down;
    340     if(!down && [self icon]->contextMenu())
    341         [self icon]->contextMenu()->hide();
     341-(void)mousePressed:(NSEvent *)mouseEvent button:(Qt::MouseButton)mouseButton
     342{
     343    down = YES;
     344    int clickCount = [mouseEvent clickCount]; 
    342345    [self setNeedsDisplay:YES];
    343346
     
    349352#endif
    350353
    351     if( down && ![self icon]->icon().isNull() ) {
     354    if (![self icon]->icon().isNull() ) {
    352355        NSImage *nsaltimage = static_cast<NSImage *>(qt_mac_create_nsimage([self icon]->icon().pixmap(QSize(scale, scale), QIcon::Selected)));
    353356        [self setImage: nsaltimage];
     
    355358    }
    356359
    357 
    358     if (down)
    359         [parent triggerSelector:self];
    360     else if ((clickCount%2))
     360    if ((clickCount == 2)) {
     361        [self menuTrackingDone:nil];
    361362        [parent doubleClickSelector:self];
    362     while (down) {
    363         mouseEvent = [[self window] nextEventMatchingMask:NSLeftMouseDownMask | NSLeftMouseUpMask
    364                         | NSLeftMouseDraggedMask | NSRightMouseDownMask | NSRightMouseUpMask
    365                         | NSRightMouseDraggedMask];
    366         switch ([mouseEvent type]) {
    367             case NSRightMouseDown:
    368             case NSRightMouseUp:
    369             case NSLeftMouseDown:
    370             case NSLeftMouseUp:
    371                 [self menuTrackingDone:nil];
    372                 break;
    373             case NSRightMouseDragged:
    374             case NSLeftMouseDragged:
    375             default:
    376                 /* Ignore any other kind of event. */
    377                 break;
    378         }
    379     };
     363    } else {
     364        [parent triggerSelector:self button:mouseButton];
     365    }
    380366}
    381367
    382368-(void)mouseDown:(NSEvent *)mouseEvent
    383369{
    384     [self mousePressed:mouseEvent];
     370    [self mousePressed:mouseEvent button:Qt::LeftButton];
     371}
     372
     373-(void)mouseUp:(NSEvent *)mouseEvent
     374{
     375    Q_UNUSED(mouseEvent);
     376    [self menuTrackingDone:nil];
    385377}
    386378
    387379- (void)rightMouseDown:(NSEvent *)mouseEvent
    388380{
    389     [self mousePressed:mouseEvent];
    390 }
    391 
     381    [self mousePressed:mouseEvent button:Qt::RightButton];
     382}
     383
     384-(void)rightMouseUp:(NSEvent *)mouseEvent
     385{
     386    Q_UNUSED(mouseEvent);
     387    [self menuTrackingDone:nil];
     388}
     389
     390- (void)otherMouseDown:(NSEvent *)mouseEvent
     391{
     392    [self mousePressed:mouseEvent button:cocoaButton2QtButton([mouseEvent buttonNumber])];
     393}
     394
     395-(void)otherMouseUp:(NSEvent *)mouseEvent
     396{
     397    Q_UNUSED(mouseEvent);
     398    [self menuTrackingDone:nil];
     399}
    392400
    393401-(void)drawRect:(NSRect)rect {
     
    397405@end
    398406
    399 @implementation QNSStatusItem
     407@implementation QT_MANGLE_NAMESPACE(QNSStatusItem)
    400408
    401409-(id)initWithIcon:(QSystemTrayIcon*)i iconPrivate:(QSystemTrayIconPrivate *)iPrivate
     
    406414        iconPrivate = iPrivate;
    407415        item = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength] retain];
    408         imageCell = [[QNSImageView alloc] initWithParent:self];
     416        imageCell = [[QT_MANGLE_NAMESPACE(QNSImageView) alloc] initWithParent:self];
    409417        [item setView: imageCell];
    410418    }
     
    434442    return QRectF();
    435443}
    436 - (void)triggerSelector:(id)sender {
     444
     445- (void)triggerSelector:(id)sender button:(Qt::MouseButton)mouseButton {
    437446    Q_UNUSED(sender);
    438     if(!icon)
     447    if (!icon)
    439448        return;
    440     qtsystray_sendActivated(icon, QSystemTrayIcon::Trigger);
     449
     450    if (mouseButton == Qt::MidButton)
     451        qtsystray_sendActivated(icon, QSystemTrayIcon::MiddleClick);
     452    else
     453        qtsystray_sendActivated(icon, QSystemTrayIcon::Trigger);
     454
    441455    if (icon->contextMenu()) {
    442 #if 0
    443         const QRectF geom = [self geometry];
    444         if(!geom.isNull()) {
    445             [[NSNotificationCenter defaultCenter] addObserver:imageCell
    446                                                   selector:@selector(menuTrackingDone:)
    447                                                   name:nil
    448                                                   object:self];
    449             icon->contextMenu()->exec(geom.topLeft().toPoint(), 0);
    450             [imageCell menuTrackingDone:nil];
    451         } else
    452 #endif
    453         {
    454456#ifndef QT_MAC_USE_COCOA
    455             [[[self item] view] removeAllToolTips];
    456             iconPrivate->updateToolTip_sys();
    457 #endif
    458             NSMenu *m = [[QNSMenu alloc] initWithQMenu:icon->contextMenu()];
    459             [m setAutoenablesItems: NO];
    460             [[NSNotificationCenter defaultCenter] addObserver:imageCell
    461                                                   selector:@selector(menuTrackingDone:)
    462                                                   name:NSMenuDidEndTrackingNotification
    463                                                   object:m];
    464             [item popUpStatusItemMenu: m];
    465             [m release];
    466         }
    467     }
    468 }
     457        [[[self item] view] removeAllToolTips];
     458        iconPrivate->updateToolTip_sys();
     459#endif
     460        NSMenu *m = [[QT_MANGLE_NAMESPACE(QNSMenu) alloc] initWithQMenu:icon->contextMenu()];
     461        [m setAutoenablesItems: NO];
     462        [[NSNotificationCenter defaultCenter] addObserver:imageCell
     463         selector:@selector(menuTrackingDone:)
     464             name:NSMenuDidEndTrackingNotification
     465                 object:m];
     466        [item popUpStatusItemMenu: m];
     467        [m release];
     468    }
     469}
     470
    469471- (void)doubleClickSelector:(id)sender {
    470472    Q_UNUSED(sender);
     
    473475    qtsystray_sendActivated(icon, QSystemTrayIcon::DoubleClick);
    474476}
     477
    475478@end
    476479
     
    483486};
    484487
    485 @implementation QNSMenu
     488@implementation QT_MANGLE_NAMESPACE(QNSMenu)
    486489-(id)initWithQMenu:(QMenu*)qm {
    487490    self = [super init];
     
    496499}
    497500-(void)menuNeedsUpdate:(NSMenu*)nsmenu {
    498     QNSMenu *menu = static_cast<QNSMenu *>(nsmenu);
     501    QT_MANGLE_NAMESPACE(QNSMenu) *menu = static_cast<QT_MANGLE_NAMESPACE(QNSMenu) *>(nsmenu);
    499502    emit static_cast<QSystemTrayIconQMenu*>(menu->qmenu)->doAboutToShow();
    500503    for(int i = [menu numberOfItems]-1; i >= 0; --i)
     
    541544            }
    542545            if(action->menu()) {
    543                 QNSMenu *sub = [[QNSMenu alloc] initWithQMenu:action->menu()];
     546                QT_MANGLE_NAMESPACE(QNSMenu) *sub = [[QT_MANGLE_NAMESPACE(QNSMenu) alloc] initWithQMenu:action->menu()];
    544547                [item setSubmenu:sub];
    545548            } else {
  • trunk/src/gui/util/qsystemtrayicon_p.h

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    8484    QRect geometry_sys() const;
    8585    void showMessage_sys(const QString &msg, const QString &title, QSystemTrayIcon::MessageIcon icon, int secs);
     86
    8687    static bool isSystemTrayAvailable_sys();
     88    static bool supportsMessages_sys();
    8789
    8890    QPointer<QMenu> menu;
  • trunk/src/gui/util/qsystemtrayicon_qws.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    7676}
    7777
     78bool QSystemTrayIconPrivate::supportsMessages_sys()
     79{
     80    return false;
     81}
     82
    7883void QSystemTrayIconPrivate::showMessage_sys(const QString &message,
    7984                                             const QString &title,
  • trunk/src/gui/util/qsystemtrayicon_win.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4242#include "qsystemtrayicon_p.h"
    4343#ifndef QT_NO_SYSTEMTRAYICON
    44 #define _WIN32_IE 0x0600 //required for NOTIFYICONDATA_V2_SIZE
    45 
    46 //missing defines for MINGW :
    47 #ifndef NIN_BALLOONTIMEOUT
    48 #define NIN_BALLOONTIMEOUT  (WM_USER + 4)
    49 #endif
    50 #ifndef NIN_BALLOONUSERCLICK
    51 #define NIN_BALLOONUSERCLICK (WM_USER + 5)
     44
     45#ifndef _WIN32_WINNT
     46#define _WIN32_WINNT 0x0600
     47#endif
     48
     49#ifndef _WIN32_IE
     50#define _WIN32_IE 0x600
    5251#endif
    5352
    5453#include <qt_windows.h>
     54#include <windowsx.h>
    5555#include <commctrl.h>
    56 #include <shlwapi.h>
    57 #include <QBitmap>
    58 #include <QLibrary>
     56
     57#include <private/qsystemlibrary_p.h>
    5958#include <QApplication>
    60 #include <QToolTip>
    61 #include <QDesktopWidget>
    6259#include <QSettings>
    6360
     
    7673};
    7774
     75#ifndef NOTIFYICON_VERSION_4
     76#define NOTIFYICON_VERSION_4 4
     77#endif
     78
     79#ifndef NIN_SELECT
     80#define NIN_SELECT (WM_USER + 0)
     81#endif
     82
     83#ifndef NIN_KEYSELECT
     84#define NIN_KEYSELECT (WM_USER + 1)
     85#endif
     86
     87#ifndef NIN_BALLOONTIMEOUT
     88#define NIN_BALLOONTIMEOUT (WM_USER + 4)
     89#endif
     90
     91#ifndef NIN_BALLOONUSERCLICK
     92#define NIN_BALLOONUSERCLICK (WM_USER + 5)
     93#endif
     94
     95#ifndef NIF_SHOWTIP
     96#define NIF_SHOWTIP 0x00000080
     97#endif
     98
    7899#define Q_MSGFLT_ALLOW 1
    79100
     
    89110    bool winEvent( MSG *m, long *result );
    90111    bool trayMessage(DWORD msg);
    91     bool iconDrawItem(LPDRAWITEMSTRUCT lpdi);
    92112    void setIconContents(NOTIFYICONDATA &data);
    93113    bool showMessage(const QString &title, const QString &message, QSystemTrayIcon::MessageIcon type, uint uSecs);
    94     bool allowsMessages();
    95     bool supportsMessages();
    96114    QRect findIconGeometry(const int a_iButtonID);
    97115    void createIcon();
     
    102120    uint notifyIconSize;
    103121    int maxTipLength;
     122    int version;
    104123    bool ignoreNextMouseRelease;
    105124};
    106125
    107 bool QSystemTrayIconSys::allowsMessages()
     126static bool allowsMessages()
    108127{
    109128#ifndef QT_NO_SETTINGS
     
    116135}
    117136
    118 bool QSystemTrayIconSys::supportsMessages()
    119 {
    120     return allowsMessages();
    121 }
    122 
    123137QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *object)
    124138    : hIcon(0), q(object), ignoreNextMouseRelease(false)
    125139
    126140{
    127     notifyIconSize = FIELD_OFFSET(NOTIFYICONDATA, guidItem); // NOTIFYICONDATAW_V2_SIZE;
     141    if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA) {
     142        notifyIconSize = sizeof(NOTIFYICONDATA);
     143        version = NOTIFYICON_VERSION_4;
     144    } else {
     145        notifyIconSize = NOTIFYICONDATA_V2_SIZE;
     146        version = NOTIFYICON_VERSION;
     147    }
     148
    128149    maxTipLength = 128;
    129150
     
    135156    // Allow the WM_TASKBARCREATED message through the UIPI filter on Windows Vista and higher
    136157    static PtrChangeWindowMessageFilterEx pChangeWindowMessageFilterEx =
    137         (PtrChangeWindowMessageFilterEx)QLibrary::resolve(QLatin1String("user32"), "ChangeWindowMessageFilterEx");
     158        (PtrChangeWindowMessageFilterEx)QSystemLibrary::resolve(QLatin1String("user32"), "ChangeWindowMessageFilterEx");
    138159
    139160    if (pChangeWindowMessageFilterEx) {
     
    142163    } else {
    143164        static PtrChangeWindowMessageFilter pChangeWindowMessageFilter =
    144             (PtrChangeWindowMessageFilter)QLibrary::resolve(QLatin1String("user32"), "ChangeWindowMessageFilter");
     165            (PtrChangeWindowMessageFilter)QSystemLibrary::resolve(QLatin1String("user32"), "ChangeWindowMessageFilter");
    145166
    146167        if (pChangeWindowMessageFilter) {
     
    159180void QSystemTrayIconSys::setIconContents(NOTIFYICONDATA &tnd)
    160181{
    161     tnd.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
     182    tnd.uFlags |= NIF_MESSAGE | NIF_ICON | NIF_TIP;
    162183    tnd.uCallbackMessage = MYWM_NOTIFYICON;
    163184    tnd.hIcon = hIcon;
     
    172193static int iconFlag( QSystemTrayIcon::MessageIcon icon )
    173194{
    174 #if NOTIFYICON_VERSION >= 3
    175195    switch (icon) {
    176196        case QSystemTrayIcon::Information:
     
    186206            return NIIF_NONE;
    187207    }
    188 #else
    189     Q_UNUSED(icon);
    190     return 0;
    191 #endif
    192208}
    193209
    194210bool QSystemTrayIconSys::showMessage(const QString &title, const QString &message, QSystemTrayIcon::MessageIcon type, uint uSecs)
    195211{
    196 #if NOTIFYICON_VERSION >= 3
    197212    NOTIFYICONDATA tnd;
    198213    memset(&tnd, 0, notifyIconSize);
    199     Q_ASSERT(testAttribute(Qt::WA_WState_Created));
    200 
    201     setIconContents(tnd);
     214
    202215    memcpy(tnd.szInfo, message.utf16(), qMin(message.length() + 1, 256) * sizeof(wchar_t));
    203216    memcpy(tnd.szInfoTitle, title.utf16(), qMin(title.length() + 1, 64) * sizeof(wchar_t));
     
    208221    tnd.hWnd = winId();
    209222    tnd.uTimeout = uSecs;
    210     tnd.uFlags = NIF_INFO;
     223    tnd.uFlags = NIF_INFO | NIF_SHOWTIP;
     224
     225    Q_ASSERT(testAttribute(Qt::WA_WState_Created));
    211226
    212227    return Shell_NotifyIcon(NIM_MODIFY, &tnd);
    213 #else
    214     Q_UNUSED(title);
    215     Q_UNUSED(message);
    216     Q_UNUSED(type);
    217     Q_UNUSED(uSecs);
    218     return false;
    219 #endif
    220228}
    221229
     
    224232    NOTIFYICONDATA tnd;
    225233    memset(&tnd, 0, notifyIconSize);
     234
    226235    tnd.uID = q_uNOTIFYICONID;
    227236    tnd.cbSize = notifyIconSize;
    228237    tnd.hWnd = winId();
     238    tnd.uFlags = NIF_SHOWTIP;
     239    tnd.uVersion = version;
    229240
    230241    Q_ASSERT(testAttribute(Qt::WA_WState_Created));
    231242
    232     if (msg != NIM_DELETE) {
     243    if (msg == NIM_ADD || msg == NIM_MODIFY) {
    233244        setIconContents(tnd);
    234245    }
    235246
    236     return Shell_NotifyIcon(msg, &tnd);
    237 }
    238 
    239 bool QSystemTrayIconSys::iconDrawItem(LPDRAWITEMSTRUCT lpdi)
    240 {
    241     if (!hIcon)
    242         return false;
    243 
    244     DrawIconEx(lpdi->hDC, lpdi->rcItem.left, lpdi->rcItem.top, hIcon, 0, 0, 0, 0, DI_NORMAL);
    245     return true;
     247    bool success = Shell_NotifyIcon(msg, &tnd);
     248
     249    if (msg == NIM_ADD)
     250        return success && Shell_NotifyIcon(NIM_SETVERSION, &tnd);
     251    else
     252        return success;
    246253}
    247254
     
    266273{
    267274    switch(m->message) {
    268     case WM_CREATE:
    269 #ifdef GWLP_USERDATA
    270         SetWindowLongPtr(winId(), GWLP_USERDATA, (LONG_PTR)((CREATESTRUCTW*)m->lParam)->lpCreateParams);
    271 #else
    272         SetWindowLong(winId(), GWL_USERDATA, (LONG)((CREATESTRUCTW*)m->lParam)->lpCreateParams);
    273 #endif
    274         break;
    275 
    276     case WM_DRAWITEM:
    277         return iconDrawItem((LPDRAWITEMSTRUCT)m->lParam);
    278 
    279275    case MYWM_NOTIFYICON:
    280276        {
    281             RECT r;
    282             GetWindowRect(winId(), &r);
    283             QEvent *e = 0;
    284             Qt::KeyboardModifiers keys = QApplication::keyboardModifiers();
    285             QPoint gpos = QCursor::pos();
    286 
    287             switch (m->lParam) {
    288             case WM_LBUTTONUP:
     277            int message = 0;
     278            QPoint gpos;
     279
     280            if (version == NOTIFYICON_VERSION_4) {
     281                Q_ASSERT(q_uNOTIFYICONID == HIWORD(m->lParam));
     282                message = LOWORD(m->lParam);
     283                gpos = QPoint(GET_X_LPARAM(m->wParam), GET_Y_LPARAM(m->wParam));
     284            } else {
     285                Q_ASSERT(q_uNOTIFYICONID == m->wParam);
     286                message = m->lParam;
     287                gpos = QCursor::pos();
     288            }
     289
     290            switch (message) {
     291            case NIN_SELECT:
     292            case NIN_KEYSELECT:
    289293                if (ignoreNextMouseRelease)
    290294                    ignoreNextMouseRelease = false;
     
    299303                break;
    300304
    301             case WM_RBUTTONUP:
     305            case WM_CONTEXTMENU:
    302306                if (q->contextMenu()) {
    303307                    q->contextMenu()->popup(gpos);
    304                     q->contextMenu()->activateWindow();
    305                     //Must be activated for proper keyboardfocus and menu closing on windows:
    306308                }
    307309                emit q->activated(QSystemTrayIcon::Context);
     
    315317                emit q->activated(QSystemTrayIcon::MiddleClick);
    316318                break;
     319
    317320            default:
    318                         break;
    319             }
    320             if (e) {
    321                 bool res = QApplication::sendEvent(q, e);
    322                 delete e;
    323                 return res;
     321                break;
    324322            }
    325323            break;
     
    353351{
    354352    static PtrShell_NotifyIconGetRect Shell_NotifyIconGetRect =
    355         (PtrShell_NotifyIconGetRect)QLibrary::resolve(QLatin1String("shell32"), "Shell_NotifyIconGetRect");
     353        (PtrShell_NotifyIconGetRect)QSystemLibrary::resolve(QLatin1String("shell32"), "Shell_NotifyIconGetRect");
    356354
    357355    if (Shell_NotifyIconGetRect) {
     
    445443void QSystemTrayIconPrivate::showMessage_sys(const QString &title, const QString &message, QSystemTrayIcon::MessageIcon type, int timeOut)
    446444{
    447     if (!sys || !sys->allowsMessages())
     445    if (!sys || !allowsMessages())
    448446        return;
    449447
     
    463461    QString titleString = title.left(63) + QChar();
    464462
    465     if (sys->supportsMessages()) {
    466         sys->showMessage(titleString, messageString, type, (unsigned int)uSecs);
    467     } else {
    468         //use fallback
    469         QRect iconPos = sys->findIconGeometry(q_uNOTIFYICONID);
    470         if (iconPos.isValid()) {
    471             QBalloonTip::showBalloon(type, title, message, sys->q, iconPos.center(), uSecs, true);
    472         }
    473     }
     463    sys->showMessage(titleString, messageString, type, uSecs);
    474464}
    475465
     
    478468    if (!sys)
    479469        return QRect();
     470
    480471    return sys->findIconGeometry(q_uNOTIFYICONID);
    481472}
     
    523514}
    524515
     516bool QSystemTrayIconPrivate::supportsMessages_sys()
     517{
     518    return allowsMessages();
     519}
     520
    525521QT_END_NAMESPACE
    526522
  • trunk/src/gui/util/qsystemtrayicon_wince.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    156156    case MYWM_NOTIFYICON:
    157157        {
    158             RECT r;
    159             GetWindowRect(winId(), &r);
    160             QEvent *e = 0;
    161             Qt::KeyboardModifiers keys = QApplication::keyboardModifiers();
    162158            QPoint gpos = QCursor::pos();
    163159
     
    187183                        q->contextMenu()->move(gpos);
    188184                    }
    189 
    190                     q->contextMenu()->activateWindow();
    191                     //Must be activated for proper keyboardfocus and menu closing on windows:
    192185                }
    193186                emit q->activated(QSystemTrayIcon::Context);
     
    197190                emit q->activated(QSystemTrayIcon::MiddleClick);
    198191                break;
     192
    199193            default:
    200194                break;
    201             }
    202             if (e) {
    203                 bool res = QApplication::sendEvent(q, e);
    204                 delete e;
    205                 return res;
    206195            }
    207196            break;
     
    295284}
    296285
     286bool QSystemTrayIconPrivate::supportsMessages_sys()
     287{
     288    return true;
     289}
     290
    297291QT_END_NAMESPACE
    298292
  • trunk/src/gui/util/qsystemtrayicon_x11.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    382382}
    383383
     384bool QSystemTrayIconPrivate::supportsMessages_sys()
     385{
     386    return true;
     387}
     388
    384389void QSystemTrayIconPrivate::showMessage_sys(const QString &message, const QString &title,
    385390                                   QSystemTrayIcon::MessageIcon icon, int msecs)
  • trunk/src/gui/util/qundogroup.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/util/qundogroup.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/util/qundostack.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    442442/*!
    443443    Constructs an empty undo stack with the parent \a parent. The
    444     stack will initally be in the clean state. If \a parent is a
     444    stack will initially be in the clean state. If \a parent is a
    445445    QUndoGroup object, the stack is automatically added to the group.
    446446
  • trunk/src/gui/util/qundostack.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/util/qundostack_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/util/qundoview.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/util/qundoview.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/util/util.pri

    r835 r846  
    5353
    5454symbian {
    55     LIBS += -lsendas2 -letext -lapmime
    56     contains(QT_CONFIG, s60): LIBS += -lplatformenv -lCommonUI
     55    LIBS += -letext -lplatformenv
     56    contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) {
     57        LIBS += -lsendas2 -lapmime
     58        contains(QT_CONFIG, s60) {
     59            contains(CONFIG, is_using_gnupoc) {
     60                LIBS += -lcommonui
     61            } else {
     62                LIBS += -lCommonUI
     63            }
     64        }
     65    } else {
     66        DEFINES += USE_SCHEMEHANDLER
     67    }
    5768}
Note: See TracChangeset for help on using the changeset viewer.