Changeset 561 for trunk/src/gui/dialogs
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 58 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/dialogs/dialogs.pri
r2 r561 8 8 dialogs/qcolordialog.h \ 9 9 dialogs/qcolordialog_p.h \ 10 dialogs/qfscompleter_p.h \ 10 11 dialogs/qdialog.h \ 11 12 dialogs/qdialog_p.h \ … … 28 29 29 30 !embedded:mac { 30 OBJECTIVE_SOURCES += dialogs/qcolordialog_mac.mm \ 31 dialogs/qfiledialog_mac.mm \ 31 OBJECTIVE_SOURCES += dialogs/qfiledialog_mac.mm \ 32 32 dialogs/qfontdialog_mac.mm \ 33 33 dialogs/qnspanelproxy_mac.mm \ 34 34 dialogs/qpagesetupdialog_mac.mm \ 35 35 dialogs/qprintdialog_mac.mm 36 37 # Compile qcolordialog_mac.mm with exception support, disregarding the -no-exceptions 38 # configure option. (qcolordialog_mac needs to catch exceptions thrown by cocoa) 39 EXCEPTION_SOURCES = dialogs/qcolordialog_mac.mm 40 exceptions_compiler.commands = $$QMAKE_CXX -c 41 exceptions_compiler.commands += $(CXXFLAGS) $(INCPATH) ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT} 42 exceptions_compiler.commands += -fexceptions 43 exceptions_compiler.dependency_type = TYPE_C 44 exceptions_compiler.output = ${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_BASE}$${first(QMAKE_EXT_OBJ)} 45 exceptions_compiler.input = EXCEPTION_SOURCES 46 exceptions_compiler.variable_out = OBJECTS 47 exceptions_compiler.name = compiling[exceptopns] ${QMAKE_FILE_IN} 48 silent:exceptions_compiler.commands = @echo compiling[exceptopns] ${QMAKE_FILE_IN} && $$exceptions_compiler.commands 49 QMAKE_EXTRA_COMPILERS += exceptions_compiler 36 50 } 51 37 52 win32 { 38 53 HEADERS += dialogs/qwizard_win_p.h … … 46 61 } 47 62 48 !mac:!embedded: unix {63 !mac:!embedded:!symbian:unix { 49 64 HEADERS += dialogs/qpagesetupdialog_unix_p.h 50 65 SOURCES += dialogs/qprintdialog_unix.cpp \ … … 71 86 } 72 87 73 wince* : FORMS += dialogs/qfiledialog_wince.ui88 wince*|symbian: FORMS += dialogs/qfiledialog_embedded.ui 74 89 else: FORMS += dialogs/qfiledialog.ui 75 90 -
trunk/src/gui/dialogs/qabstractpagesetupdialog.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** -
trunk/src/gui/dialogs/qabstractpagesetupdialog.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** -
trunk/src/gui/dialogs/qabstractpagesetupdialog_p.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** -
trunk/src/gui/dialogs/qabstractprintdialog.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 59 59 \brief The QAbstractPrintDialog class provides a base implementation for 60 60 print dialogs used to configure printers. 61 62 \ingroup printing 61 63 62 64 This class implements getter and setter functions that are used to … … 358 360 the printer's configuration. 359 361 360 \ingroup dialogs 362 \ingroup standard-dialogs 363 \ingroup printing 361 364 362 365 The dialog allows users to change document-related settings, such … … 396 399 On Windows and Mac OS X, the native print dialog is used, which means that 397 400 some QWidget and QDialog properties set on the dialog won't be respected. 398 The native print dialog on 399 Mac OS X does not support setting printer options, i.e. 400 QAbstractPrintDialog::setEnabledOptions() and 401 QAbstractPrintDialog::addEnabledOption() have no effect. 402 403 In Qt 4.4, it was possible to use the satic functions to show a sheet on 401 The native print dialog on Mac OS X does not support setting printer options, 402 i.e. setOptions() and setOption() have no effect. 403 404 In Qt 4.4, it was possible to use the static functions to show a sheet on 404 405 Mac OS X. This is no longer supported in Qt 4.5. If you want this 405 406 functionality, use QPrintDialog::open(). -
trunk/src/gui/dialogs/qabstractprintdialog.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** -
trunk/src/gui/dialogs/qabstractprintdialog_p.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** -
trunk/src/gui/dialogs/qcolordialog.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 63 63 #include "qspinbox.h" 64 64 #include "qdialogbuttonbox.h" 65 #include "private/qguiplatformplugin_p.h" 66 67 #ifdef Q_WS_S60 68 #include "private/qt_s60_p.h" 69 #endif 65 70 66 71 QT_BEGIN_NAMESPACE … … 1067 1072 gl->setMargin(gl->spacing()); 1068 1073 lab = new QColorShowLabel(this); 1069 #ifndef Q_OS_WINCE 1074 1075 #ifdef Q_WS_S60 1076 QS60Data s60Data = QS60Data(); 1077 const bool nonTouchUI = !s60Data.hasTouchscreen; 1078 #endif 1079 1080 1081 #ifndef Q_WS_WINCE 1082 #ifdef Q_WS_S60 1083 lab->setMinimumHeight(60); 1084 #endif 1070 1085 lab->setMinimumWidth(60); 1071 1086 #else 1072 1087 lab->setMinimumWidth(20); 1073 1088 #endif 1089 1090 // In S60, due to small screen and different screen layouts need to re-arrange the widgets. 1091 // For QVGA screens only the comboboxes and color label are visible. 1092 // For nHD screens only color and luminence pickers and color label are visible. 1093 #ifndef Q_WS_S60 1074 1094 gl->addWidget(lab, 0, 0, -1, 1); 1095 #else 1096 if (nonTouchUI) 1097 gl->addWidget(lab, 0, 0, 1, -1); 1098 else 1099 gl->addWidget(lab, 0, 0, -1, 1); 1100 #endif 1075 1101 connect(lab, SIGNAL(colorDropped(QRgb)), this, SIGNAL(newCol(QRgb))); 1076 1102 connect(lab, SIGNAL(colorDropped(QRgb)), this, SLOT(setRgb(QRgb))); … … 1083 1109 #endif 1084 1110 lblHue->setAlignment(Qt::AlignRight|Qt::AlignVCenter); 1111 #ifndef Q_WS_S60 1085 1112 gl->addWidget(lblHue, 0, 1); 1086 1113 gl->addWidget(hEd, 0, 2); 1114 #else 1115 if (nonTouchUI) { 1116 gl->addWidget(lblHue, 1, 0); 1117 gl->addWidget(hEd, 2, 0); 1118 } else { 1119 lblHue->hide(); 1120 hEd->hide(); 1121 } 1122 #endif 1087 1123 1088 1124 sEd = new QColSpinBox(this); … … 1092 1128 #endif 1093 1129 lblSat->setAlignment(Qt::AlignRight|Qt::AlignVCenter); 1130 #ifndef Q_WS_S60 1094 1131 gl->addWidget(lblSat, 1, 1); 1095 1132 gl->addWidget(sEd, 1, 2); 1133 #else 1134 if (nonTouchUI) { 1135 gl->addWidget(lblSat, 1, 1); 1136 gl->addWidget(sEd, 2, 1); 1137 } else { 1138 lblSat->hide(); 1139 sEd->hide(); 1140 } 1141 #endif 1096 1142 1097 1143 vEd = new QColSpinBox(this); … … 1101 1147 #endif 1102 1148 lblVal->setAlignment(Qt::AlignRight|Qt::AlignVCenter); 1149 #ifndef Q_WS_S60 1103 1150 gl->addWidget(lblVal, 2, 1); 1104 1151 gl->addWidget(vEd, 2, 2); 1152 #else 1153 if (nonTouchUI) { 1154 gl->addWidget(lblVal, 1, 2); 1155 gl->addWidget(vEd, 2, 2); 1156 } else { 1157 lblVal->hide(); 1158 vEd->hide(); 1159 } 1160 #endif 1105 1161 1106 1162 rEd = new QColSpinBox(this); … … 1110 1166 #endif 1111 1167 lblRed->setAlignment(Qt::AlignRight|Qt::AlignVCenter); 1168 #ifndef Q_WS_S60 1112 1169 gl->addWidget(lblRed, 0, 3); 1113 1170 gl->addWidget(rEd, 0, 4); 1171 #else 1172 if (nonTouchUI) { 1173 gl->addWidget(lblRed, 3, 0); 1174 gl->addWidget(rEd, 4, 0); 1175 } else { 1176 lblRed->hide(); 1177 rEd->hide(); 1178 } 1179 #endif 1114 1180 1115 1181 gEd = new QColSpinBox(this); … … 1119 1185 #endif 1120 1186 lblGreen->setAlignment(Qt::AlignRight|Qt::AlignVCenter); 1187 #ifndef Q_WS_S60 1121 1188 gl->addWidget(lblGreen, 1, 3); 1122 1189 gl->addWidget(gEd, 1, 4); 1190 #else 1191 if (nonTouchUI) { 1192 gl->addWidget(lblGreen, 3, 1); 1193 gl->addWidget(gEd, 4, 1); 1194 } else { 1195 lblGreen->hide(); 1196 gEd->hide(); 1197 } 1198 #endif 1123 1199 1124 1200 bEd = new QColSpinBox(this); … … 1128 1204 #endif 1129 1205 lblBlue->setAlignment(Qt::AlignRight|Qt::AlignVCenter); 1206 #ifndef Q_WS_S60 1130 1207 gl->addWidget(lblBlue, 2, 3); 1131 1208 gl->addWidget(bEd, 2, 4); 1209 #else 1210 if (nonTouchUI) { 1211 gl->addWidget(lblBlue, 3, 2); 1212 gl->addWidget(bEd, 4, 2); 1213 } else { 1214 lblBlue->hide(); 1215 bEd->hide(); 1216 } 1217 #endif 1132 1218 1133 1219 alphaEd = new QColSpinBox(this); … … 1137 1223 #endif 1138 1224 alphaLab->setAlignment(Qt::AlignRight|Qt::AlignVCenter); 1225 #ifndef Q_WS_S60 1139 1226 gl->addWidget(alphaLab, 3, 1, 1, 3); 1140 1227 gl->addWidget(alphaEd, 3, 4); 1228 #else 1229 if (nonTouchUI) { 1230 gl->addWidget(alphaLab, 1, 3, 3, 1); 1231 gl->addWidget(alphaEd, 4, 3); 1232 } else { 1233 alphaLab->hide(); 1234 alphaEd->hide(); 1235 } 1236 #endif 1141 1237 alphaEd->hide(); 1142 1238 alphaLab->hide(); … … 1263 1359 { 1264 1360 QColor oldQColor(curQColor); 1265 curQColor.setRgba(qRgba(qRed(curCol), qGreen(curCol), qBlue(curCol), qAlpha(curCol)));1361 curQColor.setRgba(qRgba(qRed(curCol), qGreen(curCol), qBlue(curCol), currentAlpha())); 1266 1362 if (curQColor != oldQColor) 1267 1363 emit currentColorChanged(curQColor); … … 1360 1456 q->setWindowTitle(QColorDialog::tr("Select Color")); 1361 1457 1458 nativeDialogInUse = false; 1459 1362 1460 nextCust = 0; 1363 1461 QVBoxLayout *mainLay = new QVBoxLayout(q); … … 1370 1468 leftLay = 0; 1371 1469 1372 #if defined(Q_OS_WINCE)1470 #if (defined(Q_WS_WINCE) || defined(Q_WS_S60)) 1373 1471 smallDisplay = true; 1374 1472 const int lumSpace = 20; … … 1376 1474 // small displays (e.g. PDAs) cannot fit the full color dialog, 1377 1475 // so just use the color picker. 1378 smallDisplay = ( qApp->desktop()->width() < 480 || qApp->desktop()->height() < 350);1476 smallDisplay = (QApplication::desktop()->width() < 480 || QApplication::desktop()->height() < 350); 1379 1477 const int lumSpace = topLay->spacing() / 2; 1380 1478 #endif … … 1400 1498 #endif 1401 1499 1500 #if defined(Q_WS_S60) 1501 QS60Data s60Data = QS60Data(); 1502 const bool nonTouchUI = !s60Data.hasTouchscreen; 1503 #endif 1504 1402 1505 if (!smallDisplay) { 1403 1506 standard = new QColorWell(q, 6, 8, stdrgb); … … 1410 1513 leftLay->addWidget(standard); 1411 1514 1412 #if !defined(Q_ OS_WINCE)1515 #if !defined(Q_WS_WINCE) 1413 1516 leftLay->addStretch(); 1414 1517 #endif … … 1430 1533 } else { 1431 1534 // better color picker size for small displays 1535 #ifdef Q_WS_S60 1536 QSize screenSize = QApplication::desktop()->availableGeometry(QCursor::pos()).size(); 1537 pWidth = pHeight = qMin(screenSize.width(), screenSize.height()); 1538 pHeight -= 20; 1539 if(screenSize.height() > screenSize.width()) 1540 pWidth -= 20; 1541 #else 1432 1542 pWidth = 150; 1433 1543 pHeight = 100; 1544 #endif 1434 1545 custom = 0; 1435 1546 standard = 0; … … 1447 1558 1448 1559 cp->setFrameStyle(QFrame::Panel + QFrame::Sunken); 1560 1561 #if defined(Q_WS_S60) 1562 if (!nonTouchUI) { 1563 pickLay->addWidget(cp); 1564 cLay->addSpacing(lumSpace); 1565 } else { 1566 cp->hide(); 1567 } 1568 #else 1449 1569 cLay->addSpacing(lumSpace); 1450 1570 cLay->addWidget(cp); 1571 #endif 1451 1572 cLay->addSpacing(lumSpace); 1452 1573 1453 1574 lp = new QColorLuminancePicker(q); 1575 #if defined(Q_WS_S60) 1576 QSize screenSize = QApplication::desktop()->availableGeometry(QCursor::pos()).size(); 1577 const int minDimension = qMin(screenSize.height(), screenSize.width()); 1578 //set picker to be finger-usable 1579 int pickerWidth = !nonTouchUI ? minDimension/9 : minDimension/12; 1580 lp->setFixedWidth(pickerWidth); 1581 if (!nonTouchUI) 1582 pickLay->addWidget(lp); 1583 else 1584 lp->hide(); 1585 #else 1454 1586 lp->setFixedWidth(20); 1455 1587 pickLay->addWidget(lp); 1588 #endif 1456 1589 1457 1590 QObject::connect(cp, SIGNAL(newCol(int,int)), lp, SLOT(setCol(int,int))); … … 1462 1595 cs = new QColorShower(q); 1463 1596 QObject::connect(cs, SIGNAL(newCol(QRgb)), q, SLOT(_q_newColorTypedIn(QRgb))); 1464 QObject::connect(cs, SIGNAL(currentColorChanged(const QColor&)), 1465 q, SIGNAL(currentColorChanged(const QColor&))); 1597 QObject::connect(cs, SIGNAL(currentColorChanged(QColor)), 1598 q, SIGNAL(currentColorChanged(QColor))); 1599 #if defined(Q_WS_S60) 1600 if (!nonTouchUI) 1601 pWidth -= cp->size().width(); 1602 topLay->addWidget(cs); 1603 #else 1466 1604 rightLay->addWidget(cs); 1605 #endif 1467 1606 1468 1607 buttons = new QDialogButtonBox(q); … … 1511 1650 \brief The QColorDialog class provides a dialog widget for specifying colors. 1512 1651 1513 \mainclass 1514 \ingroup dialogs 1515 \ingroup multimedia 1652 \ingroup standard-dialogs 1516 1653 1517 1654 The color dialog's function is to allow users to choose colors. … … 1579 1716 Q_D(QColorDialog); 1580 1717 d->setCurrentColor(color.rgb()); 1581 d->selectColor(color .rgb());1718 d->selectColor(color); 1582 1719 d->setCurrentAlpha(color.alpha()); 1583 1720 1584 1721 #ifdef Q_WS_MAC 1585 if (d->delegate) 1586 QColorDialogPrivate::setColor(d->delegate, color); 1587 #endif 1722 d->setCurrentQColor(color); 1723 d->setCocoaPanelColor(color); 1724 #endif 1725 if (d->nativeDialogInUse) 1726 qt_guiPlatformPlugin()->colorDialogSetCurrentColor(this, color); 1588 1727 } 1589 1728 … … 1725 1864 #if defined(Q_WS_MAC) 1726 1865 if (visible) { 1727 if (!d->delegate && QColorDialogPrivate::sharedColorPanelAvailable && 1728 !(testAttribute(Qt::WA_DontShowOnScreen) || (d->opts & DontUseNativeDialog))){ 1729 d->delegate = QColorDialogPrivate::openCocoaColorPanel( 1730 currentColor(), parentWidget(), windowTitle(), options(), d); 1866 if (d->delegate || (QColorDialogPrivate::sharedColorPanelAvailable && 1867 !(testAttribute(Qt::WA_DontShowOnScreen) || (d->opts & DontUseNativeDialog)))){ 1868 d->openCocoaColorPanel(currentColor(), parentWidget(), windowTitle(), options()); 1731 1869 QColorDialogPrivate::sharedColorPanelAvailable = false; 1732 1870 setAttribute(Qt::WA_DontShowOnScreen); … … 1735 1873 } else { 1736 1874 if (d->delegate) { 1737 QColorDialogPrivate::closeCocoaColorPanel(d->delegate); 1738 d->delegate = 0; 1739 QColorDialogPrivate::sharedColorPanelAvailable = true; 1875 d->closeCocoaColorPanel(); 1740 1876 setAttribute(Qt::WA_DontShowOnScreen, false); 1741 1877 } 1742 1878 } 1879 #else 1880 1881 if (!(d->opts & DontUseNativeDialog) && qt_guiPlatformPlugin()->colorDialogSetVisible(this, visible)) { 1882 d->nativeDialogInUse = true; 1883 // Set WA_DontShowOnScreen so that QDialog::setVisible(visible) below 1884 // updates the state correctly, but skips showing the non-native version: 1885 setAttribute(Qt::WA_DontShowOnScreen); 1886 } else { 1887 d->nativeDialogInUse = false; 1888 setAttribute(Qt::WA_DontShowOnScreen, false); 1889 } 1743 1890 #endif 1744 1891 … … 1750 1897 \since 4.5 1751 1898 1752 Opens the dialog and connects its accepted() signal to the slot specified1899 Opens the dialog and connects its colorSelected() signal to the slot specified 1753 1900 by \a receiver and \a member. 1754 1901 … … 1758 1905 { 1759 1906 Q_D(QColorDialog); 1760 connect(this, SIGNAL(colorSelected( const QColor&)), receiver, member);1907 connect(this, SIGNAL(colorSelected(QColor)), receiver, member); 1761 1908 d->receiverToDisconnectOnClose = receiver; 1762 1909 d->memberToDisconnectOnClose = member; … … 1840 1987 QColorDialog::~QColorDialog() 1841 1988 { 1989 Q_D(QColorDialog); 1990 #if defined(Q_WS_MAC) 1991 if (d->delegate) { 1992 d->releaseCocoaColorPanelDelegate(); 1993 QColorDialogPrivate::sharedColorPanelAvailable = true; 1994 } 1995 #endif 1996 1842 1997 #ifndef QT_NO_SETTINGS 1843 1998 if (!customSet) { … … 1847 2002 } 1848 2003 #endif 2004 if (d->nativeDialogInUse) 2005 qt_guiPlatformPlugin()->colorDialogDelete(this); 2006 1849 2007 } 1850 2008 … … 1873 2031 QDialog::done(result); 1874 2032 if (result == Accepted) { 1875 d->selectedQColor = d->currentQColor(); 2033 d->selectedQColor = d->currentQColor(); 1876 2034 emit colorSelected(d->selectedQColor); 1877 2035 } else { … … 1879 2037 } 1880 2038 if (d->receiverToDisconnectOnClose) { 1881 disconnect(this, SIGNAL(colorSelected( const QColor&)),2039 disconnect(this, SIGNAL(colorSelected(QColor)), 1882 2040 d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose); 1883 2041 d->receiverToDisconnectOnClose = 0; -
trunk/src/gui/dialogs/qcolordialog.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** -
trunk/src/gui/dialogs/qcolordialog_mac.mm
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 45 45 #include <qtimer.h> 46 46 #include <qdialogbuttonbox.h> 47 #include <qabstracteventdispatcher.h> 47 48 #include <private/qapplication_p.h> 48 49 #include <private/qt_mac_p.h> … … 55 56 #endif 56 57 58 59 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5 60 @protocol NSWindowDelegate <NSObject> 61 - (void)windowDidResize:(NSNotification *)notification; 62 - (BOOL)windowShouldClose:(id)window; 63 @end 64 #endif 65 57 66 QT_USE_NAMESPACE 58 67 59 68 @class QCocoaColorPanelDelegate; 60 69 61 @interface QCocoaColorPanelDelegate : NSObject {70 @interface QCocoaColorPanelDelegate : NSObject<NSWindowDelegate> { 62 71 NSColorPanel *mColorPanel; 63 72 NSView *mStolenContentView; … … 69 78 CGFloat mExtraHeight; // currently unused 70 79 BOOL mHackedPanel; 80 NSInteger mResultCode; 81 BOOL mDialogIsExecuting; 82 BOOL mResultSet; 71 83 } 72 84 - (id)initWithColorPanel:(NSColorPanel *)panel … … 75 87 cancelButton:(NSButton *)cancelButton 76 88 priv:(QColorDialogPrivate *)priv; 77 - (BOOL)windowShouldClose:(id)window;78 - (void)windowDidResize:(NSNotification *)notification;79 89 - (void)colorChanged:(NSNotification *)notification; 80 90 - (void)relayout; … … 85 95 - (QColor)qtColor; 86 96 - (void)finishOffWithCode:(NSInteger)result; 87 - (void)cleanUpAfterMyself; 97 - (void)showColorPanel; 98 - (void)exec; 88 99 @end 89 100 … … 105 116 mExtraHeight = 0.0; 106 117 mHackedPanel = (okButton != 0); 118 mResultCode = NSCancelButton; 119 mDialogIsExecuting = false; 120 mResultSet = false; 107 121 108 122 if (mHackedPanel) { … … 116 130 } 117 131 118 if (mPriv)119 [[NSNotificationCenter defaultCenter] addObserver:self120 selector:@selector(colorChanged:)121 name:NSColorPanelColorDidChangeNotification122 object:mColorPanel]; 132 [[NSNotificationCenter defaultCenter] addObserver:self 133 selector:@selector(colorChanged:) 134 name:NSColorPanelColorDidChangeNotification 135 object:mColorPanel]; 136 123 137 mQtColor = new QColor(); 124 138 return self; … … 127 141 - (void)dealloc 128 142 { 129 if (mPriv) 130 [[NSNotificationCenter defaultCenter] removeObserver:self]; 143 QMacCocoaAutoReleasePool pool; 144 if (mHackedPanel) { 145 NSView *ourContentView = [mColorPanel contentView]; 146 147 // return stolen stuff to its rightful owner 148 [mStolenContentView removeFromSuperview]; 149 [mColorPanel setContentView:mStolenContentView]; 150 151 [mOkButton release]; 152 [mCancelButton release]; 153 [ourContentView release]; 154 } 155 [mColorPanel setDelegate:nil]; 156 [[NSNotificationCenter defaultCenter] removeObserver:self]; 131 157 delete mQtColor; 132 158 [super dealloc]; … … 136 162 { 137 163 Q_UNUSED(window); 138 if (mHackedPanel) { 139 [self onCancelClicked]; 164 if (!mHackedPanel) 165 [self updateQtColor]; 166 if (mDialogIsExecuting) { 167 [self finishOffWithCode:NSCancelButton]; 140 168 } else { 141 [self updateQtColor];142 [self finishOffWithCode:NSCancelButton];169 mResultSet = true; 170 mPriv->colorDialog()->reject(); 143 171 } 144 172 return true; … … 155 183 { 156 184 Q_UNUSED(notification); 157 if (mPriv) 158 [self updateQtColor]; 185 [self updateQtColor]; 159 186 } 160 187 … … 218 245 - (void)onCancelClicked 219 246 { 220 Q_ASSERT(mHackedPanel); 221 [[mStolenContentView window] close]; 222 delete mQtColor; 223 mQtColor = new QColor(); 224 [self finishOffWithCode:NSCancelButton]; 247 if (mHackedPanel) { 248 [[mStolenContentView window] close]; 249 delete mQtColor; 250 mQtColor = new QColor(); 251 [self finishOffWithCode:NSCancelButton]; 252 } 225 253 } 226 254 … … 230 258 mQtColor = new QColor(); 231 259 NSColor *color = [mColorPanel color]; 232 NSString *colorSpace = [color colorSpaceName];233 if (colorSpace == NSDeviceCMYKColorSpace) {234 CGFloat cyan , magenta, yellow, black, alpha;260 NSString *colorSpaceName = [color colorSpaceName]; 261 if (colorSpaceName == NSDeviceCMYKColorSpace) { 262 CGFloat cyan = 0, magenta = 0, yellow = 0, black = 0, alpha = 0; 235 263 [color getCyan:&cyan magenta:&magenta yellow:&yellow black:&black alpha:&alpha]; 236 264 mQtColor->setCmykF(cyan, magenta, yellow, black, alpha); 237 } else { 238 NSColor *tmpColor; 239 if (colorSpace == NSCalibratedRGBColorSpace || colorSpace == NSDeviceRGBColorSpace) { 240 tmpColor = color; 241 } else { 242 tmpColor = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; 243 } 244 CGFloat red, green, blue, alpha; 265 } else if (colorSpaceName == NSCalibratedRGBColorSpace || colorSpaceName == NSDeviceRGBColorSpace) { 266 CGFloat red = 0, green = 0, blue = 0, alpha = 0; 267 [color getRed:&red green:&green blue:&blue alpha:&alpha]; 268 mQtColor->setRgbF(red, green, blue, alpha); 269 } else if (colorSpaceName == NSNamedColorSpace) { 270 NSColor *tmpColor = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; 271 CGFloat red = 0, green = 0, blue = 0, alpha = 0; 245 272 [tmpColor getRed:&red green:&green blue:&blue alpha:&alpha]; 246 273 mQtColor->setRgbF(red, green, blue, alpha); 247 } 248 249 if (mPriv) 250 mPriv->setCurrentQColor(*mQtColor); 274 } else { 275 NSColorSpace *colorSpace = [color colorSpace]; 276 if ([colorSpace colorSpaceModel] == NSCMYKColorSpaceModel && [color numberOfComponents] == 5){ 277 CGFloat components[5]; 278 [color getComponents:components]; 279 mQtColor->setCmykF(components[0], components[1], components[2], components[3], components[4]); 280 } else { 281 NSColor *tmpColor = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; 282 CGFloat red = 0, green = 0, blue = 0, alpha = 0; 283 [tmpColor getRed:&red green:&green blue:&blue alpha:&alpha]; 284 mQtColor->setRgbF(red, green, blue, alpha); 285 } 286 } 287 288 mPriv->setCurrentQColor(*mQtColor); 251 289 } 252 290 … … 263 301 - (void)finishOffWithCode:(NSInteger)code 264 302 { 265 if (mPriv) { 266 // Finish the QColorDialog as well. But since a call to accept or reject will 267 // close down the QEventLoop found in QDialog, we need to make sure that the 268 // current thread has exited the native dialogs modal session/run loop first. 269 // We ensure this by posting the call: 303 mResultCode = code; 304 if (mDialogIsExecuting) { 305 // We stop the current modal event loop. The control 306 // will then return inside -(void)exec below. 307 // It's important that the modal event loop is stopped before 308 // we accept/reject QColorDialog, since QColorDialog has its 309 // own event loop that needs to be stopped last. 270 310 [NSApp stopModalWithCode:code]; 271 if (code == NSOKButton)272 QMetaObject::invokeMethod(mPriv->colorDialog(), "accept", Qt::QueuedConnection);273 else274 QMetaObject::invokeMethod(mPriv->colorDialog(), "reject", Qt::QueuedConnection);275 311 } else { 276 [NSApp stopModalWithCode:code]; 277 } 278 } 279 280 - (void)cleanUpAfterMyself 281 { 282 if (mHackedPanel) { 283 NSView *ourContentView = [mColorPanel contentView]; 284 285 // return stolen stuff to its rightful owner 286 [mStolenContentView removeFromSuperview]; 287 [mColorPanel setContentView:mStolenContentView]; 288 289 [mOkButton release]; 290 [mCancelButton release]; 291 [ourContentView release]; 292 } 293 [mColorPanel setDelegate:nil]; 294 } 312 // Since we are not in a modal event loop, we can safely close 313 // down QColorDialog 314 // Calling accept() or reject() can in turn call closeCocoaColorPanel. 315 // This check will prevent any such recursion. 316 if (!mResultSet) { 317 mResultSet = true; 318 if (mResultCode == NSCancelButton) { 319 mPriv->colorDialog()->reject(); 320 } else { 321 mPriv->colorDialog()->accept(); 322 } 323 } 324 } 325 } 326 327 - (void)showColorPanel 328 { 329 mDialogIsExecuting = false; 330 [mColorPanel makeKeyAndOrderFront:mColorPanel]; 331 } 332 333 - (void)exec 334 { 335 QBoolBlocker nativeDialogOnTop(QApplicationPrivate::native_modal_dialog_active); 336 QMacCocoaAutoReleasePool pool; 337 mDialogIsExecuting = true; 338 bool modalEnded = false; 339 while (!modalEnded) { 340 @try { 341 [NSApp runModalForWindow:mColorPanel]; 342 modalEnded = true; 343 } @catch (NSException *) { 344 // For some reason, NSColorPanel throws an exception when 345 // clicking on 'SelectedMenuItemColor' from the 'Developer' 346 // palette (tab three). 347 } 348 } 349 350 if (mResultCode == NSCancelButton) 351 mPriv->colorDialog()->reject(); 352 else 353 mPriv->colorDialog()->accept(); 354 } 355 295 356 @end 296 357 … … 301 362 extern NSButton *macCreateButton(const char *text, NSView *superview); 302 363 303 void *QColorDialogPrivate::openCocoaColorPanel(const QColor &initial, 304 QWidget *parent, const QString &title, QColorDialog::ColorDialogOptions options, 305 QColorDialogPrivate *priv) 364 void QColorDialogPrivate::openCocoaColorPanel(const QColor &initial, 365 QWidget *parent, const QString &title, QColorDialog::ColorDialogOptions options) 306 366 { 307 367 Q_UNUSED(parent); // we would use the parent if only NSColorPanel could be a sheet 308 368 QMacCocoaAutoReleasePool pool; 309 369 310 /*311 The standard Cocoa color panel has no OK or Cancel button and312 is created as a utility window, whereas we want something like313 the Carbon color panel. We need to take the following steps:314 315 1. Intercept the color panel constructor to turn off the 316 NSUtilityWindowMask flag. This is done by temporarily317 replacing initWithContentRect:styleMask:backing:defer:318 in NSPanel by our own method.319 320 2. Modify the color panel so that its content view is part 321 of a new content view that contains it as well as two322 buttons (OK and Cancel).323 324 3. Lay out the original content view and the buttons when 325 the color panel is shown and whenever it is resized.326 327 4. Clean up after ourselves. 328 */329 330 bool hackColorPanel = !(options & QColorDialog::NoButtons); 331 332 if (hackColorPanel) 333 macStartInterceptNSPanelCtor();334 NSColorPanel *colorPanel = [NSColorPanel sharedColorPanel];335 if (hackColorPanel)336 macStopInterceptNSPanelCtor();337 338 [colorPanel setHidesOnDeactivate:false]; 339 340 // set up the Cocoa color panel 341 [colorPanel setShowsAlpha:options & QColorDialog::ShowAlphaChannel];342 [colorPanel setTitle:(NSString*)(CFStringRef)QCFString(title)];343 344 NSView *stolenContentView = 0; 345 NSButton *okButton= 0;346 NSButton *cancelButton = 0;347 348 if (hackColorPanel) { 349 // steal the color panel's contents view350 stolenContentView = [colorPanel contentView];351 [stolenContentView retain];352 [colorPanel setContentView:0];353 354 // create a new content view and add the stolen one as a subview 355 NSRect frameRect = { { 0.0, 0.0 }, { 0.0, 0.0 } };356 NSView *ourContentView = [[NSView alloc] initWithFrame:frameRect];357 [ourContentView addSubview:stolenContentView];358 359 // create OK and Cancel buttons and add these as subviews 360 okButton = macCreateButton("&OK", ourContentView);361 cancelButton = macCreateButton("Cancel", ourContentView);362 363 [colorPanel setContentView:ourContentView]; 364 [colorPanel setDefaultButtonCell:[okButton cell]];365 }366 367 // create a delegate and set it 368 QCocoaColorPanelDelegate *delegate =369 [[QCocoaColorPanelDelegate alloc] initWithColorPanel:colorPanel370 stolenContentView:stolenContentView371 okButton:okButton372 cancelButton:cancelButton373 priv:priv];374 [colorPanel setDelegate:delegate];375 setColor(delegate, initial); 376 [colorPanel makeKeyAndOrderFront:colorPanel];377 378 return delegate; 379 } 380 381 void QColorDialogPrivate::closeCocoaColorPanel(void *delegate) 382 { 383 QMacCocoaAutoReleasePool pool; 384 QCocoaColorPanelDelegate *theDelegate = static_cast<QCocoaColorPanelDelegate *>(delegate); 385 [[theDelegate colorPanel] close]; 386 [theDelegate cleanUpAfterMyself]; 387 [ theDelegate autorelease];370 if (!delegate) { 371 /* 372 The standard Cocoa color panel has no OK or Cancel button and 373 is created as a utility window, whereas we want something like 374 the Carbon color panel. We need to take the following steps: 375 376 1. Intercept the color panel constructor to turn off the 377 NSUtilityWindowMask flag. This is done by temporarily 378 replacing initWithContentRect:styleMask:backing:defer: 379 in NSPanel by our own method. 380 381 2. Modify the color panel so that its content view is part 382 of a new content view that contains it as well as two 383 buttons (OK and Cancel). 384 385 3. Lay out the original content view and the buttons when 386 the color panel is shown and whenever it is resized. 387 388 4. Clean up after ourselves. 389 */ 390 391 bool hackColorPanel = !(options & QColorDialog::NoButtons); 392 393 if (hackColorPanel) 394 macStartInterceptNSPanelCtor(); 395 NSColorPanel *colorPanel = [NSColorPanel sharedColorPanel]; 396 if (hackColorPanel) 397 macStopInterceptNSPanelCtor(); 398 399 [colorPanel setHidesOnDeactivate:false]; 400 401 // set up the Cocoa color panel 402 [colorPanel setShowsAlpha:options & QColorDialog::ShowAlphaChannel]; 403 [colorPanel setTitle:(NSString*)(CFStringRef)QCFString(title)]; 404 405 NSView *stolenContentView = 0; 406 NSButton *okButton = 0; 407 NSButton *cancelButton = 0; 408 409 if (hackColorPanel) { 410 // steal the color panel's contents view 411 stolenContentView = [colorPanel contentView]; 412 [stolenContentView retain]; 413 [colorPanel setContentView:0]; 414 415 // create a new content view and add the stolen one as a subview 416 NSRect frameRect = { { 0.0, 0.0 }, { 0.0, 0.0 } }; 417 NSView *ourContentView = [[NSView alloc] initWithFrame:frameRect]; 418 [ourContentView addSubview:stolenContentView]; 419 420 // create OK and Cancel buttons and add these as subviews 421 okButton = macCreateButton("&OK", ourContentView); 422 cancelButton = macCreateButton("Cancel", ourContentView); 423 424 [colorPanel setContentView:ourContentView]; 425 [colorPanel setDefaultButtonCell:[okButton cell]]; 426 } 427 428 delegate = [[QCocoaColorPanelDelegate alloc] initWithColorPanel:colorPanel 429 stolenContentView:stolenContentView 430 okButton:okButton 431 cancelButton:cancelButton 432 priv:this]; 433 [colorPanel setDelegate:static_cast<QCocoaColorPanelDelegate *>(delegate)]; 434 } 435 436 setCocoaPanelColor(initial); 437 [static_cast<QCocoaColorPanelDelegate *>(delegate) showColorPanel]; 438 } 439 440 void QColorDialogPrivate::closeCocoaColorPanel() 441 { 442 [static_cast<QCocoaColorPanelDelegate *>(delegate) onCancelClicked]; 443 } 444 445 void QColorDialogPrivate::releaseCocoaColorPanelDelegate() 446 { 447 [static_cast<QCocoaColorPanelDelegate *>(delegate) release]; 388 448 } 389 449 … … 405 465 void QColorDialogPrivate::_q_macRunNativeAppModalPanel() 406 466 { 407 QBoolBlocker nativeDialogOnTop(QApplicationPrivate::native_modal_dialog_active); 408 QMacCocoaAutoReleasePool pool; 409 QCocoaColorPanelDelegate *delegateCasted = static_cast<QCocoaColorPanelDelegate *>(delegate); 410 [NSApp runModalForWindow:[delegateCasted colorPanel]]; 411 } 412 413 void QColorDialogPrivate::setColor(void *delegate, const QColor &color) 467 [static_cast<QCocoaColorPanelDelegate *>(delegate) exec]; 468 } 469 470 void QColorDialogPrivate::setCocoaPanelColor(const QColor &color) 414 471 { 415 472 QMacCocoaAutoReleasePool pool; 416 473 QCocoaColorPanelDelegate *theDelegate = static_cast<QCocoaColorPanelDelegate *>(delegate); 417 NSColor *nsColor = [NSColor colorWithCalibratedRed:color.red() / 255.0 418 green:color.green() / 255.0 419 blue:color.blue() / 255.0 420 alpha:color.alpha() / 255.0]; 474 NSColor *nsColor; 475 const QColor::Spec spec = color.spec(); 476 if (spec == QColor::Cmyk) { 477 nsColor = [NSColor colorWithDeviceCyan:color.cyanF() 478 magenta:color.magentaF() 479 yellow:color.yellowF() 480 black:color.blackF() 481 alpha:color.alphaF()]; 482 } else { 483 nsColor = [NSColor colorWithCalibratedRed:color.redF() 484 green:color.greenF() 485 blue:color.blueF() 486 alpha:color.alphaF()]; 487 } 421 488 [[theDelegate colorPanel] setColor:nsColor]; 422 489 } -
trunk/src/gui/dialogs/qcolordialog_p.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 115 115 QPointer<QObject> receiverToDisconnectOnClose; 116 116 QByteArray memberToDisconnectOnClose; 117 bool nativeDialogInUse; 117 118 118 119 #ifdef Q_WS_MAC 119 static void *openCocoaColorPanel(const QColor &initial, 120 QWidget *parent, const QString &title, 121 QColorDialog::ColorDialogOptions options, 122 QColorDialogPrivate *priv = 0); 123 static void closeCocoaColorPanel(void *delegate); 124 static QColor execCocoaColorPanel(const QColor &initial, QWidget *parent, 125 const QString &title, QColorDialog::ColorDialogOptions options); 126 static void setColor(void *delegate, const QColor &color); 120 void openCocoaColorPanel(const QColor &initial, 121 QWidget *parent, const QString &title, QColorDialog::ColorDialogOptions options); 122 void closeCocoaColorPanel(); 123 void releaseCocoaColorPanelDelegate(); 124 void setCocoaPanelColor(const QColor &color); 127 125 128 126 inline void done(int result) { q_func()->done(result); } -
trunk/src/gui/dialogs/qdialog.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 56 56 #include "qaccessible.h" 57 57 #endif 58 #if defined(Q_ OS_WINCE)58 #if defined(Q_WS_WINCE) 59 59 #include "qt_windows.h" 60 60 #include "qmenubar.h" … … 65 65 #elif defined(Q_WS_X11) 66 66 # include "../kernel/qt_x11_p.h" 67 #elif defined(Q_OS_SYMBIAN) 68 # include "qfiledialog.h" 69 # include "qfontdialog.h" 70 # include "qcolordialog.h" 71 # include "qwizard.h" 72 # include "qmenubar.h" 73 #endif 74 75 #if defined(Q_WS_S60) 76 #include "private/qt_s60_p.h" 67 77 #endif 68 78 69 79 #ifndef SPI_GETSNAPTODEFBUTTON 70 # define SPI_GETSNAPTODEFBUTTON 9580 # define SPI_GETSNAPTODEFBUTTON 95 71 81 #endif 72 82 … … 77 87 \brief The QDialog class is the base class of dialog windows. 78 88 79 \ingroup dialog s89 \ingroup dialog-classes 80 90 \ingroup abstractwidgets 81 \mainclass 91 82 92 83 93 A dialog window is a top-level window mostly used for short-term … … 252 262 f | QFlag((f & Qt::WindowType_Mask) == 0 ? Qt::Dialog : 0)) 253 263 { 254 #ifdef Q_ OS_WINCE264 #ifdef Q_WS_WINCE 255 265 if (!qt_wince_is_smartphone()) 256 266 setWindowFlags(windowFlags() | Qt::WindowOkButtonHint | QFlag(qt_wince_is_mobile() ? 0 : Qt::WindowCancelButtonHint)); … … 281 291 : QWidget(dd, parent, f | QFlag((f & Qt::WindowType_Mask) == 0 ? Qt::Dialog : 0)) 282 292 { 283 #ifdef Q_ OS_WINCE293 #ifdef Q_WS_WINCE 284 294 if (!qt_wince_is_smartphone()) 285 295 setWindowFlags(windowFlags() | Qt::WindowOkButtonHint | QFlag(qt_wince_is_mobile() ? 0 : Qt::WindowCancelButtonHint)); … … 293 303 QDialog::~QDialog() 294 304 { 295 // Need to hide() here, as our (to-be) overridden hide() 296 // will not be called in ~QWidget. 297 hide(); 305 QT_TRY { 306 // Need to hide() here, as our (to-be) overridden hide() 307 // will not be called in ~QWidget. 308 hide(); 309 } QT_CATCH(...) { 310 // we're in the destructor - just swallow the exception 311 } 298 312 } 299 313 … … 365 379 } 366 380 367 #if def Q_OS_WINCE368 #ifdef Q_ OS_WINCE_WM381 #if defined(Q_WS_WINCE) || defined(Q_WS_S60) 382 #ifdef Q_WS_WINCE_WM 369 383 void QDialogPrivate::_q_doneAction() 370 384 { … … 380 394 { 381 395 bool result = QWidget::event(e); 396 #ifdef Q_WS_WINCE 382 397 if (e->type() == QEvent::OkRequest) { 383 398 accept(); 384 399 result = true; 385 400 } 401 #else 402 if ((e->type() == QEvent::StyleChange) || (e->type() == QEvent::Resize )) 403 adjustPosition(parentWidget()); 404 #endif 386 405 return result; 387 406 } … … 474 493 475 494 //On Windows Mobile we create an empty menu to hide the current menu 476 #ifdef Q_ OS_WINCE_WM495 #ifdef Q_WS_WINCE_WM 477 496 #ifndef QT_NO_MENUBAR 478 497 QMenuBar *menuBar = 0; … … 485 504 } 486 505 #endif //QT_NO_MENUBAR 487 #endif //Q_OS_WINCE_WM 488 489 show(); 506 #endif //Q_WS_WINCE_WM 507 508 #ifdef Q_OS_SYMBIAN 509 #ifndef QT_NO_MENUBAR 510 QMenuBar *menuBar = 0; 511 if (!findChild<QMenuBar *>()) 512 menuBar = new QMenuBar(this); 513 #endif 514 515 if (qobject_cast<QFileDialog *>(this) || qobject_cast<QFontDialog *>(this) || 516 qobject_cast<QColorDialog *>(this) || qobject_cast<QWizard *>(this)) 517 showMaximized(); 518 else 519 #endif // Q_OS_SYMBIAN 520 521 show(); 490 522 491 523 #ifdef Q_WS_MAC … … 506 538 if (deleteOnClose) 507 539 delete this; 508 #ifdef Q_ OS_WINCE_WM540 #ifdef Q_WS_WINCE_WM 509 541 #ifndef QT_NO_MENUBAR 510 542 else if (menuBar) 511 543 delete menuBar; 512 544 #endif //QT_NO_MENUBAR 513 #endif //Q_OS_WINCE_WM 545 #endif //Q_WS_WINCE_WM 546 #ifdef Q_OS_SYMBIAN 547 #ifndef QT_NO_MENUBAR 548 else if (menuBar) 549 delete menuBar; 550 #endif //QT_NO_MENUBAR 551 #endif //Q_OS_SYMBIAN 552 514 553 return res; 515 554 } … … 634 673 case Qt::Key_Escape: 635 674 reject(); 636 break;637 case Qt::Key_Up:638 case Qt::Key_Left:639 if (focusWidget() &&640 (focusWidget()->focusPolicy() == Qt::StrongFocus ||641 focusWidget()->focusPolicy() == Qt::WheelFocus)) {642 e->ignore();643 break;644 }645 // call ours, since c++ blocks us from calling the one646 // belonging to focusWidget().647 focusNextPrevChild(false);648 break;649 case Qt::Key_Down:650 case Qt::Key_Right:651 if (focusWidget() &&652 (focusWidget()->focusPolicy() == Qt::StrongFocus ||653 focusWidget()->focusPolicy() == Qt::WheelFocus)) {654 e->ignore();655 break;656 }657 focusNextPrevChild(true);658 675 break; 659 676 default: … … 763 780 if (d->mainDef && isActiveWindow()) { 764 781 BOOL snapToDefault = false; 765 if ( QT_WA_INLINE( SystemParametersInfo(SPI_GETSNAPTODEFBUTTON, 0, &snapToDefault, 0) , 766 SystemParametersInfoA(SPI_GETSNAPTODEFBUTTON, 0, &snapToDefault, 0) )) { 782 if (SystemParametersInfo(SPI_GETSNAPTODEFBUTTON, 0, &snapToDefault, 0)) { 767 783 if (snapToDefault) 768 784 QCursor::setPos(d->mainDef->mapToGlobal(d->mainDef->rect().center())); … … 790 806 // if the WM advertises that it will place the windows properly for us, let it do it :) 791 807 if (X11->isSupportedByWM(ATOM(_NET_WM_FULL_PLACEMENT))) 808 return; 809 #endif 810 811 #ifdef Q_WS_S60 812 if (s60AdjustedPosition()) 813 //dialog has already been positioned 792 814 return; 793 815 #endif … … 856 878 } 857 879 880 #if defined(Q_WS_S60) 881 /*! \internal */ 882 bool QDialog::s60AdjustedPosition() 883 { 884 QPoint p; 885 const QSize mainAreaSize = QApplication::desktop()->availableGeometry(QCursor::pos()).size(); 886 const int statusPaneHeight = (S60->screenHeightInPixels - mainAreaSize.height())>>1; 887 const bool doS60Positioning = !(isFullScreen()||isMaximized()); 888 if (doS60Positioning) { 889 // naive way to deduce screen orientation 890 if (S60->screenHeightInPixels > S60->screenWidthInPixels) { 891 int cbaHeight; 892 const CEikButtonGroupContainer* bgContainer = S60->buttonGroupContainer(); 893 if (!bgContainer) { 894 cbaHeight = 0; 895 } else { 896 cbaHeight = qt_TSize2QSize(bgContainer->Size()).height(); 897 } 898 p.setY(S60->screenHeightInPixels-height()-cbaHeight); 899 p.setX(0); 900 } else { 901 const int scrollbarWidth = style()->pixelMetric(QStyle::PM_ScrollBarExtent); 902 TRect cbaRect = TRect(); 903 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EControlPane, cbaRect); 904 AknLayoutUtils::TAknCbaLocation cbaLocation = AknLayoutUtils::CbaLocation(); 905 switch (cbaLocation) { 906 case AknLayoutUtils::EAknCbaLocationBottom: 907 p.setY(S60->screenHeightInPixels - height()-cbaRect.Height()); 908 p.setX((S60->screenWidthInPixels - width())>>1); 909 break; 910 case AknLayoutUtils::EAknCbaLocationRight: 911 p.setY((S60->screenHeightInPixels - height())>>1); 912 p.setX(qMax(0,S60->screenWidthInPixels-width()-scrollbarWidth-cbaRect.Width())); 913 break; 914 case AknLayoutUtils::EAknCbaLocationLeft: 915 p.setY((S60->screenHeightInPixels - height())>>1); 916 p.setX(qMax(0,scrollbarWidth+cbaRect.Width())); 917 break; 918 } 919 } 920 move(p); 921 } 922 return doS60Positioning; 923 } 924 #endif 858 925 859 926 /*! … … 1015 1082 QWidget::sizeHint().height()); 1016 1083 } 1017 1084 #if defined(Q_WS_S60) 1085 // if size is not fixed, try to adjust it according to S60 layoutting 1086 if (minimumSize() != maximumSize()) { 1087 // In S60, dialogs are always the width of screen (in portrait, regardless of current layout) 1088 return QSize(qMax(S60->screenHeightInPixels, S60->screenWidthInPixels), QWidget::sizeHint().height()); 1089 } else { 1090 return QWidget::sizeHint(); 1091 } 1092 #else 1018 1093 return QWidget::sizeHint(); 1094 #endif //Q_WS_S60 1019 1095 } 1020 1096 -
trunk/src/gui/dialogs/qdialog.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 108 108 QDialog(QDialogPrivate &, QWidget *parent, Qt::WindowFlags f = 0); 109 109 110 #if def Q_OS_WINCE110 #if defined(Q_WS_WINCE) || defined(Q_WS_S60) 111 111 bool event(QEvent *e); 112 112 #endif … … 120 120 bool eventFilter(QObject *, QEvent *); 121 121 void adjustPosition(QWidget*); 122 123 122 private: 124 123 Q_DECLARE_PRIVATE(QDialog) 125 124 Q_DISABLE_COPY(QDialog) 126 125 127 #ifdef Q_OS_WINCE_WM 126 #if defined(Q_WS_S60) 127 bool s60AdjustedPosition(); 128 #endif 129 130 131 #ifdef Q_WS_WINCE_WM 128 132 Q_PRIVATE_SLOT(d_func(), void _q_doneAction()) 129 133 #endif -
trunk/src/gui/dialogs/qdialog_p.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 94 94 void resetModalitySetByOpen(); 95 95 96 #ifdef Q_ OS_WINCE_WM96 #ifdef Q_WS_WINCE_WM 97 97 void _q_doneAction(); 98 98 #endif 99 99 100 100 #ifdef Q_WS_MAC 101 virtual void mac_nativeDialogModalHelp() {};101 virtual void mac_nativeDialogModalHelp() {} 102 102 #endif 103 103 -
trunk/src/gui/dialogs/qdialogsbinarycompat_win.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** -
trunk/src/gui/dialogs/qerrormessage.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 62 62 #include <stdlib.h> 63 63 64 #ifdef Q_ OS_WINCE64 #ifdef Q_WS_WINCE 65 65 extern bool qt_wince_is_mobile(); //defined in qguifunctions_wince.cpp 66 66 extern bool qt_wince_is_high_dpi(); //defined in qguifunctions_wince.cpp 67 67 68 68 #include "qguifunctions_wince.h" 69 #endif 70 71 #if defined(QT_SOFTKEYS_ENABLED) 72 #include <qaction.h> 73 #ifdef Q_WS_S60 74 #include "private/qt_s60_p.h" 75 #endif 69 76 #endif 70 77 … … 79 86 QTextEdit * errors; 80 87 QLabel * icon; 88 #ifdef QT_SOFTKEYS_ENABLED 89 QAction *okAction; 90 #endif 81 91 QQueue<QPair<QString, QString> > pending; 82 92 QSet<QString> doNotShow; … … 101 111 QSize QErrorMessageTextView::minimumSizeHint() const 102 112 { 103 #ifdef Q_ OS_WINCE113 #ifdef Q_WS_WINCE 104 114 if (qt_wince_is_mobile()) 105 115 if (qt_wince_is_high_dpi()) … … 116 126 QSize QErrorMessageTextView::sizeHint() const 117 127 { 118 #ifdef Q_ OS_WINCE128 #ifdef Q_WS_WINCE 119 129 if (qt_wince_is_mobile()) 120 130 if (qt_wince_is_high_dpi()) … … 125 135 return QSize(300, 100); 126 136 #else 137 138 #ifdef Q_WS_S60 139 const int smallerDimension = qMin(S60->screenHeightInPixels, S60->screenWidthInPixels); 140 // In S60 layout data, error messages seem to be one third of the screen height (in portrait) minus two. 141 return QSize(smallerDimension, smallerDimension/3-2); 142 #else 127 143 return QSize(250, 75); 128 #endif 144 #endif //Q_WS_S60 145 #endif //Q_WS_WINCE 129 146 } 130 147 … … 134 151 \brief The QErrorMessage class provides an error message display dialog. 135 152 136 \ingroup dialogs 137 \ingroup misc 153 \ingroup standard-dialog 138 154 139 155 An error message widget consists of a text label and a checkbox. The … … 241 257 grid->addWidget(d->again, 1, 1, Qt::AlignTop); 242 258 d->ok = new QPushButton(this); 243 #ifdef Q_OS_WINCE 259 #ifdef QT_SOFTKEYS_ENABLED 260 d->okAction = new QAction(d->ok); 261 d->okAction->setSoftKeyRole(QAction::PositiveSoftKey); 262 connect(d->okAction, SIGNAL(triggered()), this, SLOT(accept())); 263 addAction(d->okAction); 264 #endif 265 266 267 #if defined(Q_WS_WINCE) || defined(Q_WS_S60) 244 268 d->ok->setFixedSize(0,0); 245 269 #endif … … 301 325 qtMessageHandler = new QErrorMessage(0); 302 326 qAddPostRoutine(deleteStaticcQErrorMessage); // clean up 303 qtMessageHandler->setWindowTitle( qApp->applicationName());327 qtMessageHandler->setWindowTitle(QApplication::applicationName()); 304 328 qInstallMsgHandler(jump); 305 329 } … … 374 398 } 375 399 376 377 400 /*! 378 401 \reimp … … 391 414 again->setText(QErrorMessage::tr("&Show this message again")); 392 415 ok->setText(QErrorMessage::tr("&OK")); 416 #ifdef QT_SOFTKEYS_ENABLED 417 okAction->setText(ok->text()); 418 #endif 393 419 } 394 420 -
trunk/src/gui/dialogs/qerrormessage.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** -
trunk/src/gui/dialogs/qfiledialog.cpp
r172 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 59 59 #include <qapplication.h> 60 60 #include <qstylepainter.h> 61 #if ndef Q_OS_WINCE61 #if !defined(Q_WS_WINCE) && !defined(Q_OS_SYMBIAN) 62 62 #include "ui_qfiledialog.h" 63 63 #else 64 #include "ui_qfiledialog_wince.h" 64 #define Q_EMBEDDED_SMALLSCREEN 65 #include "ui_qfiledialog_embedded.h" 66 #if defined(Q_OS_WINCE) 65 67 extern bool qt_priv_ptr_valid; 68 #endif 66 69 #endif 67 70 … … 90 93 \class QFileDialog 91 94 \brief The QFileDialog class provides a dialog that allow users to select files or directories. 92 \ingroup dialogs93 \mainclass 95 \ingroup standard-dialogs 96 94 97 95 98 The QFileDialog class enables a user to traverse the file system in … … 97 100 98 101 The easiest way to create a QFileDialog is to use the static 99 functions. On Windows, these static functions will call the native 100 Windows file dialog, and on Mac OS X these static function will call 101 the native Mac OS X file dialog. 102 functions. On Windows, Mac OS X, KDE and GNOME, these static functions will 103 call the native file dialog when possible. 102 104 103 105 \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 0 … … 211 213 \enum QFileDialog::Option 212 214 213 \value ShowDirsOnly Only show directories in the file dialog. By default both files and 214 directories are shown. (Valid only in the \l Directory file mode.) 215 \value DontResolveSymlinks Don't resolve symlinks in the file dialog. By default symlinks 216 are resolved. 217 \value DontConfirmOverwrite Don't ask for confirmation if an existing file is selected. 218 By default confirmation is requested. 219 \value DontUseNativeDialog Don't use the native file dialog. By default on Mac OS X and Windows, 220 the native file dialog is used unless you use a subclass of QFileDialog that contains the 221 Q_OBJECT macro. 215 \value ShowDirsOnly Only show directories in the file dialog. By 216 default both files and directories are shown. (Valid only in the 217 \l Directory file mode.) 218 219 \value DontResolveSymlinks Don't resolve symlinks in the file 220 dialog. By default symlinks are resolved. 221 222 \value DontConfirmOverwrite Don't ask for confirmation if an 223 existing file is selected. By default confirmation is requested. 224 225 \value DontUseNativeDialog Don't use the native file dialog. By 226 default, the native file dialog is used unless you use a subclass 227 of QFileDialog that contains the Q_OBJECT macro. 228 222 229 \value ReadOnly Indicates that the model is readonly. 230 223 231 \value HideNameFilterDetails Indicates if the is hidden or not. 224 225 232 This value is obsolete and does nothing since Qt 4.5: 226 233 227 \value DontUseSheet In previous versions of Qt, the static functions would228 create a sheet by default if the static function was given a parent. This229 is no longer supported in Qt 4.5, The static functions will always be an230 application modal dialog. If you want to use sheets, use231 QFileDialog::open() instead.234 \value DontUseSheet In previous versions of Qt, the static 235 functions would create a sheet by default if the static function 236 was given a parent. This is no longer supported in Qt 4.5, The 237 static functions will always be an application modal dialog. If 238 you want to use sheets, use QFileDialog::open() instead. 232 239 233 240 */ … … 311 318 Q_D(QFileDialog); 312 319 d->init(); 320 d->lineEdit()->selectAll(); 313 321 } 314 322 … … 328 336 Q_D(QFileDialog); 329 337 d->init(directory, filter, caption); 338 d->lineEdit()->selectAll(); 330 339 } 331 340 … … 355 364 settings.setValue(QLatin1String("filedialog"), saveState()); 356 365 #endif 357 delete d->qFileDialogUi;358 366 d->deleteNativeDialog_sys(); 359 367 } … … 390 398 391 399 static const qint32 QFileDialogMagic = 0xbe; 400 401 const char *qt_file_dialog_filter_reg_exp = 402 "^(.*)\\(([a-zA-Z0-9_.*? +;#\\-\\[\\]@\\{\\}/!<>\\$%&=^~:\\|]*)\\)$"; 392 403 393 404 /*! … … 487 498 } 488 499 500 QFileDialogPrivate::QFileDialogPrivate() 501 : 502 #ifndef QT_NO_PROXYMODEL 503 proxyModel(0), 504 #endif 505 model(0), 506 fileMode(QFileDialog::AnyFile), 507 acceptMode(QFileDialog::AcceptOpen), 508 currentHistoryLocation(-1), 509 renameAction(0), 510 deleteAction(0), 511 showHiddenAction(0), 512 useDefaultCaption(true), 513 defaultFileTypes(true), 514 fileNameLabelExplicitlySat(false), 515 nativeDialogInUse(false), 516 #ifdef Q_WS_MAC 517 mDelegate(0), 518 #ifndef QT_MAC_USE_COCOA 519 mDialog(0), 520 mDialogStarted(false), 521 mDialogClosed(true), 522 #endif 523 #endif 524 qFileDialogUi(0) 525 { 526 } 527 528 QFileDialogPrivate::~QFileDialogPrivate() 529 { 530 } 531 489 532 void QFileDialogPrivate::retranslateWindowTitle() 490 533 { … … 567 610 568 611 /*! 569 Sets the given \a option to be enabled if \a on is true; 570 otherwise, clears the given \a option. 612 \since 4.5 613 Sets the given \a option to be enabled if \a on is true; otherwise, 614 clears the given \a option. 571 615 572 616 \sa options, testOption() … … 639 683 \since 4.5 640 684 641 Opens the dialog and connects its accepted() signal to the slot specified 642 by \a receiver and \a member. 685 This function connects one of its signals to the slot specified by \a receiver 686 and \a member. The specific signal depends is filesSelected() if fileMode is 687 ExistingFiles and fileSelected() if fileMode is anything else. 643 688 644 689 The signal will be disconnected from the slot when the dialog is closed. … … 647 692 { 648 693 Q_D(QFileDialog); 649 const char *signal = (fileMode() == ExistingFiles) ? SIGNAL(filesSelected( const QStringList&))650 : SIGNAL(fileSelected( const QString&));694 const char *signal = (fileMode() == ExistingFiles) ? SIGNAL(filesSelected(QStringList)) 695 : SIGNAL(fileSelected(QString)); 651 696 connect(this, signal, receiver, member); 652 697 d->signalToDisconnectOnClose = signal; … … 694 739 void QFileDialogPrivate::_q_goToUrl(const QUrl &url) 695 740 { 696 QModelIndex idx = model->index(url.toLocalFile()); 741 //The shortcut in the side bar may have a parent that is not fetched yet (e.g. an hidden file) 742 //so we force the fetching 743 QFileSystemModelPrivate::QFileSystemNode *node = model->d_func()->node(url.toLocalFile(), true); 744 QModelIndex idx = model->d_func()->index(node); 697 745 _q_enterDirectory(idx); 698 746 } … … 730 778 d->qFileDialogUi->newFolderButton->setEnabled(d->model->flags(root) & Qt::ItemIsDropEnabled); 731 779 if (root != d->rootIndex()) { 732 #ifndef QT_NO_ COMPLETER780 #ifndef QT_NO_FSCOMPLETER 733 781 if (directory.endsWith(QLatin1Char('/'))) 734 782 d->completer->setCompletionPrefix(newDirectory); … … 775 823 776 824 QModelIndex index = d->model->index(filename); 825 QString file; 777 826 if (!index.isValid()) { 778 827 // save as dialog where we want to input a default value … … 789 838 text = text.remove(0,1); 790 839 } 791 if (!isVisible() || !d->lineEdit()->hasFocus()) 792 d->lineEdit()->setText(text); 840 file = text; 793 841 } else { 794 d->qFileDialogUi->listView->selectionModel()->clear(); 795 if (!isVisible() || !d->lineEdit()->hasFocus()) 796 d->lineEdit()->setText(index.data().toString()); 797 } 842 file = index.data().toString(); 843 } 844 d->qFileDialogUi->listView->selectionModel()->clear(); 845 if (!isVisible() || !d->lineEdit()->hasFocus()) 846 d->lineEdit()->setText(file); 798 847 } 799 848 … … 836 885 // and on Windows it already ends with slash. 837 886 QString path = rootPath(); 838 if (!path.endsWith(QLatin1 String("/")))839 path += QLatin1 String("/");887 if (!path.endsWith(QLatin1Char('/'))) 888 path += QLatin1Char('/'); 840 889 path += name; 841 890 files.append(path); … … 958 1007 Q_D(QFileDialog); 959 1008 d->defaultFileTypes = (filters == QStringList(QFileDialog::tr("All Files (*)"))); 960 d->nameFilters = filters; 1009 QStringList cleanedFilters; 1010 for (int i = 0; i < filters.count(); ++i) { 1011 cleanedFilters << filters[i].simplified(); 1012 } 1013 d->nameFilters = cleanedFilters; 961 1014 962 1015 if (d->nativeDialogInUse){ 963 d->setNameFilters_sys( filters);1016 d->setNameFilters_sys(cleanedFilters); 964 1017 return; 965 1018 } 966 1019 967 1020 d->qFileDialogUi->fileTypeCombo->clear(); 968 if ( filters.isEmpty())1021 if (cleanedFilters.isEmpty()) 969 1022 return; 970 1023 971 1024 if (testOption(HideNameFilterDetails)) { 972 1025 QStringList strippedFilters; 973 for (int i = 0; i < filters.count(); ++i) { 974 strippedFilters.append(filters[i].mid(0, filters[i].indexOf(QLatin1String(" (")))); 1026 QRegExp r(QString::fromLatin1(qt_file_dialog_filter_reg_exp)); 1027 for (int i = 0; i < cleanedFilters.count(); ++i) { 1028 QString filterName; 1029 int index = r.indexIn(cleanedFilters[i]); 1030 if (index >= 0) 1031 filterName = r.cap(1); 1032 strippedFilters.append(filterName.simplified()); 975 1033 } 976 1034 d->qFileDialogUi->fileTypeCombo->addItems(strippedFilters); 977 1035 } else { 978 d->qFileDialogUi->fileTypeCombo->addItems( filters);1036 d->qFileDialogUi->fileTypeCombo->addItems(cleanedFilters); 979 1037 } 980 1038 d->_q_useNameFilter(0); … … 1434 1492 Q_D(QFileDialog); 1435 1493 d->model->setIconProvider(provider); 1494 //It forces the refresh of all entries in the side bar, then we can get new icons 1495 d->qFileDialogUi->sidebar->setUrls(d->qFileDialogUi->sidebar->urls()); 1436 1496 } 1437 1497 … … 1530 1590 1531 1591 /*! 1532 This is a convenience static function that returns an existing file 1533 selected by the user. If the user presses Cancel, it returns a null 1534 string. 1535 1536 \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 8 1537 1538 The function creates a modal file dialog with the given \a parent widget. 1539 If the parent is not 0, the dialog will be shown centered over the 1540 parent widget. 1541 1542 The file dialog's working directory will be set to \a dir. If \a 1543 dir includes a file name, the file will be selected. Only files 1544 that match the given \a filter are shown. The filter selected is 1545 set to \a selectedFilter. The parameters \a dir, \a 1546 selectedFilter, and \a filter may be empty strings. If you want 1547 multiple filters, separate them with ';;', for example: 1548 1549 \code 1592 This is a convenience static function that returns an existing file 1593 selected by the user. If the user presses Cancel, it returns a null string. 1594 1595 \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 8 1596 1597 The function creates a modal file dialog with the given \a parent widget. 1598 If \a parent is not 0, the dialog will be shown centered over the parent 1599 widget. 1600 1601 The file dialog's working directory will be set to \a dir. If \a dir 1602 includes a file name, the file will be selected. Only files that match the 1603 given \a filter are shown. The filter selected is set to \a selectedFilter. 1604 The parameters \a dir, \a selectedFilter, and \a filter may be empty 1605 strings. If you want multiple filters, separate them with ';;', for 1606 example: 1607 1608 \code 1550 1609 "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)" 1551 \endcode1552 1553 The \a options argument holds various1554 options about how to run the dialog, see the QFileDialog::Option enum for1555 more information on the flags you canpass.1556 1557 The dialog's caption is set to \a caption. If \a caption is not1558 specifiedthen a default caption will be used.1559 1560 Under Windows and Mac OS X, this static function will use the native1561 filedialog and not a QFileDialog.1562 1563 Note that on Windows the dialog will spin a blocking modal event loop1564 that will not dispatch any QTimers, and if parent is not 0 then it will1565 position the dialog just underthe parent's title bar.1566 1567 Under Unix/X11, the normal behavior of the file dialog is to resolve1568 and follow symlinks. For example, if \c{/usr/tmp} is a symlink to1569 \c{/var/tmp}, the file dialog will change to \c{/var/tmp} after1570 entering \c{/usr/tmp}. If \a options includes DontResolveSymlinks,1571 the file dialog will treatsymlinks as regular directories.1572 1573 \warning Do not delete \a parent during the execution of the dialog.1574 If you want to do this, you should create the dialog1575 yourself using one of theQFileDialog constructors.1576 1577 \sa getOpenFileNames(), getSaveFileName(), getExistingDirectory()1610 \endcode 1611 1612 The \a options argument holds various options about how to run the dialog, 1613 see the QFileDialog::Option enum for more information on the flags you can 1614 pass. 1615 1616 The dialog's caption is set to \a caption. If \a caption is not specified 1617 then a default caption will be used. 1618 1619 On Windows and Mac OS X, this static function will use the native file 1620 dialog and not a QFileDialog. 1621 1622 On Windows the dialog will spin a blocking modal event loop that will not 1623 dispatch any QTimers, and if \a parent is not 0 then it will position the 1624 dialog just below the parent's title bar. 1625 1626 On Unix/X11, the normal behavior of the file dialog is to resolve and 1627 follow symlinks. For example, if \c{/usr/tmp} is a symlink to \c{/var/tmp}, 1628 the file dialog will change to \c{/var/tmp} after entering \c{/usr/tmp}. If 1629 \a options includes DontResolveSymlinks, the file dialog will treat 1630 symlinks as regular directories. 1631 1632 \warning Do not delete \a parent during the execution of the dialog. If you 1633 want to do this, you should create the dialog yourself using one of the 1634 QFileDialog constructors. 1635 1636 \sa getOpenFileNames(), getSaveFileName(), getExistingDirectory() 1578 1637 */ 1579 1638 QString QFileDialog::getOpenFileName(QWidget *parent, … … 1613 1672 1614 1673 /*! 1615 This is a convenience static function that will return one or more1616 existingfiles selected by the user.1617 1618 \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 91619 1620 This function creates a modal file dialog with the given \a parent1621 widget. If the parent is not 0, the dialog will be shown centered1622 over the parentwidget.1623 1624 The file dialog's working directory will be set to \a dir. If \a1625 dir includes a file name, the file will be selected. The filter1626 is set to \a filter so that only those files which match the filter1627 are shown. The filter selected is set to \a selectedFilter. The parameters1628 \a dir, \a selectedFilter and \a filter may be empty strings. If you1629 need multiplefilters, separate them with ';;', for instance:1630 1631 \code1674 This is a convenience static function that will return one or more existing 1675 files selected by the user. 1676 1677 \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 9 1678 1679 This function creates a modal file dialog with the given \a parent widget. 1680 If \a parent is not 0, the dialog will be shown centered over the parent 1681 widget. 1682 1683 The file dialog's working directory will be set to \a dir. If \a dir 1684 includes a file name, the file will be selected. The filter is set to 1685 \a filter so that only those files which match the filter are shown. The 1686 filter selected is set to \a selectedFilter. The parameters \a dir, 1687 \a selectedFilter and \a filter may be empty strings. If you need multiple 1688 filters, separate them with ';;', for instance: 1689 1690 \code 1632 1691 "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)" 1633 \endcode 1634 1635 The dialog's caption is set to \a caption. If \a caption is not 1636 specified then a default caption will be used. 1637 1638 Under Windows and Mac OS X, this static function will use the native 1639 file dialog and not a QFileDialog. On Mac OS X, the \a dir argument 1640 is ignored, the native dialog always displays the last visited directory. 1641 1642 Note that on Windows the dialog will spin a blocking modal event loop 1643 that will not dispatch any QTimers, and if parent is not 0 then it will 1644 position the dialog just under the parent's title bar. 1645 1646 Under Unix/X11, the normal behavior of the file dialog is to resolve 1647 and follow symlinks. For example, if \c{/usr/tmp} is a symlink to 1648 \c{/var/tmp}, the file dialog will change to \c{/var/tmp} after 1649 entering \c{/usr/tmp}. The \a options argument holds various 1650 options about how to run the dialog, see the QFileDialog::Option enum for 1651 more information on the flags you can pass. 1652 1653 Note that if you want to iterate over the list of files, you should 1654 iterate over a copy. For example: 1692 \endcode 1693 1694 The dialog's caption is set to \a caption. If \a caption is not specified 1695 then a default caption will be used. 1696 1697 On Windows and Mac OS X, this static function will use the native file 1698 dialog and not a QFileDialog. 1699 1700 On Windows the dialog will spin a blocking modal event loop that will not 1701 dispatch any QTimers, and if \a parent is not 0 then it will position the 1702 dialog just below the parent's title bar. 1703 1704 On Unix/X11, the normal behavior of the file dialog is to resolve and 1705 follow symlinks. For example, if \c{/usr/tmp} is a symlink to \c{/var/tmp}, 1706 the file dialog will change to \c{/var/tmp} after entering \c{/usr/tmp}. 1707 The \a options argument holds various options about how to run the dialog, 1708 see the QFileDialog::Option enum for more information on the flags you can 1709 pass. 1710 1711 \note If you want to iterate over the list of files, you should iterate 1712 over a copy. For example: 1655 1713 1656 1714 \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 10 1657 1715 1658 \warning Do not delete \a parent during the execution of the dialog.1659 If you want to do this, you should create the dialog1660 yourself using one of theQFileDialog constructors.1661 1662 \sa getOpenFileName(), getSaveFileName(), getExistingDirectory()1716 \warning Do not delete \a parent during the execution of the dialog. If you 1717 want to do this, you should create the dialog yourself using one of the 1718 QFileDialog constructors. 1719 1720 \sa getOpenFileName(), getSaveFileName(), getExistingDirectory() 1663 1721 */ 1664 1722 QStringList QFileDialog::getOpenFileNames(QWidget *parent, … … 1669 1727 Options options) 1670 1728 { 1671 if (qt_filedialog_open_filenames_hook )1729 if (qt_filedialog_open_filenames_hook && !(options & DontUseNativeDialog)) 1672 1730 return qt_filedialog_open_filenames_hook(parent, caption, dir, filter, selectedFilter, options); 1673 1731 QFileDialogArgs args; … … 1699 1757 1700 1758 /*! 1701 This is a convenience static function that will return a file name 1702 selected by the user. The file does not have to exist. 1703 1704 It creates a modal file dialog with the given \a parent widget. If the 1705 parent is not 0, the dialog will be shown centered over the parent 1706 widget. 1707 1708 \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 11 1709 1710 The file dialog's working directory will be set to \a dir. If \a 1711 dir includes a file name, the file will be selected. Only files that 1712 match the \a filter are shown. The filter selected is set to 1713 \a selectedFilter. The parameters \a dir, \a selectedFilter, and 1714 \a filter may be empty strings. Multiple filters are separated with ';;'. 1715 For instance: 1716 1717 \code 1759 This is a convenience static function that will return a file name selected 1760 by the user. The file does not have to exist. 1761 1762 It creates a modal file dialog with the given \a parent widget. If 1763 \a parent is not 0, the dialog will be shown centered over the parent 1764 widget. 1765 1766 \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 11 1767 1768 The file dialog's working directory will be set to \a dir. If \a dir 1769 includes a file name, the file will be selected. Only files that match the 1770 \a filter are shown. The filter selected is set to \a selectedFilter. The 1771 parameters \a dir, \a selectedFilter, and \a filter may be empty strings. 1772 Multiple filters are separated with ';;'. For instance: 1773 1774 \code 1718 1775 "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)" 1719 \endcode 1720 1721 The \a options argument holds various 1722 options about how to run the dialog, see the QFileDialog::Option enum for 1723 more information on the flags you can pass. 1724 1725 The default filter can be chosen by setting \a selectedFilter to the desired value. 1726 1727 The dialog's caption is set to \a caption. If \a caption is not 1728 specified then a default caption will be used. 1729 1730 Under Windows and Mac OS X, this static function will use the native 1731 file dialog and not a QFileDialog. 1732 1733 Note that on Windows the dialog will spin a blocking modal event loop 1734 that will not dispatch any QTimers, and if parent is not 0 then it will 1735 position the dialog just under the parent's title bar. 1736 On Mac OS X, the filter argument is ignored. 1737 1738 Under Unix/X11, the normal behavior of the file dialog is to resolve 1739 and follow symlinks. For example, if \c{/usr/tmp} is a symlink to 1740 \c{/var/tmp}, the file dialog will change to \c{/var/tmp} after 1741 entering \c{/usr/tmp}. If \a options includes DontResolveSymlinks, 1742 the file dialog will treat symlinks as regular directories. 1743 1744 \warning Do not delete \a parent during the execution of the dialog. 1745 If you want to do this, you should create the dialog 1746 yourself using one of the QFileDialog constructors. 1747 1748 \sa getOpenFileName(), getOpenFileNames(), getExistingDirectory() 1776 \endcode 1777 1778 The \a options argument holds various options about how to run the dialog, 1779 see the QFileDialog::Option enum for more information on the flags you can 1780 pass. 1781 1782 The default filter can be chosen by setting \a selectedFilter to the 1783 desired value. 1784 1785 The dialog's caption is set to \a caption. If \a caption is not specified, 1786 a default caption will be used. 1787 1788 On Windows and Mac OS X, this static function will use the native file 1789 dialog and not a QFileDialog. 1790 1791 On Windows the dialog will spin a blocking modal event loop that will not 1792 dispatch any QTimers, and if \a parent is not 0 then it will position the 1793 dialog just below the parent's title bar. On Mac OS X, with its native file 1794 dialog, the filter argument is ignored. 1795 1796 On Unix/X11, the normal behavior of the file dialog is to resolve and 1797 follow symlinks. For example, if \c{/usr/tmp} is a symlink to \c{/var/tmp}, 1798 the file dialog will change to \c{/var/tmp} after entering \c{/usr/tmp}. If 1799 \a options includes DontResolveSymlinks the file dialog will treat symlinks 1800 as regular directories. 1801 1802 \warning Do not delete \a parent during the execution of the dialog. If you 1803 want to do this, you should create the dialog yourself using one of the 1804 QFileDialog constructors. 1805 1806 \sa getOpenFileName(), getOpenFileNames(), getExistingDirectory() 1749 1807 */ 1750 1808 QString QFileDialog::getSaveFileName(QWidget *parent, … … 1755 1813 Options options) 1756 1814 { 1757 if (qt_filedialog_save_filename_hook )1815 if (qt_filedialog_save_filename_hook && !(options & DontUseNativeDialog)) 1758 1816 return qt_filedialog_save_filename_hook(parent, caption, dir, filter, selectedFilter, options); 1759 1817 QFileDialogArgs args; … … 1787 1845 1788 1846 /*! 1789 This is a convenience static function that will return an existing 1790 directory selected by the user. 1791 1792 \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 12 1793 1794 This function creates a modal file dialog with the given \a parent 1795 widget. If the parent is not 0, the dialog will be shown centered over 1796 the parent widget. 1797 1798 The dialog's working directory is set to \a dir, and the caption is 1799 set to \a caption. Either of these may be an empty string in which case 1800 the current directory and a default caption will be used 1801 respectively. 1802 1803 The \a options argument holds various 1804 options about how to run the dialog, see the QFileDialog::Option enum for 1805 more information on the flags you can pass. Note that \l{QFileDialog::}{ShowDirsOnly} 1806 must be set to ensure a native file dialog. 1807 1808 Under Windows and Mac OS X, this static function will use the native 1809 file dialog and not a QFileDialog. On Mac OS X, the \a dir argument 1810 is ignored, the native dialog always displays the last visited directory. 1811 On Windows CE, if the device has no native file dialog, a QFileDialog 1812 will be used. 1813 1814 Under Unix/X11, the normal behavior of the file dialog is to resolve 1815 and follow symlinks. For example, if \c{/usr/tmp} is a symlink to 1816 \c{/var/tmp}, the file dialog will change to \c{/var/tmp} after 1817 entering \c{/usr/tmp}. If \a options includes DontResolveSymlinks, 1818 the file dialog will treat symlinks as regular directories. 1819 1820 Note that on Windows the dialog will spin a blocking modal event loop 1821 that will not dispatch any QTimers, and if parent is not 0 then it will 1822 position the dialog just under the parent's title bar. 1823 1824 \warning Do not delete \a parent during the execution of the dialog. 1825 If you want to do this, you should create the dialog 1826 yourself using one of the QFileDialog constructors. 1827 1828 \sa getOpenFileName(), getOpenFileNames(), getSaveFileName() 1847 This is a convenience static function that will return an existing 1848 directory selected by the user. 1849 1850 \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 12 1851 1852 This function creates a modal file dialog with the given \a parent widget. 1853 If \a parent is not 0, the dialog will be shown centered over the parent 1854 widget. 1855 1856 The dialog's working directory is set to \a dir, and the caption is set to 1857 \a caption. Either of these may be an empty string in which case the 1858 current directory and a default caption will be used respectively. 1859 1860 The \a options argument holds various options about how to run the dialog, 1861 see the QFileDialog::Option enum for more information on the flags you can 1862 pass. To ensure a native file dialog, \l{QFileDialog::}{ShowDirsOnly} must 1863 be set. 1864 1865 On Windows and Mac OS X, this static function will use the native file 1866 dialog and not a QFileDialog. On Windows CE, if the device has no native 1867 file dialog, a QFileDialog will be used. 1868 1869 On Unix/X11, the normal behavior of the file dialog is to resolve and 1870 follow symlinks. For example, if \c{/usr/tmp} is a symlink to \c{/var/tmp}, 1871 the file dialog will change to \c{/var/tmp} after entering \c{/usr/tmp}. If 1872 \a options includes DontResolveSymlinks, the file dialog will treat 1873 symlinks as regular directories. 1874 1875 On Windows the dialog will spin a blocking modal event loop that will not 1876 dispatch any QTimers, and if \a parent is not 0 then it will position the 1877 dialog just below the parent's title bar. 1878 1879 \warning Do not delete \a parent during the execution of the dialog. If you 1880 want to do this, you should create the dialog yourself using one of the 1881 QFileDialog constructors. 1882 1883 \sa getOpenFileName(), getOpenFileNames(), getSaveFileName() 1829 1884 */ 1830 1885 QString QFileDialog::getExistingDirectory(QWidget *parent, … … 1833 1888 Options options) 1834 1889 { 1835 if (qt_filedialog_existing_directory_hook )1890 if (qt_filedialog_existing_directory_hook && !(options & DontUseNativeDialog)) 1836 1891 return qt_filedialog_existing_directory_hook(parent, caption, dir, options); 1837 1892 QFileDialogArgs args; … … 1844 1899 #if defined(Q_WS_WIN) 1845 1900 if (qt_use_native_dialogs && !(args.options & DontUseNativeDialog) && (options & ShowDirsOnly) 1846 #if defined(Q_ OS_WINCE)1901 #if defined(Q_WS_WINCE) 1847 1902 && qt_priv_ptr_valid 1848 1903 #endif … … 2058 2113 #endif 2059 2114 2060 #if def Q_OS_WINCE2115 #if defined(Q_EMBEDDED_SMALLSCREEN) 2061 2116 qFileDialogUi->lookInLabel->setVisible(false); 2062 2117 qFileDialogUi->fileNameLabel->setVisible(false); … … 2090 2145 model->setNameFilterDisables(false); 2091 2146 #endif 2092 QFileDialog::connect(model, SIGNAL(fileRenamed(const QString &, const QString &, const QString &)), q, SLOT(_q_fileRenamed(const QString &, const QString &, const QString &))); 2093 QFileDialog::connect(model, SIGNAL(rootPathChanged(const QString &)), 2094 q, SLOT(_q_pathChanged(const QString &))); 2095 QFileDialog::connect(model, SIGNAL(rowsInserted(const QModelIndex &, int, int)), 2096 q, SLOT(_q_rowsInserted(const QModelIndex &))); 2147 model->d_func()->disableRecursiveSort = true; 2148 QFileDialog::connect(model, SIGNAL(fileRenamed(QString,QString,QString)), q, SLOT(_q_fileRenamed(QString,QString,QString))); 2149 QFileDialog::connect(model, SIGNAL(rootPathChanged(QString)), 2150 q, SLOT(_q_pathChanged(QString))); 2151 QFileDialog::connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)), 2152 q, SLOT(_q_rowsInserted(QModelIndex))); 2097 2153 model->setReadOnly(false); 2098 2154 2099 qFileDialogUi = new Ui_QFileDialog();2155 qFileDialogUi.reset(new Ui_QFileDialog()); 2100 2156 qFileDialogUi->setupUi(q); 2101 2157 … … 2104 2160 << QUrl::fromLocalFile(QDir::homePath()); 2105 2161 qFileDialogUi->sidebar->init(model, initialBookmarks); 2106 QFileDialog::connect(qFileDialogUi->sidebar, SIGNAL(goToUrl( const QUrl &)),2107 q, SLOT(_q_goToUrl( const QUrl &)));2162 QFileDialog::connect(qFileDialogUi->sidebar, SIGNAL(goToUrl(QUrl)), 2163 q, SLOT(_q_goToUrl(QUrl))); 2108 2164 2109 2165 QObject::connect(qFileDialogUi->buttonBox, SIGNAL(accepted()), q, SLOT(accept())); … … 2122 2178 qFileDialogUi->fileNameLabel->setBuddy(qFileDialogUi->fileNameEdit); 2123 2179 #endif 2124 #ifndef QT_NO_ COMPLETER2125 completer = new QFSComplet or(model, q);2180 #ifndef QT_NO_FSCOMPLETER 2181 completer = new QFSCompleter(model, q); 2126 2182 qFileDialogUi->fileNameEdit->setCompleter(completer); 2127 completer->sourceModel = model;2128 2183 QObject::connect(qFileDialogUi->fileNameEdit, SIGNAL(textChanged(QString)), 2129 2184 q, SLOT(_q_autoCompleteFileName(QString))); 2130 #endif // QT_NO_ COMPLETER2185 #endif // QT_NO_FSCOMPLETER 2131 2186 QObject::connect(qFileDialogUi->fileNameEdit, SIGNAL(textChanged(QString)), 2132 2187 q, SLOT(_q_updateOkButton())); … … 2140 2195 QObject::connect(qFileDialogUi->fileTypeCombo, SIGNAL(activated(int)), 2141 2196 q, SLOT(_q_useNameFilter(int))); 2142 QObject::connect(qFileDialogUi->fileTypeCombo, SIGNAL(activated( const QString &)),2143 q, SIGNAL(filterSelected( const QString &)));2197 QObject::connect(qFileDialogUi->fileTypeCombo, SIGNAL(activated(QString)), 2198 q, SIGNAL(filterSelected(QString))); 2144 2199 2145 2200 qFileDialogUi->listView->init(this); … … 2167 2222 QActionGroup *showActionGroup = new QActionGroup(q); 2168 2223 showActionGroup->setExclusive(false); 2169 QObject::connect(showActionGroup, SIGNAL(triggered(QAction 2170 q, SLOT(_q_showHeader(QAction 2224 QObject::connect(showActionGroup, SIGNAL(triggered(QAction*)), 2225 q, SLOT(_q_showHeader(QAction*)));; 2171 2226 2172 2227 QAbstractItemModel *abstractModel = model; … … 2182 2237 } 2183 2238 2184 Q ItemSelectionModel *selModel = qFileDialogUi->treeView->selectionModel();2239 QScopedPointer<QItemSelectionModel> selModel(qFileDialogUi->treeView->selectionModel()); 2185 2240 qFileDialogUi->treeView->setSelectionModel(qFileDialogUi->listView->selectionModel()); 2186 delete selModel; 2241 2187 2242 QObject::connect(qFileDialogUi->treeView, SIGNAL(activated(QModelIndex)), 2188 2243 q, SLOT(_q_enterDirectory(QModelIndex))); … … 2197 2252 // Selections 2198 2253 QItemSelectionModel *selections = qFileDialogUi->listView->selectionModel(); 2199 QObject::connect(selections, SIGNAL(selectionChanged( const QItemSelection &, const QItemSelection &)),2254 QObject::connect(selections, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), 2200 2255 q, SLOT(_q_selectionChanged())); 2201 2256 QObject::connect(selections, SIGNAL(currentChanged(QModelIndex,QModelIndex)), … … 2235 2290 QModelIndex idx = d->rootIndex(); 2236 2291 if (d->proxyModel) { 2237 disconnect(d->proxyModel, SIGNAL(rowsInserted( const QModelIndex &, int,int)),2238 this, SLOT(_q_rowsInserted( const QModelIndex &)));2292 disconnect(d->proxyModel, SIGNAL(rowsInserted(QModelIndex,int,int)), 2293 this, SLOT(_q_rowsInserted(QModelIndex))); 2239 2294 } else { 2240 disconnect(d->model, SIGNAL(rowsInserted( const QModelIndex &, int,int)),2241 this, SLOT(_q_rowsInserted( const QModelIndex &)));2295 disconnect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)), 2296 this, SLOT(_q_rowsInserted(QModelIndex))); 2242 2297 } 2243 2298 … … 2248 2303 d->qFileDialogUi->listView->setModel(d->proxyModel); 2249 2304 d->qFileDialogUi->treeView->setModel(d->proxyModel); 2250 #ifndef QT_NO_ COMPLETER2305 #ifndef QT_NO_FSCOMPLETER 2251 2306 d->completer->setModel(d->proxyModel); 2252 2307 d->completer->proxyModel = d->proxyModel; 2253 2308 #endif 2254 connect(d->proxyModel, SIGNAL(rowsInserted( const QModelIndex &, int,int)),2255 this, SLOT(_q_rowsInserted( const QModelIndex &)));2309 connect(d->proxyModel, SIGNAL(rowsInserted(QModelIndex,int,int)), 2310 this, SLOT(_q_rowsInserted(QModelIndex))); 2256 2311 } else { 2257 2312 d->proxyModel = 0; 2258 2313 d->qFileDialogUi->listView->setModel(d->model); 2259 2314 d->qFileDialogUi->treeView->setModel(d->model); 2260 #ifndef QT_NO_ COMPLETER2315 #ifndef QT_NO_FSCOMPLETER 2261 2316 d->completer->setModel(d->model); 2262 2317 d->completer->sourceModel = d->model; 2263 2318 d->completer->proxyModel = 0; 2264 2319 #endif 2265 connect(d->model, SIGNAL(rowsInserted( const QModelIndex &, int,int)),2266 this, SLOT(_q_rowsInserted( const QModelIndex &)));2267 } 2268 Q ItemSelectionModel *selModel = d->qFileDialogUi->treeView->selectionModel();2320 connect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)), 2321 this, SLOT(_q_rowsInserted(QModelIndex))); 2322 } 2323 QScopedPointer<QItemSelectionModel> selModel(d->qFileDialogUi->treeView->selectionModel()); 2269 2324 d->qFileDialogUi->treeView->setSelectionModel(d->qFileDialogUi->listView->selectionModel()); 2270 delete selModel; 2325 2271 2326 d->setRootIndex(idx); 2272 2327 2273 2328 // reconnect selection 2274 2329 QItemSelectionModel *selections = d->qFileDialogUi->listView->selectionModel(); 2275 QObject::connect(selections, SIGNAL(selectionChanged( const QItemSelection &, const QItemSelection &)),2330 QObject::connect(selections, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), 2276 2331 this, SLOT(_q_selectionChanged())); 2277 2332 QObject::connect(selections, SIGNAL(currentChanged(QModelIndex,QModelIndex)), … … 2633 2688 void QFileDialogPrivate::_q_autoCompleteFileName(const QString &text) 2634 2689 { 2635 if (text.startsWith(QLatin1String("//")) || text.startsWith(QLatin1 String("\\"))) {2690 if (text.startsWith(QLatin1String("//")) || text.startsWith(QLatin1Char('\\'))) { 2636 2691 qFileDialogUi->listView->selectionModel()->clearSelection(); 2637 2692 return; … … 2675 2730 QString lineEditText = lineEdit()->text(); 2676 2731 2677 if (lineEditText.startsWith(QLatin1String("//")) || lineEditText.startsWith(QLatin1 String("\\"))) {2732 if (lineEditText.startsWith(QLatin1String("//")) || lineEditText.startsWith(QLatin1Char('\\'))) { 2678 2733 button->setEnabled(true); 2679 2734 if (acceptMode == QFileDialog::AcceptSave) 2680 button->setText( isOpenDirectory ? QFileDialog::tr("&Open") :acceptLabel);2735 button->setText(acceptLabel); 2681 2736 return; 2682 2737 } … … 2775 2830 Q_Q(QFileDialog); 2776 2831 // My Computer or a directory 2777 QModelIndex sourceIndex = mapToSource(index);2832 QModelIndex sourceIndex = index.model() == proxyModel ? mapToSource(index) : index; 2778 2833 QString path = sourceIndex.data(QFileSystemModel::FilePathRole).toString(); 2779 2834 if (path.isEmpty() || model->isDir(sourceIndex)) { … … 2827 2882 } 2828 2883 2829 const char *qt_file_dialog_filter_reg_exp =2830 "^([^()]*)\\(([a-zA-Z0-9_.*? +;#\\-\\[\\]@\\{\\}/!<>\\$%&=^~:\\|]*)\\)$";2831 2832 2884 // Makes a list of filters from a normal filter string "Image Files (*.png *.jpg)" 2833 2885 QStringList qt_clean_filter_list(const QString &filter) … … 3088 3140 void QFileDialogListView::keyPressEvent(QKeyEvent *e) 3089 3141 { 3090 if (!d_ptr->itemViewKeyboardEvent(e)) { 3142 #ifdef QT_KEYPAD_NAVIGATION 3143 if (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional) { 3091 3144 QListView::keyPressEvent(e); 3092 } 3145 return; 3146 } 3147 #endif // QT_KEYPAD_NAVIGATION 3148 3149 if (!d_ptr->itemViewKeyboardEvent(e)) 3150 QListView::keyPressEvent(e); 3093 3151 e->accept(); 3094 3152 } … … 3117 3175 void QFileDialogTreeView::keyPressEvent(QKeyEvent *e) 3118 3176 { 3119 if (!d_ptr->itemViewKeyboardEvent(e)) { 3177 #ifdef QT_KEYPAD_NAVIGATION 3178 if (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional) { 3120 3179 QTreeView::keyPressEvent(e); 3121 } 3180 return; 3181 } 3182 #endif // QT_KEYPAD_NAVIGATION 3183 3184 if (!d_ptr->itemViewKeyboardEvent(e)) 3185 QTreeView::keyPressEvent(e); 3122 3186 e->accept(); 3123 3187 } … … 3136 3200 void QFileDialogLineEdit::keyPressEvent(QKeyEvent *e) 3137 3201 { 3202 #ifdef QT_KEYPAD_NAVIGATION 3203 if (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional) { 3204 QLineEdit::keyPressEvent(e); 3205 return; 3206 } 3207 #endif // QT_KEYPAD_NAVIGATION 3208 3138 3209 int key = e->key(); 3139 3210 QLineEdit::keyPressEvent(e); … … 3147 3218 } 3148 3219 3149 #ifndef QT_NO_ COMPLETER3150 3151 QString QFSComplet or::pathFromIndex(const QModelIndex &index) const3220 #ifndef QT_NO_FSCOMPLETER 3221 3222 QString QFSCompleter::pathFromIndex(const QModelIndex &index) const 3152 3223 { 3153 3224 const QFileSystemModel *dirModel; … … 3164 3235 } 3165 3236 3166 QStringList QFSComplet or::splitPath(const QString &path) const3237 QStringList QFSCompleter::splitPath(const QString &path) const 3167 3238 { 3168 3239 if (path.isEmpty()) … … 3171 3242 QString pathCopy = QDir::toNativeSeparators(path); 3172 3243 QString sep = QDir::separator(); 3173 #if defined(Q_OS_WIN) || defined(Q_OS_OS2) 3244 #if defined(Q_OS_SYMBIAN) 3245 if (pathCopy == QLatin1String("\\")) 3246 return QStringList(pathCopy); 3247 #elif defined(Q_OS_WIN) || defined(Q_OS_OS2) 3174 3248 if (pathCopy == QLatin1String("\\") || pathCopy == QLatin1String("\\\\")) 3175 3249 return QStringList(pathCopy); … … 3181 3255 #endif 3182 3256 3183 QRegExp re(QLatin1String("[") + QRegExp::escape(sep) + QLatin1String("]")); 3184 3185 #if defined(Q_OS_WIN) || defined(Q_OS_OS2) 3257 QRegExp re(QLatin1Char('[') + QRegExp::escape(sep) + QLatin1Char(']')); 3258 3259 #if defined(Q_OS_SYMBIAN) 3260 QStringList parts = pathCopy.split(re, QString::SkipEmptyParts); 3261 if (pathCopy.endsWith(sep)) 3262 parts.append(QString()); 3263 #elif defined(Q_OS_WIN) || defined(Q_OS_OS2) 3186 3264 QStringList parts = pathCopy.split(re, QString::SkipEmptyParts); 3187 3265 if (!doubleSlash.isEmpty() && !parts.isEmpty()) … … 3195 3273 #endif 3196 3274 3197 #if defined(Q_OS_WIN) || defined(Q_OS_ OS2)3275 #if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) || defined(Q_OS_OS2) 3198 3276 bool startsFromRoot = !parts.isEmpty() && parts[0].endsWith(QLatin1Char(':')); 3199 3277 #else -
trunk/src/gui/dialogs/qfiledialog.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** -
trunk/src/gui/dialogs/qfiledialog.ui
r2 r561 3 3 ** 4 4 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 5 ** Contact: Qt Software Information (qt-info@nokia.com) 5 ** All rights reserved. 6 ** Contact: Nokia Corporation (qt-info@nokia.com) 6 7 ** 7 8 ** This file is part of the QtGui module of the Qt Toolkit. … … 22 23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 23 24 ** 24 ** In addition, as a special exception, Nokia gives you certain 25 ** additional rights. These rights are described in the Nokia Qt LGPL 26 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 27 ** package. 25 ** In addition, as a special exception, Nokia gives you certain additional 26 ** rights. These rights are described in the Nokia Qt LGPL Exception 27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 28 ** 29 29 ** GNU General Public License Usage … … 35 35 ** met: http://www.gnu.org/copyleft/gpl.html. 36 36 ** 37 ** If you are unsure which license is appropriate for your use, please38 ** contact the sales department at qt-sales@nokia.com.37 ** If you have questions regarding the use of this file, please contact 38 ** Nokia at qt-info@nokia.com. 39 39 ** $QT_END_LICENSE$ 40 40 ** -
trunk/src/gui/dialogs/qfiledialog_mac.mm
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 63 63 #include <qdesktopwidget.h> 64 64 #include <stdlib.h> 65 #include <qabstracteventdispatcher.h> 65 66 #include "ui_qfiledialog.h" 66 67 … … 246 247 runModalForDirectory:mCurrentDir 247 248 file:selectable ? filename : @"untitled"]; 249 250 QAbstractEventDispatcher::instance()->interrupt(); 248 251 return (mReturnCode == NSOKButton); 249 252 } … … 278 281 { 279 282 Q_UNUSED(sender); 283 284 if ([filename length] == 0) 285 return NO; 286 280 287 QString qtFileName = QT_PREPEND_NAMESPACE(qt_mac_NSStringToQString)(filename); 281 288 QFileInfo info(qtFileName.normalized(QT_PREPEND_NAMESPACE(QString::NormalizationForm_C))); … … 393 400 { 394 401 Q_UNUSED(sender); 395 *mCurrentSelection = QT_PREPEND_NAMESPACE(qt_mac_NSStringToQString([mSavePanel filename])); 396 if (mPriv) 397 mPriv->QNSOpenSavePanelDelegate_selectionChanged(*mCurrentSelection); 402 if (mPriv) { 403 QString selection = QT_PREPEND_NAMESPACE(qt_mac_NSStringToQString([mSavePanel filename])); 404 if (selection != mCurrentSelection) { 405 *mCurrentSelection = selection; 406 mPriv->QNSOpenSavePanelDelegate_selectionChanged(selection); 407 } 408 } 398 409 } 399 410 … … 820 831 // When changing directory, the current selection is cleared if 821 832 // we are supposed to be selecting files only: 822 fileDialogPrivate->mCurrentSelectionList.clear();823 833 if (!fileDialogPrivate->mCurrentSelection.isEmpty()){ 834 fileDialogPrivate->mCurrentSelectionList.clear(); 824 835 fileDialogPrivate->mCurrentSelection.clear(); 825 836 emit fileDialogPrivate->q_func()->currentChanged(fileDialogPrivate->mCurrentSelection); … … 912 923 navOptions.windowTitle = QCFString::toCFStringRef(q->windowTitle()); 913 924 914 static const int w = 450, h = 350; 915 navOptions.location.h = navOptions.location.v = -1; 925 navOptions.location.h = -1; 926 navOptions.location.v = -1; 927 916 928 QWidget *parent = q->parentWidget(); 917 929 if (parent && parent->isVisible()) { … … 921 933 QString s = parent->windowTitle(); 922 934 navOptions.clientName = QCFString::toCFStringRef(s); 923 navOptions.location.h = (parent->x() + (parent->width() / 2)) - (w / 2);924 navOptions.location.v = (parent->y() + (parent->height() / 2)) - (h / 2);925 926 QRect r = QApplication::desktop()->screenGeometry(927 QApplication::desktop()->screenNumber(parent));928 const int border = 10;929 if (navOptions.location.h + w > r.right())930 navOptions.location.h -= (navOptions.location.h + w) - r.right() + border;931 if (navOptions.location.v + h > r.bottom())932 navOptions.location.v -= (navOptions.location.v + h) - r.bottom() + border;933 if (navOptions.location.h < r.left())934 navOptions.location.h = r.left() + border;935 if (navOptions.location.v < r.top())936 navOptions.location.v = r.top() + border;937 935 } 938 936 -
trunk/src/gui/dialogs/qfiledialog_p.h
r172 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 74 74 #include <qcompleter.h> 75 75 #include <qpointer.h> 76 #include <qtimeline.h>77 76 #include <qdebug.h> 78 77 #include "qsidebar_p.h" 78 #include "qfscompleter_p.h" 79 #include "private/qguiplatformplugin_p.h" 80 79 81 80 82 #if defined (Q_OS_UNIX) … … 92 94 class Ui_QFileDialog; 93 95 94 #ifndef QT_NO_COMPLETER95 /*!96 QCompleter that can deal with QFileSystemModel97 */98 class QFSCompletor : public QCompleter {99 public:100 QFSCompletor(QAbstractItemModel *model, QObject *parent = 0) : QCompleter(model, parent), proxyModel(0), sourceModel(0)101 {102 #if defined(Q_OS_WIN) || defined(Q_OS_OS2)103 setCaseSensitivity(Qt::CaseInsensitive);104 #endif105 }106 QString pathFromIndex(const QModelIndex &index) const;107 QStringList splitPath(const QString& path) const;108 109 QAbstractProxyModel *proxyModel;110 QFileSystemModel *sourceModel;111 };112 #endif // QT_NO_COMPLETER113 96 114 97 struct QFileDialogArgs … … 132 115 133 116 public: 134 QFileDialogPrivate() : 135 #ifndef QT_NO_PROXYMODEL 136 proxyModel(0), 137 #endif 138 model(0), 139 fileMode(QFileDialog::AnyFile), 140 acceptMode(QFileDialog::AcceptOpen), 141 currentHistoryLocation(-1), 142 renameAction(0), 143 deleteAction(0), 144 showHiddenAction(0), 145 useDefaultCaption(true), 146 defaultFileTypes(true), 147 fileNameLabelExplicitlySat(false), 148 nativeDialogInUse(false), 149 #ifdef Q_WS_MAC 150 mDelegate(0), 151 #ifndef QT_MAC_USE_COCOA 152 mDialog(0), 153 mDialogStarted(false), 154 mDialogClosed(true), 155 #endif 156 #endif 157 qFileDialogUi(0) 158 {} 117 QFileDialogPrivate(); 159 118 160 119 void createToolButtons(); … … 188 147 DWORD maxLength; 189 148 QString drive = path.left(3); 190 if (QT_WA_INLINE(::GetVolumeInformationW(reinterpret_cast<const WCHAR *>(drive.utf16()), NULL, 0, NULL, &maxLength, NULL, NULL, 0), 191 ::GetVolumeInformationA(drive.toLocal8Bit().constData(), NULL, 0, NULL, &maxLength, NULL, NULL, 0)) == FALSE) 149 if (::GetVolumeInformation(reinterpret_cast<const wchar_t *>(drive.utf16()), NULL, 0, NULL, &maxLength, NULL, NULL, 0) == FALSE) 192 150 return -1; 193 151 return maxLength; … … 228 186 static inline QString toInternal(const QString &path) 229 187 { 230 #if defined(Q_FS_FAT) || defined(Q_OS_OS2EMX) 188 #if defined(Q_FS_FAT) || defined(Q_OS_OS2EMX) || defined(Q_OS_SYMBIAN) 231 189 QString n(path); 232 190 for (int i = 0; i < (int)n.length(); ++i) … … 279 237 QStringList watching; 280 238 QFileSystemModel *model; 281 QFSCompletor *completer; 239 240 #ifndef QT_NO_FSCOMPLETER 241 QFSCompleter *completer; 242 #endif //QT_NO_FSCOMPLETER 282 243 283 244 QFileDialog::FileMode fileMode; … … 361 322 #endif 362 323 363 Ui_QFileDialog *qFileDialogUi;324 QScopedPointer<Ui_QFileDialog> qFileDialogUi; 364 325 365 326 QString acceptLabel; … … 370 331 371 332 QFileDialog::Options opts; 333 334 ~QFileDialogPrivate(); 335 336 private: 337 Q_DISABLE_COPY(QFileDialogPrivate) 372 338 }; 373 339 … … 445 411 #ifndef Q_WS_MAC 446 412 // Dummies for platforms that don't use native dialogs: 447 inline void QFileDialogPrivate::deleteNativeDialog_sys() { }448 inline bool QFileDialogPrivate::setVisible_sys(bool ) { return false; }449 inline QDialog::DialogCode QFileDialogPrivate::dialogResultCode_sys(){ return QDialog::Rejected; }450 inline void QFileDialogPrivate::setDirectory_sys(const QString & ) {}451 inline QString QFileDialogPrivate::directory_sys() const { return QString(); }452 inline void QFileDialogPrivate::selectFile_sys(const QString & ) {}453 inline QStringList QFileDialogPrivate::selectedFiles_sys() const { return QStringList(); }454 inline void QFileDialogPrivate::setFilter_sys() { }455 inline void QFileDialogPrivate::setNameFilters_sys(const QStringList & ) {}456 inline void QFileDialogPrivate::selectNameFilter_sys(const QString & ) {}457 inline QString QFileDialogPrivate::selectedNameFilter_sys() const { return QString(); }413 inline void QFileDialogPrivate::deleteNativeDialog_sys() { qt_guiPlatformPlugin()->fileDialogDelete(q_func()); } 414 inline bool QFileDialogPrivate::setVisible_sys(bool visible) { return qt_guiPlatformPlugin()->fileDialogSetVisible(q_func(), visible); } 415 inline QDialog::DialogCode QFileDialogPrivate::dialogResultCode_sys(){ return qt_guiPlatformPlugin()->fileDialogResultCode(q_func()); } 416 inline void QFileDialogPrivate::setDirectory_sys(const QString &directory) { qt_guiPlatformPlugin()->fileDialogSetDirectory(q_func(), directory); } 417 inline QString QFileDialogPrivate::directory_sys() const { return qt_guiPlatformPlugin()->fileDialogDirectory(q_func()); } 418 inline void QFileDialogPrivate::selectFile_sys(const QString &filename) { qt_guiPlatformPlugin()->fileDialogSelectFile(q_func(), filename); } 419 inline QStringList QFileDialogPrivate::selectedFiles_sys() const { return qt_guiPlatformPlugin()->fileDialogSelectedFiles(q_func()); } 420 inline void QFileDialogPrivate::setFilter_sys() { qt_guiPlatformPlugin()->fileDialogSetFilter(q_func()); } 421 inline void QFileDialogPrivate::setNameFilters_sys(const QStringList &filters) { qt_guiPlatformPlugin()->fileDialogSetNameFilters(q_func(), filters); } 422 inline void QFileDialogPrivate::selectNameFilter_sys(const QString &filter) { qt_guiPlatformPlugin()->fileDialogSelectNameFilter(q_func(), filter); } 423 inline QString QFileDialogPrivate::selectedNameFilter_sys() const { return qt_guiPlatformPlugin()->fileDialogSelectedNameFilter(q_func()); } 458 424 #endif 459 425 -
trunk/src/gui/dialogs/qfiledialog_win.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 60 60 61 61 #include <shlobj.h> 62 63 #ifdef Q_OS_WINCE 62 //At some point we can hope that mingw will support that interface 63 #if !defined(Q_WS_WINCE) && !defined(Q_CC_MINGW) 64 #include <shobjidl.h> 65 #endif 66 67 #include <objbase.h> 68 69 #if defined(__IFileDialog_INTERFACE_DEFINED__) \ 70 && defined(__IFileOpenDialog_INTERFACE_DEFINED__) 71 #define USE_COMMON_ITEM_DIALOG 72 #endif 73 74 #ifdef Q_WS_WINCE 64 75 #include <commdlg.h> 65 76 # ifndef BFFM_SETSELECTION … … 71 82 HWND hwndOwner; 72 83 LPCITEMIDLIST pidlRoot; 73 LP TSTR pszDisplayName;74 LPC TSTR lpszTitle;84 LPWSTR pszDisplayName; 85 LPCWSTR lpszTitle; 75 86 UINT ulFlags; 76 87 BFFCALLBACK lpfn; … … 91 102 typedef BOOL (WINAPI *PtrSHGetPathFromIDList)(LPITEMIDLIST,LPWSTR); 92 103 static PtrSHGetPathFromIDList ptrSHGetPathFromIDList = 0; 104 typedef HRESULT (WINAPI *PtrSHGetMalloc)(LPMALLOC *); 105 static PtrSHGetMalloc ptrSHGetMalloc = 0; 106 93 107 94 108 QT_BEGIN_NAMESPACE … … 112 126 113 127 triedResolve = true; 114 if (!(QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based)) { 115 #if !defined(Q_OS_WINCE) 116 QLibrary lib(QLatin1String("shell32"));117 ptrSHBrowseForFolder = (PtrSHBrowseForFolder) lib.resolve("SHBrowseForFolderW");118 ptrSHGetPathFromIDList = (PtrSHGetPathFromIDList) lib.resolve("SHGetPathFromIDListW");128 #if !defined(Q_WS_WINCE) 129 QLibrary lib(QLatin1String("shell32")); 130 ptrSHBrowseForFolder = (PtrSHBrowseForFolder) lib.resolve("SHBrowseForFolderW"); 131 ptrSHGetPathFromIDList = (PtrSHGetPathFromIDList) lib.resolve("SHGetPathFromIDListW"); 132 ptrSHGetMalloc = (PtrSHGetMalloc) lib.resolve("SHGetMalloc"); 119 133 #else 120 121 122 123 124 if (ptrSHBrowseForFolder && ptrSHGetPathFromIDList)125 qt_priv_ptr_valid = true;126 #endif 127 } 134 // CE stores them in a different lib and does not use unicode version 135 HINSTANCE handle = LoadLibraryW(L"Ceshell"); 136 ptrSHBrowseForFolder = (PtrSHBrowseForFolder)GetProcAddress(handle, L"SHBrowseForFolder"); 137 ptrSHGetPathFromIDList = (PtrSHGetPathFromIDList)GetProcAddress(handle, L"SHGetPathFromIDList"); 138 ptrSHGetMalloc = (PtrSHGetMalloc)GetProcAddress(handle, L"SHGetMalloc"); 139 if (ptrSHBrowseForFolder && ptrSHGetPathFromIDList && ptrSHGetMalloc) 140 qt_priv_ptr_valid = true; 141 #endif 128 142 } 129 143 } … … 164 178 165 179 // Makes a NUL-oriented Windows filter from a Qt filter. 166 static QString qt_win_filter(const QString &filter )180 static QString qt_win_filter(const QString &filter, bool hideFiltersDetails) 167 181 { 168 182 QStringList filterLst = qt_win_make_filters_list(filter); 169 183 QStringList::Iterator it = filterLst.begin(); 170 184 QString winfilters; 185 QRegExp r(QString::fromLatin1(qt_file_dialog_filter_reg_exp)); 171 186 for (; it != filterLst.end(); ++it) { 172 187 QString subfilter = *it; 173 188 if (!subfilter.isEmpty()) { 174 winfilters += subfilter; 189 if (hideFiltersDetails) { 190 int index = r.indexIn(subfilter); 191 if (index >= 0) 192 winfilters += r.cap(1); 193 } else { 194 winfilters += subfilter; 195 } 175 196 winfilters += QChar(); 176 197 winfilters += qt_win_extract_filter(subfilter); … … 187 208 } 188 209 189 #ifndef Q_OS_WINCE190 // Static vars for OFNA funcs:191 static QByteArray aInitDir;192 static QByteArray aInitSel;193 static QByteArray aTitle;194 static QByteArray aFilter;195 // Use ANSI strings and API196 197 // If you change this, then make sure you change qt_win_make_OFN (below) too198 static OPENFILENAMEA *qt_win_make_OFNA(QWidget *parent,199 const QString &initialSelection,200 const QString &initialDirectory,201 const QString &title,202 const QString &filters,203 QFileDialog::FileMode mode,204 QFileDialog::Options options)205 {206 if (parent)207 parent = parent->window();208 else209 parent = qApp->activeWindow();210 211 aTitle = title.toLocal8Bit();212 aInitDir = QDir::toNativeSeparators(initialDirectory).toLocal8Bit();213 if (initialSelection.isEmpty()) {214 aInitSel = "";215 } else {216 aInitSel = QDir::toNativeSeparators(initialSelection).toLocal8Bit();217 aInitSel.replace("<", "");218 aInitSel.replace(">", "");219 aInitSel.replace("\"", "");220 aInitSel.replace("|", "");221 }222 int maxLen = mode == QFileDialog::ExistingFiles ? maxMultiLen : maxNameLen;223 aInitSel.resize(maxLen + 1); // make room for return value224 aFilter = filters.toLocal8Bit();225 226 OPENFILENAMEA* ofn = new OPENFILENAMEA;227 memset(ofn, 0, sizeof(OPENFILENAMEA));228 229 #if defined(Q_CC_BOR) && (WINVER >= 0x0500) && (_WIN32_WINNT >= 0x0500)230 // according to the MSDN, this should also be necessary for MSVC, but231 // OPENFILENAME_SIZE_VERSION_400A is in not Microsoft header, as it seems232 if (QApplication::winVersion()==Qt::WV_NT || QApplication::winVersion()&Qt::WV_DOS_based) {233 ofn->lStructSize = OPENFILENAME_SIZE_VERSION_400A;234 } else {235 ofn->lStructSize = sizeof(OPENFILENAMEA);236 }237 #else238 ofn->lStructSize = sizeof(OPENFILENAMEA);239 #endif240 Q_ASSERT(!parent ||parent->testAttribute(Qt::WA_WState_Created));241 ofn->hwndOwner = parent ? parent->winId() : 0;242 ofn->lpstrFilter = aFilter;243 ofn->lpstrFile = aInitSel.data();244 ofn->nMaxFile = maxLen;245 ofn->lpstrInitialDir = aInitDir.data();246 ofn->lpstrTitle = aTitle.data();247 ofn->Flags = (OFN_NOCHANGEDIR | OFN_HIDEREADONLY | OFN_EXPLORER);248 249 if (mode == QFileDialog::ExistingFile ||250 mode == QFileDialog::ExistingFiles)251 ofn->Flags |= (OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST);252 if (mode == QFileDialog::ExistingFiles)253 ofn->Flags |= (OFN_ALLOWMULTISELECT);254 if (!(options & QFileDialog::DontConfirmOverwrite))255 ofn->Flags |= OFN_OVERWRITEPROMPT;256 257 return ofn;258 }259 260 static void qt_win_clean_up_OFNA(OPENFILENAMEA **ofn)261 {262 delete *ofn;263 *ofn = 0;264 }265 #endif266 267 210 static QString tFilters, tTitle, tInitDir; 268 211 269 #ifdef UNICODE270 // If you change this, then make sure you change qt_win_make_OFNA (above) too271 212 static OPENFILENAME* qt_win_make_OFN(QWidget *parent, 272 213 const QString& initialSelection, … … 275 216 const QString& filters, 276 217 QFileDialog::FileMode mode, 277 218 QFileDialog::Options options) 278 219 { 279 220 if (parent) 280 221 parent = parent->window(); 281 222 else 282 parent = qApp->activeWindow();223 parent = QApplication::activeWindow(); 283 224 284 225 tInitDir = QDir::toNativeSeparators(initialDirectory); … … 287 228 QString initSel = QDir::toNativeSeparators(initialSelection); 288 229 if (!initSel.isEmpty()) { 289 initSel.replace(QLatin1String("<"), QLatin1String(""));290 initSel.replace(QLatin1String(">"), QLatin1String(""));291 initSel.replace(QLatin1String("\""), QLatin1String(""));292 initSel.replace(QLatin1String("|"), QLatin1String(""));230 initSel.remove(QLatin1Char('<')); 231 initSel.remove(QLatin1Char('>')); 232 initSel.remove(QLatin1Char('\"')); 233 initSel.remove(QLatin1Char('|')); 293 234 } 294 235 295 236 int maxLen = mode == QFileDialog::ExistingFiles ? maxMultiLen : maxNameLen; 296 TCHAR *tInitSel = new TCHAR[maxLen+1];237 wchar_t *tInitSel = new wchar_t[maxLen + 1]; 297 238 if (initSel.length() > 0 && initSel.length() <= maxLen) 298 239 memcpy(tInitSel, initSel.utf16(), (initSel.length()+1)*sizeof(QChar)); … … 303 244 memset(ofn, 0, sizeof(OPENFILENAME)); 304 245 305 #if defined(Q_CC_BOR) && (WINVER >= 0x0500) && (_WIN32_WINNT >= 0x0500)306 // according to the MSDN, this should also be necessary for MSVC, but307 // OPENFILENAME_SIZE_VERSION_400 is in not Microsoft header, as it seems308 if (QApplication::winVersion()==Qt::WV_NT || QApplication::winVersion()&Qt::WV_DOS_based) {309 ofn->lStructSize= OPENFILENAME_SIZE_VERSION_400;310 } else {311 ofn->lStructSize = sizeof(OPENFILENAME);312 }313 #else314 246 ofn->lStructSize = sizeof(OPENFILENAME); 315 #endif316 247 Q_ASSERT(!parent ||parent->testAttribute(Qt::WA_WState_Created)); 317 248 ofn->hwndOwner = parent ? parent->winId() : 0; 318 ofn->lpstrFilter = ( TCHAR*)tFilters.utf16();249 ofn->lpstrFilter = (wchar_t*)tFilters.utf16(); 319 250 ofn->lpstrFile = tInitSel; 320 251 ofn->nMaxFile = maxLen; 321 ofn->lpstrInitialDir = ( TCHAR*)tInitDir.utf16();322 ofn->lpstrTitle = ( TCHAR*)tTitle.utf16();323 ofn->Flags = (OFN_NOCHANGEDIR | OFN_HIDEREADONLY | OFN_EXPLORER );252 ofn->lpstrInitialDir = (wchar_t*)tInitDir.utf16(); 253 ofn->lpstrTitle = (wchar_t*)tTitle.utf16(); 254 ofn->Flags = (OFN_NOCHANGEDIR | OFN_HIDEREADONLY | OFN_EXPLORER | OFN_PATHMUSTEXIST); 324 255 if (mode == QFileDialog::ExistingFile || 325 256 mode == QFileDialog::ExistingFiles) 326 ofn->Flags |= (OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST);257 ofn->Flags |= (OFN_FILEMUSTEXIST); 327 258 if (mode == QFileDialog::ExistingFiles) 328 259 ofn->Flags |= (OFN_ALLOWMULTISELECT); … … 333 264 } 334 265 335 336 266 static void qt_win_clean_up_OFN(OPENFILENAME **ofn) 337 267 { … … 340 270 *ofn = 0; 341 271 } 342 343 #endif // UNICODE344 272 345 273 extern void qt_win_eatMouseMove(); … … 378 306 modal_widget.setParent(args.parent, Qt::Window); 379 307 QApplicationPrivate::enterModal(&modal_widget); 380 QT_WA({ 381 // Use Unicode strings and API 382 OPENFILENAME* ofn = qt_win_make_OFN(args.parent, args.selection, 383 args.directory, args.caption, 384 qt_win_filter(args.filter), 385 QFileDialog::ExistingFile, 386 args.options); 387 if (idx) 388 ofn->nFilterIndex = idx + 1; 389 if (GetOpenFileName(ofn)) { 390 result = QString::fromUtf16((ushort*)ofn->lpstrFile); 391 selFilIdx = ofn->nFilterIndex; 392 } 393 qt_win_clean_up_OFN(&ofn); 394 } , { 395 // Use ANSI strings and API 396 OPENFILENAMEA* ofn = qt_win_make_OFNA(args.parent, args.selection, 397 args.directory, args.caption, 398 qt_win_filter(args.filter), 399 QFileDialog::ExistingFile, 400 args.options); 401 if (idx) 402 ofn->nFilterIndex = idx + 1; 403 if (GetOpenFileNameA(ofn)) { 404 result = QString::fromLocal8Bit(ofn->lpstrFile); 405 selFilIdx = ofn->nFilterIndex; 406 } 407 qt_win_clean_up_OFNA(&ofn); 408 }); 308 309 bool hideFiltersDetails = args.options & QFileDialog::HideNameFilterDetails; 310 OPENFILENAME* ofn = qt_win_make_OFN(args.parent, args.selection, 311 args.directory, args.caption, 312 qt_win_filter(args.filter, hideFiltersDetails), 313 QFileDialog::ExistingFile, 314 args.options); 315 if (idx) 316 ofn->nFilterIndex = idx + 1; 317 if (GetOpenFileName(ofn)) { 318 result = QString::fromWCharArray(ofn->lpstrFile); 319 selFilIdx = ofn->nFilterIndex; 320 } 321 qt_win_clean_up_OFN(&ofn); 322 409 323 QApplicationPrivate::leaveModal(&modal_widget); 410 324 … … 423 337 QString qt_win_get_save_file_name(const QFileDialogArgs &args, 424 338 QString *initialDirectory, 425 339 QString *selectedFilter) 426 340 { 427 341 QString result; … … 453 367 modal_widget.setParent(args.parent, Qt::Window); 454 368 QApplicationPrivate::enterModal(&modal_widget); 455 369 bool hideFiltersDetails = args.options & QFileDialog::HideNameFilterDetails; 456 370 // This block is used below for the lpstrDefExt member. 457 371 // Note that the current MSDN docs document this member wrong. … … 471 385 } 472 386 473 QT_WA({ 474 // Use Unicode strings and API 475 OPENFILENAME *ofn = qt_win_make_OFN(args.parent, args.selection, 476 args.directory, args.caption, 477 qt_win_filter(args.filter), 478 QFileDialog::AnyFile, 479 args.options); 480 481 ofn->lpstrDefExt = (TCHAR *)defaultSaveExt.utf16(); 482 483 if (idx) 484 ofn->nFilterIndex = idx + 1; 485 if (GetSaveFileName(ofn)) { 486 result = QString::fromUtf16((ushort*)ofn->lpstrFile); 487 selFilIdx = ofn->nFilterIndex; 488 } 489 qt_win_clean_up_OFN(&ofn); 490 } , { 491 // Use ANSI strings and API 492 OPENFILENAMEA *ofn = qt_win_make_OFNA(args.parent, args.selection, 493 args.directory, args.caption, 494 qt_win_filter(args.filter), 495 QFileDialog::AnyFile, 496 args.options); 497 QByteArray asciiExt = defaultSaveExt.toAscii(); 498 ofn->lpstrDefExt = asciiExt.data(); 499 500 if (idx) 501 ofn->nFilterIndex = idx + 1; 502 if (GetSaveFileNameA(ofn)) { 503 result = QString::fromLocal8Bit(ofn->lpstrFile); 504 selFilIdx = ofn->nFilterIndex; 505 } 506 qt_win_clean_up_OFNA(&ofn); 507 }); 508 #if defined(Q_OS_WINCE) 387 OPENFILENAME *ofn = qt_win_make_OFN(args.parent, args.selection, 388 args.directory, args.caption, 389 qt_win_filter(args.filter, hideFiltersDetails), 390 QFileDialog::AnyFile, 391 args.options); 392 393 ofn->lpstrDefExt = (wchar_t*)defaultSaveExt.utf16(); 394 395 if (idx) 396 ofn->nFilterIndex = idx + 1; 397 if (GetSaveFileName(ofn)) { 398 result = QString::fromWCharArray(ofn->lpstrFile); 399 selFilIdx = ofn->nFilterIndex; 400 } 401 qt_win_clean_up_OFN(&ofn); 402 403 #if defined(Q_WS_WINCE) 509 404 int semIndex = result.indexOf(QLatin1Char(';')); 510 405 if (semIndex >= 0) … … 526 421 } 527 422 528 QStringList qt_win_get_open_file_names(const QFileDialogArgs &args, 423 424 #if defined(USE_COMMON_ITEM_DIALOG) 425 426 typedef HRESULT (WINAPI *PtrSHCreateItemFromParsingName)(PCWSTR pszPath, IBindCtx *pbc, REFIID riid, void **ppv); 427 static PtrSHCreateItemFromParsingName pSHCreateItemFromParsingName = 0; 428 429 static bool qt_win_set_IFileDialogOptions(IFileDialog *pfd, 430 const QString& initialSelection, 431 const QString& initialDirectory, 432 const QString& title, 433 const QStringList& filterLst, 434 QFileDialog::FileMode mode, 435 QFileDialog::Options options) 436 { 437 if (!pSHCreateItemFromParsingName) { 438 // This function is available only in Vista & above. 439 QLibrary shellLib(QLatin1String("Shell32")); 440 pSHCreateItemFromParsingName = (PtrSHCreateItemFromParsingName) 441 shellLib.resolve("SHCreateItemFromParsingName"); 442 if (!pSHCreateItemFromParsingName) 443 return false; 444 } 445 HRESULT hr; 446 QString winfilters; 447 int numFilters = 0; 448 quint32 currentOffset = 0; 449 QList<quint32> offsets; 450 QStringList::ConstIterator it = filterLst.begin(); 451 // Create the native filter string and save offset to each entry. 452 for (; it != filterLst.end(); ++it) { 453 QString subfilter = *it; 454 if (!subfilter.isEmpty()) { 455 offsets<<currentOffset; 456 //Here the COMMON_ITEM_DIALOG API always add the details for the filter (e.g. *.txt) 457 //so we don't need to handle the flag HideNameFilterDetails. 458 winfilters += subfilter; // The name of the filter. 459 winfilters += QChar(); 460 currentOffset += subfilter.size()+1; 461 offsets<<currentOffset; 462 QString spec = qt_win_extract_filter(subfilter); 463 winfilters += spec; // The actual filter spec. 464 winfilters += QChar(); 465 currentOffset += spec.size()+1; 466 numFilters++; 467 } 468 } 469 // Add the filters to the file dialog. 470 if (numFilters) { 471 wchar_t *szData = (wchar_t*)winfilters.utf16(); 472 COMDLG_FILTERSPEC *filterSpec = new COMDLG_FILTERSPEC[numFilters]; 473 for(int i = 0; i<numFilters; i++) { 474 filterSpec[i].pszName = szData+offsets[i*2]; 475 filterSpec[i].pszSpec = szData+offsets[(i*2)+1]; 476 } 477 hr = pfd->SetFileTypes(numFilters, filterSpec); 478 delete []filterSpec; 479 } 480 // Set the starting folder. 481 tInitDir = QDir::toNativeSeparators(initialDirectory); 482 if (!tInitDir.isEmpty()) { 483 IShellItem *psiDefaultFolder; 484 hr = pSHCreateItemFromParsingName((wchar_t*)tInitDir.utf16(), 485 NULL, 486 IID_PPV_ARGS(&psiDefaultFolder)); 487 488 if (SUCCEEDED(hr)) { 489 hr = pfd->SetFolder(psiDefaultFolder); 490 psiDefaultFolder->Release(); 491 } 492 } 493 // Set the currently selected file. 494 QString initSel = QDir::toNativeSeparators(initialSelection); 495 if (!initSel.isEmpty()) { 496 initSel.remove(QLatin1Char('<')); 497 initSel.remove(QLatin1Char('>')); 498 initSel.remove(QLatin1Char('\"')); 499 initSel.remove(QLatin1Char('|')); 500 } 501 if (!initSel.isEmpty()) { 502 hr = pfd->SetFileName((wchar_t*)initSel.utf16()); 503 } 504 // Set the title for the file dialog. 505 if (!title.isEmpty()) { 506 hr = pfd->SetTitle((wchar_t*)title.utf16()); 507 } 508 // Set other flags for the dialog. 509 DWORD newOptions; 510 hr = pfd->GetOptions(&newOptions); 511 if (SUCCEEDED(hr)) { 512 newOptions |= FOS_NOCHANGEDIR; 513 if (mode == QFileDialog::ExistingFile || 514 mode == QFileDialog::ExistingFiles) 515 newOptions |= (FOS_FILEMUSTEXIST | FOS_PATHMUSTEXIST); 516 if (mode == QFileDialog::ExistingFiles) 517 newOptions |= FOS_ALLOWMULTISELECT; 518 if (!(options & QFileDialog::DontConfirmOverwrite)) 519 newOptions |= FOS_OVERWRITEPROMPT; 520 hr = pfd->SetOptions(newOptions); 521 } 522 return SUCCEEDED(hr); 523 } 524 525 QStringList qt_win_CID_get_open_file_names(const QFileDialogArgs &args, 529 526 QString *initialDirectory, 530 QString *selectedFilter) 527 const QStringList &filterList, 528 QString *selectedFilter, 529 int selectedFilterIndex) 531 530 { 532 531 QStringList result; 533 QFileInfo fi;534 QDir dir;535 QString isel;536 537 if (initialDirectory && initialDirectory->left(5) == QLatin1String("file:"))538 initialDirectory->remove(0, 5);539 fi = QFileInfo(*initialDirectory);540 541 if (initialDirectory && !fi.isDir()) {542 *initialDirectory = fi.absolutePath();543 isel = fi.fileName();544 }545 546 if (!fi.exists())547 *initialDirectory = QDir::homePath();548 549 DWORD selFilIdx = 0;550 551 int idx = 0;552 if (selectedFilter) {553 QStringList filterLst = qt_win_make_filters_list(args.filter);554 idx = filterLst.indexOf(*selectedFilter);555 }556 557 532 QDialog modal_widget; 558 533 modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true); 559 534 modal_widget.setParent(args.parent, Qt::Window); 560 535 QApplicationPrivate::enterModal(&modal_widget); 561 QT_WA({ 562 OPENFILENAME* ofn = qt_win_make_OFN(args.parent, args.selection, 563 args.directory, args.caption, 564 qt_win_filter(args.filter), 565 QFileDialog::ExistingFiles, 566 args.options); 567 if (idx) 568 ofn->nFilterIndex = idx + 1; 569 if (GetOpenFileName(ofn)) { 570 QString fileOrDir = QString::fromUtf16((ushort*)ofn->lpstrFile); 571 selFilIdx = ofn->nFilterIndex; 572 int offset = fileOrDir.length() + 1; 573 if (ofn->lpstrFile[offset] == 0) { 574 // Only one file selected; has full path 575 fi.setFile(fileOrDir); 536 // Multiple selection is allowed only in IFileOpenDialog. 537 IFileOpenDialog *pfd = 0; 538 HRESULT hr = CoCreateInstance(CLSID_FileOpenDialog, 539 NULL, 540 CLSCTX_INPROC_SERVER, 541 IID_PPV_ARGS(&pfd)); 542 543 if (SUCCEEDED(hr)) { 544 qt_win_set_IFileDialogOptions(pfd, args.selection, 545 args.directory, args.caption, 546 filterList, QFileDialog::ExistingFiles, 547 args.options); 548 // Set the currently selected filter (one-based index). 549 hr = pfd->SetFileTypeIndex(selectedFilterIndex+1); 550 QWidget *parentWindow = args.parent; 551 if (parentWindow) 552 parentWindow = parentWindow->window(); 553 else 554 parentWindow = QApplication::activeWindow(); 555 // Show the file dialog. 556 hr = pfd->Show(parentWindow ? parentWindow->winId() : 0); 557 if (SUCCEEDED(hr)) { 558 // Retrieve the results. 559 IShellItemArray *psiaResults; 560 hr = pfd->GetResults(&psiaResults); 561 if (SUCCEEDED(hr)) { 562 DWORD numItems = 0; 563 psiaResults->GetCount(&numItems); 564 for (DWORD i = 0; i<numItems; i++) { 565 IShellItem *psi = 0; 566 hr = psiaResults->GetItemAt(i, &psi); 567 if (SUCCEEDED(hr)) { 568 // Retrieve the file name from shell item. 569 wchar_t *pszPath; 570 hr = psi->GetDisplayName(SIGDN_FILESYSPATH, &pszPath); 571 if (SUCCEEDED(hr)) { 572 QString fileName = QString::fromWCharArray(pszPath); 573 result.append(fileName); 574 CoTaskMemFree(pszPath); 575 } 576 psi->Release(); // Free the current item. 577 } 578 } 579 psiaResults->Release(); // Free the array of items. 580 } 581 } 582 } 583 QApplicationPrivate::leaveModal(&modal_widget); 584 585 qt_win_eatMouseMove(); 586 587 if (!result.isEmpty()) { 588 // Retrieve the current folder name. 589 IShellItem *psi = 0; 590 hr = pfd->GetFolder(&psi); 591 if (SUCCEEDED(hr)) { 592 wchar_t *pszPath; 593 hr = psi->GetDisplayName(SIGDN_FILESYSPATH, &pszPath); 594 if (SUCCEEDED(hr)) { 595 *initialDirectory = QString::fromWCharArray(pszPath); 596 CoTaskMemFree(pszPath); 597 } 598 psi->Release(); 599 } 600 // Retrieve the currently selected filter. 601 if (selectedFilter) { 602 quint32 filetype = 0; 603 hr = pfd->GetFileTypeIndex(&filetype); 604 if (SUCCEEDED(hr) && filetype && filetype <= (quint32)filterList.length()) { 605 // This is a one-based index, not zero-based. 606 *selectedFilter = filterList[filetype-1]; 607 } 608 } 609 } 610 if (pfd) 611 pfd->Release(); 612 return result; 613 } 614 615 #endif 616 617 QStringList qt_win_get_open_file_names(const QFileDialogArgs &args, 618 QString *initialDirectory, 619 QString *selectedFilter) 620 { 621 QFileInfo fi; 622 QDir dir; 623 624 if (initialDirectory && initialDirectory->left(5) == QLatin1String("file:")) 625 initialDirectory->remove(0, 5); 626 fi = QFileInfo(*initialDirectory); 627 628 if (initialDirectory && !fi.isDir()) { 629 *initialDirectory = fi.absolutePath(); 630 } 631 632 if (!fi.exists()) 633 *initialDirectory = QDir::homePath(); 634 635 DWORD selFilIdx = 0; 636 637 QStringList filterLst = qt_win_make_filters_list(args.filter); 638 int idx = 0; 639 if (selectedFilter) { 640 idx = filterLst.indexOf(*selectedFilter); 641 } 642 // Windows Vista (& above) allows users to search from file dialogs. If user selects 643 // multiple files belonging to different folders from these search results, the 644 // GetOpenFileName() will return only one folder name for all the files. To retrieve 645 // the correct path for all selected files, we have to use Common Item Dialog interfaces. 646 #if defined(USE_COMMON_ITEM_DIALOG) 647 if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based) 648 return qt_win_CID_get_open_file_names(args, initialDirectory, filterLst, selectedFilter, idx); 649 #endif 650 651 QStringList result; 652 QDialog modal_widget; 653 modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true); 654 modal_widget.setParent(args.parent, Qt::Window); 655 QApplicationPrivate::enterModal(&modal_widget); 656 657 bool hideFiltersDetails = args.options & QFileDialog::HideNameFilterDetails; 658 OPENFILENAME* ofn = qt_win_make_OFN(args.parent, args.selection, 659 args.directory, args.caption, 660 qt_win_filter(args.filter, hideFiltersDetails), 661 QFileDialog::ExistingFiles, 662 args.options); 663 if (idx) 664 ofn->nFilterIndex = idx + 1; 665 if (GetOpenFileName(ofn)) { 666 QString fileOrDir = QString::fromWCharArray(ofn->lpstrFile); 667 selFilIdx = ofn->nFilterIndex; 668 int offset = fileOrDir.length() + 1; 669 if (ofn->lpstrFile[offset] == 0) { 670 // Only one file selected; has full path 671 fi.setFile(fileOrDir); 672 QString res = fi.absoluteFilePath(); 673 if (!res.isEmpty()) 674 result.append(res); 675 } 676 else { 677 // Several files selected; first string is path 678 dir.setPath(fileOrDir); 679 QString f; 680 while(!(f = QString::fromWCharArray(ofn->lpstrFile + offset)).isEmpty()) { 681 fi.setFile(dir, f); 576 682 QString res = fi.absoluteFilePath(); 577 683 if (!res.isEmpty()) 578 684 result.append(res); 685 offset += f.length() + 1; 579 686 } 580 else { 581 // Several files selected; first string is path 582 dir.setPath(fileOrDir); 583 QString f; 584 while(!(f = QString::fromUtf16((ushort*)ofn->lpstrFile+offset)).isEmpty()) { 585 fi.setFile(dir, f); 586 QString res = fi.absoluteFilePath(); 587 if (!res.isEmpty()) 588 result.append(res); 589 offset += f.length() + 1; 590 } 591 } 592 } 593 qt_win_clean_up_OFN(&ofn); 594 } , { 595 OPENFILENAMEA* ofn = qt_win_make_OFNA(args.parent, args.selection, 596 args.directory, args.caption, 597 qt_win_filter(args.filter), 598 QFileDialog::ExistingFiles, 599 args.options); 600 if (idx) 601 ofn->nFilterIndex = idx + 1; 602 if (GetOpenFileNameA(ofn)) { 603 QByteArray fileOrDir(ofn->lpstrFile); 604 selFilIdx = ofn->nFilterIndex; 605 int offset = fileOrDir.length() + 1; 606 if (ofn->lpstrFile[offset] == '\0') { 607 // Only one file selected; has full path 608 fi.setFile(QString::fromLocal8Bit(fileOrDir)); 609 QString res = fi.absoluteFilePath(); 610 if (!res.isEmpty()) 611 result.append(res); 612 } 613 else { 614 // Several files selected; first string is path 615 dir.setPath(QString::fromLocal8Bit(fileOrDir)); 616 QByteArray f; 617 while (!(f = QByteArray(ofn->lpstrFile + offset)).isEmpty()) { 618 fi.setFile(dir, QString::fromLocal8Bit(f)); 619 QString res = fi.absoluteFilePath(); 620 if (!res.isEmpty()) 621 result.append(res); 622 offset += f.length() + 1; 623 } 624 } 625 qt_win_clean_up_OFNA(&ofn); 626 } 627 }); 687 } 688 } 689 qt_win_clean_up_OFN(&ofn); 690 628 691 QApplicationPrivate::leaveModal(&modal_widget); 629 692 … … 648 711 QString *initDir = (QString *)(lpData); 649 712 if (!initDir->isEmpty()) { 650 // ### Lars asks: is this correct for the A version???? 651 QT_WA({ 652 SendMessage(hwnd, BFFM_SETSELECTION, TRUE, LPARAM(initDir->utf16())); 653 } , { 654 SendMessageA(hwnd, BFFM_SETSELECTION, TRUE, LPARAM(initDir->utf16())); 655 }); 713 SendMessage(hwnd, BFFM_SETSELECTION, TRUE, LPARAM(initDir->utf16())); 656 714 } 657 715 } else if (uMsg == BFFM_SELCHANGED) { 658 QT_WA({659 qt_win_resolve_libs();660 TCHARpath[MAX_PATH];716 qt_win_resolve_libs(); 717 if (ptrSHGetPathFromIDList) { 718 wchar_t path[MAX_PATH]; 661 719 ptrSHGetPathFromIDList(LPITEMIDLIST(lParam), path); 662 QString tmpStr = QString::from Utf16((ushort*)path);720 QString tmpStr = QString::fromWCharArray(path); 663 721 if (!tmpStr.isEmpty()) 664 722 SendMessage(hwnd, BFFM_ENABLEOK, 1, 1); … … 666 724 SendMessage(hwnd, BFFM_ENABLEOK, 0, 0); 667 725 SendMessage(hwnd, BFFM_SETSTATUSTEXT, 1, LPARAM(path)); 668 } , { 669 char path[MAX_PATH]; 670 SHGetPathFromIDListA(LPITEMIDLIST(lParam), path); 671 QString tmpStr = QString::fromLocal8Bit(path); 672 if (!tmpStr.isEmpty()) 673 SendMessageA(hwnd, BFFM_ENABLEOK, 1, 1); 674 else 675 SendMessageA(hwnd, BFFM_ENABLEOK, 0, 0); 676 SendMessageA(hwnd, BFFM_SETSTATUSTEXT, 1, LPARAM(path)); 677 }); 726 } 678 727 } 679 728 return 0; … … 693 742 parent = parent->window(); 694 743 else 695 parent = qApp->activeWindow();744 parent = QApplication::activeWindow(); 696 745 if (parent) 697 746 parent->createWinId(); … … 701 750 modal_widget.setParent(parent, Qt::Window); 702 751 QApplicationPrivate::enterModal(&modal_widget); 703 #if !defined(Q_OS_WINCE) 704 QT_WA({ 705 qt_win_resolve_libs(); 706 QString initDir = QDir::toNativeSeparators(args.directory); 707 TCHAR path[MAX_PATH]; 708 TCHAR initPath[MAX_PATH]; 709 initPath[0] = 0; 710 path[0] = 0; 711 tTitle = args.caption; 712 BROWSEINFO bi; 713 Q_ASSERT(!parent ||parent->testAttribute(Qt::WA_WState_Created)); 714 bi.hwndOwner = (parent ? parent->winId() : 0); 715 bi.pidlRoot = NULL; 716 //### This does not seem to be respected? - the dialog always displays "Browse for folder" 717 bi.lpszTitle = (TCHAR*)tTitle.utf16(); 718 bi.pszDisplayName = initPath; 719 bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT | BIF_NEWDIALOGSTYLE; 720 bi.lpfn = winGetExistDirCallbackProc; 721 bi.lParam = LPARAM(&initDir); 722 if (ptrSHBrowseForFolder) { 723 LPITEMIDLIST pItemIDList = ptrSHBrowseForFolder(&bi); 724 if (pItemIDList && ptrSHGetPathFromIDList) { 725 ptrSHGetPathFromIDList(pItemIDList, path); 726 IMalloc *pMalloc; 727 if (SHGetMalloc(&pMalloc) != NOERROR) 728 result = QString(); 729 else { 730 pMalloc->Free(pItemIDList); 731 pMalloc->Release(); 732 result = QString::fromUtf16((ushort*)path); 733 } 734 } else 735 result = QString(); 736 } 737 tTitle = QString(); 738 } , { 739 QString initDir = QDir::toNativeSeparators(args.directory); 740 char path[MAX_PATH]; 741 char initPath[MAX_PATH]; 742 QByteArray ctitle = args.caption.toLocal8Bit(); 743 initPath[0]=0; 744 path[0]=0; 745 BROWSEINFOA bi; 746 Q_ASSERT(!parent ||parent->testAttribute(Qt::WA_WState_Created)); 747 bi.hwndOwner = (parent ? parent->winId() : 0); 748 bi.pidlRoot = NULL; 749 bi.lpszTitle = ctitle; 750 bi.pszDisplayName = initPath; 751 bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT | BIF_NEWDIALOGSTYLE; 752 bi.lpfn = winGetExistDirCallbackProc; 753 bi.lParam = LPARAM(&initDir); 754 LPITEMIDLIST pItemIDList = SHBrowseForFolderA(&bi); 755 if (pItemIDList) { 756 SHGetPathFromIDListA(pItemIDList, path); 757 IMalloc *pMalloc; 758 if (SHGetMalloc(&pMalloc) != NOERROR) 759 result = QString(); 760 else { 761 pMalloc->Free(pItemIDList); 762 pMalloc->Release(); 763 result = QString::fromLocal8Bit(path); 764 } 765 } else 766 result = QString(); 767 }); 752 753 QString initDir = QDir::toNativeSeparators(args.directory); 754 wchar_t path[MAX_PATH]; 755 wchar_t initPath[MAX_PATH]; 756 initPath[0] = 0; 757 path[0] = 0; 758 tTitle = args.caption; 759 760 #if !defined(Q_WS_WINCE) 761 BROWSEINFO bi; 768 762 #else 769 qt_win_resolve_libs();770 QString initDir = QDir::toNativeSeparators(args.directory);771 TCHAR path[MAX_PATH];772 TCHAR initPath[MAX_PATH];773 memset(initPath, 0 , MAX_PATH*sizeof(TCHAR));774 memset(path, 0, MAX_PATH*sizeof(TCHAR));775 tTitle = args.caption;776 763 qt_BROWSEINFO bi; 764 #endif 765 777 766 Q_ASSERT(!parent ||parent->testAttribute(Qt::WA_WState_Created)); 778 767 bi.hwndOwner = (parent ? parent->winId() : 0); 779 768 bi.pidlRoot = NULL; 780 bi.lpszTitle = (TCHAR*)tTitle.utf16(); 769 //### This does not seem to be respected? - the dialog always displays "Browse for folder" 770 bi.lpszTitle = (wchar_t*)tTitle.utf16(); 781 771 bi.pszDisplayName = initPath; 782 772 bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT | BIF_NEWDIALOGSTYLE; 783 773 bi.lpfn = winGetExistDirCallbackProc; 784 774 bi.lParam = LPARAM(&initDir); 775 776 qt_win_resolve_libs(); 785 777 if (ptrSHBrowseForFolder) { 786 778 LPITEMIDLIST pItemIDList = ptrSHBrowseForFolder((BROWSEINFO*)&bi); 787 if (pItemIDList && ptrSHGetPathFromIDList) {779 if (pItemIDList) { 788 780 ptrSHGetPathFromIDList(pItemIDList, path); 789 781 IMalloc *pMalloc; 790 if (SHGetMalloc(&pMalloc) != NOERROR) 791 result = QString(); 792 else { 782 if (ptrSHGetMalloc(&pMalloc) == NOERROR) { 793 783 pMalloc->Free(pItemIDList); 794 784 pMalloc->Release(); 795 result = QString::from Utf16((ushort*)path);785 result = QString::fromWCharArray(path); 796 786 } 797 } else 798 result = QString(); 787 } 799 788 } 800 789 tTitle = QString(); 801 790 802 #endif803 791 QApplicationPrivate::leaveModal(&modal_widget); 804 792 805 793 qt_win_eatMouseMove(); 806 794 807 // Due to a bug on Windows Me, we need to reset the current808 // directory809 if ((QSysInfo::WindowsVersion == QSysInfo::WV_98 || QSysInfo::WindowsVersion == QSysInfo::WV_Me)810 && QDir::currentPath() != currentDir)811 QDir::setCurrent(currentDir);812 813 795 if (!result.isEmpty()) 814 result.replace(QLatin1 String("\\"), QLatin1String("/"));796 result.replace(QLatin1Char('\\'), QLatin1Char('/')); 815 797 return result; 816 798 } -
trunk/src/gui/dialogs/qfileinfogatherer.cpp
r172 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 45 45 #include <qdiriterator.h> 46 46 #ifndef Q_OS_WIN 47 #include <unistd.h> 48 #include <sys/types.h> 47 # include <unistd.h> 48 # include <sys/types.h> 49 #endif 50 #if defined(Q_OS_VXWORKS) 51 # include "qplatformdefs.h" 49 52 #endif 50 53 … … 73 76 #ifndef QT_NO_FILESYSTEMWATCHER 74 77 watcher = new QFileSystemWatcher(this); 75 connect(watcher, SIGNAL(directoryChanged( const QString &)), this, SLOT(list(const QString &)));76 connect(watcher, SIGNAL(fileChanged( const QString &)), this, SLOT(updateFile(const QString &)));78 connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(list(QString))); 79 connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(updateFile(QString))); 77 80 #endif 78 81 start(LowPriority); … … 84 87 QFileInfoGatherer::~QFileInfoGatherer() 85 88 { 86 mutex.lock();89 QMutexLocker locker(&mutex); 87 90 abort = true; 88 91 condition.wakeOne(); 89 mutex.unlock();92 locker.unlock(); 90 93 wait(); 91 94 } … … 95 98 Q_UNUSED(enable); 96 99 #ifdef Q_OS_WIN 97 mutex.lock();100 QMutexLocker locker(&mutex); 98 101 m_resolveSymlinks = enable; 99 mutex.unlock();100 102 #endif 101 103 } … … 108 110 void QFileInfoGatherer::setIconProvider(QFileIconProvider *provider) 109 111 { 110 mutex.lock();112 QMutexLocker locker(&mutex); 111 113 m_iconProvider = provider; 112 mutex.unlock();113 114 } 114 115 … … 125 126 void QFileInfoGatherer::fetchExtendedInformation(const QString &path, const QStringList &files) 126 127 { 127 mutex.lock();128 QMutexLocker locker(&mutex); 128 129 // See if we already have this dir/file in our que 129 130 int loc = this->path.lastIndexOf(path); 130 131 while (loc > 0) { 131 132 if (this->files.at(loc) == files) { 132 mutex.unlock();133 133 return; 134 134 } … … 138 138 this->files.push(files); 139 139 condition.wakeAll(); 140 mutex.unlock();141 140 } 142 141 … … 161 160 { 162 161 #ifndef QT_NO_FILESYSTEMWATCHER 163 mutex.lock();162 QMutexLocker locker(&mutex); 164 163 watcher->removePaths(watcher->files()); 165 164 watcher->removePaths(watcher->directories()); 166 mutex.unlock();167 165 #endif 168 166 } … … 176 174 { 177 175 #ifndef QT_NO_FILESYSTEMWATCHER 178 mutex.lock();176 QMutexLocker locker(&mutex); 179 177 watcher->removePath(path); 180 mutex.unlock();181 178 #endif 182 179 } … … 199 196 forever { 200 197 bool updateFiles = false; 201 mutex.lock();198 QMutexLocker locker(&mutex); 202 199 if (abort) { 203 mutex.unlock();204 200 return; 205 201 } … … 215 211 updateFiles = true; 216 212 } 217 mutex.unlock(); 218 if (updateFiles) getFileInfos(path, list); 213 locker.unlock(); 214 if (updateFiles) 215 getFileInfos(path, list); 219 216 } 220 217 } … … 288 285 if (driveName.startsWith(QLatin1Char('/'))) // UNC host 289 286 return drive.fileName(); 287 #endif 288 #if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN) 290 289 if (driveName.endsWith(QLatin1Char('/'))) 291 290 driveName.chop(1); -
trunk/src/gui/dialogs/qfileinfogatherer_p.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 185 185 QMutex mutex; 186 186 QWaitCondition condition; 187 bool abort;187 volatile bool abort; 188 188 189 189 QStack<QString> path; -
trunk/src/gui/dialogs/qfilesystemmodel.cpp
r173 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 50 50 51 51 #ifdef Q_OS_WIN 52 #include < windows.h>52 #include <qt_windows.h> 53 53 #endif 54 54 … … 297 297 QString longSection = QDir::toNativeSeparators(section); 298 298 #endif 299 QT_WA({ 300 WIN32_FIND_DATAW findData; 301 h = ::FindFirstFileW((wchar_t *)longSection.utf16(), &findData); 302 if (h != INVALID_HANDLE_VALUE) 303 longPath.append(QString::fromUtf16((ushort*)findData.cFileName)); 304 } , { 305 WIN32_FIND_DATAA findData; 306 h = ::FindFirstFileA(section.toLocal8Bit(), &findData); 307 if (h != INVALID_HANDLE_VALUE) 308 longPath.append(QString::fromLocal8Bit(findData.cFileName)); 309 }); 310 if (h == INVALID_HANDLE_VALUE) { 299 WIN32_FIND_DATA findData; 300 h = ::FindFirstFile((wchar_t*)longSection.utf16(), &findData); 301 if (h != INVALID_HANDLE_VALUE) { 302 longPath.append(QString::fromWCharArray(findData.cFileName)); 303 ::FindClose(h); 304 } else { 311 305 longPath.append(section); 312 306 break; 313 } else {314 ::FindClose(h);315 307 } 316 308 } … … 338 330 Q_Q(const QFileSystemModel); 339 331 Q_UNUSED(q); 340 if (path.isEmpty() || path == myComputer() || path.startsWith(QLatin1 String(":")))332 if (path.isEmpty() || path == myComputer() || path.startsWith(QLatin1Char(':'))) 341 333 return const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root); 342 334 … … 355 347 QStringList pathElements = absolutePath.split(QLatin1Char('/'), QString::SkipEmptyParts); 356 348 if ((pathElements.isEmpty()) 357 #if !defined(Q_OS_OS2) && (!defined(Q_OS_WIN) || defined(Q_OS_WINCE))349 #if (!defined(Q_OS_WIN) || defined(Q_OS_WINCE)) && !defined(Q_OS_SYMBIAN) && !defined(Q_OS_OS2) 358 350 && QDir::fromNativeSeparators(longPath) != QLatin1String("/") 359 351 #endif … … 384 376 index = q->index(r, 0, QModelIndex()); 385 377 pathElements.pop_front(); 386 } else { 387 if (!pathElements.at(0).contains(QLatin1String(":"))) 388 pathElements.prepend(QDir(longPath).rootPath()); 378 } else 379 #endif 380 381 #if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN) 382 { 383 if (!pathElements.at(0).contains(QLatin1String(":"))) { 384 // The reason we express it like this instead of with anonymous, temporary 385 // variables, is to workaround a compiler crash with Q_CC_NOKIAX86. 386 QString rootPath = QDir(longPath).rootPath(); 387 pathElements.prepend(rootPath); 388 } 389 389 if (pathElements.at(0).endsWith(QLatin1Char('/'))) 390 390 pathElements[0].chop(1); … … 880 880 return pixmap; 881 881 } 882 break; 882 883 case Qt::TextAlignmentRole: 883 884 return Qt::AlignLeft; … … 1083 1084 void QFileSystemModelPrivate::sortChildren(int column, const QModelIndex &parent) 1084 1085 { 1086 Q_Q(QFileSystemModel); 1085 1087 QFileSystemModelPrivate::QFileSystemNode *indexNode = node(parent); 1086 1088 if (indexNode->children.count() == 0) … … 1102 1104 // First update the new visible list 1103 1105 indexNode->visibleChildren.clear(); 1106 //No more dirty item we reset our internal dirty index 1107 indexNode->dirtyChildrenIndex = -1; 1104 1108 for (int i = 0; i < values.count(); ++i) { 1105 1109 indexNode->visibleChildren.append(values.at(i).first->fileName); 1106 1110 values.at(i).first->isVisible = true; 1111 } 1112 1113 if (!disableRecursiveSort) { 1114 for (int i = 0; i < q->rowCount(parent); ++i) { 1115 const QModelIndex childIndex = q->index(i, 0, parent); 1116 QFileSystemModelPrivate::QFileSystemNode *indexNode = node(childIndex); 1117 //Only do a recursive sort on visible nodes 1118 if (indexNode->isVisible) 1119 sortChildren(column, childIndex); 1120 } 1107 1121 } 1108 1122 } … … 1396 1410 Q_D(QFileSystemModel); 1397 1411 d->fileInfoGatherer.setIconProvider(provider); 1398 qApp->processEvents();1412 QApplication::processEvents(); 1399 1413 d->root.updateIcon(provider, QString()); 1400 1414 } … … 1585 1599 return; 1586 1600 QStringList toRemove; 1601 #if defined(Q_OS_SYMBIAN) 1602 // Filename case must be exact in qBinaryFind below, so create a list of all lowercase names. 1603 QStringList newFiles; 1604 for(int i = 0; i < files.size(); i++) { 1605 newFiles << files.at(i).toLower(); 1606 } 1607 #else 1587 1608 QStringList newFiles = files; 1609 #endif 1588 1610 qSort(newFiles.begin(), newFiles.end()); 1589 1611 QHash<FileNameKey, QFileSystemNode*>::const_iterator i = parentNode->children.constBegin(); 1590 1612 while (i != parentNode->children.constEnd()) { 1591 1613 QStringList::iterator iterator; 1592 iterator = qBinaryFind(newFiles.begin(), newFiles.end(), i.value()->fileName); 1614 iterator = qBinaryFind(newFiles.begin(), newFiles.end(), 1615 #if defined(Q_OS_SYMBIAN) 1616 i.value()->fileName.toLower()); 1617 #else 1618 i.value()->fileName); 1619 #endif 1593 1620 if (iterator == newFiles.end()) { 1594 1621 toRemove.append(i.value()->fileName); … … 1681 1708 q->beginInsertRows(parent, parentNode->visibleChildren.count() , parentNode->visibleChildren.count() + newFiles.count() - 1); 1682 1709 } 1710 1711 if (parentNode->dirtyChildrenIndex == -1) 1712 parentNode->dirtyChildrenIndex = parentNode->visibleChildren.count(); 1713 1683 1714 for (int i = 0; i < newFiles.count(); ++i) { 1684 1715 parentNode->visibleChildren.append(newFiles.at(i)); … … 1833 1864 Q_Q(QFileSystemModel); 1834 1865 qRegisterMetaType<QList<QPair<QString,QFileInfo> > >("QList<QPair<QString,QFileInfo> >"); 1835 q->connect(&fileInfoGatherer, SIGNAL(newListOfFiles( const QString &, const QStringList &)),1836 q, SLOT(_q_directoryChanged( const QString &, const QStringList &)));1837 q->connect(&fileInfoGatherer, SIGNAL(updates( const QString &, const QList<QPair<QString, QFileInfo> > &)),1838 q, SLOT(_q_fileSystemChanged( const QString &, const QList<QPair<QString, QFileInfo> > &)));1839 q->connect(&fileInfoGatherer, SIGNAL(nameResolved( const QString &, const QString &)),1840 q, SLOT(_q_resolvedName( const QString &, const QString &)));1866 q->connect(&fileInfoGatherer, SIGNAL(newListOfFiles(QString,QStringList)), 1867 q, SLOT(_q_directoryChanged(QString,QStringList))); 1868 q->connect(&fileInfoGatherer, SIGNAL(updates(QString,QList<QPair<QString,QFileInfo> >)), 1869 q, SLOT(_q_fileSystemChanged(QString,QList<QPair<QString,QFileInfo> >))); 1870 q->connect(&fileInfoGatherer, SIGNAL(nameResolved(QString,QString)), 1871 q, SLOT(_q_resolvedName(QString,QString))); 1841 1872 q->connect(&delayedSortTimer, SIGNAL(timeout()), q, SLOT(_q_performDelayedSort()), Qt::QueuedConnection); 1842 1873 } … … 1913 1944 } 1914 1945 1946 QT_END_NAMESPACE 1947 1915 1948 #include "moc_qfilesystemmodel.cpp" 1916 1949 1917 1950 #endif // QT_NO_FILESYSTEMMODEL 1918 1919 QT_END_NAMESPACE -
trunk/src/gui/dialogs/qfilesystemmodel.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 159 159 Q_PRIVATE_SLOT(d_func(), void _q_fileSystemChanged(const QString &path, const QList<QPair<QString, QFileInfo> > &)) 160 160 Q_PRIVATE_SLOT(d_func(), void _q_resolvedName(const QString &fileName, const QString &resolvedName)) 161 162 friend class QFileDialogPrivate; 161 163 }; 162 164 -
trunk/src/gui/dialogs/qfilesystemmodel_p.h
r173 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 108 108 public: 109 109 QFileSystemNode(const QString &filename = QString(), QFileSystemNode *p = 0) 110 : fileName(filename), populatedChildren(false), isVisible(false), parent(p), info(0) {}110 : fileName(filename), populatedChildren(false), isVisible(false), dirtyChildrenIndex(-1), parent(p), info(0) {} 111 111 ~QFileSystemNode() { 112 112 QHash<FileNameKey, QFileSystemNode*>::const_iterator i = children.constBegin(); … … 187 187 QHash<FileNameKey, QFileSystemNode *>::const_iterator iterator; 188 188 for(iterator = children.constBegin() ; iterator != children.constEnd() ; ++iterator) { 189 iterator.value()->updateIcon(iconProvider, path + QLatin1Char('/') + iterator.value()->fileName); 189 //On windows the root (My computer) has no path so we don't want to add a / for nothing (e.g. /C:/) 190 if (!path.isEmpty()) { 191 if (path.endsWith(QLatin1Char('/'))) 192 iterator.value()->updateIcon(iconProvider, path + iterator.value()->fileName); 193 else 194 iterator.value()->updateIcon(iconProvider, path + QLatin1Char('/') + iterator.value()->fileName); 195 } else 196 iterator.value()->updateIcon(iconProvider, iterator.value()->fileName); 190 197 } 191 198 } … … 196 203 QHash<FileNameKey, QFileSystemNode *>::const_iterator iterator; 197 204 for(iterator = children.constBegin() ; iterator != children.constEnd() ; ++iterator) { 198 iterator.value()->retranslateStrings(iconProvider, path + QLatin1Char('/') + iterator.value()->fileName); 205 //On windows the root (My computer) has no path so we don't want to add a / for nothing (e.g. /C:/) 206 if (!path.isEmpty()) { 207 if (path.endsWith(QLatin1Char('/'))) 208 iterator.value()->retranslateStrings(iconProvider, path + iterator.value()->fileName); 209 else 210 iterator.value()->retranslateStrings(iconProvider, path + QLatin1Char('/') + iterator.value()->fileName); 211 } else 212 iterator.value()->retranslateStrings(iconProvider, iterator.value()->fileName); 199 213 } 200 214 } … … 204 218 QHash<FileNameKey, QFileSystemNode *> children; 205 219 QList<QString> visibleChildren; 220 int dirtyChildrenIndex; 206 221 QFileSystemNode *parent; 207 222 … … 218 233 setRootPath(false), 219 234 filters(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::AllDirs), 220 nameFilterDisables(true) // false on windows, true on mac and unix 235 nameFilterDisables(true), // false on windows, true on mac and unix 236 disableRecursiveSort(false) 221 237 { 222 238 delayedSortTimer.setSingleShot(true); … … 246 262 247 263 inline int translateVisibleLocation(QFileSystemNode *parent, int row) const { 248 return (sortOrder == Qt::AscendingOrder) ? row : parent->visibleChildren.count() - row - 1; 264 if (sortOrder == Qt::AscendingOrder) 265 return row; 266 if (parent->dirtyChildrenIndex == -1 || row < parent->dirtyChildrenIndex) 267 if (parent->dirtyChildrenIndex != -1) 268 return parent->dirtyChildrenIndex - row - 1; 269 else 270 return parent->visibleChildren.count() - row - 1; 271 else 272 return row; 249 273 } 250 274 … … 304 328 QHash<const QFileSystemNode*, bool> bypassFilters; 305 329 bool nameFilterDisables; 330 //This flag is an optimization for the QFileDialog 331 //It enable a sort which is not recursive, it means 332 //we sort only what we see. 333 bool disableRecursiveSort; 306 334 #ifndef QT_NO_REGEXP 307 335 QList<QRegExp> nameFilters; -
trunk/src/gui/dialogs/qfontdialog.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 66 66 #include <private/qfont_p.h> 67 67 68 #if defined(Q_WS_S60) 69 #include <QtGui/qdesktopwidget.h> 70 #endif 71 68 72 QT_BEGIN_NAMESPACE 69 73 … … 113 117 /*! 114 118 \class QFontDialog 115 \ingroup dialogs 116 \ingroup text 117 \mainclass 119 \ingroup standard-dialogs 120 118 121 \brief The QFontDialog class provides a dialog widget for selecting a font. 119 122 … … 312 315 QObject::connect(buttonBox, SIGNAL(rejected()), q, SLOT(reject())); 313 316 314 #if defined(Q_ OS_WINCE)317 #if defined(Q_WS_WINCE) 315 318 q->resize(180, 120); 319 #elif defined(Q_WS_S60) 320 q->resize(QApplication::desktop()->availableGeometry(QCursor::pos()).size()); 316 321 #else 317 322 q->resize(500, 360); 318 #endif // Q_ OS_WINCE323 #endif // Q_WS_WINCE 319 324 320 325 sizeEdit->installEventFilter(q); … … 338 343 QFontDialog::~QFontDialog() 339 344 { 345 #ifdef Q_WS_MAC 346 Q_D(QFontDialog); 347 if (d->delegate) { 348 QFontDialogPrivate::closeCocoaFontPanel(d->delegate); 349 QFontDialogPrivate::sharedFontPanelAvailable = true; 350 return; 351 } 352 #endif 340 353 } 341 354 … … 494 507 Q_Q(QFontDialog); 495 508 496 familyList->blockSignals(true);497 498 509 enum match_t { MATCH_NONE = 0, MATCH_LAST_RESORT = 1, MATCH_APP = 2, MATCH_FAMILY = 3 }; 499 510 … … 549 560 familyEdit->selectAll(); 550 561 551 familyList->blockSignals(false);552 562 updateStyles(); 553 563 } … … 560 570 { 561 571 Q_Q(QFontDialog); 562 563 styleList->blockSignals(true);564 565 572 QStringList styles = fdb.styles(familyList->currentText()); 566 573 styleList->model()->setStringList(styles); … … 596 603 if (!found) 597 604 styleList->setCurrentItem(0); 605 } else { 606 styleList->setCurrentItem(0); 598 607 } 599 608 … … 606 615 } 607 616 608 styleList->blockSignals(false);609 610 617 updateSizes(); 611 618 } … … 620 627 { 621 628 Q_Q(QFontDialog); 622 623 sizeList->blockSignals(true);624 629 625 630 if (!familyList->currentText().isEmpty()) { … … 652 657 } 653 658 654 sizeList->blockSignals(false);655 659 _q_updateSample(); 656 660 } … … 773 777 styleAccel->setText(QFontDialog::tr("Font st&yle")); 774 778 sizeAccel->setText(QFontDialog::tr("&Size")); 779 #ifndef Q_WS_S60 780 // Removed the title due to lack of screen estate in small S60 screen. 781 // The effects are descriptive without a title (strikeout, underline). 775 782 effects->setTitle(QFontDialog::tr("Effects")); 783 #endif 776 784 strikeout->setText(QFontDialog::tr("Stri&keout")); 777 785 underline->setText(QFontDialog::tr("&Underline")); … … 797 805 \property QFontDialog::currentFont 798 806 \brief the current font of the dialog. 799 */ 807 */ 800 808 801 809 /*! … … 821 829 822 830 #ifdef Q_WS_MAC 823 if (d->delegate) 831 if (d->delegate) 824 832 QFontDialogPrivate::setFont(d->delegate, font); 825 833 #endif … … 933 941 \overload 934 942 935 Opens the dialog and connects its accepted() signal to the slot specified943 Opens the dialog and connects its fontSelected() signal to the slot specified 936 944 by \a receiver and \a member. 937 945 … … 941 949 { 942 950 Q_D(QFontDialog); 943 connect(this, SIGNAL(fontSelected( const QFont&)), receiver, member);951 connect(this, SIGNAL(fontSelected(QFont)), receiver, member); 944 952 d->receiverToDisconnectOnClose = receiver; 945 953 d->memberToDisconnectOnClose = member; … … 1031 1039 } 1032 1040 if (d->receiverToDisconnectOnClose) { 1033 disconnect(this, SIGNAL(fontSelected( const QFont&)),1041 disconnect(this, SIGNAL(fontSelected(QFont)), 1034 1042 d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose); 1035 1043 d->receiverToDisconnectOnClose = 0; -
trunk/src/gui/dialogs/qfontdialog.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** -
trunk/src/gui/dialogs/qfontdialog_mac.mm
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 48 48 #include <private/qfont_p.h> 49 49 #include <private/qfontengine_p.h> 50 #include <private/qt_cocoa_helpers_mac_p.h> 50 51 #include <private/qt_mac_p.h> 51 52 #include <qdebug.h> … … 78 79 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5 79 80 80 @protocol NSWindowDelegate <NSObject> @end 81 @protocol NSWindowDelegate <NSObject> 82 - (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize; 83 @end 81 84 82 85 #endif … … 88 91 NSButton *mCancelButton; 89 92 QFontDialogPrivate *mPriv; 90 NSFont *mCocoaFont;91 93 QFont *mQtFont; 92 94 BOOL mPanelHackedWithButtons; … … 120 122 @end 121 123 124 static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont) 125 { 126 QFont newFont; 127 if (cocoaFont) { 128 int pSize = qRound([cocoaFont pointSize]); 129 QString family(qt_mac_NSStringToQString([cocoaFont familyName])); 130 QString typeface(qt_mac_NSStringToQString([cocoaFont fontName])); 131 132 int hyphenPos = typeface.indexOf(QLatin1Char('-')); 133 if (hyphenPos != -1) { 134 typeface.remove(0, hyphenPos + 1); 135 } else { 136 typeface = QLatin1String("Normal"); 137 } 138 139 newFont = QFontDatabase().font(family, typeface, pSize); 140 newFont.setUnderline(resolveFont.underline()); 141 newFont.setStrikeOut(resolveFont.strikeOut()); 142 143 } 144 return newFont; 145 } 146 122 147 @implementation QCocoaFontPanelDelegate 123 148 - (id)initWithFontPanel:(NSFontPanel *)panel … … 135 160 mCancelButton = cancelButton; 136 161 mPriv = priv; 137 mCocoaFont = 0;138 162 mPanelHackedWithButtons = (okButton != 0); 139 163 mDialogExtraWidth = extraWidth; … … 156 180 - (void)dealloc 157 181 { 158 if (mCocoaFont)159 [mCocoaFont release];160 182 delete mQtFont; 161 183 [super dealloc]; … … 164 186 - (void)changeFont:(id)sender 165 187 { 166 Q_UNUSED(sender);167 168 QFont newFont;169 170 if (mCocoaFont)171 [mCocoaFont autorelease];172 188 NSFont *dummyFont = [NSFont userFontOfSize:12.0]; 173 mCocoaFont = [sender convertFont:dummyFont]; 174 if (mCocoaFont) { 175 [mCocoaFont retain]; 176 177 int pSize = qRound([mCocoaFont pointSize]); 178 QString family(QCFString::toQString(reinterpret_cast<CFStringRef>([mCocoaFont familyName]))); 179 QString typeface(QCFString::toQString(reinterpret_cast<CFStringRef>([mCocoaFont fontName]))); 180 // qDebug() << "original family" << family << "typeface" << typeface << "psize" << pSize; 181 int hyphenPos = typeface.indexOf(QLatin1Char('-')); 182 if (hyphenPos != -1) { 183 typeface.remove(0, hyphenPos + 1); 184 } else { 185 typeface = QLatin1String("Normal"); 186 } 187 // qDebug() << " massaged family" << family << "typeface" << typeface << "psize" << pSize; 188 newFont = QFontDatabase().font(family, typeface, pSize); 189 newFont.setUnderline(mQtFont->underline()); 190 newFont.setStrikeOut(mQtFont->strikeOut()); 191 } 192 193 [self setQtFont:newFont]; 189 [self setQtFont:qfontForCocoaFont([sender convertFont:dummyFont], *mQtFont)]; 194 190 if (mPriv) 195 191 mPriv->updateSampleFont(*mQtFont); … … 318 314 { 319 315 Q_ASSERT(mPanelHackedWithButtons); 316 NSFontManager *fontManager = [NSFontManager sharedFontManager]; 317 [self setQtFont:qfontForCocoaFont([fontManager convertFont:[fontManager selectedFont]], 318 *mQtFont)]; 320 319 [[mStolenContentView window] close]; 321 320 [self finishOffWithCode:NSOKButton]; … … 375 374 } 376 375 377 // temporary hack to work around bug in deleteLater() in Qt/Mac Cocoa378 #if 1379 bool deleteDialog = mPriv->fontDialog()->testAttribute(Qt::WA_DeleteOnClose);380 mPriv->fontDialog()->setAttribute(Qt::WA_DeleteOnClose, false);381 #endif382 376 mPriv->done((code == NSOKButton) ? QDialog::Accepted : QDialog::Rejected); 383 #if 1384 if (deleteDialog)385 delete mPriv->fontDialog();386 #endif387 377 } else { 388 378 [NSApp stopModalWithCode:code]; … … 405 395 [mFontPanel setDelegate:nil]; 406 396 [[NSFontManager sharedFontManager] setDelegate:nil]; 397 #ifdef QT_MAC_USE_COCOA 407 398 [[NSFontManager sharedFontManager] setTarget:nil]; 399 #endif 408 400 } 409 401 @end … … 529 521 [ourPanel setDelegate:delegate]; 530 522 [[NSFontManager sharedFontManager] setDelegate:delegate]; 523 #ifdef QT_MAC_USE_COCOA 531 524 [[NSFontManager sharedFontManager] setTarget:delegate]; 525 #endif 532 526 setFont(delegate, initial); 533 527 … … 580 574 void QFontDialogPrivate::closeCocoaFontPanel(void *delegate) 581 575 { 576 QMacCocoaAutoReleasePool pool; 582 577 QCocoaFontPanelDelegate *theDelegate = static_cast<QCocoaFontPanelDelegate *>(delegate); 583 578 NSWindow *ourPanel = [theDelegate actualPanel]; … … 611 606 } 612 607 613 void QFontDialogPrivate::setFont(void * delegate, const QFont &font) 614 { 608 void QFontDialogPrivate::setFont(void *delegate, const QFont &font) 609 { 610 QMacCocoaAutoReleasePool pool; 615 611 QFontEngine *fe = font.d->engineForScript(QUnicodeTables::Common); 612 NSFontManager *mgr = [NSFontManager sharedFontManager]; 613 NSFont *nsFont = 0; 614 616 615 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 617 616 if (qstrcmp(fe->name(), "CoreText") == 0) { 618 const NSFont *nsFont = reinterpret_cast<const NSFont *>(static_cast<QCoreTextFontEngineMulti *>(fe)->ctfont); 619 [[NSFontManager sharedFontManager] setSelectedFont:nsFont isMultiple:NO]; 620 } 621 #endif 617 nsFont = reinterpret_cast<const NSFont *>(static_cast<QCoreTextFontEngineMulti *>(fe)->ctfont); 618 } else 619 #endif 620 { 621 int weight = 5; 622 NSFontTraitMask mask = 0; 623 if (font.style() == QFont::StyleItalic) { 624 mask |= NSItalicFontMask; 625 } 626 if (font.weight() == QFont::Bold) { 627 weight = 9; 628 mask |= NSBoldFontMask; 629 } 630 631 NSFontManager *mgr = [NSFontManager sharedFontManager]; 632 QFontInfo fontInfo(font); 633 nsFont = [mgr fontWithFamily:qt_mac_QStringToNSString(fontInfo.family()) 634 traits:mask 635 weight:weight 636 size:fontInfo.pointSize()]; 637 } 638 639 [mgr setSelectedFont:nsFont isMultiple:NO]; 622 640 [static_cast<QCocoaFontPanelDelegate *>(delegate) setQtFont:font]; 623 641 } -
trunk/src/gui/dialogs/qfontdialog_p.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** -
trunk/src/gui/dialogs/qinputdialog.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 96 96 QInputDialogSpinBox(QWidget *parent) 97 97 : QSpinBox(parent) { 98 connect(lineEdit(), SIGNAL(textChanged( const QString&)), this, SLOT(notifyTextChanged()));98 connect(lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(notifyTextChanged())); 99 99 connect(this, SIGNAL(editingFinished()), this, SLOT(notifyTextChanged())); 100 100 } … … 131 131 QInputDialogDoubleSpinBox(QWidget *parent = 0) 132 132 : QDoubleSpinBox(parent) { 133 connect(lineEdit(), SIGNAL(textChanged( const QString&)), this, SLOT(notifyTextChanged()));133 connect(lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(notifyTextChanged())); 134 134 connect(this, SIGNAL(editingFinished()), this, SLOT(notifyTextChanged())); 135 135 } … … 246 246 lineEdit = new QLineEdit(q); 247 247 lineEdit->hide(); 248 QObject::connect(lineEdit, SIGNAL(textChanged( const QString&)),249 q, SLOT(_q_textChanged( const QString&)));248 QObject::connect(lineEdit, SIGNAL(textChanged(QString)), 249 q, SLOT(_q_textChanged(QString))); 250 250 } 251 251 } … … 257 257 comboBox = new QComboBox(q); 258 258 comboBox->hide(); 259 QObject::connect(comboBox, SIGNAL(editTextChanged( const QString&)),260 q, SLOT(_q_textChanged( const QString&)));261 QObject::connect(comboBox, SIGNAL(currentIndexChanged( const QString&)),262 q, SLOT(_q_textChanged( const QString&)));259 QObject::connect(comboBox, SIGNAL(editTextChanged(QString)), 260 q, SLOT(_q_textChanged(QString))); 261 QObject::connect(comboBox, SIGNAL(currentIndexChanged(QString)), 262 q, SLOT(_q_textChanged(QString))); 263 263 } 264 264 } … … 277 277 listView->setCurrentIndex(QModelIndex()); // ### 278 278 QObject::connect(listView->selectionModel(), 279 SIGNAL(currentRowChanged( const QModelIndex&, const QModelIndex&)),280 q, SLOT(_q_currentRowChanged( const QModelIndex&, const QModelIndex&)));279 SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), 280 q, SLOT(_q_currentRowChanged(QModelIndex,QModelIndex))); 281 281 } 282 282 } … … 308 308 if (spinBox) { 309 309 QAbstractButton *okButton = buttonBox->button(QDialogButtonBox::Ok); 310 QObject::disconnect(spinBox, SIGNAL(textChanged(bool)), okButton, SLOT(setEnabled(bool))); 311 QObject::connect(spinBox, SIGNAL(textChanged(bool)), okButton, SLOT(setEnabled(bool))); 310 QObject::connect(spinBox, SIGNAL(textChanged(bool)), okButton, SLOT(setEnabled(bool)), Qt::UniqueConnection); 312 311 } 313 312 } … … 427 426 \brief The QInputDialog class provides a simple convenience dialog to get a 428 427 single value from the user. 429 \ingroup dialogs430 \mainclass 428 \ingroup standard-dialogs 429 431 430 432 431 The input value can be a string, a number or an item from a list. A label … … 1021 1020 \overload 1022 1021 1023 Opens the dialog and connects its accepted() signal to the slot specified 1024 by \a receiver and \a member. 1022 This function connects one of its signals to the slot specified by \a receiver 1023 and \a member. The specific signal depends on the arguments that are specified 1024 in \a member. These are: 1025 1026 \list 1027 \o textValueSelected() if \a member has a QString for its first argument. 1028 \o intValueSelected() if \a member has an int for its first argument. 1029 \o doubleValueSelected() if \a member has a double for its first argument. 1030 \o accepted() if \a member has NO arguments. 1031 \endlist 1025 1032 1026 1033 The signal will be disconnected from the slot when the dialog is closed. … … 1122 1129 \a flags. 1123 1130 1124 This function returns the text which has been entered in the line1125 edit. It will not return an empty string.1131 If the dialog is accepted, this function returns the text in the dialog's 1132 line edit. If the dialog is rejected, a null QString is returned. 1126 1133 1127 1134 Use this static function like this: … … 1152 1159 return dialog.textValue(); 1153 1160 } else { 1154 return text;1161 return QString(); 1155 1162 } 1156 1163 } … … 1243 1250 dialog.setWindowTitle(title); 1244 1251 dialog.setLabelText(label); 1252 dialog.setDoubleDecimals(decimals); 1245 1253 dialog.setDoubleRange(min, max); 1246 1254 dialog.setDoubleValue(value); 1247 dialog.setDoubleDecimals(decimals);1248 1255 1249 1256 int ret = dialog.exec(); -
trunk/src/gui/dialogs/qinputdialog.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** -
trunk/src/gui/dialogs/qmessagebox.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 46 46 #include <QtGui/qdialogbuttonbox.h> 47 47 #include "private/qlabel_p.h" 48 #include "private/qapplication_p.h" 48 49 #include <QtCore/qlist.h> 49 50 #include <QtCore/qdebug.h> … … 64 65 #include <QtGui/qclipboard.h> 65 66 66 #ifdef Q_ OS_WINCE67 #ifdef Q_WS_WINCE 67 68 extern bool qt_wince_is_mobile(); //defined in qguifunctions_wince.cpp 68 69 extern bool qt_wince_is_smartphone();//defined in qguifunctions_wince.cpp … … 73 74 74 75 QT_BEGIN_NAMESPACE 75 76 extern QHash<QByteArray, QFont> *qt_app_fonts_hash();77 76 78 77 enum Button { Old_Ok = 1, Old_Cancel = 2, Old_Yes = 3, Old_No = 4, Old_Abort = 5, Old_Retry = 6, … … 153 152 void retranslateStrings(); 154 153 155 #ifdef Q_ OS_WINCE154 #ifdef Q_WS_WINCE 156 155 void hideSpecial(); 157 156 #endif … … 190 189 QAbstractButton *detectedEscapeButton; 191 190 QLabel *informativeLabel; 191 #ifdef Q_OS_SYMBIAN 192 QTextEdit *textEdit; 193 #endif 192 194 QPointer<QObject> receiverToDisconnectOnClose; 193 195 QByteArray memberToDisconnectOnClose; … … 259 261 int QMessageBoxPrivate::layoutMinimumWidth() 260 262 { 261 Q_Q(QMessageBox); 262 263 q->layout()->activate(); 264 return q->layout()->totalMinimumSize().width(); 263 layout->activate(); 264 return layout->totalMinimumSize().width(); 265 265 } 266 266 … … 273 273 274 274 QSize screenSize = QApplication::desktop()->availableGeometry(QCursor::pos()).size(); 275 #ifdef Q_WS_QWS 276 // the width of the screen, less the window border. 277 int hardLimit = screenSize.width() - (q->frameGeometry().width() - q->geometry().width()); 278 #elif defined(Q_OS_WINCE) 275 #if defined(Q_WS_QWS) || defined(Q_WS_WINCE) || defined(Q_OS_SYMBIAN) 279 276 // the width of the screen, less the window border. 280 277 int hardLimit = screenSize.width() - (q->frameGeometry().width() - q->geometry().width()); 281 278 #else 282 279 int hardLimit = qMin(screenSize.width() - 480, 1000); // can never get bigger than this 280 // on small screens allows the messagebox be the same size as the screen 281 if (screenSize.width() <= 1024) 282 hardLimit = screenSize.width(); 283 283 #endif 284 284 #ifdef Q_WS_MAC … … 288 288 #else 289 289 // note: ideally on windows, hard and soft limits but it breaks compat 290 #ifndef Q_ OS_WINCE290 #ifndef Q_WS_WINCE 291 291 int softLimit = qMin(screenSize.width()/2, 500); 292 292 #else 293 293 int softLimit = qMin(screenSize.width() * 3 / 4, 500); 294 #endif //Q_ OS_WINCE294 #endif //Q_WS_WINCE 295 295 #endif 296 296 … … 314 314 width = hardLimit; 315 315 } 316 #ifdef Q_WS_S60 317 // in S60 portait messageBoxes should always occupy maximum width 318 if (QApplication::desktop()->size().height() > QApplication::desktop()->size().width()){ 319 width = hardLimit; 320 } else { 321 // in landscape the messageBoxes should be of same width as in portrait 322 width = qMin(QApplication::desktop()->size().height(), hardLimit); 323 } 324 #endif 316 325 } 317 326 … … 335 344 } 336 345 337 QFontMetrics fm( qApp->font("QWorkspaceTitleBar"));346 QFontMetrics fm(QApplication::font("QWorkspaceTitleBar")); 338 347 int windowTitleWidth = qMin(fm.width(q->windowTitle()) + 50, hardLimit); 339 348 if (windowTitleWidth > width) 340 349 width = windowTitleWidth; 341 350 342 q->layout()->activate();343 int height = ( q->layout()->hasHeightForWidth())344 ? q->layout()->totalHeightForWidth(width)345 : q->layout()->totalMinimumSize().height();351 layout->activate(); 352 int height = (layout->hasHeightForWidth()) 353 ? layout->totalHeightForWidth(width) 354 : layout->totalMinimumSize().height(); 346 355 q->setFixedSize(width, height); 347 356 QCoreApplication::removePostedEvents(q, QEvent::LayoutRequest); … … 349 358 350 359 351 #ifdef Q_ OS_WINCE360 #ifdef Q_WS_WINCE 352 361 /*! 353 362 \internal … … 364 373 QString text = pb->text(); 365 374 text.remove(QChar::fromLatin1('&')); 366 if (text == qApp->translate("QMessageBox", "OK" ))375 if (text == QApplication::translate("QMessageBox", "OK" )) 367 376 pb->setFixedSize(0,0); 368 377 } … … 438 447 the user or for asking the user a question and receiving an answer. 439 448 440 \ingroup dialogs441 \mainclass 449 \ingroup standard-dialogs 450 442 451 443 452 A message box displays a primary \l{QMessageBox::text}{text} to … … 704 713 passed to the QDialog constructor. 705 714 706 If \a parent is 0, the message box is an \l{Qt::ApplicationModal} 707 {application modal} dialog box. If \a parent is a widget, the 708 message box is \l{Qt::WindowModal} {window modal} relative to \a 709 parent. 710 711 On Mac OS X, if \a parent is not 0 and you want your message box 712 to appear as a Qt::Sheet of that parent, set the message box's 713 \l{setWindowModality()} {window modality} to Qt::WindowModal 714 (default). Otherwise, the message box will be a standard dialog. 715 On Mac OS X, if you want your message box to appear 716 as a Qt::Sheet of its \a parent, set the message box's 717 \l{setWindowModality()} {window modality} to Qt::WindowModal or use open(). 718 Otherwise, the message box will be a standard dialog. 715 719 716 720 */ … … 1211 1215 d_func()->retranslateStrings(); 1212 1216 break; 1213 #ifdef Q_ OS_WINCE1217 #ifdef Q_WS_WINCE 1214 1218 case QEvent::OkRequest: 1215 1219 case QEvent::HelpRequest: { 1216 1220 QString bName = 1217 1221 (e->type() == QEvent::OkRequest) 1218 ? qApp->translate("QMessageBox", "OK")1219 : qApp->translate("QMessageBox", "Help");1222 ? QApplication::translate("QMessageBox", "OK") 1223 : QApplication::translate("QMessageBox", "Help"); 1220 1224 QList<QPushButton*> list = qFindChildren<QPushButton*>(this); 1221 1225 for (int i=0; i<list.size(); ++i) { … … 1316 1320 QString separator = QString::fromLatin1("---------------------------\n"); 1317 1321 QString textToCopy = separator; 1318 separator.prepend(QLatin1 String("\n"));1322 separator.prepend(QLatin1Char('\n')); 1319 1323 textToCopy += windowTitle() + separator; // title 1320 1324 textToCopy += d->label->text() + separator; // text … … 1330 1334 textToCopy += buttonTexts + separator; 1331 1335 1332 qApp->clipboard()->setText(textToCopy);1336 QApplication::clipboard()->setText(textToCopy); 1333 1337 return; 1334 1338 } … … 1354 1358 } 1355 1359 1356 #ifdef Q_ OS_WINCE1360 #ifdef Q_WS_WINCE 1357 1361 /*! 1358 1362 \reimp … … 1371 1375 \overload 1372 1376 1373 Opens the dialog and connects its accepted() signal to the slot specified 1374 by \a receiver and \a member. 1377 Opens the dialog and connects its finished() or buttonClicked() signal to 1378 the slot specified by \a receiver and \a member. If the slot in \a member 1379 has a pointer for its first parameter the connection is to buttonClicked(), 1380 otherwise the connection is to finished(). 1375 1381 1376 1382 The signal will be disconnected from the slot when the dialog is closed. … … 1423 1429 if (d->autoAddOkButton) { 1424 1430 addButton(Ok); 1425 #if defined(Q_ OS_WINCE)1431 #if defined(Q_WS_WINCE) 1426 1432 d->hideSpecial(); 1427 1433 #endif … … 1690 1696 #endif 1691 1697 1692 QString translatedTextAboutQt ;1693 translatedTextAboutQt = QMessageBox::tr(1698 QString translatedTextAboutQtCaption; 1699 translatedTextAboutQtCaption = QMessageBox::tr( 1694 1700 "<h3>About Qt</h3>" 1695 1701 "<p>This program uses Qt version %1.</p>" 1702 ).arg(QLatin1String(QT_VERSION_STR)); 1703 QString translatedTextAboutQtText; 1704 translatedTextAboutQtText = QMessageBox::tr( 1696 1705 "<p>Qt is a C++ toolkit for cross-platform application " 1697 1706 "development.</p>" … … 1702 1711 "<p>Qt is available under three different licensing options designed " 1703 1712 "to accommodate the needs of our various users.</p>" 1704 " Qt licensed under our commercial license agreement is appropriate "1713 "<p>Qt licensed under our commercial license agreement is appropriate " 1705 1714 "for development of proprietary/commercial software where you do not " 1706 1715 "want to share any source code with third parties or otherwise cannot " … … 1716 1725 "terms of the GNU GPL version 3.0 or where you are otherwise willing " 1717 1726 "to comply with the terms of the GNU GPL version 3.0.</p>" 1718 "<p>Please see <a href=\"http:// www.qtsoftware.com/products/licensing\">www.qtsoftware.com/products/licensing</a> "1727 "<p>Please see <a href=\"http://qt.nokia.com/products/licensing\">qt.nokia.com/products/licensing</a> " 1719 1728 "for an overview of Qt licensing.</p>" 1720 1729 "<p>Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).</p>" 1721 "<p>Qt is a Nokia product. See <a href=\"http:// www.qtsoftware.com/qt/\">www.qtsoftware.com/qt</a> "1730 "<p>Qt is a Nokia product. See <a href=\"http://qt.nokia.com/\">qt.nokia.com</a> " 1722 1731 "for more information.</p>" 1723 ).arg(QLatin1String(QT_VERSION_STR)); 1724 1732 ); 1725 1733 QMessageBox *msgBox = new QMessageBox(parent); 1726 1734 msgBox->setAttribute(Qt::WA_DeleteOnClose); 1727 1735 msgBox->setWindowTitle(title.isEmpty() ? tr("About Qt") : title); 1728 msgBox->setText(translatedTextAboutQt); 1736 msgBox->setText(translatedTextAboutQtCaption); 1737 msgBox->setInformativeText(translatedTextAboutQtText); 1729 1738 1730 1739 QPixmap pm(QLatin1String(":/trolltech/qmessagebox/images/qtlogo-64.png")); 1731 1740 if (!pm.isNull()) 1732 1741 msgBox->setIconPixmap(pm); 1733 #if defined(Q_ OS_WINCE)1742 #if defined(Q_WS_WINCE) 1734 1743 msgBox->setDefaultButton(msgBox->addButton(QMessageBox::Ok)); 1735 1744 #endif … … 2454 2463 label->setWordWrap(true); 2455 2464 QGridLayout *grid = static_cast<QGridLayout *>(layout()); 2465 #ifdef Q_OS_SYMBIAN 2466 label->hide(); 2467 QTextEdit *textEdit = new QTextEdit(this); 2468 textEdit->setReadOnly(true); 2469 grid->addWidget(textEdit, 1, 1, 1, 1); 2470 d->textEdit = textEdit; 2471 #else 2456 2472 grid->addWidget(label, 1, 1, 1, 1); 2473 #endif 2457 2474 d->informativeLabel = label; 2458 2475 } 2459 2476 d->informativeLabel->setText(text); 2477 2478 #ifdef Q_OS_SYMBIAN 2479 //We need to put the informative label inside textEdit to enable scrolling of long texts. 2480 d->textEdit->setText(d->informativeLabel->text()); 2481 #endif 2482 2460 2483 d->updateSize(); 2461 2484 } -
trunk/src/gui/dialogs/qmessagebox.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 146 146 void removeButton(QAbstractButton *button); 147 147 148 #ifdef Q_ OS_WINCE148 #ifdef Q_WS_WINCE 149 149 void setVisible(bool visible); 150 150 #endif … … 192 192 const QString &text, StandardButtons buttons = Ok, 193 193 StandardButton defaultButton = NoButton); 194 // ### Qt 5: Replace Ok with Yes|No in question() function. 195 // Also consider if Ok == Yes and Cancel == No. 194 196 static StandardButton question(QWidget *parent, const QString &title, 195 197 const QString &text, StandardButtons buttons = Ok, -
trunk/src/gui/dialogs/qnspanelproxy_mac.mm
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 145 145 { 146 146 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 147 // The following code replaces the _implementation_ for the selector we want to hack 148 // (originalSel) with the implementation found in proxyClass. Then it creates 149 // a new 'backup' method inside baseClass containing the old, original, 150 // implementation (fakeSel). You can let the proxy implementation of originalSel 151 // call fakeSel if needed (similar approach to calling a super class implementation). 152 // fakeSel must also be implemented in proxyClass, as the signature is used 153 // as template for the method one we add into baseClass. 154 // NB: You will typically never create any instances of proxyClass; we use it 155 // only for stealing its contents and put it into baseClass. 147 156 Method originalMethod = class_getInstanceMethod(baseClass, originalSel); 148 157 Method newMethod = class_getInstanceMethod(proxyClass, originalSel); 149 158 Method fakeMethod = class_getInstanceMethod(proxyClass, fakeSel); 150 159 151 IMP originalCtorImp = method_setImplementation(originalMethod, 152 method_getImplementation(newMethod)); 153 class_addMethod(baseClass, fakeSel, originalCtorImp, 154 method_getTypeEncoding(fakeMethod)); 160 IMP originalImp = method_setImplementation(originalMethod, method_getImplementation(newMethod)); 161 class_addMethod(baseClass, fakeSel, originalImp, method_getTypeEncoding(fakeMethod)); 155 162 #endif 156 163 } -
trunk/src/gui/dialogs/qpagesetupdialog.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 45 45 46 46 QT_BEGIN_NAMESPACE 47 48 /*! 49 \class QPageSetupDialog 50 51 \brief The QPageSetupDialog class provides a configuration dialog 52 for the page-related options on a printer. 53 54 \ingroup standard-dialogs 55 \ingroup printing 56 57 On Windows and Mac OS X the page setup dialog is implemented using 58 the native page setup dialogs. 59 60 Note that on Windows and Mac OS X custom paper sizes won't be 61 reflected in the native page setup dialogs. Additionally, custom 62 page margins set on a QPrinter won't show in the native Mac OS X 63 page setup dialog. 64 65 \sa QPrinter, QPrintDialog 66 */ 67 68 69 /*! 70 \fn QPageSetupDialog::QPageSetupDialog(QPrinter *printer, QWidget *parent) 71 72 Constructs a page setup dialog that configures \a printer with \a 73 parent as the parent widget. 74 */ 75 76 /*! 77 \since 4.5 78 79 \fn QPageSetupDialog::QPageSetupDialog(QWidget *parent) 80 81 Constructs a page setup dialog that configures a default-constructed 82 QPrinter with \a parent as the parent widget. 83 84 \sa printer() 85 */ 86 87 /*! 88 \fn QPrinter *QPageSetupDialog::printer() 89 90 Returns the printer that was passed to the QPageSetupDialog 91 constructor. 92 */ 47 93 48 94 // hack … … 181 227 } 182 228 229 #if defined(Q_WS_MAC) || defined(Q_OS_WIN) 230 /*! \fn void QPageSetupDialog::setVisible(bool visible) 231 \reimp 232 */ 233 #endif 234 183 235 QT_END_NAMESPACE 184 236 -
trunk/src/gui/dialogs/qpagesetupdialog.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** -
trunk/src/gui/dialogs/qpagesetupdialog_mac.mm
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 252 252 } 253 253 254 /*!255 \reimp256 */257 254 void QPageSetupDialog::setVisible(bool visible) 258 255 { -
trunk/src/gui/dialogs/qpagesetupdialog_unix.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** -
trunk/src/gui/dialogs/qpagesetupdialog_unix_p.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** -
trunk/src/gui/dialogs/qpagesetupdialog_win.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 72 72 73 73 QWin32PrintEngine *engine = static_cast<QWin32PrintEngine*>(d->printer->paintEngine()); 74 QWin32PrintEnginePrivate *ep = static_cast<QWin32PrintEnginePrivate *>(engine->d_ptr );74 QWin32PrintEnginePrivate *ep = static_cast<QWin32PrintEnginePrivate *>(engine->d_ptr.data()); 75 75 76 76 PAGESETUPDLG psd; … … 79 79 80 80 // we need a temp DEVMODE struct if we don't have a global DEVMODE 81 HGLOBAL hDevMode ;82 int devModeSize ;81 HGLOBAL hDevMode = 0; 82 int devModeSize = 0; 83 83 if (!ep->globalDevMode) { 84 QT_WA( { devModeSize = sizeof(DEVMODEW) + ((DEVMODEW *) ep->devMode)->dmDriverExtra; }, 85 { devModeSize = sizeof(DEVMODEA) + ((DEVMODEA *) ep->devMode)->dmDriverExtra; }); 84 devModeSize = sizeof(DEVMODE) + ep->devMode->dmDriverExtra; 86 85 hDevMode = GlobalAlloc(GHND, devModeSize); 87 86 if (hDevMode) { … … 99 98 100 99 QWidget *parent = parentWidget(); 101 parent = parent ? parent->window() : qApp->activeWindow();100 parent = parent ? parent->window() : QApplication::activeWindow(); 102 101 Q_ASSERT(!parent ||parent->testAttribute(Qt::WA_WState_Created)); 103 102 psd.hwndOwner = parent ? parent->winId() : 0; -
trunk/src/gui/dialogs/qprintdialog.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** -
trunk/src/gui/dialogs/qprintdialog_mac.mm
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 122 122 123 123 QT_USE_NAMESPACE 124 125 #ifdef QT_MAC_USE_COCOA 124 126 125 127 @class QCocoaPrintPanelDelegate; … … 167 169 // Keep us in sync with file output 168 170 PMDestinationType dest; 171 172 // If the user selected print to file, the session has been 173 // changed behind our back and our d->ep->session object is a 174 // dangling pointer. Update it based on the "current" session 175 d->ep->session = static_cast<PMPrintSession>([d->ep->printInfo PMPrintSession]); 176 169 177 PMSessionGetDestinationType(d->ep->session, d->ep->settings, &dest); 170 178 if (dest == kPMDestinationFile) { … … 191 199 } 192 200 @end 201 202 #endif 193 203 194 204 QT_BEGIN_NAMESPACE -
trunk/src/gui/dialogs/qprintdialog_unix.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 45 45 46 46 #include "private/qabstractprintdialog_p.h" 47 #include "qfiledialog_p.h"48 47 #include <QtGui/qmessagebox.h> 49 48 #include "qprintdialog.h" 50 49 #include "qfiledialog.h" 51 50 #include <QtCore/qdir.h> 51 #include <QtGui/qevent.h> 52 52 #include <QtGui/qfilesystemmodel.h> 53 53 #include <QtGui/qstyleditemdelegate.h> … … 56 56 #include <QtGui/qdialogbuttonbox.h> 57 57 58 #include "qfscompleter_p.h" 58 59 #include "ui_qprintpropertieswidget.h" 59 60 #include "ui_qprintsettingsoutput.h" … … 193 194 selected(-1), 194 195 selDescription(0), 195 parentItem(pi) {} ;196 parentItem(pi) {} 196 197 197 198 ~QOptionTreeItem() { 198 199 while (!childItems.isEmpty()) 199 200 delete childItems.takeFirst(); 200 } ;201 } 201 202 202 203 ItemType type; … … 238 239 Q_OBJECT 239 240 public: 240 QPPDOptionsEditor(QObject* parent = 0) : QStyledItemDelegate(parent) {} ;241 ~QPPDOptionsEditor() {} ;241 QPPDOptionsEditor(QObject* parent = 0) : QStyledItemDelegate(parent) {} 242 ~QPPDOptionsEditor() {} 242 243 243 244 QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const; … … 670 671 QString printerName(QString::fromLocal8Bit(cupsPrinters[i].name)); 671 672 if (cupsPrinters[i].instance) 672 printerName += QLatin1 String("/") + QString::fromLocal8Bit(cupsPrinters[i].instance);673 printerName += QLatin1Char('/') + QString::fromLocal8Bit(cupsPrinters[i].instance); 673 674 674 675 widget.printers->addItem(printerName); … … 696 697 QFileSystemModel *fsm = new QFileSystemModel(widget.filename); 697 698 fsm->setRootPath(QDir::homePath()); 698 #if !defined(QT_NO_ COMPLETER) && !defined(QT_NO_FILEDIALOG)699 widget.filename->setCompleter(new QFSComplet or(fsm, widget.filename));699 #if !defined(QT_NO_FSCOMPLETER) && !defined(QT_NO_FILEDIALOG) 700 widget.filename->setCompleter(new QFSCompleter(fsm, widget.filename)); 700 701 #endif 701 702 #endif … … 728 729 filePrintersAdded = false; 729 730 } 730 if (printer && filePrintersAdded && printer->printerName().isEmpty()) { 731 if (printer && filePrintersAdded && (printer->outputFormat() != QPrinter::NativeFormat 732 || printer->printerName().isEmpty())) 733 { 731 734 if (printer->outputFormat() == QPrinter::PdfFormat) 732 735 widget.printers->setCurrentIndex(widget.printers->count() - 2); … … 812 815 #endif 813 816 if (lprPrinters.count() > 0) { 814 QString type = lprPrinters.at(index).name + QLatin1 String("@") + lprPrinters.at(index).host;817 QString type = lprPrinters.at(index).name + QLatin1Char('@') + lprPrinters.at(index).host; 815 818 if (!lprPrinters.at(index).comment.isEmpty()) 816 819 type += QLatin1String(", ") + lprPrinters.at(index).comment; … … 833 836 void QUnixPrintWidgetPrivate::_q_btnBrowseClicked() 834 837 { 835 const int prevPrinter = widget.printers->currentIndex();836 widget.printers->setCurrentIndex(widget.printers->count() - 2); // the pdf one837 838 838 QString filename = widget.filename->text(); 839 839 #ifndef QT_NO_FILEDIALOG … … 847 847 if (filename.endsWith(QString::fromLatin1(".ps"), Qt::CaseInsensitive)) 848 848 widget.printers->setCurrentIndex(widget.printers->count() - 1); // the postscript one 849 } 850 else 851 widget.printers->setCurrentIndex(prevPrinter); 849 else if (filename.endsWith(QString::fromLatin1(".pdf"), Qt::CaseInsensitive)) 850 widget.printers->setCurrentIndex(widget.printers->count() - 2); // the pdf one 851 else if (widget.printers->currentIndex() != widget.printers->count() - 1) // if ps is not selected, pdf is default 852 widget.printers->setCurrentIndex(widget.printers->count() - 2); // the pdf one 853 } 852 854 } 853 855 … … 1193 1195 switch(section){ 1194 1196 case 0: 1195 return QVariant(QApplication::translate("QPPDOptionsModel", "Name"));1197 return QVariant(QApplication::translate("QPPDOptionsModel", "Name")); 1196 1198 case 1: 1197 return QVariant(QApplication::translate("QPPDOptionsModel", "Value"));1199 return QVariant(QApplication::translate("QPPDOptionsModel", "Value")); 1198 1200 default: 1199 1201 return QVariant(); -
trunk/src/gui/dialogs/qprintdialog_win.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 52 52 #include <private/qprintengine_win_p.h> 53 53 #include <private/qprinter_p.h> 54 55 #if defined(Q_CC_MINGW) && !defined(PD_NOCURRENTPAGE) 56 #define PD_NOCURRENTPAGE 0x00800000 57 #define PD_RESULT_PRINT 1 58 #define PD_RESULT_APPLY 2 59 #define START_PAGE_GENERAL 0XFFFFFFFF 60 #endif 54 61 55 62 QT_BEGIN_NAMESPACE … … 78 85 }; 79 86 80 #ifndef Q_OS_WINCE 81 // If you change this function, make sure you also change the unicode equivalent 82 template <class PrintDialog, class DeviceMode> 83 static PrintDialog *qt_win_make_PRINTDLG(QWidget *parent, 84 QPrintDialog *pdlg, 85 QPrintDialogPrivate *d, HGLOBAL *tempDevNames) 86 { 87 PrintDialog *pd = new PrintDialog; 88 memset(pd, 0, sizeof(PrintDialog)); 89 pd->lStructSize = sizeof(PrintDialog); 90 91 void *devMode = sizeof(DeviceMode) == sizeof(DEVMODEA) 92 ? (void *) d->ep->devModeA() 93 : (void *) d->ep->devModeW(); 87 static void qt_win_setup_PRINTDLGEX(PRINTDLGEX *pd, QWidget *parent, 88 QPrintDialog *pdlg, 89 QPrintDialogPrivate *d, HGLOBAL *tempDevNames) 90 { 91 DEVMODE *devMode = d->ep->devMode; 94 92 95 93 if (devMode) { 96 int size = sizeof(D eviceMode) + ((DeviceMode *) devMode)->dmDriverExtra;94 int size = sizeof(DEVMODE) + devMode->dmDriverExtra; 97 95 pd->hDevMode = GlobalAlloc(GHND, size); 98 96 { 99 97 void *dest = GlobalLock(pd->hDevMode); 100 memcpy(dest, d ->ep->devMode, size);98 memcpy(dest, devMode, size); 101 99 GlobalUnlock(pd->hDevMode); 102 100 } … … 131 129 pd->Flags |= PD_NOPAGENUMS; 132 130 131 // we don't have a 'current page' notion in the QPrinter API yet. 132 // Neither do we support more than one page range, so limit those 133 // options 134 pd->Flags |= PD_NOCURRENTPAGE; 135 pd->nStartPage = START_PAGE_GENERAL; 136 pd->nPageRanges = 1; 137 pd->nMaxPageRanges = 1; 138 133 139 if (d->ep->printToFile) 134 140 pd->Flags |= PD_PRINTTOFILE; 135 Q_ASSERT( !parent ||parent->testAttribute(Qt::WA_WState_Created));136 pd->hwndOwner = parent ? parent->winId() : 0;137 pd-> nFromPage = qMax(pdlg->fromPage(), pdlg->minPage());138 pd-> nToPage = (pdlg->toPage() > 0) ? qMin(pdlg->toPage(), pdlg->maxPage()) : 1;141 Q_ASSERT(parent != 0 && parent->testAttribute(Qt::WA_WState_Created)); 142 pd->hwndOwner = parent->window()->winId(); 143 pd->lpPageRanges[0].nFromPage = qMax(pdlg->fromPage(), pdlg->minPage()); 144 pd->lpPageRanges[0].nToPage = (pdlg->toPage() > 0) ? qMin(pdlg->toPage(), pdlg->maxPage()) : 1; 139 145 pd->nCopies = d->ep->num_copies; 140 141 return pd; 142 } 143 #endif // Q_OS_WINCE 144 145 // If you change this function, make sure you also change the ansi equivalent 146 template <typename T> 147 static void qt_win_clean_up_PRINTDLG(T **pd) 148 { 149 delete *pd; 150 *pd = 0; 151 } 152 153 154 // If you change this function, make sure you also change the ansi equivalent 155 template <typename T> 156 static void qt_win_read_back_PRINTDLG(T *pd, QPrintDialog *pdlg, QPrintDialogPrivate *d) 146 } 147 148 static void qt_win_read_back_PRINTDLGEX(PRINTDLGEX *pd, QPrintDialog *pdlg, QPrintDialogPrivate *d) 157 149 { 158 150 if (pd->Flags & PD_SELECTION) { … … 161 153 } else if (pd->Flags & PD_PAGENUMS) { 162 154 pdlg->setPrintRange(QPrintDialog::PageRange); 163 pdlg->setFromTo(pd-> nFromPage, pd->nToPage);155 pdlg->setFromTo(pd->lpPageRanges[0].nFromPage, pd->lpPageRanges[0].nToPage); 164 156 } else { 165 157 pdlg->setPrintRange(QPrintDialog::AllPages); … … 226 218 parent = parent->window(); 227 219 else 228 parent = qApp->activeWindow(); 220 parent = QApplication::activeWindow(); 221 222 // If there is no window, fall back to the print dialog itself 223 if (parent == 0) 224 parent = q; 229 225 230 226 QWidget modal_widget; … … 235 231 HGLOBAL *tempDevNames = ep->createDevNames(); 236 232 233 bool done; 237 234 bool result; 238 bool done; 239 void *pd = QT_WA_INLINE( 240 (void*)(qt_win_make_PRINTDLG<PRINTDLGW, DEVMODEW>(parent, q, this, tempDevNames)), 241 (void*)(qt_win_make_PRINTDLG<PRINTDLGA, DEVMODEA>(parent, q, this, tempDevNames)) 242 ); 235 bool doPrinting; 236 237 PRINTPAGERANGE pageRange; 238 PRINTDLGEX pd; 239 memset(&pd, 0, sizeof(PRINTDLGEX)); 240 pd.lStructSize = sizeof(PRINTDLGEX); 241 pd.lpPageRanges = &pageRange; 242 qt_win_setup_PRINTDLGEX(&pd, parent, q, this, tempDevNames); 243 243 244 244 do { 245 245 done = true; 246 QT_WA({ 247 PRINTDLGW *pdw = reinterpret_cast<PRINTDLGW *>(pd); 248 result = PrintDlgW(pdw); 249 if ((pdw->Flags & PD_PAGENUMS) && (pdw->nFromPage > pdw->nToPage)) 246 doPrinting = false; 247 result = (PrintDlgEx(&pd) == S_OK); 248 if (result && (pd.dwResultAction == PD_RESULT_PRINT 249 || pd.dwResultAction == PD_RESULT_APPLY)) 250 { 251 doPrinting = (pd.dwResultAction == PD_RESULT_PRINT); 252 if ((pd.Flags & PD_PAGENUMS) 253 && (pd.lpPageRanges[0].nFromPage > pd.lpPageRanges[0].nToPage)) 254 { 255 pd.lpPageRanges[0].nFromPage = 1; 256 pd.lpPageRanges[0].nToPage = 1; 250 257 done = false; 251 if (result && pdw->hDC == 0) 258 } 259 if (pd.hDC == 0) 252 260 result = false; 253 else if (!result) 254 done = true; 255 }, { 256 PRINTDLGA *pda = reinterpret_cast<PRINTDLGA *>(pd); 257 result = PrintDlgA(pda); 258 if ((pda->Flags & PD_PAGENUMS) && (pda->nFromPage > pda->nToPage)) 259 done = false; 260 if (result && pda->hDC == 0) 261 result = false; 262 else if (!result) 263 done = true; 264 }); 261 } 262 265 263 if (!done) { 266 264 QMessageBox::warning(0, QPrintDialog::tr("Print"), … … 275 273 276 274 // write values back... 277 if (result) { 278 QT_WA({ 279 PRINTDLGW *pdw = reinterpret_cast<PRINTDLGW *>(pd); 280 qt_win_read_back_PRINTDLG(pdw, q, this); 281 qt_win_clean_up_PRINTDLG(&pdw); 282 }, { 283 PRINTDLGA *pda = reinterpret_cast<PRINTDLGA *>(pd); 284 qt_win_read_back_PRINTDLG(pda, q, this); 285 qt_win_clean_up_PRINTDLG(&pda); 286 }); 275 if (result && (pd.dwResultAction == PD_RESULT_PRINT 276 || pd.dwResultAction == PD_RESULT_APPLY)) 277 { 278 qt_win_read_back_PRINTDLGEX(&pd, q, this); 287 279 // update printer validity 288 280 printer->d_func()->validPrinter = !ep->name.isEmpty(); … … 292 284 GlobalFree(tempDevNames); 293 285 294 q->done(result );295 296 return result ;286 q->done(result && doPrinting); 287 288 return result && doPrinting; 297 289 } 298 290 -
trunk/src/gui/dialogs/qprintpreviewdialog.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 43 43 #include "qprintpreviewwidget.h" 44 44 #include <private/qprinter_p.h> 45 #include "private/qdialog_p.h" 45 46 46 47 #include <QtGui/qaction.h> … … 55 56 #include <QtGui/qvalidator.h> 56 57 #include <QtGui/qfiledialog.h> 58 #include <QtGui/qmainwindow.h> 59 #include <QtGui/qtoolbar.h> 60 #include <QtGui/qformlayout.h> 57 61 #include <QtCore/QCoreApplication> 58 62 … … 64 68 65 69 namespace { 70 class QPrintPreviewMainWindow : public QMainWindow 71 { 72 public: 73 QPrintPreviewMainWindow(QWidget *parent) : QMainWindow(parent) {} 74 QMenu *createPopupMenu() { return 0; } 75 }; 76 66 77 class ZoomFactorValidator : public QDoubleValidator 67 78 { … … 129 140 } // anonymous namespace 130 141 131 class QPrintPreviewDialogPrivate 142 class QPrintPreviewDialogPrivate : public QDialogPrivate 132 143 { 133 144 Q_DECLARE_PUBLIC(QPrintPreviewDialog) 134 145 public: 135 QPrintPreviewDialogPrivate( QPrintPreviewDialog *q)136 : q_ptr(q),printDialog(0), ownPrinter(false),146 QPrintPreviewDialogPrivate() 147 : printDialog(0), ownPrinter(false), 137 148 initialized(false) {} 138 149 … … 159 170 void updateZoomFactor(); 160 171 161 QPrintPreviewDialog *q_ptr;162 172 QPrintDialog *printDialog; 163 173 QPrintPreviewWidget *preview; … … 198 208 QAction *printAction; 199 209 QAction *pageSetupAction; 200 QAction *closeAction;201 210 202 211 QPointer<QObject> receiverToDisconnectOnClose; … … 216 225 preview = new QPrintPreviewWidget(printer, q); 217 226 } 218 QObject::connect(preview, SIGNAL(paintRequested(QPrinter *)), q, SIGNAL(paintRequested(QPrinter*)));227 QObject::connect(preview, SIGNAL(paintRequested(QPrinter*)), q, SIGNAL(paintRequested(QPrinter*))); 219 228 QObject::connect(preview, SIGNAL(previewChanged()), q, SLOT(_q_previewChanged())); 220 229 setupActions(); 221 230 222 // Navigation223 QToolButton* nextPageButton = new QToolButton;224 nextPageButton->setDefaultAction(nextPageAction);225 QToolButton* prevPageButton = new QToolButton;226 prevPageButton->setDefaultAction(prevPageAction);227 QToolButton* firstPageButton = new QToolButton;228 firstPageButton->setDefaultAction(firstPageAction);229 QToolButton* lastPageButton = new QToolButton;230 lastPageButton->setDefaultAction(lastPageAction);231 232 231 pageNumEdit = new LineEdit; 233 232 pageNumEdit->setAlignment(Qt::AlignRight); 234 pageNumEdit->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy:: MinimumExpanding));233 pageNumEdit->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); 235 234 pageNumLabel = new QLabel; 236 235 QObject::connect(pageNumEdit, SIGNAL(editingFinished()), q, SLOT(_q_pageNumEdited())); 237 238 QToolButton* fitWidthButton = new QToolButton;239 fitWidthButton->setDefaultAction(fitWidthAction);240 QToolButton* fitPageButton = new QToolButton;241 fitPageButton->setDefaultAction(fitPageAction);242 236 243 237 zoomFactor = new QComboBox; … … 256 250 q, SLOT(_q_zoomFactorChanged())); 257 251 258 QToolButton* zoomInButton = new QToolButton; 259 zoomInButton->setDefaultAction(zoomInAction); 252 QPrintPreviewMainWindow *mw = new QPrintPreviewMainWindow(q); 253 QToolBar *toolbar = new QToolBar(mw); 254 toolbar->addAction(fitWidthAction); 255 toolbar->addAction(fitPageAction); 256 toolbar->addSeparator(); 257 toolbar->addWidget(zoomFactor); 258 toolbar->addAction(zoomOutAction); 259 toolbar->addAction(zoomInAction); 260 toolbar->addSeparator(); 261 toolbar->addAction(portraitAction); 262 toolbar->addAction(landscapeAction); 263 toolbar->addSeparator(); 264 toolbar->addAction(firstPageAction); 265 toolbar->addAction(prevPageAction); 266 267 // this is to ensure the label text and the editor text are 268 // aligned in all styles - the extra QVBoxLayout is a workaround 269 // for bug in QFormLayout 270 QWidget *pageEdit = new QWidget(toolbar); 271 QVBoxLayout *vboxLayout = new QVBoxLayout; 272 vboxLayout->setContentsMargins(0, 0, 0, 0); 273 QFormLayout *formLayout = new QFormLayout; 274 formLayout->setWidget(0, QFormLayout::LabelRole, pageNumEdit); 275 formLayout->setWidget(0, QFormLayout::FieldRole, pageNumLabel); 276 vboxLayout->addLayout(formLayout); 277 vboxLayout->setAlignment(Qt::AlignVCenter); 278 pageEdit->setLayout(vboxLayout); 279 toolbar->addWidget(pageEdit); 280 281 toolbar->addAction(nextPageAction); 282 toolbar->addAction(lastPageAction); 283 toolbar->addSeparator(); 284 toolbar->addAction(singleModeAction); 285 toolbar->addAction(facingModeAction); 286 toolbar->addAction(overviewModeAction); 287 toolbar->addSeparator(); 288 toolbar->addAction(pageSetupAction); 289 toolbar->addAction(printAction); 290 291 // Cannot use the actions' triggered signal here, since it doesn't autorepeat 292 QToolButton *zoomInButton = static_cast<QToolButton *>(toolbar->widgetForAction(zoomInAction)); 293 QToolButton *zoomOutButton = static_cast<QToolButton *>(toolbar->widgetForAction(zoomOutAction)); 260 294 zoomInButton->setAutoRepeat(true); 261 295 zoomInButton->setAutoRepeatInterval(200); 262 296 zoomInButton->setAutoRepeatDelay(200); 263 264 QToolButton* zoomOutButton = new QToolButton;265 zoomOutButton->setDefaultAction(zoomOutAction);266 297 zoomOutButton->setAutoRepeat(true); 267 298 zoomOutButton->setAutoRepeatInterval(200); 268 299 zoomOutButton->setAutoRepeatDelay(200); 269 270 //Cannot use the actions' triggered signal here, since it doesnt autorepeat271 300 QObject::connect(zoomInButton, SIGNAL(clicked()), q, SLOT(_q_zoomIn())); 272 301 QObject::connect(zoomOutButton, SIGNAL(clicked()), q, SLOT(_q_zoomOut())); 273 302 274 QToolButton* portraitButton = new QToolButton; 275 portraitButton->setDefaultAction(portraitAction); 276 QToolButton* landscapeButton = new QToolButton; 277 landscapeButton->setDefaultAction(landscapeAction); 278 279 QToolButton* singleModeButton = new QToolButton; 280 singleModeButton->setDefaultAction(singleModeAction); 281 QToolButton* facingModeButton = new QToolButton; 282 facingModeButton->setDefaultAction(facingModeAction); 283 QToolButton* overviewModeButton = new QToolButton; 284 overviewModeButton->setDefaultAction(overviewModeAction); 285 286 QToolButton *printButton = new QToolButton; 287 printButton->setDefaultAction(printAction); 288 QToolButton *pageSetupButton = new QToolButton; 289 pageSetupButton->setDefaultAction(pageSetupAction); 290 QToolButton *closeButton = new QToolButton; 291 closeButton->setDefaultAction(closeAction); 292 293 QHBoxLayout* modeLayout = new QHBoxLayout; 294 modeLayout->setSpacing(0); 295 modeLayout->addWidget(singleModeButton); 296 modeLayout->addWidget(facingModeButton); 297 modeLayout->addWidget(overviewModeButton); 298 299 QHBoxLayout *barLayout = new QHBoxLayout; 300 barLayout->addWidget(fitWidthButton); 301 barLayout->addWidget(fitPageButton); 302 barLayout->addWidget(zoomFactor); 303 barLayout->addWidget(zoomOutButton); 304 barLayout->addWidget(zoomInButton); 305 barLayout->addWidget(portraitButton); 306 barLayout->addWidget(landscapeButton); 307 barLayout->addStretch(); 308 barLayout->addWidget(firstPageButton); 309 barLayout->addWidget(prevPageButton); 310 barLayout->addWidget(pageNumEdit); 311 barLayout->addWidget(pageNumLabel); 312 barLayout->addWidget(nextPageButton); 313 barLayout->addWidget(lastPageButton); 314 barLayout->addStretch(); 315 barLayout->addLayout(modeLayout); 316 barLayout->addStretch(); 317 barLayout->addWidget(pageSetupButton); 318 barLayout->addWidget(printButton); 319 barLayout->addWidget(closeButton); 320 321 QWidget* buttonBar = new QWidget; 322 buttonBar->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum)); 323 barLayout->setMargin(0); 324 buttonBar->setLayout(barLayout); 303 mw->addToolBar(toolbar); 304 mw->setCentralWidget(preview); 305 // QMainWindows are always created as top levels, force it to be a 306 // plain widget 307 mw->setParent(q, Qt::Widget); 325 308 326 309 QVBoxLayout *topLayout = new QVBoxLayout; 327 topLayout->addWidget( buttonBar);328 topLayout-> addWidget(preview);310 topLayout->addWidget(mw); 311 topLayout->setMargin(0); 329 312 q->setLayout(topLayout); 330 313 … … 339 322 #endif 340 323 ) 341 pageSetupButton->setEnabled(false); 324 pageSetupAction->setEnabled(false); 325 preview->setFocus(); 342 326 } 343 327 … … 419 403 printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print")); 420 404 pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup")); 421 closeAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Close"));422 405 qt_setupActionIcon(printAction, QLatin1String("print")); 423 406 qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup")); 424 407 QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print())); 425 408 QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup())); 426 QObject::connect(closeAction, SIGNAL(triggered(bool)), q, SLOT(reject()));427 409 428 410 // Initial state: … … 465 447 { 466 448 int curPage = preview->currentPage(); 467 int numPages = preview-> numPages();449 int numPages = preview->pageCount(); 468 450 nextPageAction->setEnabled(curPage < numPages); 469 451 prevPageAction->setEnabled(curPage > 1); … … 477 459 Q_Q(QPrintPreviewDialog); 478 460 479 int numPages = preview-> numPages();461 int numPages = preview->pageCount(); 480 462 int maxChars = QString::number(numPages).length(); 481 pageNumLabel->setText(QString (QLatin1String("/ %1")).arg(numPages));463 pageNumLabel->setText(QString::fromLatin1("/ %1").arg(numPages)); 482 464 int cyphersWidth = q->fontMetrics().width(QString().fill(QLatin1Char('8'), maxChars)); 483 465 int maxWidth = pageNumEdit->minimumSizeHint().width() + cyphersWidth; … … 534 516 preview->setCurrentPage(1); 535 517 else if (action == lastPageAction) 536 preview->setCurrentPage(preview-> numPages());518 preview->setCurrentPage(preview->pageCount()); 537 519 updateNavActions(); 538 520 } … … 577 559 } 578 560 QString fileName = QFileDialog::getSaveFileName(q, title, printer->outputFileName(), 579 QLatin1 String("*") + suffix);561 QLatin1Char('*') + suffix); 580 562 if (!fileName.isEmpty()) { 581 563 if (QFileInfo(fileName).suffix().isEmpty()) … … 630 612 if (ok) { 631 613 preview->setZoomFactor(factor/100.0); 632 zoomFactor->setEditText(QString (QLatin1String("%1%")).arg(factor));614 zoomFactor->setEditText(QString::fromLatin1("%1%").arg(factor)); 633 615 setFitting(false); 634 616 } … … 643 625 \brief The QPrintPreviewDialog class provides a dialog for 644 626 previewing and configuring page layouts for printer output. 627 628 \ingroup standard-dialogs 629 \ingroup printing 645 630 646 631 Using QPrintPreviewDialog in your existing application is … … 681 666 */ 682 667 QPrintPreviewDialog::QPrintPreviewDialog(QPrinter* printer, QWidget *parent, Qt::WindowFlags flags) 683 : QDialog( parent, flags), d_ptr(new QPrintPreviewDialogPrivate(this))668 : QDialog(*new QPrintPreviewDialogPrivate, parent, flags) 684 669 { 685 670 Q_D(QPrintPreviewDialog); … … 695 680 */ 696 681 QPrintPreviewDialog::QPrintPreviewDialog(QWidget *parent, Qt::WindowFlags f) 697 : QDialog( parent, f), d_ptr(new QPrintPreviewDialogPrivate(this))682 : QDialog(*new QPrintPreviewDialogPrivate, parent, f) 698 683 { 699 684 Q_D(QPrintPreviewDialog); … … 710 695 delete d->printer; 711 696 delete d->printDialog; 712 delete d_ptr;713 697 } 714 698 -
trunk/src/gui/dialogs/qprintpreviewdialog.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 95 95 Q_PRIVATE_SLOT(d_func(), void _q_zoomFactorChanged()) 96 96 97 QPrintPreviewDialogPrivate *d_ptr;97 void *dummy; // ### Qt 5 - remove me 98 98 }; 99 99 -
trunk/src/gui/dialogs/qprogressdialog.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 58 58 #include <limits.h> 59 59 60 #if defined(QT_SOFTKEYS_ENABLED) 61 #include <qaction.h> 62 #endif 63 #ifdef Q_WS_S60 64 #include <QtGui/qdesktopwidget.h> 65 #endif 66 67 60 68 QT_BEGIN_NAMESPACE 61 69 … … 77 85 #ifndef QT_NO_SHORTCUT 78 86 escapeShortcut(0), 87 #endif 88 #ifdef QT_SOFTKEYS_ENABLED 89 cancelAction(0), 79 90 #endif 80 91 useDefaultCancelText(false) … … 103 114 #ifndef QT_NO_SHORTCUT 104 115 QShortcut *escapeShortcut; 116 #endif 117 #ifdef QT_SOFTKEYS_ENABLED 118 QAction *cancelAction; 105 119 #endif 106 120 bool useDefaultCancelText; … … 197 211 \class QProgressDialog 198 212 \brief The QProgressDialog class provides feedback on the progress of a slow operation. 199 \ingroup dialogs200 \mainclass 213 \ingroup standard-dialogs 214 201 215 202 216 A progress dialog is used to give the user an indication of how long … … 432 446 resize(w, h); 433 447 if (cancelButton) 448 #if !defined(QT_SOFTKEYS_ENABLED) 434 449 cancelButton->show(); 450 #else 451 { 452 d->cancelAction = new QAction(cancelButton->text(), cancelButton); 453 d->cancelAction->setSoftKeyRole(QAction::NegativeSoftKey); 454 connect(d->cancelAction, SIGNAL(triggered()), this, SIGNAL(canceled())); 455 addAction(d->cancelAction); 456 } 457 #endif 435 458 } 436 459 … … 449 472 450 473 if (!cancelButtonText.isNull()) { 451 if (d->cancel) 474 if (d->cancel) { 452 475 d->cancel->setText(cancelButtonText); 453 else 476 #ifdef QT_SOFTKEYS_ENABLED 477 d->cancelAction->setText(cancelButtonText); 478 #endif 479 } else { 454 480 setCancelButton(new QPushButton(cancelButtonText, this)); 481 } 455 482 } else { 456 483 setCancelButton(0); … … 627 654 \warning If the progress dialog is modal 628 655 (see QProgressDialog::QProgressDialog()), 629 this functioncalls QApplication::processEvents(), so take care that656 setValue() calls QApplication::processEvents(), so take care that 630 657 this does not cause undesirable re-entrancy in your code. For example, 631 658 don't use a QProgressDialog inside a paintEvent()! … … 644 671 if (d->shown_once) { 645 672 if (isModal()) 646 qApp->processEvents();673 QApplication::processEvents(); 647 674 } else { 648 675 if (progress == 0) { … … 702 729 if (d->cancel) 703 730 h += d->cancel->sizeHint().height() + spacing; 731 #ifdef Q_WS_S60 732 if (QApplication::desktop()->size().height() > QApplication::desktop()->size().width()) 733 return QSize(qMax(QApplication::desktop()->size().width(), sh.width() + 2 * margin), h); 734 else 735 return QSize(qMax(QApplication::desktop()->size().height(), sh.width() + 2 * margin), h); 736 #else 704 737 return QSize(qMax(200, sh.width() + 2 * margin), h); 738 #endif 705 739 } 706 740 … … 719 753 { 720 754 Q_D(QProgressDialog); 721 if (ev->type() == QEvent::StyleChange) 755 if (ev->type() == QEvent::StyleChange) { 722 756 d->layout(); 723 else if (ev->type() == QEvent::LanguageChange)757 } else if (ev->type() == QEvent::LanguageChange) { 724 758 d->retranslateStrings(); 759 } 725 760 QDialog::changeEvent(ev); 726 761 } -
trunk/src/gui/dialogs/qprogressdialog.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** -
trunk/src/gui/dialogs/qsidebar.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 56 56 QT_BEGIN_NAMESPACE 57 57 58 void QSideBarDelegate::initStyleOption(QStyleOptionViewItem *option, 59 const QModelIndex &index) const 60 { 61 QStyledItemDelegate::initStyleOption(option,index); 62 QVariant value = index.data(QUrlModel::EnabledRole); 63 if (value.isValid()) { 64 //If the bookmark/entry is not enabled then we paint it in gray 65 if (!qvariant_cast<bool>(value)) 66 option->state &= ~QStyle::State_Enabled; 67 } 68 } 69 58 70 /*! 59 71 QUrlModel lets you have indexes from a QFileSystemModel to a list. When QFileSystemModel … … 87 99 88 100 if (index.data(Qt::DecorationRole).isNull()) 89 flags &= ~Qt::ItemIsEnabled;90 91 if (invalidUrls.contains(index.data(UrlRole).toUrl()))92 101 flags &= ~Qt::ItemIsEnabled; 93 102 … … 194 203 if (!invalidUrls.contains(url)) 195 204 invalidUrls.append(url); 205 //The bookmark is invalid then we set to false the EnabledRole 206 setData(index, false, EnabledRole); 207 } else { 208 //The bookmark is valid then we set to true the EnabledRole 209 setData(index, true, EnabledRole); 196 210 } 197 211 … … 234 248 if (!url.isValid() || url.scheme() != QLatin1String("file")) 235 249 continue; 250 //this makes sure the url is clean 251 const QString cleanUrl = QDir::cleanPath(url.toLocalFile()); 252 url = QUrl::fromLocalFile(cleanUrl); 253 236 254 for (int j = 0; move && j < rowCount(); ++j) { 237 if (index(j, 0).data(UrlRole) == url) { 255 QString local = index(j, 0).data(UrlRole).toUrl().toLocalFile(); 256 #if defined(Q_OS_WIN) 257 if (index(j, 0).data(UrlRole).toUrl().toLocalFile().toLower() == cleanUrl.toLower()) { 258 #else 259 if (index(j, 0).data(UrlRole).toUrl().toLocalFile() == cleanUrl) { 260 #endif 238 261 removeRow(j); 239 262 if (j <= row) … … 243 266 } 244 267 row = qMax(row, 0); 245 QModelIndex idx = fileSystemModel->index( url.toLocalFile());268 QModelIndex idx = fileSystemModel->index(cleanUrl); 246 269 if (!fileSystemModel->isDir(idx)) 247 270 continue; 248 271 insertRows(row, 1); 249 272 setUrl(index(row, 0), url, idx); 250 watching.append( QPair<QModelIndex, QString>(idx, url.toLocalFile()));273 watching.append(qMakePair(idx, cleanUrl)); 251 274 } 252 275 } … … 271 294 return; 272 295 if (fileSystemModel != 0) { 273 disconnect(model, SIGNAL(dataChanged( const QModelIndex &, const QModelIndex &)),274 this, SLOT(dataChanged( const QModelIndex &, const QModelIndex &)));296 disconnect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), 297 this, SLOT(dataChanged(QModelIndex,QModelIndex))); 275 298 disconnect(model, SIGNAL(layoutChanged()), 276 299 this, SLOT(layoutChanged())); 277 disconnect(model, SIGNAL(rowsRemoved( const QModelIndex &, int,int)),300 disconnect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)), 278 301 this, SLOT(layoutChanged())); 279 302 } 280 303 fileSystemModel = model; 281 304 if (fileSystemModel != 0) { 282 connect(model, SIGNAL(dataChanged( const QModelIndex &, const QModelIndex &)),283 this, SLOT(dataChanged( const QModelIndex &, const QModelIndex &)));305 connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), 306 this, SLOT(dataChanged(QModelIndex,QModelIndex))); 284 307 connect(model, SIGNAL(layoutChanged()), 285 308 this, SLOT(layoutChanged())); 286 connect(model, SIGNAL(rowsRemoved( const QModelIndex &, int,int)),309 connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)), 287 310 this, SLOT(layoutChanged())); 288 311 } … … 357 380 urlModel->setFileSystemModel(model); 358 381 setModel(urlModel); 359 360 connect(selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), 361 this, SLOT(clicked(const QModelIndex &))); 382 setItemDelegate(new QSideBarDelegate(this)); 383 384 connect(selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), 385 this, SLOT(clicked(QModelIndex))); 362 386 #ifndef QT_NO_DRAGANDDROP 363 387 setDragDropMode(QAbstractItemView::DragDrop); 364 388 #endif 365 389 setContextMenuPolicy(Qt::CustomContextMenu); 366 connect(this, SIGNAL(customContextMenuRequested( const QPoint &)),367 this, SLOT(showContextMenu( const QPoint &)));390 connect(this, SIGNAL(customContextMenuRequested(QPoint)), 391 this, SLOT(showContextMenu(QPoint))); 368 392 urlModel->setUrls(newUrls); 369 393 setCurrentIndex(this->model()->index(0,0)); … … 391 415 void QSidebar::selectUrl(const QUrl &url) 392 416 { 393 disconnect(selectionModel(), SIGNAL(currentChanged( const QModelIndex &, const QModelIndex &)),394 this, SLOT(clicked( const QModelIndex &)));417 disconnect(selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), 418 this, SLOT(clicked(QModelIndex))); 395 419 396 420 selectionModel()->clear(); … … 402 426 } 403 427 404 connect(selectionModel(), SIGNAL(currentChanged( const QModelIndex &, const QModelIndex &)),405 this, SLOT(clicked( const QModelIndex &)));428 connect(selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), 429 this, SLOT(clicked(QModelIndex))); 406 430 } 407 431 -
trunk/src/gui/dialogs/qsidebar_p.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 56 56 #include <qlistwidget.h> 57 57 #include <qstandarditemmodel.h> 58 #include <qstyleditemdelegate.h> 58 59 #include <qurl.h> 59 60 … … 63 64 64 65 class QFileSystemModel; 66 67 class QSideBarDelegate : public QStyledItemDelegate 68 { 69 public: 70 QSideBarDelegate(QWidget *parent = 0) : QStyledItemDelegate(parent) {} 71 void initStyleOption(QStyleOptionViewItem *option, 72 const QModelIndex &index) const; 73 }; 74 65 75 class Q_AUTOTEST_EXPORT QUrlModel : public QStandardItemModel 66 76 { … … 69 79 public: 70 80 enum Roles { 71 UrlRole = Qt::UserRole + 1 81 UrlRole = Qt::UserRole + 1, 82 EnabledRole = Qt::UserRole + 2 72 83 }; 73 84 -
trunk/src/gui/dialogs/qwizard.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 70 70 #include <qdebug.h> 71 71 72 #ifdef Q_ OS_WINCE72 #ifdef Q_WS_WINCE 73 73 extern bool qt_wince_is_mobile(); //defined in qguifunctions_wce.cpp 74 74 #endif 75 75 76 76 #include <string.h> // for memset() 77 78 #ifdef QT_SOFTKEYS_ENABLED 79 #include "qaction.h" 80 #endif 77 81 78 82 QT_BEGIN_NAMESPACE … … 84 88 const int MacButtonTopMargin = 13; 85 89 const int MacLayoutLeftMargin = 20; 86 const int MacLayoutTopMargin = 14; 90 //const int MacLayoutTopMargin = 14; // Unused. Save some space and avoid warning. 87 91 const int MacLayoutRightMargin = 20; 88 92 const int MacLayoutBottomMargin = 17; … … 245 249 && topLevelMarginRight == other.topLevelMarginRight 246 250 && topLevelMarginTop == other.topLevelMarginTop 247 && topLevelMarginBottom == other.topLevelMarginBottom 251 && topLevelMarginBottom == other.topLevelMarginBottom 248 252 && childMarginLeft == other.childMarginLeft 249 253 && childMarginRight == other.childMarginRight … … 329 333 QWizard *wiz = parentWidget() ? qobject_cast <QWizard *>(parentWidget()->parentWidget()) : 0; 330 334 if (wiz) { 331 // Designer dosen't support the Vista style for Wizards. This property is used to turn 335 // Designer dosen't support the Vista style for Wizards. This property is used to turn 332 336 // off the Vista style. 333 337 const QVariant v = wiz->property("_q_wizard_vista_off"); … … 344 348 bool modern = ((info.wizStyle == QWizard::ModernStyle) 345 349 #if !defined(QT_NO_STYLE_WINDOWSVISTA) 346 || ((info.wizStyle == QWizard::AeroStyle )347 && (QVistaHelper::vistaState() == QVistaHelper::Classic) || vistaDisabled())350 || ((info.wizStyle == QWizard::AeroStyle 351 && QVistaHelper::vistaState() == QVistaHelper::Classic) || vistaDisabled()) 348 352 #endif 349 353 ); … … 378 382 There is no widthForHeight() function, so we simulate it with a loop. 379 383 */ 380 int candidateSubTitleWidth = qMin(512, 2 * qApp->desktop()->width() / 3);384 int candidateSubTitleWidth = qMin(512, 2 * QApplication::desktop()->width() / 3); 381 385 int delta = candidateSubTitleWidth >> 1; 382 386 while (delta > 0) { … … 524 528 , maximumHeight(QWIDGETSIZE_MAX) 525 529 { 526 for (int i = 0; i < QWizard::NButtons; ++i) 530 for (int i = 0; i < QWizard::NButtons; ++i) { 527 531 btns[i] = 0; 532 #ifdef QT_SOFTKEYS_ENABLED 533 softKeys[i] = 0; 534 #endif 535 } 528 536 #if !defined(QT_NO_STYLE_WINDOWSVISTA) 529 537 if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA … … 561 569 void _q_emitCustomButtonClicked(); 562 570 void _q_updateButtonStates(); 571 void _q_handleFieldObjectDestroyed(QObject *); 563 572 void setStyle(QStyle *style); 564 573 #ifdef Q_WS_MAC … … 609 618 QLabel *subTitleLabel; 610 619 QWizardRuler *bottomRuler; 620 #ifdef QT_SOFTKEYS_ENABLED 621 mutable QAction *softKeys[QWizard::NButtons]; 622 #endif 611 623 612 624 QVBoxLayout *pageVBoxLayout; … … 634 646 const bool macStyle = (wstyle == QWizard::MacStyle); 635 647 switch (which) { 636 case QWizard::BackButton: 648 case QWizard::BackButton: 637 649 return macStyle ? QWizard::tr("Go Back") : QWizard::tr("< &Back"); 638 case QWizard::NextButton: 650 case QWizard::NextButton: 639 651 if (macStyle) 640 652 return QWizard::tr("Continue"); … … 732 744 void QWizardPrivate::addField(const QWizardField &field) 733 745 { 746 Q_Q(QWizard); 747 734 748 QWizardField myField = field; 735 749 myField.resolve(defaultPropertyTable); … … 745 759 QObject::connect(myField.object, myField.changedSignal, 746 760 myField.page, SLOT(_q_maybeEmitCompleteChanged())); 761 QObject::connect( 762 myField.object, SIGNAL(destroyed(QObject*)), q, 763 SLOT(_q_handleFieldObjectDestroyed(QObject*))); 747 764 } 748 765 749 766 void QWizardPrivate::removeFieldAt(int index) 750 767 { 768 Q_Q(QWizard); 769 751 770 const QWizardField &field = fields.at(index); 752 771 fieldIndexMap.remove(field.name); … … 754 773 QObject::disconnect(field.object, field.changedSignal, 755 774 field.page, SLOT(_q_maybeEmitCompleteChanged())); 775 QObject::disconnect( 776 field.object, SIGNAL(destroyed(QObject*)), q, 777 SLOT(_q_handleFieldObjectDestroyed(QObject*))); 756 778 fields.remove(index); 757 779 } … … 949 971 mainLayout->setMargin(0); 950 972 mainLayout->setSpacing(0); 951 pageVBoxLayout->setContentsMargins(deltaMarginLeft, deltaMarginTop, 973 pageVBoxLayout->setContentsMargins(deltaMarginLeft, deltaMarginTop, 952 974 deltaMarginRight, deltaMarginBottom); 953 buttonLayout->setContentsMargins(info.topLevelMarginLeft, info.topLevelMarginTop, 975 buttonLayout->setContentsMargins(info.topLevelMarginLeft, info.topLevelMarginTop, 954 976 info.topLevelMarginRight, info.topLevelMarginBottom); 955 977 } else { 956 mainLayout->setContentsMargins(info.topLevelMarginLeft, info.topLevelMarginTop, 978 mainLayout->setContentsMargins(info.topLevelMarginLeft, info.topLevelMarginTop, 957 979 info.topLevelMarginRight, info.topLevelMarginBottom); 958 980 mainLayout->setHorizontalSpacing(info.hspacing); … … 1202 1224 Q_ASSERT(bottomSpacer); 1203 1225 bottomSpacer->changeSize(0, 0, QSizePolicy::Ignored, expandPage ? QSizePolicy::Ignored : QSizePolicy::MinimumExpanding); 1204 pageVBoxLayout->invalidate(); 1226 pageVBoxLayout->invalidate(); 1205 1227 } 1206 1228 … … 1241 1263 #endif 1242 1264 QSize minimumSize = mainLayout->totalMinimumSize() + QSize(0, extraHeight); 1243 QSize maximumSize; 1244 #if defined(Q_WS_WIN) 1245 if (QSysInfo::WindowsVersion > QSysInfo::WV_Me) // ### See Tasks 164078 and 161660 1246 #endif 1247 maximumSize = mainLayout->totalMaximumSize(); 1265 QSize maximumSize = mainLayout->totalMaximumSize(); 1248 1266 if (info.header && headerWidget->maximumWidth() != QWIDGETSIZE_MAX) { 1249 1267 minimumSize.setWidth(headerWidget->maximumWidth()); … … 1321 1339 if (which < QWizard::NStandardButtons) 1322 1340 pushButton->setText(buttonDefaultText(wizStyle, which, this)); 1341 1342 #ifdef QT_SOFTKEYS_ENABLED 1343 QAction *softKey = new QAction(pushButton->text(), pushButton); 1344 QAction::SoftKeyRole softKeyRole; 1345 switch(which) { 1346 case QWizard::NextButton: 1347 case QWizard::FinishButton: 1348 case QWizard::CancelButton: 1349 softKeyRole = QAction::NegativeSoftKey; 1350 break; 1351 case QWizard::BackButton: 1352 case QWizard::CommitButton: 1353 case QWizard::HelpButton: 1354 case QWizard::CustomButton1: 1355 case QWizard::CustomButton2: 1356 case QWizard::CustomButton3: 1357 default: 1358 softKeyRole = QAction::PositiveSoftKey; 1359 break; 1360 } 1361 softKey->setSoftKeyRole(softKeyRole); 1362 softKeys[which] = softKey; 1363 #endif 1323 1364 connectButton(which); 1324 1365 } … … 1334 1375 QObject::connect(btns[which], SIGNAL(clicked()), q, SLOT(_q_emitCustomButtonClicked())); 1335 1376 } 1377 1378 #ifdef QT_SOFTKEYS_ENABLED 1379 QObject::connect(softKeys[which], SIGNAL(triggered()), btns[which], SIGNAL(clicked())); 1380 #endif 1336 1381 } 1337 1382 … … 1347 1392 else if (i < QWizard::NStandardButtons) 1348 1393 btns[i]->setText(buttonDefaultText(wizStyle, i, this)); 1394 #ifdef QT_SOFTKEYS_ENABLED 1395 softKeys[i]->setText(btns[i]->text()); 1396 #endif 1349 1397 } 1350 1398 } … … 1466 1514 inHandleAeroStyleChange = true; 1467 1515 1468 vistaHelper-> backButton()->disconnect();1516 vistaHelper->disconnectBackButton(); 1469 1517 q->removeEventFilter(vistaHelper); 1470 1518 … … 1490 1538 } else { 1491 1539 q->setMouseTracking(true); // ### original value possibly different 1540 #ifndef QT_NO_CURSOR 1492 1541 q->unsetCursor(); // ### ditto 1542 #endif 1493 1543 antiFlickerWidget->move(0, 0); 1494 vistaHelper-> backButton()->hide();1544 vistaHelper->hideBackButton(); 1495 1545 vistaHelper->setTitleBarIconAndCaptionVisible(true); 1496 1546 } … … 1589 1639 #endif 1590 1640 1641 #ifdef QT_SOFTKEYS_ENABLED 1642 QAbstractButton *wizardButton; 1643 for (int i = 0; i < QWizard::NButtons; ++i) { 1644 wizardButton = btns[i]; 1645 if (wizardButton && !wizardButton->testAttribute(Qt::WA_WState_Hidden)) { 1646 wizardButton->hide(); 1647 q->addAction(softKeys[i]); 1648 } else { 1649 q->removeAction(softKeys[i]); 1650 } 1651 } 1652 #endif 1653 1591 1654 enableUpdates(); 1655 } 1656 1657 void QWizardPrivate::_q_handleFieldObjectDestroyed(QObject *object) 1658 { 1659 QVector<QWizardField>::iterator it = fields.begin(); 1660 while (it != fields.end()) { 1661 const QWizardField &field = *it; 1662 if (field.object == object) { 1663 fieldIndexMap.remove(field.name); 1664 it = fields.erase(it); 1665 } else { 1666 ++it; 1667 } 1668 } 1592 1669 } 1593 1670 … … 1603 1680 1604 1681 #ifdef Q_WS_MAC 1605 1606 #ifdef Q_WS_MAC321607 QT_BEGIN_INCLUDE_NAMESPACE1608 #include <QuickTime/QuickTime.h>1609 QT_END_INCLUDE_NAMESPACE1610 typedef OSErr (*PtrQTNewDataReferenceFromCFURL)(CFURLRef, UInt32, Handle*, OSType*);1611 typedef OSErr (*PtrGetGraphicsImporterForDataRefWithFlags)(Handle, OSType, ComponentInstance*, long);1612 typedef ComponentResult (*PtrGraphicsImportSetFlags)(GraphicsImportComponent, long);1613 typedef ComponentResult (*PtrGraphicsImportCreateCGImage)(GraphicsImportComponent, CGImageRef*, UInt32);1614 1615 static PtrQTNewDataReferenceFromCFURL ptrQTNewDataReferenceFromCFURL = 0;1616 static PtrGetGraphicsImporterForDataRefWithFlags ptrGetGraphicsImporterForDataRefWithFlags = 0;1617 static PtrGraphicsImportSetFlags ptrGraphicsImportSetFlags = 0;1618 static PtrGraphicsImportCreateCGImage ptrGraphicsImportCreateCGImage = 0;1619 1620 static bool resolveQuickTimeSymbols()1621 {1622 if (ptrQTNewDataReferenceFromCFURL == 0) {1623 QLibrary library(QLatin1String("/System/Library/Frameworks/QuickTime.framework/QuickTime"));1624 ptrQTNewDataReferenceFromCFURL = reinterpret_cast<PtrQTNewDataReferenceFromCFURL>(library.resolve("QTNewDataReferenceFromCFURL"));1625 ptrGetGraphicsImporterForDataRefWithFlags = reinterpret_cast<PtrGetGraphicsImporterForDataRefWithFlags>(library.resolve("GetGraphicsImporterForDataRefWithFlags"));1626 ptrGraphicsImportSetFlags = reinterpret_cast<PtrGraphicsImportSetFlags>(library.resolve("GraphicsImportSetFlags"));1627 ptrGraphicsImportCreateCGImage = reinterpret_cast<PtrGraphicsImportCreateCGImage>(library.resolve("GraphicsImportCreateCGImage"));1628 }1629 1630 return ptrQTNewDataReferenceFromCFURL != 0 && ptrGetGraphicsImporterForDataRefWithFlags != 01631 && ptrGraphicsImportSetFlags != 0 && ptrGraphicsImportCreateCGImage != 0;1632 }1633 1634 1635 static QPixmap quicktimeTiff(const CFURLRef url)1636 {1637 if (!resolveQuickTimeSymbols())1638 return QPixmap();1639 1640 QCFType <CGImageRef> imageRef = 0;1641 Handle dataRef;1642 OSType dataRefType;1643 GraphicsImportComponent gi;1644 ComponentResult result;1645 result = ptrQTNewDataReferenceFromCFURL(url, 0, &dataRef, &dataRefType);1646 if (dataRef != 0) {1647 OSStatus err = ptrGetGraphicsImporterForDataRefWithFlags(dataRef, dataRefType, &gi, 0);1648 if (err == noErr && gi) {1649 result = ptrGraphicsImportSetFlags(gi, (kGraphicsImporterDontDoGammaCorrection1650 + kGraphicsImporterDontUseColorMatching));1651 if (!result)1652 result = ptrGraphicsImportCreateCGImage(gi, &imageRef, 0);1653 if (result)1654 qWarning("Qt: Problem reading TIFF image %ld(%s:%d)", result, __FILE__, __LINE__);1655 DisposeHandle(dataRef);1656 CloseComponent(gi);1657 }1658 }1659 1660 if (imageRef)1661 return QPixmap::fromMacCGImageRef(imageRef);1662 return QPixmap();1663 }1664 #endif // Q_WS_MAC321665 1682 1666 1683 QPixmap QWizardPrivate::findDefaultBackgroundPixmap() … … 1675 1692 url = CFBundleCopyResourceURL(bundle, CFSTR("Background"), CFSTR("tif"), 0); 1676 1693 if (url) { 1677 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 1678 if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) { 1679 QCFType<CGImageSourceRef> imageSource = CGImageSourceCreateWithURL(url, 0); 1680 QCFType<CGImageRef> image = CGImageSourceCreateImageAtIndex(imageSource, 0, 0); 1681 if (image) { 1682 int width = CGImageGetWidth(image); 1683 int height = CGImageGetHeight(image); 1684 if (width == ExpectedImageWidth && height == ExpectedImageHeight) 1685 return QPixmap::fromMacCGImageRef(image); 1686 } 1687 } else 1688 #endif 1689 { 1690 #ifdef Q_WS_MAC32 1691 return quicktimeTiff(url); 1692 #endif 1694 QCFType<CGImageSourceRef> imageSource = CGImageSourceCreateWithURL(url, 0); 1695 QCFType<CGImageRef> image = CGImageSourceCreateImageAtIndex(imageSource, 0, 0); 1696 if (image) { 1697 int width = CGImageGetWidth(image); 1698 int height = CGImageGetHeight(image); 1699 if (width == ExpectedImageWidth && height == ExpectedImageHeight) 1700 return QPixmap::fromMacCGImageRef(image); 1693 1701 } 1694 1702 } … … 2121 2129 Q_D(QWizard); 2122 2130 d->init(); 2123 #ifdef Q_ OS_WINCE2131 #ifdef Q_WS_WINCE 2124 2132 if (!qt_wince_is_mobile()) 2125 2133 setWindowFlags(windowFlags() & ~Qt::WindowOkButtonHint); … … 2837 2845 Q_D(const QWizard); 2838 2846 QSize result = d->mainLayout->totalSizeHint(); 2847 #ifdef Q_WS_S60 2848 QSize extra(QApplication::desktop()->availableGeometry(QCursor::pos()).size()); 2849 #else 2839 2850 QSize extra(500, 360); 2851 #endif 2840 2852 if (d->wizStyle == MacStyle && d->current != -1) { 2841 2853 QSize pixmap(currentPage()->pixmap(BackgroundPixmap).size()); … … 3437 3449 changes. This ensures that QWizard updates the enabled or disabled state of 3438 3450 its buttons. An example of the reimplementation is 3439 available \l{http:// doc.trolltech.com/qq/qq22-qwizard.html#validatebeforeitstoolate}3440 {here}. 3451 available \l{http://qt.nokia.com/doc/qq/qq22-qwizard.html#validatebeforeitstoolate} 3452 {here}. 3441 3453 3442 3454 \sa completeChanged(), isFinalPage() -
trunk/src/gui/dialogs/qwizard.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 198 198 Q_PRIVATE_SLOT(d_func(), void _q_emitCustomButtonClicked()) 199 199 Q_PRIVATE_SLOT(d_func(), void _q_updateButtonStates()) 200 Q_PRIVATE_SLOT(d_func(), void _q_handleFieldObjectDestroyed(QObject *)) 200 201 201 202 friend class QWizardPage; -
trunk/src/gui/dialogs/qwizard_win.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 240 240 : pressed(false) 241 241 , wizard(wizard) 242 , backButton_(0) 242 243 { 243 244 is_vista = resolveSymbols(); 244 backButton_ = new QVistaBackButton(wizard); 245 if (is_vista) 246 backButton_ = new QVistaBackButton(wizard); 245 247 } 246 248 … … 278 280 { 279 281 DWORD rgb; 280 HANDLE hTheme = pOpenThemeData( qApp->desktop()->winId(), L"WINDOW");282 HANDLE hTheme = pOpenThemeData(QApplication::desktop()->winId(), L"WINDOW"); 281 283 pGetThemeColor( 282 284 hTheme, WIZ_WP_CAPTION, WIZ_CS_ACTIVE, … … 311 313 painter->paintEngine()->getDC()); 312 314 315 Q_ASSERT(backButton_); 313 316 const int btnTop = backButton_->mapToParent(QPoint()).y(); 314 317 const int btnHeight = backButton_->size().height(); … … 385 388 void QVistaHelper::setMouseCursor(QPoint pos) 386 389 { 390 #ifndef QT_NO_CURSOR 387 391 if (rtTop.contains(pos)) 388 392 wizard->setCursor(Qt::SizeVerCursor); 389 393 else 390 394 wizard->setCursor(Qt::ArrowCursor); 395 #endif 391 396 } 392 397 … … 609 614 bool value = false; 610 615 if (vistaState() == VistaAero) { 611 HANDLE hTheme = pOpenThemeData( qApp->desktop()->winId(), L"WINDOW");616 HANDLE hTheme = pOpenThemeData(QApplication::desktop()->winId(), L"WINDOW"); 612 617 if (!hTheme) return false; 613 618 // Set up a memory DC and bitmap that we'll draw into 614 619 HDC dcMem; 615 620 HBITMAP bmp; 616 BITMAPINFO dib = { 0};621 BITMAPINFO dib = {{0}}; 617 622 dcMem = CreateCompatibleDC(hdc); 618 623 … … 660 665 HDC dcMem; 661 666 HBITMAP bmp; 662 BITMAPINFO dib = { 0};667 BITMAPINFO dib = {{0}}; 663 668 dcMem = CreateCompatibleDC(hdc); 664 669 -
trunk/src/gui/dialogs/qwizard_win_p.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 57 57 #ifndef QT_NO_STYLE_WINDOWSVISTA 58 58 59 #include < windows.h>59 #include <qt_windows.h> 60 60 #include <qobject.h> 61 61 #include <qwidget.h> … … 95 95 void paintEvent(QPaintEvent *event); 96 96 QVistaBackButton *backButton() const { return backButton_; } 97 void disconnectBackButton() { if (backButton_) backButton_->disconnect(); } 98 void hideBackButton() { if (backButton_) backButton_->hide(); } 97 99 void setWindowPosHack(); 98 100 QColor basicWindowFrameColor();
Note:
See TracChangeset
for help on using the changeset viewer.