Changeset 561 for trunk/src/gui/widgets/qlabel.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
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/widgets/qlabel.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 63 63 \ingroup basicwidgets 64 \ingroup text65 \mainclass66 64 67 65 QLabel is used for displaying text or an image. No user … … 889 887 { 890 888 Q_D(QLabel); 891 d->sendControlEvent(ev); 889 if (d->control) { 890 d->sendControlEvent(ev); 891 QTextCursor cursor = d->control->textCursor(); 892 Qt::FocusReason reason = ev->reason(); 893 if (reason != Qt::ActiveWindowFocusReason 894 && reason != Qt::PopupFocusReason 895 && cursor.hasSelection()) { 896 cursor.clearSelection(); 897 d->control->setTextCursor(cursor); 898 } 899 } 900 892 901 QFrame::focusOutEvent(ev); 893 902 } … … 972 981 if (d->isTextLabel) { 973 982 QRectF lr = d->layoutRect(); 983 QStyleOption opt; 984 opt.initFrom(this); 985 #ifndef QT_NO_STYLE_STYLESHEET 986 if (QStyleSheetStyle* cssStyle = qobject_cast<QStyleSheetStyle*>(style)) { 987 cssStyle->styleSheetPalette(this, &opt, &opt.palette); 988 } 989 #endif 974 990 if (d->control) { 975 991 #ifndef QT_NO_SHORTCUT … … 985 1001 986 1002 QAbstractTextDocumentLayout::PaintContext context; 987 QStyleOption opt(0);988 opt.init(this);989 990 if (!isEnabled() &&style->styleHint(QStyle::SH_EtchDisabledText, &opt, this)) {991 context.palette = palette();1003 if (!isEnabled() && !d->control && 1004 // We cannot support etched for rich text controls because custom 1005 // colors and links will override the light palette 1006 style->styleHint(QStyle::SH_EtchDisabledText, &opt, this)) { 1007 context.palette = opt.palette; 992 1008 context.palette.setColor(QPalette::Text, context.palette.light().color()); 993 1009 painter.save(); … … 1000 1016 1001 1017 // Adjust the palette 1002 context.palette = palette(); 1003 #ifndef QT_NO_STYLE_STYLESHEET 1004 if (QStyleSheetStyle* cssStyle = qobject_cast<QStyleSheetStyle*>(style)) { 1005 cssStyle->focusPalette(this, &opt, &context.palette); 1006 } 1007 #endif 1018 context.palette = opt.palette; 1008 1019 1009 1020 if (foregroundRole() != QPalette::Text && isEnabled()) … … 1020 1031 if (d->hasShortcut) { 1021 1032 flags |= Qt::TextShowMnemonic; 1022 QStyleOption opt;1023 opt.initFrom(this);1024 1033 if (!style->styleHint(QStyle::SH_UnderlineShortcut, &opt, this)) 1025 1034 flags |= Qt::TextHideMnemonic; 1026 1035 } 1027 style->drawItemText(&painter, lr.toRect(), flags, palette(), isEnabled(), d->text, foregroundRole());1036 style->drawItemText(&painter, lr.toRect(), flags, opt.palette, isEnabled(), d->text, foregroundRole()); 1028 1037 } 1029 1038 } else … … 1162 1171 hasShortcut = false; 1163 1172 1164 if (control) { 1165 ensureTextPopulated(); 1166 // Underline the first character that follows an ampersand 1167 shortcutCursor = control->document()->find(QLatin1String("&")); 1168 if (shortcutCursor.isNull()) 1169 return; 1170 hasShortcut = true; 1171 shortcutId = q->grabShortcut(QKeySequence::mnemonic(text)); 1172 shortcutCursor.deleteChar(); // remove the ampersand 1173 shortcutCursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor); 1174 } else { 1175 if (!text.contains(QLatin1String("&"))) 1176 return; 1177 hasShortcut = true; 1178 shortcutId = q->grabShortcut(QKeySequence::mnemonic(text)); 1179 } 1173 if (!text.contains(QLatin1Char('&'))) 1174 return; 1175 hasShortcut = true; 1176 shortcutId = q->grabShortcut(QKeySequence::mnemonic(text)); 1180 1177 } 1181 1178 … … 1448 1445 #endif 1449 1446 doc->setUndoRedoEnabled(false); 1447 1448 #ifndef QT_NO_SHORTCUT 1449 if (hasShortcut) { 1450 // Underline the first character that follows an ampersand (and remove the others ampersands) 1451 int from = 0; 1452 bool found = false; 1453 QTextCursor cursor; 1454 while (!(cursor = control->document()->find((QLatin1String("&")), from)).isNull()) { 1455 cursor.deleteChar(); // remove the ampersand 1456 cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor); 1457 from = cursor.position(); 1458 if (!found && cursor.selectedText() != QLatin1String("&")) { //not a second & 1459 found = true; 1460 shortcutCursor = cursor; 1461 } 1462 } 1463 } 1464 #endif 1450 1465 } 1451 1466 }
Note:
See TracChangeset
for help on using the changeset viewer.