--- /dev/null
+#include "charthelpwindow.h"
+#include "chartwidget.h"
+
+#include <QTextEdit>
+#include <QToolTip>
+
+ChartHelpWindow::ChartHelpWindow(QWidget *parent) :
+ QMainWindow(parent)
+{
+ setWindowTitle("Chart Help");
+ setWindowFlags(Qt::Tool);
+ setAttribute(Qt::WA_ShowWithoutActivating);
+ setAttribute(Qt::WA_DeleteOnClose);
+ setPalette(QToolTip::palette());
+ setWindowOpacity(0.9);
+ setAutoFillBackground(true);
+ auto textEdit = new QTextEdit(this);
+ textEdit->setReadOnly(true);
+ textEdit->setContextMenuPolicy(Qt::NoContextMenu);
+ textEdit->viewport()->setAutoFillBackground(false);
+ setCentralWidget(textEdit);
+ 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>" \
+ "<p>Use <u>left mouse button</u> with modifier keys to:</p>" \
+ "<ul>" \
+ "<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>";
+ 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));
+}
+
+ChartHelpWindow::~ChartHelpWindow()
+{
+ ChartWidget::HelpWindow = nullptr;
+}
+
+void ChartHelpWindow::closeEvent(QCloseEvent *event)
+{
+ QMainWindow::closeEvent(event);
+ ChartOptions::GlobalOptions = ChartOptions::setOption(ChartOptions::GlobalOptions, ChartOptions::ShowHelp, false);
+}
--- /dev/null
+#ifndef HELPWIDGET_H
+#define HELPWIDGET_H
+
+#include <QMainWindow>
+#include <QWidget>
+
+class ChartHelpWindow: public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ explicit ChartHelpWindow(QWidget *parent = 0);
+ ~ChartHelpWindow();
+
+protected:
+ virtual void closeEvent(QCloseEvent *event) override;
+};
+
+#endif // HELPWIDGET_H
#include "chartwidget.h"
#include <QMainWindow>
-#include <QTextEdit>
-#include <QToolTip>
#include <QVBoxLayout>
#if defined(KChart_FOUND)
#include <KChartHeaderFooter>
#include <KChartLegend>
#elif defined(QWT_FOUND)
+#include "charthelpwindow.h"
+
#include <algorithm>
#include <math.h>
#include <QAction>
};
}
#elif defined(QWT_FOUND)
-class HelpWidget : public QMainWindow
-{
- Q_OBJECT
-public:
- explicit HelpWidget(QWidget *parent) : QMainWindow(parent)
- {
- setWindowTitle("Chart Help");
- setWindowFlags(Qt::Tool);
- setAttribute(Qt::WA_ShowWithoutActivating);
- setAttribute(Qt::WA_DeleteOnClose);
- setPalette(QToolTip::palette());
- setWindowOpacity(0.9);
- setAutoFillBackground(true);
- auto textEdit = new QTextEdit(this);
- textEdit->setReadOnly(true);
- textEdit->setContextMenuPolicy(Qt::NoContextMenu);
- textEdit->viewport()->setAutoFillBackground(false);
- setCentralWidget(textEdit);
- 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>" \
- "<p>Use <u>left mouse button</u> with modifier keys to:</p>" \
- "<ul>" \
- "<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>";
- 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()
- {
- ChartWidget::HelpWindow = nullptr;
- }
-protected:
- virtual void closeEvent(QCloseEvent *event) override
- {
- QMainWindow::closeEvent(event);
- ChartOptions::GlobalOptions = ChartOptions::setOption(ChartOptions::GlobalOptions, ChartOptions::ShowHelp, false);
- }
-};
-
QWidget* ChartWidget::HelpWindow;
QWidget* ChartWidget::MainWindow;
#endif // QWT_FOUND
{
if (HelpWindow == nullptr)
{
- HelpWindow = new HelpWidget(MainWindow);
+ HelpWindow = new ChartHelpWindow(MainWindow);
QPoint p = mapToGlobal(pos());
HelpWindow->move(p.x() + 32, p.y() + 32);
}
}
#endif // QWT_FOUND
-#include "chartwidget.moc"
+// seems it's not needed; causes build errors in some environments
+// (e.g. Qt 5.11.0 MSVC2017 64bit, Release build only)
+//#include "chartwidget.moc"
}
#endif // QWT_FOUND
-#include "histogramwidget.moc"
+// seems it's not needed; causes build errors in some environments
+// (e.g. Qt 5.11.0 MSVC2017 64bit, Release build only)
+//#include "histogramwidget.moc"
QWT_CHART {
SOURCES += \
+ analyze/gui/charthelpwindow.cpp \
analyze/gui/chartmodel2qwtseriesdata.cpp \
analyze/gui/chartwidgetqwtplot.cpp \
analyze/gui/contextmenuqwt.cpp \
analyze/gui/histogramwidgetqwtplot.cpp
HEADERS += \
+ analyze/gui/charthelpwindow.h \
analyze/gui/chartmodel2qwtseriesdata.h \
analyze/gui/chartwidgetqwtplot.h \
analyze/gui/contextmenuqwt.h \