QIcon ManhattanStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const { QIcon icon; switch (standardIcon) { case QStyle::SP_TitleBarCloseButton: case QStyle::SP_ToolBarHorizontalExtensionButton: return QIcon(standardPixmap(standardIcon, option, widget)); default: icon = d->style->standardIcon(standardIcon, option, widget); } return icon; }
/** * See QMessageBox for details. */ QIMessageBox::QIMessageBox (const QString &aCaption, const QString &aText, Icon aIcon, int aButton0, int aButton1, int aButton2, QWidget *aParent, const char *aName, bool aModal) : QIDialog (aParent) , mText (aText) , mDetailsIndex (-1) , mWasDone (false) , mWasPolished (false) { #ifdef Q_WS_MAC /* No sheets in another mode than normal for now. Firstly it looks ugly and * secondly in some cases it is broken. */ if (vboxGlobal().isSheetWindowsAllowed(aParent)) setWindowFlags(Qt::Sheet); #endif /* Q_WS_MAC */ setWindowTitle (aCaption); /* Necessary to later find some of the message boxes */ setObjectName (aName); setModal (aModal); mButton0 = aButton0; mButton1 = aButton1; mButton2 = aButton2; QVBoxLayout *layout = new QVBoxLayout (this); #ifdef Q_WS_MAC layout->setContentsMargins (40, 11, 40, 11); #else /* !Q_WS_MAC */ VBoxGlobal::setLayoutMargin (layout, 11); #endif /* !Q_WS_MAC */ layout->setSpacing (10); layout->setSizeConstraint (QLayout::SetMinimumSize); QWidget *main = new QWidget(); QHBoxLayout *hLayout = new QHBoxLayout (main); VBoxGlobal::setLayoutMargin (hLayout, 0); hLayout->setSpacing (10); layout->addWidget (main); mIconLabel = new QLabel(); mIconLabel->setPixmap (standardPixmap (aIcon)); mIconLabel->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Minimum); mIconLabel->setAlignment (Qt::AlignHCenter | Qt::AlignTop); hLayout->addWidget (mIconLabel); QVBoxLayout* messageVBoxLayout = new QVBoxLayout(); VBoxGlobal::setLayoutMargin (messageVBoxLayout, 0); messageVBoxLayout->setSpacing (10); hLayout->addLayout (messageVBoxLayout); mTextLabel = new QILabel (aText); mTextLabel->setAlignment (Qt::AlignLeft | Qt::AlignTop); mTextLabel->setWordWrap (true); QSizePolicy sp (QSizePolicy::Minimum, QSizePolicy::Minimum); sp.setHeightForWidth (true); mTextLabel->setSizePolicy (sp); messageVBoxLayout->addWidget (mTextLabel); mFlagCB_Main = new QCheckBox(); mFlagCB_Main->hide(); messageVBoxLayout->addWidget (mFlagCB_Main); mDetailsVBox = new QWidget(); layout->addWidget (mDetailsVBox); QVBoxLayout* detailsVBoxLayout = new QVBoxLayout (mDetailsVBox); VBoxGlobal::setLayoutMargin (detailsVBoxLayout, 0); detailsVBoxLayout->setSpacing (10); mDetailsText = new QTextEdit(); { /* Calculate the minimum size dynamically, approx. * for 40 chars, 4 lines & 2 <table> margins */ QFontMetrics fm = mDetailsText->fontMetrics(); mDetailsText->setMinimumSize (fm.width ('m') * 40, fm.lineSpacing() * 4 + 4 * 2); } mDetailsText->setReadOnly (true); mDetailsText->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::MinimumExpanding); mDetailsSplitter = new QIArrowSplitter (mDetailsText); connect (mDetailsSplitter, SIGNAL (showBackDetails()), this, SLOT (detailsBack())); connect (mDetailsSplitter, SIGNAL (showNextDetails()), this, SLOT (detailsNext())); detailsVBoxLayout->addWidget (mDetailsSplitter); mFlagCB_Details = new QCheckBox(); mFlagCB_Details->hide(); detailsVBoxLayout->addWidget (mFlagCB_Details); mSpacer = new QSpacerItem (0, 0); layout->addItem (mSpacer); mButtonBox = new QIDialogButtonBox; mButtonBox->setCenterButtons (true); layout->addWidget (mButtonBox); mButtonEsc = 0; mButton0PB = createButton (aButton0); if (mButton0PB) connect (mButton0PB, SIGNAL (clicked()), SLOT (done0())); mButton1PB = createButton (aButton1); if (mButton1PB) connect (mButton1PB, SIGNAL (clicked()), SLOT (done1())); mButton2PB = createButton (aButton2); if (mButton2PB) connect (mButton2PB, SIGNAL (clicked()), SLOT (done2())); /* If this is an error message add an "Copy to clipboard" button for easier * bug reports. */ if (aIcon == QIMessageBox::Critical) { QPushButton *pCopyButton = createButton(Copy); pCopyButton->setToolTip(tr("Copy all errors to the clipboard")); connect(pCopyButton, SIGNAL(clicked()), SLOT(copy())); } /* this call is a must -- it initializes mFlagCB and mSpacer */ setDetailsShown (false); }
void DarkStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const { switch (control) { #if 0 case CC_TitleBar: if (const QStyleOptionTitleBar *titleBar = qstyleoption_cast<const QStyleOptionTitleBar *>(option)) { painter->save(); bool active = (titleBar->titleBarState & State_Active); QRect fullRect = titleBar->rect; // ### use palette colors instead //QColor titleBarGradientStart(active ? 0x3b508a : 0x6e6e6e); //QColor titleBarGradientStop(active ? 0x5d6e9e : 0x818181); //QColor titleBarFrameBorder(0x393939); //QColor titleBarAlphaCorner(active ? 0x4b5e7f : 0x6a6a6a); //QColor titleBarInnerTopLine(active ? 0x8e98ba : 0xa4a4a4); //QColor titleBarInnerInnerTopLine(active ? 0x57699b : 0x808080); //QColor leftCorner(active ? 0x6f7ea8 : 0x8e8e8e); //QColor rightCorner(active ? 0x44537d : 0x676767); QColor textColor(active ? 0x282e40 : 0x282e40); QColor textAlphaColor(active ? 0x3f4862 : 0x3f4862); // max button if ((titleBar->subControls & SC_TitleBarMaxButton) && (titleBar->titleBarFlags & Qt::WindowMaximizeButtonHint) && !(titleBar->titleBarState & Qt::WindowMaximized)) { bool hover = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_MouseOver); bool sunken = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_Sunken); QRect maxButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarMaxButton, widget); QImage image(Maximize_xpm); //qt_plastique_draw_mdibutton(painter, titleBar, maxButtonRect, hover, sunken); painter->drawImage(maxButtonRect, image); //int xoffset = maxButtonRect.width() / 3; //int yoffset = maxButtonRect.height() / 3; //QRect maxButtonIconRect(maxButtonRect.left() + xoffset, maxButtonRect.top() + yoffset, // maxButtonRect.width() - xoffset * 2, maxButtonRect.height() - yoffset * 2); //painter->setPen(textColor); //painter->drawRect(maxButtonIconRect.adjusted(0, 0, -1, -1)); //painter->drawLine(maxButtonIconRect.left() + 1, maxButtonIconRect.top() + 1, // maxButtonIconRect.right() - 1, maxButtonIconRect.top() + 1); //painter->setPen(textAlphaColor); //const QPoint points[4] = { // maxButtonIconRect.topLeft(), maxButtonIconRect.topRight(), // maxButtonIconRect.bottomLeft(), maxButtonIconRect.bottomRight() }; //painter->drawPoints(points, 4); } // close button if (titleBar->subControls & SC_TitleBarCloseButton && titleBar->titleBarFlags & Qt::WindowSystemMenuHint) { bool hover = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_MouseOver); bool sunken = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_Sunken); QRect closeButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarCloseButton, widget); QImage image(Office2007_FrameCaptionClose23_xpm); //qt_plastique_draw_mdibutton(painter, titleBar, closeButtonRect, hover, sunken); painter->drawImage(closeButtonRect, image); //int xoffset = closeButtonRect.width() / 3; //int yoffset = closeButtonRect.height() / 3; //QRect closeIconRect(closeButtonRect.left() + xoffset, closeButtonRect.top() + yoffset, // closeButtonRect.width() - xoffset * 2, closeButtonRect.height() - yoffset * 2); //painter->setPen(textAlphaColor); //{ // const QLine lines[4] = { // QLine(closeIconRect.left() + 1, closeIconRect.top(), // closeIconRect.right(), closeIconRect.bottom() - 1), // QLine(closeIconRect.left(), closeIconRect.top() + 1, // closeIconRect.right() - 1, closeIconRect.bottom()), // QLine(closeIconRect.right() - 1, closeIconRect.top(), // closeIconRect.left(), closeIconRect.bottom() - 1), // QLine(closeIconRect.right(), closeIconRect.top() + 1, // closeIconRect.left() + 1, closeIconRect.bottom()) }; // painter->drawLines(lines, 4); // const QPoint points[4] = { // closeIconRect.topLeft(), closeIconRect.topRight(), // closeIconRect.bottomLeft(), closeIconRect.bottomRight() }; // painter->drawPoints(points, 4); //} //painter->setPen(textColor); //{ // const QLine lines[2] = { // QLine(closeIconRect.left() + 1, closeIconRect.top() + 1, // closeIconRect.right() - 1, closeIconRect.bottom() - 1), // QLine(closeIconRect.left() + 1, closeIconRect.bottom() - 1, // closeIconRect.right() - 1, closeIconRect.top() + 1) }; // painter->drawLines(lines, 2); //} } // from qwindowsstyle.cpp if ((titleBar->subControls & SC_TitleBarSysMenu) && (titleBar->titleBarFlags & Qt::WindowSystemMenuHint)) { bool hover = (titleBar->activeSubControls & SC_TitleBarSysMenu) && (titleBar->state & State_MouseOver); bool sunken = (titleBar->activeSubControls & SC_TitleBarSysMenu) && (titleBar->state & State_Sunken); QRect iconRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarSysMenu, widget); if (hover) qt_plastique_draw_mdibutton(painter, titleBar, iconRect, hover, sunken); if (!titleBar->icon.isNull()) { titleBar->icon.paint(painter, iconRect); } else { QStyleOption tool(0); tool.palette = titleBar->palette; QPixmap pm = standardPixmap(SP_TitleBarMenuButton, &tool, widget); tool.rect = iconRect; painter->save(); drawItemPixmap(painter, iconRect, Qt::AlignCenter, pm); painter->restore(); } } painter->restore(); } break; #endif default: QPlastiqueStyle::drawComplexControl(control, option, painter, widget); break; } }