Changeset 6064
- Timestamp:
- 02/20/08 04:08:08 (7 months ago)
- Location:
- branches/qt-gui_qt4/src
- Files:
-
- 3 modified
-
userevents/usersendcommon.cpp (modified) (2 diffs)
-
widgets/mledit.cpp (modified) (2 diffs)
-
widgets/mledit.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/qt-gui_qt4/src/userevents/usersendcommon.cpp
r6048 r6064 423 423 424 424 mleSend = new MLEdit(true, bottom, true); 425 mleSend->setSizeHintLines(3); 425 426 mleSend->setCheckSpellingEnabled(Config::Chat::instance()->checkSpelling()); 426 427 mleSend->installEventFilter(this); // Enables send with enter … … 453 454 splView->setStretchFactor(splView->indexOf(mleHistory), 1); 454 455 splView->setStretchFactor(splView->indexOf(bottom), 0); 455 splView->setSizes(QList<int>() << 1 << 100);456 456 457 457 connect(mleHistory, SIGNAL(quote(const QString&)), -
branches/qt-gui_qt4/src/widgets/mledit.cpp
r5892 r6064 35 35 : BaseClass(parent), 36 36 myFixSetTextNewlines(true), 37 myLastKeyWasReturn(false) 37 myLastKeyWasReturn(false), 38 myLinesHint(0) 38 39 { 39 40 setObjectName(name); … … 228 229 229 230 // Get height of current font 230 int textHeight = fontMetrics().height(); 231 232 // Set minimum height of text area to one line of text We need to 233 // add frame width and the added height of the scroll area as we're 234 // setting height on the widget, not the viewport 235 setMinimumHeight(textHeight + height() - viewport()->height() + 2 * frameWidth()); 231 myFontHeight = fontMetrics().height(); 232 233 // Set minimum height of text area to one line of text. 234 setMinimumHeight(heightForLines(1)); 235 } 236 237 int MLEdit::heightForLines(int lines) const 238 { 239 // We need to add frame width and the added height of the scroll area as 240 // we're calculating height for the widget, not the viewport. 241 return lines*myFontHeight + height() - viewport()->height() + 2 * frameWidth(); 242 } 243 244 void MLEdit::setSizeHintLines(int lines) 245 { 246 myLinesHint = lines; 247 } 248 249 QSize MLEdit::sizeHint() const 250 { 251 QSize s = BaseClass::sizeHint(); 252 if (myLinesHint > 0) 253 s.setHeight(heightForLines(myLinesHint)); 254 return s; 236 255 } 237 256 -
branches/qt-gui_qt4/src/widgets/mledit.h
r5580 r6064 67 67 bool checkSpellingEnabled() const; 68 68 69 /** 70 * Caclulate height for widget to fit a specified number of lines with 71 * current font 72 * 73 * @param lines Number of text lines to calculate for 74 * @return Widget height in pixels 75 */ 76 int heightForLines(int lines) const; 77 78 /** 79 * Set size hint as number of lines of text 80 * 81 * @param lines Lines of text that should be visible 82 */ 83 void setSizeHintLines(int lines); 84 85 /** 86 * Get recommended widget size 87 * 88 * @return Recommended size 89 */ 90 QSize sizeHint() const; 91 69 92 signals: 70 93 void ctrlEnterPressed(); … … 74 97 bool myFixSetTextNewlines; 75 98 bool myLastKeyWasReturn; 99 int myFontHeight; 100 int myLinesHint; 76 101 77 102 virtual void keyPressEvent(QKeyEvent* event);
