Changeset 6166 for trunk/qt4-gui/src/widgets
- Timestamp:
- 04/22/08 04:18:22 (7 months ago)
- Location:
- trunk/qt4-gui/src/widgets
- Files:
-
- 2 modified
-
mlview.cpp (modified) (3 diffs)
-
mlview.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/qt4-gui/src/widgets/mlview.cpp
r6160 r6166 34 34 35 35 #include "config/emoticons.h" 36 #include "config/general.h" 36 37 #include "core/licqgui.h" 37 38 … … 46 47 setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); 47 48 connect(this, SIGNAL(selectionChanged()), SLOT(slotCopy())); 49 50 updateFont(); 51 connect(Config::General::instance(), SIGNAL(fontChanged()), SLOT(updateFont())); 48 52 } 49 53 … … 358 362 return textCursor().selectedText(); 359 363 } 364 365 void MLView::updateFont() 366 { 367 setFont(Config::General::instance()->editFont()); 368 369 // Get height of current font 370 myFontHeight = fontMetrics().height(); 371 372 // Set minimum height of text area to one line of text. 373 setMinimumHeight(heightForLines(1)); 374 } 375 376 int MLView::heightForLines(int lines) const 377 { 378 // We need to add frame width and the added height of the scroll area as 379 // we're calculating height for the widget, not the viewport. 380 return lines*myFontHeight + height() - viewport()->height() + 2 * frameWidth(); 381 } 382 383 void MLView::setSizeHintLines(int lines) 384 { 385 myLinesHint = lines; 386 } 387 388 QSize MLView::sizeHint() const 389 { 390 QSize s = QTextBrowser::sizeHint(); 391 if (myLinesHint > 0) 392 s.setHeight(heightForLines(myLinesHint)); 393 return s; 394 } -
trunk/qt4-gui/src/widgets/mlview.h
r6160 r6166 46 46 static QString toRichText(const QString& s, bool highlightURLs = false, bool useHTML = false, QRegExp highlight = QRegExp()); 47 47 48 /** 49 * Caclulate height for widget to fit a specified number of lines with 50 * current font 51 * 52 * @param lines Number of text lines to calculate for 53 * @return Widget height in pixels 54 */ 55 int heightForLines(int lines) const; 56 57 /** 58 * Set size hint as number of lines of text 59 * 60 * @param lines Lines of text that should be visible 61 */ 62 void setSizeHintLines(int lines); 63 64 /** 65 * Get recommended widget size 66 * 67 * @return Recommended size 68 */ 69 QSize sizeHint() const; 70 48 71 protected: 49 72 virtual void contextMenuEvent(QContextMenuEvent* event); … … 56 79 void slotCopyUrl(); 57 80 void makeQuote(); 81 void updateFont(); 58 82 59 83 private: 60 84 bool m_handleLinks; 61 85 QString m_url; 86 int myFontHeight; 87 int myLinesHint; 62 88 63 89 signals:
