Refactoring. Move pointer to mouse position label to "no GUI" class.
* * * Fix crash. Access to null pointer. --HG-- branch : develop
This commit is contained in:
parent
37a113abd6
commit
5ed2134a29
|
@ -160,7 +160,7 @@ QVector<DetailForLayout> SortDetailsForLayout(const QHash<quint32, VPiece> *allD
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
:MainWindowsNoGUI(parent), ui(new Ui::MainWindow), watcher(new QFileSystemWatcher(this)), currentTool(Tool::Arrow),
|
:MainWindowsNoGUI(parent), ui(new Ui::MainWindow), watcher(new QFileSystemWatcher(this)), currentTool(Tool::Arrow),
|
||||||
lastUsedTool(Tool::Arrow), sceneDraw(nullptr), sceneDetails(nullptr),
|
lastUsedTool(Tool::Arrow), sceneDraw(nullptr), sceneDetails(nullptr),
|
||||||
mouseCoordinate(nullptr), isInitialized(false), mChanges(false), mChangesAsked(true),
|
isInitialized(false), mChanges(false), mChangesAsked(true),
|
||||||
patternReadOnly(false),
|
patternReadOnly(false),
|
||||||
dialogTable(nullptr),
|
dialogTable(nullptr),
|
||||||
dialogTool(),
|
dialogTool(),
|
||||||
|
@ -1894,10 +1894,6 @@ void MainWindow::OpenAt(QAction *where)
|
||||||
void MainWindow::ToolBarOption()
|
void MainWindow::ToolBarOption()
|
||||||
{
|
{
|
||||||
ui->toolBarOption->clear();
|
ui->toolBarOption->clear();
|
||||||
if (not mouseCoordinate.isNull())
|
|
||||||
{
|
|
||||||
delete mouseCoordinate;
|
|
||||||
}
|
|
||||||
if (not gradationHeights.isNull())
|
if (not gradationHeights.isNull())
|
||||||
{
|
{
|
||||||
delete gradationHeights;
|
delete gradationHeights;
|
||||||
|
@ -1962,8 +1958,8 @@ void MainWindow::ToolBarOption()
|
||||||
|
|
||||||
ui->toolBarOption->addSeparator();
|
ui->toolBarOption->addSeparator();
|
||||||
|
|
||||||
mouseCoordinate = new QLabel(QString("0, 0 (%1)").arg(UnitsToStr(qApp->patternUnit(), true)));
|
m_mouseCoordinate = new QLabel(QString("0, 0 (%1)").arg(UnitsToStr(qApp->patternUnit(), true)));
|
||||||
ui->toolBarOption->addWidget(mouseCoordinate);
|
ui->toolBarOption->addWidget(m_mouseCoordinate);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -2136,12 +2132,12 @@ void MainWindow::InitToolButtons()
|
||||||
*/
|
*/
|
||||||
void MainWindow::MouseMove(const QPointF &scenePos)
|
void MainWindow::MouseMove(const QPointF &scenePos)
|
||||||
{
|
{
|
||||||
if (mouseCoordinate)
|
if (not m_mouseCoordinate.isNull())
|
||||||
{
|
{
|
||||||
//: Coords in status line: "X, Y (units)"
|
//: Coords in status line: "X, Y (units)"
|
||||||
mouseCoordinate->setText(QString("%1, %2 (%3)").arg(static_cast<qint32>(qApp->fromPixel(scenePos.x())))
|
m_mouseCoordinate->setText(QString("%1, %2 (%3)").arg(static_cast<qint32>(qApp->fromPixel(scenePos.x())))
|
||||||
.arg(static_cast<qint32>(qApp->fromPixel(scenePos.y())))
|
.arg(static_cast<qint32>(qApp->fromPixel(scenePos.y())))
|
||||||
.arg(UnitsToStr(qApp->patternUnit(), true)));
|
.arg(UnitsToStr(qApp->patternUnit(), true)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2673,7 +2669,10 @@ void MainWindow::ActionLayout(bool checked)
|
||||||
SetEnableWidgets(true);
|
SetEnableWidgets(true);
|
||||||
ui->toolBox->setCurrentIndex(ui->toolBox->indexOf(ui->layoutPage));
|
ui->toolBox->setCurrentIndex(ui->toolBox->indexOf(ui->layoutPage));
|
||||||
|
|
||||||
mouseCoordinate->setText(QString());
|
if (not m_mouseCoordinate.isNull())
|
||||||
|
{
|
||||||
|
m_mouseCoordinate->setText(QString());
|
||||||
|
}
|
||||||
|
|
||||||
if (qApp->patternType() == MeasurementsType::Multisize)
|
if (qApp->patternType() == MeasurementsType::Multisize)
|
||||||
{
|
{
|
||||||
|
@ -3463,8 +3462,8 @@ void MainWindow::on_actionNew_triggered()
|
||||||
|
|
||||||
AddPP(patternPieceName);
|
AddPP(patternPieceName);
|
||||||
|
|
||||||
mouseCoordinate = new QLabel(QString("0, 0 (%1)").arg(UnitsToStr(qApp->patternUnit(), true)));
|
m_mouseCoordinate = new QLabel(QString("0, 0 (%1)").arg(UnitsToStr(qApp->patternUnit(), true)));
|
||||||
ui->toolBarOption->addWidget(mouseCoordinate);
|
ui->toolBarOption->addWidget(m_mouseCoordinate);
|
||||||
|
|
||||||
m_curFileFormatVersion = VPatternConverter::PatternMaxVer;
|
m_curFileFormatVersion = VPatternConverter::PatternMaxVer;
|
||||||
m_curFileFormatVersionStr = VPatternConverter::PatternMaxVerStr;
|
m_curFileFormatVersionStr = VPatternConverter::PatternMaxVerStr;
|
||||||
|
|
|
@ -225,9 +225,6 @@ private:
|
||||||
/** @brief sceneDetails details scene. */
|
/** @brief sceneDetails details scene. */
|
||||||
VMainGraphicsScene *sceneDetails;
|
VMainGraphicsScene *sceneDetails;
|
||||||
|
|
||||||
/** @brief mouseCoordinate pointer to label who show mouse coordinate. */
|
|
||||||
QPointer<QLabel> mouseCoordinate;
|
|
||||||
|
|
||||||
/** @brief isInitialized true after first show window. */
|
/** @brief isInitialized true after first show window. */
|
||||||
bool isInitialized;
|
bool isInitialized;
|
||||||
|
|
||||||
|
|
|
@ -134,6 +134,7 @@ MainWindowsNoGUI::MainWindowsNoGUI(QWidget *parent)
|
||||||
margins(),
|
margins(),
|
||||||
paperSize(),
|
paperSize(),
|
||||||
m_dialogSaveLayout(),
|
m_dialogSaveLayout(),
|
||||||
|
m_mouseCoordinate(),
|
||||||
#if defined(Q_OS_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
|
#if defined(Q_OS_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
|
||||||
m_taskbarButton(new QWinTaskbarButton(this)),
|
m_taskbarButton(new QWinTaskbarButton(this)),
|
||||||
m_taskbarProgress(nullptr),
|
m_taskbarProgress(nullptr),
|
||||||
|
@ -155,6 +156,7 @@ MainWindowsNoGUI::MainWindowsNoGUI(QWidget *parent)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
MainWindowsNoGUI::~MainWindowsNoGUI()
|
MainWindowsNoGUI::~MainWindowsNoGUI()
|
||||||
{
|
{
|
||||||
|
delete m_mouseCoordinate;
|
||||||
delete tempSceneLayout;
|
delete tempSceneLayout;
|
||||||
delete pattern;
|
delete pattern;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,9 @@
|
||||||
#ifndef MAINWINDOWSNOGUI_H
|
#ifndef MAINWINDOWSNOGUI_H
|
||||||
#define MAINWINDOWSNOGUI_H
|
#define MAINWINDOWSNOGUI_H
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
#include <QPointer>
|
||||||
#include <QPrinter>
|
#include <QPrinter>
|
||||||
|
|
||||||
#include "../vlayout/vlayoutpiece.h"
|
#include "../vlayout/vlayoutpiece.h"
|
||||||
|
@ -114,6 +116,9 @@ protected:
|
||||||
|
|
||||||
QSharedPointer<DialogSaveLayout> m_dialogSaveLayout;
|
QSharedPointer<DialogSaveLayout> m_dialogSaveLayout;
|
||||||
|
|
||||||
|
/** @brief mouseCoordinate pointer to label who show mouse coordinate. */
|
||||||
|
QPointer<QLabel> m_mouseCoordinate;
|
||||||
|
|
||||||
#if defined(Q_OS_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
|
#if defined(Q_OS_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
|
||||||
QWinTaskbarButton *m_taskbarButton;
|
QWinTaskbarButton *m_taskbarButton;
|
||||||
QWinTaskbarProgress *m_taskbarProgress;
|
QWinTaskbarProgress *m_taskbarProgress;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user