src/gui/dialogs/qmessagebox.cpp
changeset 19 fcece45ef507
parent 18 2f34d5167611
child 30 5dc02b23752f
equal deleted inserted replaced
18:2f34d5167611 19:fcece45ef507
    63 #include "qdialog_p.h"
    63 #include "qdialog_p.h"
    64 #include <QtGui/qfont.h>
    64 #include <QtGui/qfont.h>
    65 #include <QtGui/qfontmetrics.h>
    65 #include <QtGui/qfontmetrics.h>
    66 #include <QtGui/qclipboard.h>
    66 #include <QtGui/qclipboard.h>
    67 
    67 
       
    68 #ifndef QT_NO_STYLE_S60
       
    69 #include <qs60style.h>
       
    70 #endif
       
    71 
    68 #ifdef Q_WS_WINCE
    72 #ifdef Q_WS_WINCE
    69 extern bool qt_wince_is_mobile();    //defined in qguifunctions_wince.cpp
    73 extern bool qt_wince_is_mobile();    //defined in qguifunctions_wince.cpp
    70 extern bool qt_wince_is_smartphone();//defined in qguifunctions_wince.cpp
    74 extern bool qt_wince_is_smartphone();//defined in qguifunctions_wince.cpp
    71 extern bool qt_wince_is_pocket_pc(); //defined in qguifunctions_wince.cpp
    75 extern bool qt_wince_is_pocket_pc(); //defined in qguifunctions_wince.cpp
    72 
    76 
   312                 opt.setWrapMode(QTextOption::WrapAnywhere);
   316                 opt.setWrapMode(QTextOption::WrapAnywhere);
   313                 control->document()->setDefaultTextOption(opt);
   317                 control->document()->setDefaultTextOption(opt);
   314             }
   318             }
   315             width = hardLimit;
   319             width = hardLimit;
   316         }
   320         }
       
   321     }
   317 #ifdef Q_WS_S60
   322 #ifdef Q_WS_S60
   318         // in S60 portait messageBoxes should always occupy maximum width
   323         // in S60 portait messageBoxes should always occupy maximum width
   319         if (QApplication::desktop()->size().height() > QApplication::desktop()->size().width()){
   324         if (QApplication::desktop()->size().height() > QApplication::desktop()->size().width()){
   320             width = hardLimit;
   325             width = hardLimit;
   321         } else {
   326         } else {
   322             // in landscape the messageBoxes should be of same width as in portrait
   327             // in landscape the messageBoxes should be of same width as in portrait
   323             width = qMin(QApplication::desktop()->size().height(), hardLimit);
   328             width = qMin(QApplication::desktop()->size().height(), hardLimit);
   324         }
   329         }
   325 #endif
   330 #endif
   326     }
       
   327 
   331 
   328     if (informativeLabel) {
   332     if (informativeLabel) {
   329         label->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
   333         label->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
   330         QSizePolicy policy(QSizePolicy::Minimum, QSizePolicy::Preferred);
   334         QSizePolicy policy(QSizePolicy::Minimum, QSizePolicy::Preferred);
   331         policy.setHeightForWidth(true);
   335         policy.setHeightForWidth(true);
   351 
   355 
   352     layout->activate();
   356     layout->activate();
   353     int height = (layout->hasHeightForWidth())
   357     int height = (layout->hasHeightForWidth())
   354                      ? layout->totalHeightForWidth(width)
   358                      ? layout->totalHeightForWidth(width)
   355                      : layout->totalMinimumSize().height();
   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     q->setFixedSize(width, height);
   370     q->setFixedSize(width, height);
   357     QCoreApplication::removePostedEvents(q, QEvent::LayoutRequest);
   371     QCoreApplication::removePostedEvents(q, QEvent::LayoutRequest);
   358 }
   372 }
   359 
   373 
   360 
   374