From: Alexey Chernobaev Date: Mon, 26 Mar 2018 15:58:53 +0000 (+0300) Subject: automatically detect the size of help window for charts (QWT) X-Git-Tag: submit/tizen/20180620.112952^2^2~45 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cb86ea342ab60abdd55133027a2fbcf3e1436fb4;p=sdk%2Ftools%2Fheaptrack.git automatically detect the size of help window for charts (QWT) --- diff --git a/src/analyze/gui/chartwidget.cpp b/src/analyze/gui/chartwidget.cpp index 95baca7..1d29485 100644 --- a/src/analyze/gui/chartwidget.cpp +++ b/src/analyze/gui/chartwidget.cpp @@ -35,6 +35,7 @@ #include #include #elif defined(QWT_FOUND) +#include #include #include #include @@ -97,9 +98,6 @@ public: setWindowFlags(Qt::Tool); setAttribute(Qt::WA_ShowWithoutActivating); setAttribute(Qt::WA_DeleteOnClose); - setGeometry(0, 0, 292, 164); - setMinimumSize(100, 70); - setMaximumSize(400, 280); setPalette(QToolTip::palette()); setWindowOpacity(0.9); setAutoFillBackground(true); @@ -108,7 +106,7 @@ public: textEdit->setContextMenuPolicy(Qt::NoContextMenu); textEdit->viewport()->setAutoFillBackground(false); setCentralWidget(textEdit); - textEdit->setHtml( + const auto text = "

Use Context Menu (right click inside the chart to open) to control different chart options.

" \ "

Use left mouse button to zoom in to selection: press the button, drag " \ "to make a rectangular selection, release.

" \ @@ -117,7 +115,15 @@ public: "
  • zoom out (one step back) - <Shift>+click;" \ "
  • reset zoom - <Ctrl>+click;" \ "
  • move (pan) the chart - <Alt>+drag." \ - ""); + ""; + textEdit->setHtml(text); + QFontMetrics fm(textEdit->font()); + QRect rect = fm.boundingRect("Use left mouse button to zoom in to selection: press the "); + int textWidth = std::max(292, (int)round(rect.width() * 1.03)); + int textHeight = std::max(164, (int)round(rect.height() * 1.03 * 12)); + setGeometry(0, 0, textWidth, textHeight); + setMinimumSize(120, 80); + setMaximumSize(std::max(400, textWidth * 2), std::max(280, textHeight * 2)); } virtual ~HelpWidget()