Changeset 769 for trunk/src/gui/dialogs
- Timestamp:
- Aug 2, 2010, 9:27:30 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.6.3 (added) merged: 768 /branches/vendor/nokia/qt/current merged: 767 /branches/vendor/nokia/qt/4.6.2 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/dialogs/qcolordialog.cpp
r651 r769 645 645 void mouseMoveEvent(QMouseEvent *); 646 646 void mousePressEvent(QMouseEvent *); 647 void resizeEvent(QResizeEvent *); 647 648 648 649 private: … … 655 656 void setCol(const QPoint &pt); 656 657 657 QPixmap *pix;658 QPixmap pix; 658 659 }; 659 660 … … 791 792 792 793 QPoint QColorPicker::colPt() 793 { return QPoint((360-hue)*(pWidth-1)/360, (255-sat)*(pHeight-1)/255); } 794 { 795 QRect r = contentsRect(); 796 return QPoint((360 - hue) * (r.width() - 1) / 360, (255 - sat) * (r.height() - 1) / 255); 797 } 798 794 799 int QColorPicker::huePt(const QPoint &pt) 795 { return 360 - pt.x()*360/(pWidth-1); } 800 { 801 QRect r = contentsRect(); 802 return 360 - pt.x() * 360 / (r.width() - 1); 803 } 804 796 805 int QColorPicker::satPt(const QPoint &pt) 797 { return 255 - pt.y()*255/(pHeight-1) ; } 806 { 807 QRect r = contentsRect(); 808 return 255 - pt.y() * 255 / (r.height() - 1); 809 } 810 798 811 void QColorPicker::setCol(const QPoint &pt) 799 { setCol(huePt(pt), satPt(pt)); } 812 { 813 setCol(huePt(pt), satPt(pt)); 814 } 800 815 801 816 QColorPicker::QColorPicker(QWidget* parent) … … 805 820 setCol(150, 255); 806 821 807 QImage img(pWidth, pHeight, QImage::Format_RGB32); 822 setAttribute(Qt::WA_NoSystemBackground); 823 setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed) ); 824 } 825 826 QColorPicker::~QColorPicker() 827 { 828 } 829 830 QSize QColorPicker::sizeHint() const 831 { 832 return QSize(pWidth + 2*frameWidth(), pHeight + 2*frameWidth()); 833 } 834 835 void QColorPicker::setCol(int h, int s) 836 { 837 int nhue = qMin(qMax(0,h), 359); 838 int nsat = qMin(qMax(0,s), 255); 839 if (nhue == hue && nsat == sat) 840 return; 841 842 QRect r(colPt(), QSize(20,20)); 843 hue = nhue; sat = nsat; 844 r = r.united(QRect(colPt(), QSize(20,20))); 845 r.translate(contentsRect().x()-9, contentsRect().y()-9); 846 // update(r); 847 repaint(r); 848 } 849 850 void QColorPicker::mouseMoveEvent(QMouseEvent *m) 851 { 852 QPoint p = m->pos() - contentsRect().topLeft(); 853 setCol(p); 854 emit newCol(hue, sat); 855 } 856 857 void QColorPicker::mousePressEvent(QMouseEvent *m) 858 { 859 QPoint p = m->pos() - contentsRect().topLeft(); 860 setCol(p); 861 emit newCol(hue, sat); 862 } 863 864 void QColorPicker::paintEvent(QPaintEvent* ) 865 { 866 QPainter p(this); 867 drawFrame(&p); 868 QRect r = contentsRect(); 869 870 p.drawPixmap(r.topLeft(), pix); 871 QPoint pt = colPt() + r.topLeft(); 872 p.setPen(Qt::black); 873 874 p.fillRect(pt.x()-9, pt.y(), 20, 2, Qt::black); 875 p.fillRect(pt.x(), pt.y()-9, 2, 20, Qt::black); 876 877 } 878 879 void QColorPicker::resizeEvent(QResizeEvent *ev) 880 { 881 QFrame::resizeEvent(ev); 882 883 int w = width() - frameWidth() * 2; 884 int h = height() - frameWidth() * 2; 885 QImage img(w, h, QImage::Format_RGB32); 808 886 int x, y; 809 887 uint *pixel = (uint *) img.scanLine(0); 810 for (y = 0; y < pHeight; y++) {811 const uint *end = pixel + pWidth;888 for (y = 0; y < h; y++) { 889 const uint *end = pixel + w; 812 890 x = 0; 813 891 while (pixel < end) { … … 820 898 } 821 899 } 822 pix = new QPixmap(QPixmap::fromImage(img)); 823 setAttribute(Qt::WA_NoSystemBackground); 824 setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed) ); 825 } 826 827 QColorPicker::~QColorPicker() 828 { 829 delete pix; 830 } 831 832 QSize QColorPicker::sizeHint() const 833 { 834 return QSize(pWidth + 2*frameWidth(), pHeight + 2*frameWidth()); 835 } 836 837 void QColorPicker::setCol(int h, int s) 838 { 839 int nhue = qMin(qMax(0,h), 359); 840 int nsat = qMin(qMax(0,s), 255); 841 if (nhue == hue && nsat == sat) 842 return; 843 844 QRect r(colPt(), QSize(20,20)); 845 hue = nhue; sat = nsat; 846 r = r.united(QRect(colPt(), QSize(20,20))); 847 r.translate(contentsRect().x()-9, contentsRect().y()-9); 848 // update(r); 849 repaint(r); 850 } 851 852 void QColorPicker::mouseMoveEvent(QMouseEvent *m) 853 { 854 QPoint p = m->pos() - contentsRect().topLeft(); 855 setCol(p); 856 emit newCol(hue, sat); 857 } 858 859 void QColorPicker::mousePressEvent(QMouseEvent *m) 860 { 861 QPoint p = m->pos() - contentsRect().topLeft(); 862 setCol(p); 863 emit newCol(hue, sat); 864 } 865 866 void QColorPicker::paintEvent(QPaintEvent* ) 867 { 868 QPainter p(this); 869 drawFrame(&p); 870 QRect r = contentsRect(); 871 872 p.drawPixmap(r.topLeft(), *pix); 873 QPoint pt = colPt() + r.topLeft(); 874 p.setPen(Qt::black); 875 876 p.fillRect(pt.x()-9, pt.y(), 20, 2, Qt::black); 877 p.fillRect(pt.x(), pt.y()-9, 2, 20, Qt::black); 878 879 } 900 pix = QPixmap::fromImage(img); 901 } 902 880 903 881 904 class QColSpinBox : public QSpinBox … … 1079 1102 #ifdef QT_SMALL_COLORDIALOG 1080 1103 # ifdef Q_WS_S60 1081 QS60Data s60Data = QS60Data(); 1082 const bool nonTouchUI = !s60Data.hasTouchscreen; 1104 const bool nonTouchUI = !S60->hasTouchscreen; 1083 1105 # elif defined Q_WS_MAEMO_5 1084 1106 const bool nonTouchUI = false; … … 1507 1529 #if defined(QT_SMALL_COLORDIALOG) 1508 1530 # if defined(Q_WS_S60) 1509 QS60Data s60Data = QS60Data(); 1510 const bool nonTouchUI = !s60Data.hasTouchscreen; 1531 const bool nonTouchUI = !S60->hasTouchscreen; 1511 1532 # elif defined(Q_WS_MAEMO_5) 1512 1533 const bool nonTouchUI = false; -
trunk/src/gui/dialogs/qcolordialog_mac.mm
r651 r769 97 97 - (void)showColorPanel; 98 98 - (void)exec; 99 - (void)setResultSet:(BOOL)result; 99 100 @end 100 101 … … 157 158 delete mQtColor; 158 159 [super dealloc]; 160 } 161 162 - (void)setResultSet:(BOOL)result 163 { 164 mResultSet = result; 159 165 } 160 166 … … 321 327 mPriv->colorDialog()->accept(); 322 328 } 323 } 329 } 324 330 } 325 331 } … … 434 440 [colorPanel setDelegate:static_cast<QCocoaColorPanelDelegate *>(delegate)]; 435 441 } 436 442 [delegate setResultSet:false]; 437 443 setCocoaPanelColor(initial); 438 444 [static_cast<QCocoaColorPanelDelegate *>(delegate) showColorPanel]; -
trunk/src/gui/dialogs/qdialog.cpp
r651 r769 70 70 # include "qcolordialog.h" 71 71 # include "qwizard.h" 72 # include "qmenubar.h"73 72 #endif 74 73 … … 416 415 } 417 416 #else 418 if ((e->type() == QEvent::StyleChange) || (e->type() == QEvent::Resize )) 419 adjustPosition(parentWidget()); 417 if ((e->type() == QEvent::StyleChange) || (e->type() == QEvent::Resize )) { 418 if (!testAttribute(Qt::WA_Moved)) { 419 Qt::WindowStates state = windowState(); 420 adjustPosition(parentWidget()); 421 setAttribute(Qt::WA_Moved, false); // not really an explicit position 422 if (state != windowState()) 423 setWindowState(state); 424 } 425 } 420 426 #endif 421 427 return result; … … 523 529 524 530 #ifdef Q_OS_SYMBIAN 525 #ifndef QT_NO_MENUBAR526 QMenuBar *menuBar = 0;527 if (!findChild<QMenuBar *>())528 menuBar = new QMenuBar(this);529 #endif530 531 531 if (qobject_cast<QFileDialog *>(this) || qobject_cast<QFontDialog *>(this) || 532 532 qobject_cast<QColorDialog *>(this) || qobject_cast<QWizard *>(this)) … … 560 560 #endif //QT_NO_MENUBAR 561 561 #endif //Q_WS_WINCE_WM 562 #ifdef Q_OS_SYMBIAN563 #ifndef QT_NO_MENUBAR564 else if (menuBar)565 delete menuBar;566 #endif //QT_NO_MENUBAR567 #endif //Q_OS_SYMBIAN568 569 562 return res; 570 563 } … … 808 801 { 809 802 if (!event->spontaneous() && !testAttribute(Qt::WA_Moved)) { 810 803 Qt::WindowStates state = windowState(); 811 804 adjustPosition(parentWidget()); 812 805 setAttribute(Qt::WA_Moved, false); // not really an explicit position 813 814 806 if (state != windowState()) 807 setWindowState(state); 815 808 } 816 809 } … … 912 905 cbaHeight = qt_TSize2QSize(bgContainer->Size()).height(); 913 906 } 914 p.setY(S60->screenHeightInPixels -height()-cbaHeight);907 p.setY(S60->screenHeightInPixels - height() - cbaHeight); 915 908 p.setX(0); 916 909 } else { 917 910 const int scrollbarWidth = style()->pixelMetric(QStyle::PM_ScrollBarExtent); 918 TRect cbaRect = TRect(); 919 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EControlPane, cbaRect); 920 AknLayoutUtils::TAknCbaLocation cbaLocation = AknLayoutUtils::CbaLocation(); 921 switch (cbaLocation) { 922 case AknLayoutUtils::EAknCbaLocationBottom: 923 p.setY(S60->screenHeightInPixels - height()-cbaRect.Height()); 924 p.setX((S60->screenWidthInPixels - width())>>1); 925 break; 926 case AknLayoutUtils::EAknCbaLocationRight: 927 p.setY((S60->screenHeightInPixels - height())>>1); 928 p.setX(qMax(0,S60->screenWidthInPixels-width()-scrollbarWidth-cbaRect.Width())); 929 break; 930 case AknLayoutUtils::EAknCbaLocationLeft: 931 p.setY((S60->screenHeightInPixels - height())>>1); 932 p.setX(qMax(0,scrollbarWidth+cbaRect.Width())); 933 break; 911 TRect staConTopRect = TRect(); 912 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EStaconTop, staConTopRect); 913 if (staConTopRect.IsEmpty()) { 914 TRect cbaRect = TRect(); 915 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EControlPane, cbaRect); 916 AknLayoutUtils::TAknCbaLocation cbaLocation = AknLayoutUtils::CbaLocation(); 917 switch (cbaLocation) { 918 case AknLayoutUtils::EAknCbaLocationBottom: 919 p.setY(S60->screenHeightInPixels - height() - cbaRect.Height()); 920 p.setX((S60->screenWidthInPixels - width()) >> 1); 921 break; 922 case AknLayoutUtils::EAknCbaLocationRight: 923 p.setY((S60->screenHeightInPixels - height()) >> 1); 924 p.setX(qMax(0,S60->screenWidthInPixels - width() - scrollbarWidth - cbaRect.Width())); 925 break; 926 case AknLayoutUtils::EAknCbaLocationLeft: 927 p.setY((S60->screenHeightInPixels - height()) >> 1); 928 p.setX(qMax(0,scrollbarWidth + cbaRect.Width())); 929 break; 930 } 931 } else { 932 p.setY((S60->screenHeightInPixels - height()) >> 1); 933 p.setX(qMax(0,S60->screenWidthInPixels - width())); 934 934 } 935 935 } -
trunk/src/gui/dialogs/qfiledialog.cpp
r651 r769 230 230 231 231 \value HideNameFilterDetails Indicates if the is hidden or not. 232 This value is obsolete and does nothing since Qt 4.5:233 232 234 233 \value DontUseSheet In previous versions of Qt, the static 235 234 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, The235 was given a parent. This is no longer supported and does nothing in Qt 4.5, The 237 236 static functions will always be an application modal dialog. If 238 237 you want to use sheets, use QFileDialog::open() instead. -
trunk/src/gui/dialogs/qfiledialog.ui
r651 r769 84 84 <string>Back</string> 85 85 </property> 86 <property name="accessibleName"> 87 <string>Back</string> 88 </property> 89 <property name="accessibleDescription"> 90 <string>Go back</string> 91 </property> 86 92 </widget> 87 93 </item> … … 91 97 <string>Forward</string> 92 98 </property> 99 <property name="accessibleName"> 100 <string>Forward</string> 101 </property> 102 <property name="accessibleDescription"> 103 <string>Go forward</string> 104 </property> 93 105 </widget> 94 106 </item> … … 98 110 <string>Parent Directory</string> 99 111 </property> 112 <property name="accessibleName"> 113 <string>Parent Directory</string> 114 </property> 115 <property name="accessibleDescription"> 116 <string>Go to the parent directory</string> 117 </property> 100 118 </widget> 101 119 </item> … … 105 123 <string>Create New Folder</string> 106 124 </property> 125 <property name="accessibleName"> 126 <string>Create New Folder</string> 127 </property> 128 <property name="accessibleDescription"> 129 <string>Create a New Folder</string> 130 </property> 107 131 </widget> 108 132 </item> … … 112 136 <string>List View</string> 113 137 </property> 138 <property name="accessibleName"> 139 <string>List View</string> 140 </property> 141 <property name="accessibleDescription"> 142 <string>Change to list view mode</string> 143 </property> 114 144 </widget> 115 145 </item> … … 118 148 <property name="toolTip" > 119 149 <string>Detail View</string> 150 </property> 151 <property name="accessibleName"> 152 <string>Detail View</string> 153 </property> 154 <property name="accessibleDescription"> 155 <string>Change to detail view mode</string> 120 156 </property> 121 157 </widget> -
trunk/src/gui/dialogs/qfilesystemmodel.cpp
r651 r769 1361 1361 return d->index(rootPath()); 1362 1362 1363 //We remove the watcher on the previous path 1364 if (!rootPath().isEmpty() && rootPath() != QLatin1String(".")) { 1365 //This remove the watcher for the old rootPath 1366 d->fileInfoGatherer.removePath(rootPath()); 1367 //This line "marks" the node as dirty, so the next fetchMore 1368 //call on the path will ask the gatherer to install a watcher again 1369 //But it doesn't re-fetch everything 1370 d->node(rootPath())->populatedChildren = false; 1371 } 1372 1363 1373 // We have a new valid root path 1364 1374 d->rootDir = newPathDir; -
trunk/src/gui/dialogs/qfontdialog.cpp
r651 r769 990 990 { 991 991 Q_D(QFontDialog); 992 if (visible) 993 d->selectedFont = QFont(); 994 995 #if defined(Q_WS_MAC) 996 bool isCurrentlyVisible = (isVisible() || d->delegate); 997 998 if (!visible == !isCurrentlyVisible) 992 if (visible) { 993 if (testAttribute(Qt::WA_WState_ExplicitShowHide) && !testAttribute(Qt::WA_WState_Hidden)) 994 return; 995 } else if (testAttribute(Qt::WA_WState_ExplicitShowHide) && testAttribute(Qt::WA_WState_Hidden)) 999 996 return; 1000 1001 if (visible) { 1002 if (!(d->opts & DontUseNativeDialog) && QFontDialogPrivate::sharedFontPanelAvailable) { 1003 d->delegate = QFontDialogPrivate::openCocoaFontPanel( 1004 currentFont(), parentWidget(), windowTitle(), options(), d); 1005 QFontDialogPrivate::sharedFontPanelAvailable = false; 1006 return; 997 #ifdef Q_WS_MAC 998 if (d->canBeNativeDialog()){ 999 if (d->setVisible_sys(visible)){ 1000 d->nativeDialogInUse = true; 1001 // Set WA_DontShowOnScreen so that QDialog::setVisible(visible) below 1002 // updates the state correctly, but skips showing the non-native version: 1003 setAttribute(Qt::WA_DontShowOnScreen, true); 1004 } else { 1005 d->nativeDialogInUse = false; 1006 setAttribute(Qt::WA_DontShowOnScreen, false); 1007 1007 } 1008 1009 setWindowFlags(windowModality() == Qt::WindowModal ? Qt::Sheet : DefaultWindowFlags); 1010 } else { 1011 if (d->delegate) { 1012 QFontDialogPrivate::closeCocoaFontPanel(d->delegate); 1013 d->delegate = 0; 1014 QFontDialogPrivate::sharedFontPanelAvailable = true; 1015 return; 1016 } 1017 } 1018 #endif 1019 1008 } 1009 #endif // Q_WS_MAC 1020 1010 QDialog::setVisible(visible); 1021 1011 } … … 1033 1023 QDialog::done(result); 1034 1024 if (result == Accepted) { 1035 d->selectedFont = currentFont(); 1025 // We check if this is the same font we had before, if so we emit currentFontChanged 1026 QFont selectedFont = currentFont(); 1027 if(selectedFont != d->selectedFont) 1028 emit(currentFontChanged(selectedFont)); 1029 d->selectedFont = selectedFont; 1036 1030 emit fontSelected(d->selectedFont); 1037 } else {1031 } else 1038 1032 d->selectedFont = QFont(); 1039 }1040 1033 if (d->receiverToDisconnectOnClose) { 1041 1034 disconnect(this, SIGNAL(fontSelected(QFont)), … … 1046 1039 } 1047 1040 1041 #ifdef Q_WS_MAC 1042 bool QFontDialogPrivate::canBeNativeDialog() 1043 { 1044 Q_Q(QFontDialog); 1045 if (nativeDialogInUse) 1046 return true; 1047 if (q->testAttribute(Qt::WA_DontShowOnScreen)) 1048 return false; 1049 if (opts & QFontDialog::DontUseNativeDialog) 1050 return false; 1051 1052 QLatin1String staticName(QFontDialog::staticMetaObject.className()); 1053 QLatin1String dynamicName(q->metaObject()->className()); 1054 return (staticName == dynamicName); 1055 } 1056 #endif // Q_WS_MAC 1057 1048 1058 /*! 1049 1059 \fn QFont QFontDialog::getFont(bool *ok, const QFont &initial, QWidget* parent, const char* name) -
trunk/src/gui/dialogs/qfontdialog.h
r651 r769 132 132 Q_PRIVATE_SLOT(d_func(), void _q_sizeHighlighted(int)) 133 133 Q_PRIVATE_SLOT(d_func(), void _q_updateSample()) 134 #if defined(Q_WS_MAC) 135 Q_PRIVATE_SLOT(d_func(), void _q_macRunNativeAppModalPanel()) 136 #endif 134 137 }; 135 138 -
trunk/src/gui/dialogs/qfontdialog_mac.mm
r651 r769 50 50 #include <private/qt_cocoa_helpers_mac_p.h> 51 51 #include <private/qt_mac_p.h> 52 #include <qabstracteventdispatcher.h> 52 53 #include <qdebug.h> 53 54 #import <AppKit/AppKit.h> … … 373 374 mModalSession = 0; 374 375 } 375 376 // Hack alert! 377 // Since this code path was never intended to be followed when starting from exec 378 // we need to force the dialog to communicate the new font, otherwise the signal 379 // won't get emitted. 380 if(code == NSOKButton) 381 mPriv->sampleEdit->setFont([self qtFont]); 376 382 mPriv->done((code == NSOKButton) ? QDialog::Accepted : QDialog::Rejected); 377 383 } else { … … 568 574 } 569 575 } 570 571 576 return delegate; 572 577 } … … 641 646 } 642 647 648 void *QFontDialogPrivate::_q_constructNativePanel() 649 { 650 QMacCocoaAutoReleasePool pool; 651 652 bool sharedFontPanelExisted = [NSFontPanel sharedFontPanelExists]; 653 NSFontPanel *sharedFontPanel = [NSFontPanel sharedFontPanel]; 654 [sharedFontPanel setHidesOnDeactivate:false]; 655 656 // hack to ensure that QCocoaApplication's validModesForFontPanel: 657 // implementation is honored 658 if (!sharedFontPanelExisted) { 659 [sharedFontPanel makeKeyAndOrderFront:sharedFontPanel]; 660 [sharedFontPanel close]; 661 } 662 663 NSPanel *ourPanel = 0; 664 NSView *stolenContentView = 0; 665 NSButton *okButton = 0; 666 NSButton *cancelButton = 0; 667 668 CGFloat dialogExtraWidth = 0.0; 669 CGFloat dialogExtraHeight = 0.0; 670 671 // compute dialogExtra{Width,Height} 672 dialogExtraWidth = 2.0 * DialogSideMargin; 673 dialogExtraHeight = DialogTopMargin + ButtonTopMargin + ButtonMinHeight 674 + ButtonBottomMargin; 675 676 // compute initial contents rectangle 677 NSRect contentRect = [sharedFontPanel contentRectForFrameRect:[sharedFontPanel frame]]; 678 contentRect.size.width += dialogExtraWidth; 679 contentRect.size.height += dialogExtraHeight; 680 681 // create the new panel 682 ourPanel = [[NSPanel alloc] initWithContentRect:contentRect 683 styleMask:StyleMask 684 backing:NSBackingStoreBuffered 685 defer:YES]; 686 [ourPanel setReleasedWhenClosed:YES]; 687 688 stolenContentView = [sharedFontPanel contentView]; 689 690 // steal the font panel's contents view 691 [stolenContentView retain]; 692 [sharedFontPanel setContentView:0]; 693 694 { 695 // create a new content view and add the stolen one as a subview 696 NSRect frameRect = { { 0.0, 0.0 }, { 0.0, 0.0 } }; 697 NSView *ourContentView = [[NSView alloc] initWithFrame:frameRect]; 698 [ourContentView addSubview:stolenContentView]; 699 700 // create OK and Cancel buttons and add these as subviews 701 okButton = macCreateButton("&OK", ourContentView); 702 cancelButton = macCreateButton("Cancel", ourContentView); 703 704 [ourPanel setContentView:ourContentView]; 705 [ourPanel setDefaultButtonCell:[okButton cell]]; 706 } 707 // create a delegate and set it 708 QCocoaFontPanelDelegate *delegate = 709 [[QCocoaFontPanelDelegate alloc] initWithFontPanel:sharedFontPanel 710 stolenContentView:stolenContentView 711 okButton:okButton 712 cancelButton:cancelButton 713 priv:this 714 extraWidth:dialogExtraWidth 715 extraHeight:dialogExtraHeight]; 716 [ourPanel setDelegate:delegate]; 717 [[NSFontManager sharedFontManager] setDelegate:delegate]; 718 #ifdef QT_MAC_USE_COCOA 719 [[NSFontManager sharedFontManager] setTarget:delegate]; 720 #endif 721 setFont(delegate, QApplication::font()); 722 723 { 724 // hack to get correct initial layout 725 NSRect frameRect = [ourPanel frame]; 726 frameRect.size.width += 1.0; 727 [ourPanel setFrame:frameRect display:NO]; 728 frameRect.size.width -= 1.0; 729 frameRect.size = [delegate windowWillResize:ourPanel toSize:frameRect.size]; 730 [ourPanel setFrame:frameRect display:NO]; 731 [ourPanel center]; 732 } 733 NSString *title = @"Select font"; 734 [ourPanel setTitle:title]; 735 736 [delegate setModalSession:[NSApp beginModalSessionForWindow:ourPanel]]; 737 return delegate; 738 } 739 740 void QFontDialogPrivate::mac_nativeDialogModalHelp() 741 { 742 // Copied from QFileDialogPrivate 743 // Do a queued meta-call to open the native modal dialog so it opens after the new 744 // event loop has started to execute (in QDialog::exec). Using a timer rather than 745 // a queued meta call is intentional to ensure that the call is only delivered when 746 // [NSApp run] runs (timers are handeled special in cocoa). If NSApp is not 747 // running (which is the case if e.g a top-most QEventLoop has been 748 // interrupted, and the second-most event loop has not yet been reactivated (regardless 749 // if [NSApp run] is still on the stack)), showing a native modal dialog will fail. 750 if (nativeDialogInUse) { 751 Q_Q(QFontDialog); 752 QTimer::singleShot(1, q, SLOT(_q_macRunNativeAppModalPanel())); 753 } 754 } 755 756 // The problem with the native font dialog is that OS X does not 757 // offer a proper dialog, but a panel (i.e. without Ok and Cancel buttons). 758 // This means we need to "construct" a native dialog by taking the panel 759 // and "adding" the buttons. 760 void QFontDialogPrivate::_q_macRunNativeAppModalPanel() 761 { 762 QBoolBlocker nativeDialogOnTop(QApplicationPrivate::native_modal_dialog_active); 763 Q_Q(QFontDialog); 764 QCocoaFontPanelDelegate *delegate = (QCocoaFontPanelDelegate *)_q_constructNativePanel(); 765 NSWindow *ourPanel = [delegate actualPanel]; 766 [ourPanel retain]; 767 int rval = [NSApp runModalForWindow:ourPanel]; 768 QAbstractEventDispatcher::instance()->interrupt(); 769 [ourPanel release]; 770 [delegate cleanUpAfterMyself]; 771 [delegate release]; 772 bool isOk = (rval == NSOKButton); 773 if(isOk) 774 rescode = QDialog::Accepted; 775 else 776 rescode = QDialog::Rejected; 777 } 778 779 bool QFontDialogPrivate::setVisible_sys(bool visible) 780 { 781 Q_Q(QFontDialog); 782 if (!visible == q->isHidden()) 783 return false; 784 return visible; 785 } 786 643 787 QT_END_NAMESPACE 644 788 -
trunk/src/gui/dialogs/qfontdialog_p.h
r651 r769 153 153 154 154 void *delegate; 155 bool nativeDialogInUse; 156 bool canBeNativeDialog(); 157 bool setVisible_sys(bool visible); 158 void *_q_constructNativePanel(); 159 void _q_macRunNativeAppModalPanel(); 160 void mac_nativeDialogModalHelp(); 155 161 156 162 static bool sharedFontPanelAvailable; -
trunk/src/gui/dialogs/qmessagebox.cpp
r651 r769 66 66 #include <QtGui/qclipboard.h> 67 67 68 #ifndef QT_NO_STYLE_S60 69 #include <qs60style.h> 70 #endif 71 68 72 #ifdef Q_WS_WINCE 69 73 extern bool qt_wince_is_mobile(); //defined in qguifunctions_wince.cpp … … 315 319 width = hardLimit; 316 320 } 321 } 317 322 #ifdef Q_WS_S60 318 323 // in S60 portait messageBoxes should always occupy maximum width … … 324 329 } 325 330 #endif 326 }327 331 328 332 if (informativeLabel) { … … 354 358 ? layout->totalHeightForWidth(width) 355 359 : layout->totalMinimumSize().height(); 360 361 #ifndef QT_NO_STYLE_S60 362 QS60Style *s60Style = 0; 363 s60Style = qobject_cast<QS60Style *>(QApplication::style()); 364 365 //use custom pixel metric to deduce the minimum height of the messagebox 366 if (s60Style) 367 height = qMax(height, s60Style->pixelMetric((QStyle::PixelMetric)PM_MessageBoxHeight)); 368 #endif 369 356 370 q->setFixedSize(width, height); 357 371 QCoreApplication::removePostedEvents(q, QEvent::LayoutRequest); -
trunk/src/gui/dialogs/qprintdialog.h
r651 r769 57 57 class QPrinter; 58 58 59 #if (defined (Q_OS_UNIX) && !defined(QTOPIA_PRINTDIALOG) && !defined(Q_WS_MAC) ) || defined (Q_WS_PM)59 #if (defined (Q_OS_UNIX) && !defined(QTOPIA_PRINTDIALOG) && !defined(Q_WS_MAC) && !defined(Q_OS_SYMBIAN)) || defined (Q_WS_PM) 60 60 class QUnixPrintWidgetPrivate; 61 61 … … 98 98 99 99 #if defined (Q_OS_UNIX) && defined (QT3_SUPPORT) 100 void setPrinter(QPrinter *, bool = false);101 Q Printer *printer() const;102 void addButton(QPushButton *button);100 QT3_SUPPORT void setPrinter(QPrinter *, bool = false); 101 QT3_SUPPORT QPrinter *printer() const; 102 QT3_SUPPORT void addButton(QPushButton *button); 103 103 #endif 104 104 -
trunk/src/gui/dialogs/qprintdialog_unix.cpp
r762 r769 155 155 void setupPrinter(); 156 156 void setOptionsPane(QPrintDialogPrivate *pane); 157 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) 158 void setCupsProperties(); 159 #endif 157 160 158 161 // slots … … 970 973 void QUnixPrintWidgetPrivate::_q_btnPropertiesClicked() 971 974 { 972 if ( propertiesDialog == 0) {975 if (!propertiesDialog) { 973 976 propertiesDialog = new QPrintPropertiesDialog(q); 974 977 propertiesDialog->setResult(QDialog::Rejected); … … 989 992 propertiesDialog->exec(); 990 993 } 994 995 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) 996 void QUnixPrintWidgetPrivate::setCupsProperties() 997 { 998 if (cups && QCUPSSupport::isAvailable() && cups->pageSizes()) { 999 QPrintEngine *engine = printer->printEngine(); 1000 const ppd_option_t* pageSizes = cups->pageSizes(); 1001 QByteArray cupsPageSize; 1002 for (int i = 0; i < pageSizes->num_choices; ++i) { 1003 if (static_cast<int>(pageSizes->choices[i].marked) == 1) 1004 cupsPageSize = pageSizes->choices[i].choice; 1005 } 1006 engine->setProperty(PPK_CupsStringPageSize, QString::fromLatin1(cupsPageSize)); 1007 engine->setProperty(PPK_CupsOptions, cups->options()); 1008 1009 QRect pageRect = cups->pageRect(cupsPageSize); 1010 engine->setProperty(PPK_CupsPageRect, pageRect); 1011 1012 QRect paperRect = cups->paperRect(cupsPageSize); 1013 engine->setProperty(PPK_CupsPaperRect, paperRect); 1014 1015 for (int ps = 0; ps < QPrinter::NPaperSize; ++ps) { 1016 QPdf::PaperSize size = QPdf::paperSize(QPrinter::PaperSize(ps)); 1017 if (size.width == paperRect.width() && size.height == paperRect.height()) 1018 printer->setPaperSize(static_cast<QPrinter::PaperSize>(ps)); 1019 } 1020 } 1021 } 1022 #endif 991 1023 992 1024 void QUnixPrintWidgetPrivate::setupPrinter() … … 1018 1050 if (propertiesDialog && propertiesDialog->result() == QDialog::Accepted) 1019 1051 propertiesDialog->setupPrinter(); 1052 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) 1053 if (!propertiesDialog) 1054 setCupsProperties(); 1055 #endif 1020 1056 } 1021 1057 -
trunk/src/gui/dialogs/qprintpreviewdialog.cpp
r651 r769 274 274 QVBoxLayout *vboxLayout = new QVBoxLayout; 275 275 vboxLayout->setContentsMargins(0, 0, 0, 0); 276 #ifdef Q_WS_MAC 277 // We query the widgets about their size and then we fix the size. 278 // This should do the trick for the laying out part... 279 QSize pageNumEditSize, pageNumLabelSize; 280 pageNumEditSize = pageNumEdit->minimumSizeHint(); 281 pageNumLabelSize = pageNumLabel->minimumSizeHint(); 282 pageNumEdit->resize(pageNumEditSize); 283 pageNumLabel->resize(pageNumLabelSize); 284 #endif 276 285 QFormLayout *formLayout = new QFormLayout; 286 #ifdef Q_WS_MAC 287 // We have to change the growth policy in Mac. 288 formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow); 289 #endif 277 290 formLayout->setWidget(0, QFormLayout::LabelRole, pageNumEdit); 278 291 formLayout->setWidget(0, QFormLayout::FieldRole, pageNumLabel);
Note:
See TracChangeset
for help on using the changeset viewer.