Changeset 846 for trunk/src/gui/util
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/util/qcompleter.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 63 63 \snippet doc/src/snippets/code/src_gui_util_qcompleter.cpp 0 64 64 65 A Q DirModel can be used to provide auto completion of file names.65 A QFileSystemModel can be used to provide auto completion of file names. 66 66 For example: 67 67 … … 121 121 122 122 Let's take the example of a user typing in a file system path. 123 The model is a (hierarchical) Q DirModel. The completion123 The model is a (hierarchical) QFileSystemModel. The completion 124 124 occurs for every element in the path. For example, if the current 125 125 text is \c C:\Wind, QCompleter might suggest \c Windows to … … 131 131 For \c C:\Windows\Sy, it needs to be split as "C:", "Windows" and "Sy". 132 132 The default implementation of splitPath(), splits the completionPrefix 133 using QDir::separator() if the model is a Q DirModel.133 using QDir::separator() if the model is a QFileSystemModel. 134 134 135 135 To provide completions, QCompleter needs to know the path from an index. 136 136 This is provided by pathFromIndex(). The default implementation of 137 137 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 Q DirModel.138 for list models and the absolute file path if the mode is a QFileSystemModel. 139 139 140 140 \sa QAbstractItemModel, QLineEdit, QComboBox, {Completer Example} … … 148 148 #include "QtGui/qstringlistmodel.h" 149 149 #include "QtGui/qdirmodel.h" 150 #include "QtGui/qfilesystemmodel.h" 150 151 #include "QtGui/qheaderview.h" 151 152 #include "QtGui/qlistview.h" … … 154 155 #include "QtGui/qheaderview.h" 155 156 #include "QtGui/qdesktopwidget.h" 157 #include "QtGui/qlineedit.h" 156 158 157 159 QT_BEGIN_NAMESPACE … … 471 473 if (curParts.count() <= 1 || c->proxy->showAll || !source) 472 474 return QMatchData(); 473 bool dirModel = false; 475 bool isDirModel = false; 476 bool isFsModel = false; 474 477 #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); 476 482 #endif 477 483 QVector<int> v; … … 483 489 if (str.startsWith(c->prefix, c->cs) 484 490 #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()) 486 492 #endif 487 493 ) … … 777 783 QCompleterPrivate::QCompleterPrivate() 778 784 : 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) 780 787 { 781 788 } … … 844 851 } 845 852 #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 846 860 } 847 861 … … 867 881 Qt::LayoutDirection dir = widget->layoutDirection(); 868 882 QPoint pos; 869 int r w, rh, w;883 int rh, w; 870 884 int h = (popup->sizeHintForRow(0) * qMin(maxVisibleItems, popup->model()->rowCount()) + 3) + 3; 871 885 QScrollBar *hsb = popup->horizontalScrollBar(); … … 875 889 if (rect.isValid()) { 876 890 rh = rect.height(); 877 w = r w = rect.width();891 w = rect.width(); 878 892 pos = widget->mapToGlobal(dir == Qt::RightToLeft ? rect.bottomRight() : rect.bottomLeft()); 879 893 } else { 880 894 rh = widget->height(); 881 rw = widget->width();882 895 pos = widget->mapToGlobal(QPoint(0, widget->height() - 2)); 883 896 w = widget->width(); 884 897 } 885 898 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())) 887 902 pos.setX(screen.x() + screen.width() - w); 888 903 if (pos.x() < screen.x()) 889 904 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 } 892 915 893 916 popup->setGeometry(pos.x(), pos.y(), w, h); … … 895 918 if (!popup->isVisible()) 896 919 popup->show(); 920 } 921 922 void 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 } 897 933 } 898 934 … … 977 1013 and it has the QCompleter as its parent, it is deleted. 978 1014 979 For convenience, if \a model is a Q DirModel, QCompleter switches its1015 For convenience, if \a model is a QFileSystemModel, QCompleter switches its 980 1016 caseSensitivity to Qt::CaseInsensitive on Windows and Qt::CaseSensitive 981 1017 on other platforms. … … 1001 1037 } 1002 1038 #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 1003 1051 } 1004 1052 … … 1084 1132 if (popup->model() != d->proxy) 1085 1133 popup->setModel(d->proxy); 1086 #if def Q_OS_MAC1134 #if defined(Q_OS_MAC) && !defined(QT_MAC_USE_COCOA) 1087 1135 popup->show(); 1088 1136 #else … … 1156 1204 1157 1205 if (d->eatFocusOut && o == d->widget && e->type() == QEvent::FocusOut) { 1206 d->hiddenBecauseNoMatch = false; 1158 1207 if (d->popup && d->popup->isVisible()) 1159 1208 return true; … … 1334 1383 Q_D(QCompleter); 1335 1384 QModelIndex idx = d->proxy->currentIndex(false); 1385 d->hiddenBecauseNoMatch = false; 1336 1386 if (d->mode == QCompleter::InlineCompletion) { 1337 1387 if (idx.isValid()) … … 1345 1395 if (d->popup) 1346 1396 d->popup->hide(); // no suggestion, hide 1397 d->hiddenBecauseNoMatch = true; 1347 1398 return; 1348 1399 } … … 1632 1683 The default implementation returns the \l{Qt::EditRole}{edit role} of the 1633 1684 item for list models. It returns the absolute file path if the model is a 1634 Q DirModel.1685 QFileSystemModel. 1635 1686 1636 1687 \sa splitPath() 1637 1688 */ 1689 1638 1690 QString QCompleter::pathFromIndex(const QModelIndex& index) const 1639 1691 { … … 1645 1697 if (!sourceModel) 1646 1698 return QString(); 1699 bool isDirModel = false; 1700 bool isFsModel = false; 1647 1701 #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) 1651 1708 return sourceModel->data(index, d->role).toString(); 1652 1709 … … 1654 1711 QStringList list; 1655 1712 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 1657 1720 list.prepend(t); 1658 1721 QModelIndex parent = idx.parent(); … … 1674 1737 1675 1738 The default implementation of splitPath() splits a file system path based on 1676 QDir::separator() when the sourceModel() is a Q DirModel.1739 QDir::separator() when the sourceModel() is a QFileSystemModel. 1677 1740 1678 1741 When used with list models, the first item in the returned list is used for … … 1684 1747 { 1685 1748 bool isDirModel = false; 1749 bool isFsModel = false; 1686 1750 #ifndef QT_NO_DIRMODEL 1687 1751 Q_D(const QCompleter); 1688 1752 isDirModel = qobject_cast<QDirModel *>(d->proxy->sourceModel()) != 0; 1689 1753 #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()) 1692 1762 return QStringList(completionPrefix()); 1693 1763 -
trunk/src/gui/util/qcompleter.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 160 160 Q_PRIVATE_SLOT(d_func(), void _q_completionSelected(const QItemSelection&)) 161 161 Q_PRIVATE_SLOT(d_func(), void _q_autoResizePopup()) 162 Q_PRIVATE_SLOT(d_func(), void _q_fileSystemModelDirectoryLoaded(const QString&)) 162 163 }; 163 164 -
trunk/src/gui/util/qcompleter_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 94 94 bool eatFocusOut; 95 95 QRect popupRect; 96 bool hiddenBecauseNoMatch; 96 97 97 98 void showPopup(const QRect&); … … 99 100 void _q_completionSelected(const QItemSelection&); 100 101 void _q_autoResizePopup(); 102 void _q_fileSystemModelDirectoryLoaded(const QString &path); 101 103 void setCurrentIndex(QModelIndex, bool = true); 102 104 }; -
trunk/src/gui/util/qdesktopservices.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/util/qdesktopservices.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/util/qdesktopservices_mac.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/util/qdesktopservices_qws.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/util/qdesktopservices_s60.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 40 40 ****************************************************************************/ 41 41 42 // This flag changes the implementation to use S60 CDcoumentHandler43 // instead of apparch when opening the files44 #define USE_DOCUMENTHANDLER45 42 46 43 #include <qcoreapplication.h> … … 49 46 #include <private/qcore_symbian_p.h> 50 47 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 51 58 #include <txtrich.h> // CRichText 52 #include <f32file.h> // TDriveUnit etc53 59 #include <eikenv.h> // CEikonEnv 54 60 #include <apgcli.h> // RApaLsSession … … 57 63 #include <rsendasmessage.h> // RSendAsMessage 58 64 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> 71 71 #endif 72 72 … … 77 77 _LIT(KBrowserPrefix, "4 " ); 78 78 _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 82 const TUid KUidMsgTypeSMTP = {0x10001028}; // 268439592 79 83 const TUid KUidBrowser = { 0x10008D39 }; 80 84 … … 135 139 #endif 136 140 137 138 141 static void handleMailtoSchemeLX(const QUrl &url) 139 142 { … … 153 156 QStringList bccs = bcc.split(QLatin1String(","), QString::SkipEmptyParts); 154 157 155 156 158 RSendAs sendAs; 157 159 User::LeaveIfError(sendAs.Connect()); 158 160 QAutoClose<RSendAs> sendAsCleanup(sendAs); 159 160 161 161 162 CSendAsAccounts* accounts = CSendAsAccounts::NewL(); … … 221 222 if (task.Exists()){ 222 223 // Switch to existing browser instance 224 task.BringToForeground(); 223 225 HBufC8* param8 = HBufC8::NewLC(buf16->Length()); 224 226 param8->Des().Append(buf16->Des()); … … 246 248 } 247 249 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_S60268 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 instead278 return PathInfo::PhoneMemoryRootPath();279 break;280 default:281 return PathInfo::PhoneMemoryRootPath();282 break;283 }284 #else285 #warning No fallback implementation of writableDataRoot()286 return 0;287 #endif288 }289 250 290 251 static void openDocumentL(const TDesC& aUrl) … … 311 272 } 312 273 313 #ifdef USE_SCHEMEHANDLER314 // The schemehandler component only exist in private SDK. This implementation315 // exist here just for convenience in case that we need to use it later on316 // The schemehandle based implementation is not yet tested.317 318 // The biggest advantage of schemehandler is that it can handle319 // wide range of schemes and is extensible by plugins320 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 mode336 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 #endif348 349 274 static bool launchWebBrowser(const QUrl &url) 350 275 { … … 370 295 } 371 296 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 304 static 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 312 static 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 323 static bool launchWebBrowser(const QUrl &url) 324 { 325 return handleUrl(url); 326 } 327 328 static bool openDocument(const QUrl &file) 329 { 330 return handleUrl(file); 331 } 332 333 #endif //USE_SCHEMEHANDLER 334 335 // Common functions to all implementations 336 337 static TDriveUnit exeDrive() 338 { 339 RProcess me; 340 TFileName processFileName = me.FileName(); 341 TDriveUnit drive(processFileName); 342 return drive; 343 } 344 345 static TDriveUnit writableExeDrive() 346 { 347 TDriveUnit drive = exeDrive(); 348 if (drive.operator TInt() == EDriveZ) 349 return TDriveUnit(EDriveC); 350 return drive; 351 } 352 353 static 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 372 374 QString QDesktopServices::storageLocation(StandardLocation type) 373 375 { … … 392 394 case MusicLocation: 393 395 path.Append(writableDataRoot()); 394 #ifdef Q_WS_S60395 396 path.Append(PathInfo::SoundsPath()); 396 #endif397 397 break; 398 398 case MoviesLocation: 399 399 path.Append(writableDataRoot()); 400 #ifdef Q_WS_S60401 400 path.Append(PathInfo::VideosPath()); 402 #endif403 401 break; 404 402 case PicturesLocation: 405 403 path.Append(writableDataRoot()); 406 #ifdef Q_WS_S60407 404 path.Append(PathInfo::ImagesPath()); 408 #endif409 405 break; 410 406 case TempLocation: … … 416 412 break; 417 413 case DataLocation: 418 CEikonEnv::Static()->FsSession().PrivatePath(path);414 qt_s60GetRFs().PrivatePath(path); 419 415 path.Insert(0, writableExeDrive().Name()); 420 416 break; 421 417 case CacheLocation: 422 CEikonEnv::Static()->FsSession().PrivatePath(path);418 qt_s60GetRFs().PrivatePath(path); 423 419 path.Insert(0, writableExeDrive().Name()); 424 420 path.Append(KCacheSubDir); -
trunk/src/gui/util/qdesktopservices_win.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 42 42 #include <qsettings.h> 43 43 #include <qdir.h> 44 #include < qlibrary.h>44 #include <private/qsystemlibrary_p.h> 45 45 #include <qurl.h> 46 46 #include <qstringlist.h> … … 60 60 #endif 61 61 62 #if defined(Q_CC_MINGW) && !defined(CSIDL_MYMUSIC)62 #ifndef CSIDL_MYMUSIC 63 63 #define CSIDL_MYMUSIC 13 64 64 #define CSIDL_MYVIDEO 14 … … 98 98 //Retrieve the commandline for the default mail client 99 99 //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; 101 101 long returnValue = -1; 102 102 QString command; … … 104 104 HKEY handle; 105 105 LONG res; 106 wchar_t keyValue[ 2 *MAX_PATH] = {0};106 wchar_t keyValue[MAX_PATH] = {0}; 107 107 QString keyName(QLatin1String("mailto")); 108 108 109 109 //Check if user has set preference, otherwise use default. 110 res = RegOpenKeyEx W(HKEY_CURRENT_USER,111 112 110 res = RegOpenKeyEx(HKEY_CURRENT_USER, 111 L"Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\mailto\\UserChoice", 112 0, KEY_READ, &handle); 113 113 if (res == ERROR_SUCCESS) { 114 114 returnValue = RegQueryValueEx(handle, L"Progid", 0, 0, reinterpret_cast<unsigned char*>(keyValue), &bufferSize); … … 122 122 return false; 123 123 124 bufferSize = 2* MAX_PATH;125 returnValue = RegQueryValueEx W(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); 126 126 if (!returnValue) 127 127 command = QString::fromRawData((QChar*)keyValue, bufferSize); … … 178 178 179 179 #ifndef Q_OS_WINCE 180 Q Library library(QLatin1String("shell32"));181 #else 182 Q Library library(QLatin1String("coredll"));180 QSystemLibrary library(QLatin1String("shell32")); 181 #else 182 QSystemLibrary library(QLatin1String("coredll")); 183 183 #endif // Q_OS_WINCE 184 184 typedef BOOL (WINAPI*GetSpecialFolderPath)(HWND, LPWSTR, int, BOOL); -
trunk/src/gui/util/qdesktopservices_x11.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 72 72 return true; 73 73 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"))) { 75 77 return true; 76 78 } 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"))) 78 80 return true; 79 81 } … … 105 107 return true; 106 108 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"))) { 108 112 return true; 109 113 } 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"))) 111 115 return true; 112 116 } -
trunk/src/gui/util/qsystemtrayicon.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 357 357 bool QSystemTrayIcon::supportsMessages() 358 358 { 359 #if defined(Q_WS_QWS) 360 return false; 361 #endif 362 return true; 359 return QSystemTrayIconPrivate::supportsMessages_sys(); 363 360 } 364 361 -
trunk/src/gui/util/qsystemtrayicon.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/util/qsystemtrayicon_mac.mm
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 76 76 #define QT_MAC_SYSTEMTRAY_USE_GROWL 77 77 78 @class QNSMenu;79 80 78 #include <private/qt_cocoa_helpers_mac_p.h> 81 79 #include <private/qsystemtrayicon_p.h> … … 94 92 extern NSString *keySequenceToKeyEqivalent(const QKeySequence &accel); // qmenu_mac.mm 95 93 extern NSUInteger keySequenceModifierMask(const QKeySequence &accel); // qmenu_mac.mm 94 extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); 96 95 QT_END_NAMESPACE 97 96 98 97 QT_USE_NAMESPACE 99 98 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 { 103 103 NSStatusItem *item; 104 104 QSystemTrayIcon *icon; 105 105 QSystemTrayIconPrivate *iconPrivate; 106 Q NSImageView*imageCell;106 QT_MANGLE_NAMESPACE(QNSImageView) *imageCell; 107 107 } 108 108 -(id)initWithIcon:(QSystemTrayIcon*)icon iconPrivate:(QSystemTrayIconPrivate *)iprivate; … … 111 111 -(NSStatusItem*)item; 112 112 -(QRectF)geometry; 113 - (void)triggerSelector:(id)sender ;113 - (void)triggerSelector:(id)sender button:(Qt::MouseButton)mouseButton; 114 114 - (void)doubleClickSelector:(id)sender; 115 115 @end 116 116 117 @interface Q NSImageView: NSImageView {117 @interface QT_MANGLE_NAMESPACE(QNSImageView) : NSImageView { 118 118 BOOL down; 119 Q NSStatusItem*parent;120 } 121 -(id)initWithParent:(Q NSStatusItem*)myParent;119 QT_MANGLE_NAMESPACE(QNSStatusItem) *parent; 120 } 121 -(id)initWithParent:(QT_MANGLE_NAMESPACE(QNSStatusItem)*)myParent; 122 122 -(QSystemTrayIcon*)icon; 123 123 -(void)menuTrackingDone:(NSNotification*)notification; 124 -(void)mousePressed:(NSEvent *)mouseEvent ;124 -(void)mousePressed:(NSEvent *)mouseEvent button:(Qt::MouseButton)mouseButton; 125 125 @end 126 126 … … 134 134 135 135 136 @interface Q NSMenu: NSMenu <NSMenuDelegate> {136 @interface QT_MANGLE_NAMESPACE(QNSMenu) : NSMenu <NSMenuDelegate> { 137 137 QMenu *qmenu; 138 138 } … … 148 148 QSystemTrayIconSys(QSystemTrayIcon *icon, QSystemTrayIconPrivate *d) { 149 149 QMacCocoaAutoReleasePool pool; 150 item = [[Q NSStatusItemalloc] initWithIcon:icon iconPrivate:d];150 item = [[QT_MANGLE_NAMESPACE(QNSStatusItem) alloc] initWithIcon:icon iconPrivate:d]; 151 151 } 152 152 ~QSystemTrayIconSys() { … … 155 155 [item release]; 156 156 } 157 Q NSStatusItem*item;157 QT_MANGLE_NAMESPACE(QNSStatusItem) *item; 158 158 }; 159 159 … … 223 223 224 224 bool QSystemTrayIconPrivate::isSystemTrayAvailable_sys() 225 { 226 return true; 227 } 228 229 bool QSystemTrayIconPrivate::supportsMessages_sys() 225 230 { 226 231 return true; … … 299 304 @end 300 305 301 @implementation Q NSImageView302 -(id)initWithParent:(Q NSStatusItem*)myParent {306 @implementation QT_MANGLE_NAMESPACE(QNSImageView) 307 -(id)initWithParent:(QT_MANGLE_NAMESPACE(QNSStatusItem)*)myParent { 303 308 self = [super init]; 304 309 parent = myParent; … … 334 339 } 335 340 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]; 342 345 [self setNeedsDisplay:YES]; 343 346 … … 349 352 #endif 350 353 351 if ( down &&![self icon]->icon().isNull() ) {354 if (![self icon]->icon().isNull() ) { 352 355 NSImage *nsaltimage = static_cast<NSImage *>(qt_mac_create_nsimage([self icon]->icon().pixmap(QSize(scale, scale), QIcon::Selected))); 353 356 [self setImage: nsaltimage]; … … 355 358 } 356 359 357 358 if (down) 359 [parent triggerSelector:self]; 360 else if ((clickCount%2)) 360 if ((clickCount == 2)) { 361 [self menuTrackingDone:nil]; 361 362 [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 } 380 366 } 381 367 382 368 -(void)mouseDown:(NSEvent *)mouseEvent 383 369 { 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]; 385 377 } 386 378 387 379 - (void)rightMouseDown:(NSEvent *)mouseEvent 388 380 { 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 } 392 400 393 401 -(void)drawRect:(NSRect)rect { … … 397 405 @end 398 406 399 @implementation Q NSStatusItem407 @implementation QT_MANGLE_NAMESPACE(QNSStatusItem) 400 408 401 409 -(id)initWithIcon:(QSystemTrayIcon*)i iconPrivate:(QSystemTrayIconPrivate *)iPrivate … … 406 414 iconPrivate = iPrivate; 407 415 item = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength] retain]; 408 imageCell = [[Q NSImageViewalloc] initWithParent:self];416 imageCell = [[QT_MANGLE_NAMESPACE(QNSImageView) alloc] initWithParent:self]; 409 417 [item setView: imageCell]; 410 418 } … … 434 442 return QRectF(); 435 443 } 436 - (void)triggerSelector:(id)sender { 444 445 - (void)triggerSelector:(id)sender button:(Qt::MouseButton)mouseButton { 437 446 Q_UNUSED(sender); 438 if (!icon)447 if (!icon) 439 448 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 441 455 if (icon->contextMenu()) { 442 #if 0443 const QRectF geom = [self geometry];444 if(!geom.isNull()) {445 [[NSNotificationCenter defaultCenter] addObserver:imageCell446 selector:@selector(menuTrackingDone:)447 name:nil448 object:self];449 icon->contextMenu()->exec(geom.topLeft().toPoint(), 0);450 [imageCell menuTrackingDone:nil];451 } else452 #endif453 {454 456 #ifndef QT_MAC_USE_COCOA 455 456 457 #endif 458 NSMenu *m = [[QNSMenualloc] initWithQMenu:icon->contextMenu()];459 460 461 462 463 464 465 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 469 471 - (void)doubleClickSelector:(id)sender { 470 472 Q_UNUSED(sender); … … 473 475 qtsystray_sendActivated(icon, QSystemTrayIcon::DoubleClick); 474 476 } 477 475 478 @end 476 479 … … 483 486 }; 484 487 485 @implementation Q NSMenu488 @implementation QT_MANGLE_NAMESPACE(QNSMenu) 486 489 -(id)initWithQMenu:(QMenu*)qm { 487 490 self = [super init]; … … 496 499 } 497 500 -(void)menuNeedsUpdate:(NSMenu*)nsmenu { 498 Q NSMenu *menu = static_cast<QNSMenu*>(nsmenu);501 QT_MANGLE_NAMESPACE(QNSMenu) *menu = static_cast<QT_MANGLE_NAMESPACE(QNSMenu) *>(nsmenu); 499 502 emit static_cast<QSystemTrayIconQMenu*>(menu->qmenu)->doAboutToShow(); 500 503 for(int i = [menu numberOfItems]-1; i >= 0; --i) … … 541 544 } 542 545 if(action->menu()) { 543 Q NSMenu *sub = [[QNSMenualloc] initWithQMenu:action->menu()];546 QT_MANGLE_NAMESPACE(QNSMenu) *sub = [[QT_MANGLE_NAMESPACE(QNSMenu) alloc] initWithQMenu:action->menu()]; 544 547 [item setSubmenu:sub]; 545 548 } else { -
trunk/src/gui/util/qsystemtrayicon_p.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 84 84 QRect geometry_sys() const; 85 85 void showMessage_sys(const QString &msg, const QString &title, QSystemTrayIcon::MessageIcon icon, int secs); 86 86 87 static bool isSystemTrayAvailable_sys(); 88 static bool supportsMessages_sys(); 87 89 88 90 QPointer<QMenu> menu; -
trunk/src/gui/util/qsystemtrayicon_qws.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 76 76 } 77 77 78 bool QSystemTrayIconPrivate::supportsMessages_sys() 79 { 80 return false; 81 } 82 78 83 void QSystemTrayIconPrivate::showMessage_sys(const QString &message, 79 84 const QString &title, -
trunk/src/gui/util/qsystemtrayicon_win.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 42 42 #include "qsystemtrayicon_p.h" 43 43 #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 52 51 #endif 53 52 54 53 #include <qt_windows.h> 54 #include <windowsx.h> 55 55 #include <commctrl.h> 56 #include <shlwapi.h> 57 #include <QBitmap> 58 #include <QLibrary> 56 57 #include <private/qsystemlibrary_p.h> 59 58 #include <QApplication> 60 #include <QToolTip>61 #include <QDesktopWidget>62 59 #include <QSettings> 63 60 … … 76 73 }; 77 74 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 78 99 #define Q_MSGFLT_ALLOW 1 79 100 … … 89 110 bool winEvent( MSG *m, long *result ); 90 111 bool trayMessage(DWORD msg); 91 bool iconDrawItem(LPDRAWITEMSTRUCT lpdi);92 112 void setIconContents(NOTIFYICONDATA &data); 93 113 bool showMessage(const QString &title, const QString &message, QSystemTrayIcon::MessageIcon type, uint uSecs); 94 bool allowsMessages();95 bool supportsMessages();96 114 QRect findIconGeometry(const int a_iButtonID); 97 115 void createIcon(); … … 102 120 uint notifyIconSize; 103 121 int maxTipLength; 122 int version; 104 123 bool ignoreNextMouseRelease; 105 124 }; 106 125 107 bool QSystemTrayIconSys::allowsMessages()126 static bool allowsMessages() 108 127 { 109 128 #ifndef QT_NO_SETTINGS … … 116 135 } 117 136 118 bool QSystemTrayIconSys::supportsMessages()119 {120 return allowsMessages();121 }122 123 137 QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *object) 124 138 : hIcon(0), q(object), ignoreNextMouseRelease(false) 125 139 126 140 { 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 128 149 maxTipLength = 128; 129 150 … … 135 156 // Allow the WM_TASKBARCREATED message through the UIPI filter on Windows Vista and higher 136 157 static PtrChangeWindowMessageFilterEx pChangeWindowMessageFilterEx = 137 (PtrChangeWindowMessageFilterEx)Q Library::resolve(QLatin1String("user32"), "ChangeWindowMessageFilterEx");158 (PtrChangeWindowMessageFilterEx)QSystemLibrary::resolve(QLatin1String("user32"), "ChangeWindowMessageFilterEx"); 138 159 139 160 if (pChangeWindowMessageFilterEx) { … … 142 163 } else { 143 164 static PtrChangeWindowMessageFilter pChangeWindowMessageFilter = 144 (PtrChangeWindowMessageFilter)Q Library::resolve(QLatin1String("user32"), "ChangeWindowMessageFilter");165 (PtrChangeWindowMessageFilter)QSystemLibrary::resolve(QLatin1String("user32"), "ChangeWindowMessageFilter"); 145 166 146 167 if (pChangeWindowMessageFilter) { … … 159 180 void QSystemTrayIconSys::setIconContents(NOTIFYICONDATA &tnd) 160 181 { 161 tnd.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;182 tnd.uFlags |= NIF_MESSAGE | NIF_ICON | NIF_TIP; 162 183 tnd.uCallbackMessage = MYWM_NOTIFYICON; 163 184 tnd.hIcon = hIcon; … … 172 193 static int iconFlag( QSystemTrayIcon::MessageIcon icon ) 173 194 { 174 #if NOTIFYICON_VERSION >= 3175 195 switch (icon) { 176 196 case QSystemTrayIcon::Information: … … 186 206 return NIIF_NONE; 187 207 } 188 #else189 Q_UNUSED(icon);190 return 0;191 #endif192 208 } 193 209 194 210 bool QSystemTrayIconSys::showMessage(const QString &title, const QString &message, QSystemTrayIcon::MessageIcon type, uint uSecs) 195 211 { 196 #if NOTIFYICON_VERSION >= 3197 212 NOTIFYICONDATA tnd; 198 213 memset(&tnd, 0, notifyIconSize); 199 Q_ASSERT(testAttribute(Qt::WA_WState_Created)); 200 201 setIconContents(tnd); 214 202 215 memcpy(tnd.szInfo, message.utf16(), qMin(message.length() + 1, 256) * sizeof(wchar_t)); 203 216 memcpy(tnd.szInfoTitle, title.utf16(), qMin(title.length() + 1, 64) * sizeof(wchar_t)); … … 208 221 tnd.hWnd = winId(); 209 222 tnd.uTimeout = uSecs; 210 tnd.uFlags = NIF_INFO; 223 tnd.uFlags = NIF_INFO | NIF_SHOWTIP; 224 225 Q_ASSERT(testAttribute(Qt::WA_WState_Created)); 211 226 212 227 return Shell_NotifyIcon(NIM_MODIFY, &tnd); 213 #else214 Q_UNUSED(title);215 Q_UNUSED(message);216 Q_UNUSED(type);217 Q_UNUSED(uSecs);218 return false;219 #endif220 228 } 221 229 … … 224 232 NOTIFYICONDATA tnd; 225 233 memset(&tnd, 0, notifyIconSize); 234 226 235 tnd.uID = q_uNOTIFYICONID; 227 236 tnd.cbSize = notifyIconSize; 228 237 tnd.hWnd = winId(); 238 tnd.uFlags = NIF_SHOWTIP; 239 tnd.uVersion = version; 229 240 230 241 Q_ASSERT(testAttribute(Qt::WA_WState_Created)); 231 242 232 if (msg != NIM_DELETE) {243 if (msg == NIM_ADD || msg == NIM_MODIFY) { 233 244 setIconContents(tnd); 234 245 } 235 246 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; 246 253 } 247 254 … … 266 273 { 267 274 switch(m->message) { 268 case WM_CREATE:269 #ifdef GWLP_USERDATA270 SetWindowLongPtr(winId(), GWLP_USERDATA, (LONG_PTR)((CREATESTRUCTW*)m->lParam)->lpCreateParams);271 #else272 SetWindowLong(winId(), GWL_USERDATA, (LONG)((CREATESTRUCTW*)m->lParam)->lpCreateParams);273 #endif274 break;275 276 case WM_DRAWITEM:277 return iconDrawItem((LPDRAWITEMSTRUCT)m->lParam);278 279 275 case MYWM_NOTIFYICON: 280 276 { 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: 289 293 if (ignoreNextMouseRelease) 290 294 ignoreNextMouseRelease = false; … … 299 303 break; 300 304 301 case WM_ RBUTTONUP:305 case WM_CONTEXTMENU: 302 306 if (q->contextMenu()) { 303 307 q->contextMenu()->popup(gpos); 304 q->contextMenu()->activateWindow();305 //Must be activated for proper keyboardfocus and menu closing on windows:306 308 } 307 309 emit q->activated(QSystemTrayIcon::Context); … … 315 317 emit q->activated(QSystemTrayIcon::MiddleClick); 316 318 break; 319 317 320 default: 318 break; 319 } 320 if (e) { 321 bool res = QApplication::sendEvent(q, e); 322 delete e; 323 return res; 321 break; 324 322 } 325 323 break; … … 353 351 { 354 352 static PtrShell_NotifyIconGetRect Shell_NotifyIconGetRect = 355 (PtrShell_NotifyIconGetRect)Q Library::resolve(QLatin1String("shell32"), "Shell_NotifyIconGetRect");353 (PtrShell_NotifyIconGetRect)QSystemLibrary::resolve(QLatin1String("shell32"), "Shell_NotifyIconGetRect"); 356 354 357 355 if (Shell_NotifyIconGetRect) { … … 445 443 void QSystemTrayIconPrivate::showMessage_sys(const QString &title, const QString &message, QSystemTrayIcon::MessageIcon type, int timeOut) 446 444 { 447 if (!sys || ! sys->allowsMessages())445 if (!sys || !allowsMessages()) 448 446 return; 449 447 … … 463 461 QString titleString = title.left(63) + QChar(); 464 462 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); 474 464 } 475 465 … … 478 468 if (!sys) 479 469 return QRect(); 470 480 471 return sys->findIconGeometry(q_uNOTIFYICONID); 481 472 } … … 523 514 } 524 515 516 bool QSystemTrayIconPrivate::supportsMessages_sys() 517 { 518 return allowsMessages(); 519 } 520 525 521 QT_END_NAMESPACE 526 522 -
trunk/src/gui/util/qsystemtrayicon_wince.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 156 156 case MYWM_NOTIFYICON: 157 157 { 158 RECT r;159 GetWindowRect(winId(), &r);160 QEvent *e = 0;161 Qt::KeyboardModifiers keys = QApplication::keyboardModifiers();162 158 QPoint gpos = QCursor::pos(); 163 159 … … 187 183 q->contextMenu()->move(gpos); 188 184 } 189 190 q->contextMenu()->activateWindow();191 //Must be activated for proper keyboardfocus and menu closing on windows:192 185 } 193 186 emit q->activated(QSystemTrayIcon::Context); … … 197 190 emit q->activated(QSystemTrayIcon::MiddleClick); 198 191 break; 192 199 193 default: 200 194 break; 201 }202 if (e) {203 bool res = QApplication::sendEvent(q, e);204 delete e;205 return res;206 195 } 207 196 break; … … 295 284 } 296 285 286 bool QSystemTrayIconPrivate::supportsMessages_sys() 287 { 288 return true; 289 } 290 297 291 QT_END_NAMESPACE 298 292 -
trunk/src/gui/util/qsystemtrayicon_x11.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 382 382 } 383 383 384 bool QSystemTrayIconPrivate::supportsMessages_sys() 385 { 386 return true; 387 } 388 384 389 void QSystemTrayIconPrivate::showMessage_sys(const QString &message, const QString &title, 385 390 QSystemTrayIcon::MessageIcon icon, int msecs) -
trunk/src/gui/util/qundogroup.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/util/qundogroup.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/util/qundostack.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 442 442 /*! 443 443 Constructs an empty undo stack with the parent \a parent. The 444 stack will init ally be in the clean state. If \a parent is a444 stack will initially be in the clean state. If \a parent is a 445 445 QUndoGroup object, the stack is automatically added to the group. 446 446 -
trunk/src/gui/util/qundostack.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/util/qundostack_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/util/qundoview.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/util/qundoview.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/util/util.pri
r835 r846 53 53 54 54 symbian { 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 } 57 68 }
Note:
See TracChangeset
for help on using the changeset viewer.