#include <KChartHeaderFooter>
#include <KChartLegend>
#elif defined(QWT_FOUND)
+#include <algorithm>
#include <QAction>
#include <QContextMenuEvent>
#include <QMenu>
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);
textEdit->setContextMenuPolicy(Qt::NoContextMenu);
textEdit->viewport()->setAutoFillBackground(false);
setCentralWidget(textEdit);
- textEdit->setHtml(
+ const auto text =
"<p>Use <u>Context Menu</u> (right click inside the chart to open) to control different chart options.</p>" \
"<p>Use <u>left mouse button</u> to <b>zoom in</b> to selection: press the button, drag " \
"to make a rectangular selection, release.</p>" \
"<li><b>zoom out</b> (one step back) - <b><Shift></b>+click;" \
"<li><b>reset zoom</b> - <b><Ctrl></b>+click;" \
"<li><b>move (pan)</b> the chart - <b><Alt></b>+drag." \
- "</ul>");
+ "</ul>";
+ 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()