Review class VPMainWindow.
Setup initial state for a window. User must click New or Open before starting to use the window.
This commit is contained in:
parent
a0dba0ea25
commit
dc50d24439
|
@ -353,12 +353,18 @@ auto VPApplication::MainWindows() -> QList<VPMainWindow *>
|
|||
return list;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPMainWindow *VPApplication::NewMainWindow()
|
||||
{
|
||||
return NewMainWindow(VPCommandLinePtr());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VPApplication::NewMainWindow(const VPCommandLinePtr &cmd) -> VPMainWindow *
|
||||
{
|
||||
VPMainWindow *puzzle = new VPMainWindow(cmd);
|
||||
mainWindows.prepend(puzzle);
|
||||
if (cmd->IsGuiEnabled())
|
||||
if (not cmd->IsTestModeEnabled())
|
||||
{
|
||||
puzzle->show();
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ public:
|
|||
virtual bool IsAppInGUIMode() const override;
|
||||
VPMainWindow *MainWindow();
|
||||
QList<VPMainWindow*> MainWindows();
|
||||
VPMainWindow *NewMainWindow();
|
||||
VPMainWindow *NewMainWindow(const VPCommandLinePtr &cmd);
|
||||
|
||||
void InitOptions();
|
||||
|
|
|
@ -57,31 +57,31 @@ QT_WARNING_POP
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
VAbstractMainWindow(parent),
|
||||
ui(new Ui::VPMainWindow),
|
||||
m_cmd(cmd)
|
||||
{
|
||||
m_layout = new VPLayout();
|
||||
|
||||
// create a standard sheet
|
||||
VPSheet *sheet = new VPSheet(m_layout);
|
||||
auto *sheet = new VPSheet(m_layout);
|
||||
sheet->SetName(QObject::tr("Sheet 1"));
|
||||
m_layout->AddSheet(sheet);
|
||||
m_layout->SetFocusedSheet();
|
||||
|
||||
// ----- for test purposes, to be removed------------------
|
||||
sheet->SetSheetMarginsConverted(1, 1, 1, 1);
|
||||
sheet->SetSheetSizeConverted(84.1, 118.9);
|
||||
sheet->SetPiecesGapConverted(1);
|
||||
// // ----- for test purposes, to be removed------------------
|
||||
// sheet->SetSheetMarginsConverted(1, 1, 1, 1);
|
||||
// sheet->SetSheetSizeConverted(84.1, 118.9);
|
||||
// sheet->SetPiecesGapConverted(1);
|
||||
|
||||
m_layout->SetUnit(Unit::Cm);
|
||||
m_layout->SetWarningSuperpositionOfPieces(true);
|
||||
m_layout->SetTitle(QString("My Test Layout"));
|
||||
m_layout->SetDescription(QString("Description of my Layout"));
|
||||
// m_layout->SetUnit(Unit::Cm);
|
||||
// m_layout->SetWarningSuperpositionOfPieces(true);
|
||||
// m_layout->SetTitle(QString("My Test Layout"));
|
||||
// m_layout->SetDescription(QString("Description of my Layout"));
|
||||
|
||||
m_layout->SetTilesSizeConverted(21,29.7);
|
||||
m_layout->SetTilesOrientation(PageOrientation::Portrait);
|
||||
m_layout->SetTilesMarginsConverted(1,1,1,1);
|
||||
// m_layout->SetTilesSizeConverted(21,29.7);
|
||||
// m_layout->SetTilesOrientation(PageOrientation::Portrait);
|
||||
// m_layout->SetTilesMarginsConverted(1,1,1,1);
|
||||
// m_layout->SetShowTiles(true);
|
||||
|
||||
// --------------------------------------------------------
|
||||
|
@ -92,7 +92,7 @@ VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) :
|
|||
m_tileFactory = new VPTileFactory(m_layout, VPApplication::VApp()->Settings());
|
||||
m_tileFactory->refreshTileInfos();
|
||||
|
||||
InitMenuBar();
|
||||
SetupMenu();
|
||||
InitProperties();
|
||||
InitCarrousel();
|
||||
|
||||
|
@ -102,9 +102,16 @@ VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) :
|
|||
|
||||
SetPropertiesData();
|
||||
|
||||
UpdateWindowTitle();
|
||||
ReadSettings();
|
||||
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
// Mac OS Dock Menu
|
||||
QMenu *menu = new QMenu(this);
|
||||
connect(menu, &QMenu::aboutToShow, this, &VPMainWindow::AboutToShowDockMenu);
|
||||
AboutToShowDockMenu();
|
||||
menu->setAsDockMenu();
|
||||
#endif //defined(Q_OS_MAC)
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -232,13 +239,17 @@ VPPiece* VPMainWindow::CreatePiece(const VLayoutPiece &rawPiece)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPMainWindow::InitMenuBar()
|
||||
void VPMainWindow::SetupMenu()
|
||||
{
|
||||
// most of the actions are connected through name convention (auto-connection)
|
||||
|
||||
|
||||
// -------------------- connects the actions for the file menu
|
||||
ui->actionNew->setShortcuts(QKeySequence::New);
|
||||
ui->actionSave->setShortcuts(QKeySequence::Save);
|
||||
ui->actionSaveAs->setShortcuts(QKeySequence::SaveAs);
|
||||
|
||||
connect(ui->actionExit, &QAction::triggered, this, &VPMainWindow::close);
|
||||
ui->actionExit->setShortcuts(QKeySequence::Quit);
|
||||
|
||||
// -------------------- connects the actions for the edit menu
|
||||
// TODO : initialise the undo / redo
|
||||
|
@ -410,6 +421,7 @@ void VPMainWindow::InitPropertyTabLayout()
|
|||
void VPMainWindow::InitCarrousel()
|
||||
{
|
||||
m_carrousel = new VPCarrousel(m_layout, ui->dockWidgetCarrousel);
|
||||
m_carrousel->setDisabled(true);
|
||||
ui->dockWidgetCarrousel->setWidget(m_carrousel);
|
||||
|
||||
connect(ui->dockWidgetCarrousel, QOverload<Qt::DockWidgetArea>::of(&QDockWidget::dockLocationChanged), this,
|
||||
|
@ -578,6 +590,7 @@ void VPMainWindow::SetPropertyTabLayoutData()
|
|||
void VPMainWindow::InitMainGraphics()
|
||||
{
|
||||
m_graphicsView = new VPMainGraphicsView(m_layout, m_tileFactory, this);
|
||||
m_graphicsView->setDisabled(true);
|
||||
ui->centralWidget->layout()->addWidget(m_graphicsView);
|
||||
|
||||
m_graphicsView->RefreshLayout();
|
||||
|
@ -594,10 +607,7 @@ void VPMainWindow::InitZoomToolBar()
|
|||
delete m_doubleSpinBoxScale;
|
||||
}
|
||||
|
||||
if (m_mouseCoordinate != nullptr)
|
||||
{
|
||||
delete m_mouseCoordinate;
|
||||
}
|
||||
delete m_mouseCoordinate;
|
||||
|
||||
// connect the zoom buttons and shortcuts to the slots
|
||||
QList<QKeySequence> zoomInShortcuts;
|
||||
|
@ -625,12 +635,13 @@ void VPMainWindow::InitZoomToolBar()
|
|||
|
||||
// defined the scale
|
||||
ui->toolBarZoom->addSeparator();
|
||||
QLabel* zoomScale = new QLabel(tr("Scale:"), this);
|
||||
auto* zoomScale = new QLabel(tr("Scale:"), this);
|
||||
ui->toolBarZoom->addWidget(zoomScale);
|
||||
|
||||
m_doubleSpinBoxScale = new QDoubleSpinBox(this);
|
||||
m_doubleSpinBoxScale->setDecimals(1);
|
||||
m_doubleSpinBoxScale->setSuffix("%");
|
||||
m_doubleSpinBoxScale->setDisabled(true);
|
||||
on_ScaleChanged(m_graphicsView->transform().m11());
|
||||
connect(m_doubleSpinBoxScale.data(), QOverload<double>::of(&QDoubleSpinBox::valueChanged),
|
||||
this, [this](double d){m_graphicsView->Zoom(d/100.0);});
|
||||
|
@ -661,6 +672,62 @@ void VPMainWindow::SetCheckBoxValue(QCheckBox *checkbox, bool value)
|
|||
checkbox->blockSignals(false);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPMainWindow::UpdateWindowTitle()
|
||||
{
|
||||
QString showName;
|
||||
bool isFileWritable = true;
|
||||
if (not curFile.isEmpty())
|
||||
{
|
||||
#ifdef Q_OS_WIN32
|
||||
qt_ntfs_permission_lookup++; // turn checking on
|
||||
#endif /*Q_OS_WIN32*/
|
||||
isFileWritable = QFileInfo(curFile).isWritable();
|
||||
#ifdef Q_OS_WIN32
|
||||
qt_ntfs_permission_lookup--; // turn it off again
|
||||
#endif /*Q_OS_WIN32*/
|
||||
showName = StrippedName(curFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
showName = tr("untitled %1.vlt").arg(VPApplication::VApp()->MainWindows().size()+1);
|
||||
}
|
||||
|
||||
showName += QLatin1String("[*]");
|
||||
|
||||
if (lIsReadOnly || not isFileWritable)
|
||||
{
|
||||
showName += QStringLiteral(" (") + tr("read only") + QChar(')');
|
||||
}
|
||||
|
||||
setWindowTitle(showName);
|
||||
setWindowFilePath(curFile);
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
static QIcon fileIcon = QIcon(QCoreApplication::applicationDirPath() +
|
||||
QLatin1String("/../Resources/layout.icns"));
|
||||
QIcon icon;
|
||||
if (not curFile.isEmpty())
|
||||
{
|
||||
if (not isWindowModified())
|
||||
{
|
||||
icon = fileIcon;
|
||||
}
|
||||
else
|
||||
{
|
||||
static QIcon darkIcon;
|
||||
|
||||
if (darkIcon.isNull())
|
||||
{
|
||||
darkIcon = QIcon(darkenPixmap(fileIcon.pixmap(16, 16)));
|
||||
}
|
||||
icon = darkIcon;
|
||||
}
|
||||
}
|
||||
setWindowIcon(icon);
|
||||
#endif //defined(Q_OS_MAC)
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPMainWindow::ReadSettings()
|
||||
{
|
||||
|
@ -673,6 +740,9 @@ void VPMainWindow::ReadSettings()
|
|||
restoreState(settings->GetWindowState());
|
||||
restoreState(settings->GetToolbarsState(), APP_VERSION);
|
||||
|
||||
// Text under tool buton icon
|
||||
ToolBarStyles();
|
||||
|
||||
ui->dockWidgetProperties->setVisible(settings->IsDockWidgetPropertiesActive());
|
||||
ui->dockWidgetPropertiesContents->setVisible(settings->IsDockWidgetPropertiesContentsActive());
|
||||
|
||||
|
@ -828,6 +898,42 @@ void VPMainWindow::generateTiledPdf(QString fileName)
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPMainWindow::CreateWindowMenu(QMenu *menu)
|
||||
{
|
||||
SCASSERT(menu != nullptr)
|
||||
|
||||
QAction *action = menu->addAction(tr("&New Window"));
|
||||
connect(action, &QAction::triggered, this, []()
|
||||
{
|
||||
VPApplication::VApp()->NewMainWindow()->activateWindow();
|
||||
});
|
||||
action->setMenuRole(QAction::NoRole);
|
||||
menu->addSeparator();
|
||||
|
||||
const QList<VPMainWindow*> windows = VPApplication::VApp()->MainWindows();
|
||||
for (int i = 0; i < windows.count(); ++i)
|
||||
{
|
||||
VPMainWindow *window = windows.at(i);
|
||||
|
||||
QString title = QStringLiteral("%1. %2").arg(i+1).arg(window->windowTitle());
|
||||
const int index = title.lastIndexOf(QLatin1String("[*]"));
|
||||
if (index != -1)
|
||||
{
|
||||
window->isWindowModified() ? title.replace(index, 3, QChar('*')) : title.replace(index, 3, QString());
|
||||
}
|
||||
|
||||
QAction *action = menu->addAction(title, this, &VPMainWindow::ShowWindow);
|
||||
action->setData(i);
|
||||
action->setCheckable(true);
|
||||
action->setMenuRole(QAction::NoRole);
|
||||
if (window->isActiveWindow())
|
||||
{
|
||||
action->setChecked(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPMainWindow::on_actionNew_triggered()
|
||||
|
@ -868,6 +974,27 @@ void VPMainWindow::closeEvent(QCloseEvent *event)
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPMainWindow::changeEvent(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::LanguageChange)
|
||||
{
|
||||
WindowsLocale();
|
||||
|
||||
// retranslate designer form (single inheritance approach)
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
|
||||
// remember to call base class implementation
|
||||
QMainWindow::changeEvent(event);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QStringList VPMainWindow::RecentFileList() const
|
||||
{
|
||||
return VPApplication::VApp()->PuzzleSettings()->GetRecentFileList();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPMainWindow::on_actionOpen_triggered()
|
||||
{
|
||||
|
@ -1538,3 +1665,64 @@ void VPMainWindow::on_MouseMoved(const QPointF &scenePos)
|
|||
.arg(UnitsToStr(m_layout->GetUnit(), true)));
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPMainWindow::ShowWindow() const
|
||||
{
|
||||
if (auto *action = qobject_cast<QAction*>(sender()))
|
||||
{
|
||||
const QVariant v = action->data();
|
||||
if (v.canConvert<int>())
|
||||
{
|
||||
const int offset = qvariant_cast<int>(v);
|
||||
const QList<VPMainWindow*> windows = VPApplication::VApp()->MainWindows();
|
||||
windows.at(offset)->raise();
|
||||
windows.at(offset)->activateWindow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPMainWindow::Preferences()
|
||||
{
|
||||
// Calling constructor of the dialog take some time. Because of this user have time to call the dialog twice.
|
||||
// static QPointer<DialogPuzzlePreferences> guard;// Prevent any second run
|
||||
// if (guard.isNull())
|
||||
// {
|
||||
// QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
// auto *preferences = new DialogPuzzlePreferences(this);
|
||||
// // QScopedPointer needs to be sure any exception will never block guard
|
||||
// QScopedPointer<DialogPuzzlePreferences> dlg(preferences);
|
||||
// guard = preferences;
|
||||
// // Must be first
|
||||
// connect(dlg.data(), &DialogPuzzlePreferences::UpdateProperties, this, &VPMainWindow::WindowsLocale);
|
||||
// connect(dlg.data(), &DialogPuzzlePreferences::UpdateProperties, this, &VPMainWindow::ToolBarStyles);
|
||||
// QGuiApplication::restoreOverrideCursor();
|
||||
// dlg->exec();
|
||||
// }
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPMainWindow::ToolBarStyles()
|
||||
{
|
||||
ToolBarStyle(ui->mainToolBar);
|
||||
ToolBarStyle(ui->toolBarZoom);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#if defined(Q_OS_MAC)
|
||||
void VPMainWindow::AboutToShowDockMenu()
|
||||
{
|
||||
if (QMenu *menu = qobject_cast<QMenu *>(sender()))
|
||||
{
|
||||
menu->clear();
|
||||
CreateWindowMenu(menu);
|
||||
|
||||
menu->addSeparator();
|
||||
|
||||
QAction *actionPreferences = menu->addAction(tr("Preferences"));
|
||||
actionPreferences->setMenuRole(QAction::NoRole);
|
||||
connect(actionPreferences, &QAction::triggered, this, &VPMainWindow::Preferences);
|
||||
}
|
||||
}
|
||||
#endif //defined(Q_OS_MAC)
|
||||
|
|
|
@ -42,13 +42,14 @@
|
|||
#include "vptilefactory.h"
|
||||
#include "vpcommandline.h"
|
||||
#include "../vlayout/vlayoutdef.h"
|
||||
#include "../vwidgets/vabstractmainwindow.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class VPMainWindow;
|
||||
}
|
||||
|
||||
class VPMainWindow : public QMainWindow
|
||||
class VPMainWindow : public VAbstractMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -90,142 +91,9 @@ public slots:
|
|||
void on_actionNew_triggered();
|
||||
|
||||
protected:
|
||||
enum { MaxRecentFiles = 5 };
|
||||
|
||||
virtual void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VPMainWindow)
|
||||
Ui::VPMainWindow *ui;
|
||||
|
||||
VPCarrousel *m_carrousel{nullptr};
|
||||
VPMainGraphicsView *m_graphicsView{nullptr};
|
||||
|
||||
VPCommandLinePtr m_cmd;
|
||||
|
||||
VPLayout *m_layout{nullptr};
|
||||
QList<VPPiece *>m_selectedPieces{QList<VPPiece *>()};
|
||||
|
||||
VPTileFactory *m_tileFactory{nullptr};
|
||||
|
||||
/**
|
||||
* @brief spin box with the scale factor of the graphic view
|
||||
*/
|
||||
QPointer<QDoubleSpinBox> m_doubleSpinBoxScale{nullptr};
|
||||
|
||||
/**
|
||||
* @brief mouseCoordinate pointer to label who show mouse coordinate.
|
||||
*/
|
||||
QLabel* m_mouseCoordinate{nullptr};
|
||||
|
||||
/**
|
||||
* @brief CreatePiece creates a piece from the given VLayoutPiece data
|
||||
* @param rawPiece the raw piece data
|
||||
*/
|
||||
VPPiece* CreatePiece(const VLayoutPiece &rawPiece);
|
||||
|
||||
/**
|
||||
* @brief InitMenuBar Inits the menu bar (File, Edit, Help ...)
|
||||
*/
|
||||
void InitMenuBar();
|
||||
|
||||
/**
|
||||
* @brief InitProperties Init the properties
|
||||
*/
|
||||
void InitProperties();
|
||||
|
||||
/**
|
||||
* @brief InitPropertyTabCurrentPiece Inits the current piece tab in the properties
|
||||
*/
|
||||
void InitPropertyTabCurrentPiece();
|
||||
|
||||
/**
|
||||
* @brief InitPropertyTabCurrentSheet Inits the current sheet tab in the properties;
|
||||
*/
|
||||
void InitPropertyTabCurrentSheet();
|
||||
|
||||
/**
|
||||
* @brief InitPropertyTabLayout Inits the layout tab in the properties
|
||||
*/
|
||||
void InitPropertyTabLayout();
|
||||
|
||||
/**
|
||||
* @brief InitPropertyTabTiles Inits the tiles tab in the properties
|
||||
*/
|
||||
void InitPropertyTabTiles();
|
||||
|
||||
/**
|
||||
* @brief InitCarrousel Inits the carrousel
|
||||
*/
|
||||
void InitCarrousel();
|
||||
|
||||
/**
|
||||
* @brief InitMainGraphics Initialises the puzzle main graphics
|
||||
*/
|
||||
void InitMainGraphics();
|
||||
|
||||
/**
|
||||
* @brief InitToolBar Initialises the tool bar
|
||||
*/
|
||||
void InitZoomToolBar();
|
||||
|
||||
/**
|
||||
* @brief SetPropertiesData Sets the values of UI elements
|
||||
* in all the property tabs to the values saved in m_layout
|
||||
*/
|
||||
void SetPropertiesData();
|
||||
|
||||
/**
|
||||
* @brief SetPropertyTabCurrentPieceData Sets the values of UI elements
|
||||
* in the Current Piece Tab to the values saved in m_layout
|
||||
*/
|
||||
void SetPropertyTabCurrentPieceData();
|
||||
|
||||
/**
|
||||
* @brief SetPropertyTabSheetData Sets the values of UI elements
|
||||
* in the Sheet Tab to the values saved in focused sheet
|
||||
*/
|
||||
void SetPropertyTabSheetData();
|
||||
|
||||
/**
|
||||
* @brief SetPropertyTabTilesData Sets the values of UI elements
|
||||
* in the Tiles Tab to the values saved in m_layout
|
||||
*/
|
||||
void SetPropertyTabTilesData();
|
||||
|
||||
/**
|
||||
* @brief SetPropertyTabLayoutData Sets the values of UI elements
|
||||
* in the Layout Tab to the values saved in m_layout
|
||||
*/
|
||||
void SetPropertyTabLayoutData();
|
||||
|
||||
/**
|
||||
* @brief SetDoubleSpinBoxValue sets the given spinbox to the given value.
|
||||
* the signals are blocked before changing the value and unblocked after
|
||||
* @param spinBox pointer to spinbox
|
||||
* @param value spinbox value
|
||||
*/
|
||||
void SetDoubleSpinBoxValue(QDoubleSpinBox *spinBox, qreal value);
|
||||
|
||||
/**
|
||||
* @brief SetCheckBoxValue sets the given checkbox to the given value.
|
||||
* the signals are blocked before changing the value and unblocked after
|
||||
* @param checkbox pointer to checkbox
|
||||
* @param value checkbox value
|
||||
*/
|
||||
void SetCheckBoxValue(QCheckBox *checkbox, bool value);
|
||||
|
||||
void ReadSettings();
|
||||
void WriteSettings();
|
||||
|
||||
bool MaybeSave();
|
||||
|
||||
/**
|
||||
* @brief generateTiledPdf Generates the tiled Pdf in the given filename
|
||||
* @param fileName output file name
|
||||
*/
|
||||
void generateTiledPdf(QString fileName);
|
||||
|
||||
virtual void changeEvent(QEvent* event) override;
|
||||
virtual QStringList RecentFileList() const override;
|
||||
|
||||
private slots:
|
||||
/**
|
||||
|
@ -521,6 +389,155 @@ private slots:
|
|||
* @param scenePos position mouse.
|
||||
*/
|
||||
void on_MouseMoved(const QPointF &scenePos);
|
||||
|
||||
void ShowWindow() const;
|
||||
void Preferences();
|
||||
void ToolBarStyles();
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
void AboutToShowDockMenu();
|
||||
#endif //defined(Q_OS_MAC)
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VPMainWindow)
|
||||
Ui::VPMainWindow *ui;
|
||||
|
||||
VPCarrousel *m_carrousel{nullptr};
|
||||
VPMainGraphicsView *m_graphicsView{nullptr};
|
||||
|
||||
VPCommandLinePtr m_cmd;
|
||||
|
||||
VPLayout *m_layout{nullptr};
|
||||
QList<VPPiece *>m_selectedPieces{QList<VPPiece *>()};
|
||||
|
||||
VPTileFactory *m_tileFactory{nullptr};
|
||||
|
||||
/**
|
||||
* @brief spin box with the scale factor of the graphic view
|
||||
*/
|
||||
QPointer<QDoubleSpinBox> m_doubleSpinBoxScale{nullptr};
|
||||
|
||||
/**
|
||||
* @brief mouseCoordinate pointer to label who show mouse coordinate.
|
||||
*/
|
||||
QLabel* m_mouseCoordinate{nullptr};
|
||||
|
||||
QString curFile{};
|
||||
|
||||
bool isInitialized{false};
|
||||
bool lIsReadOnly{false};
|
||||
|
||||
/**
|
||||
* @brief CreatePiece creates a piece from the given VLayoutPiece data
|
||||
* @param rawPiece the raw piece data
|
||||
*/
|
||||
VPPiece* CreatePiece(const VLayoutPiece &rawPiece);
|
||||
|
||||
/**
|
||||
* @brief InitMenuBar Inits the menu bar (File, Edit, Help ...)
|
||||
*/
|
||||
void SetupMenu();
|
||||
|
||||
/**
|
||||
* @brief InitProperties Init the properties
|
||||
*/
|
||||
void InitProperties();
|
||||
|
||||
/**
|
||||
* @brief InitPropertyTabCurrentPiece Inits the current piece tab in the properties
|
||||
*/
|
||||
void InitPropertyTabCurrentPiece();
|
||||
|
||||
/**
|
||||
* @brief InitPropertyTabCurrentSheet Inits the current sheet tab in the properties;
|
||||
*/
|
||||
void InitPropertyTabCurrentSheet();
|
||||
|
||||
/**
|
||||
* @brief InitPropertyTabLayout Inits the layout tab in the properties
|
||||
*/
|
||||
void InitPropertyTabLayout();
|
||||
|
||||
/**
|
||||
* @brief InitPropertyTabTiles Inits the tiles tab in the properties
|
||||
*/
|
||||
void InitPropertyTabTiles();
|
||||
|
||||
/**
|
||||
* @brief InitCarrousel Inits the carrousel
|
||||
*/
|
||||
void InitCarrousel();
|
||||
|
||||
/**
|
||||
* @brief InitMainGraphics Initialises the puzzle main graphics
|
||||
*/
|
||||
void InitMainGraphics();
|
||||
|
||||
/**
|
||||
* @brief InitToolBar Initialises the tool bar
|
||||
*/
|
||||
void InitZoomToolBar();
|
||||
|
||||
/**
|
||||
* @brief SetPropertiesData Sets the values of UI elements
|
||||
* in all the property tabs to the values saved in m_layout
|
||||
*/
|
||||
void SetPropertiesData();
|
||||
|
||||
/**
|
||||
* @brief SetPropertyTabCurrentPieceData Sets the values of UI elements
|
||||
* in the Current Piece Tab to the values saved in m_layout
|
||||
*/
|
||||
void SetPropertyTabCurrentPieceData();
|
||||
|
||||
/**
|
||||
* @brief SetPropertyTabSheetData Sets the values of UI elements
|
||||
* in the Sheet Tab to the values saved in focused sheet
|
||||
*/
|
||||
void SetPropertyTabSheetData();
|
||||
|
||||
/**
|
||||
* @brief SetPropertyTabTilesData Sets the values of UI elements
|
||||
* in the Tiles Tab to the values saved in m_layout
|
||||
*/
|
||||
void SetPropertyTabTilesData();
|
||||
|
||||
/**
|
||||
* @brief SetPropertyTabLayoutData Sets the values of UI elements
|
||||
* in the Layout Tab to the values saved in m_layout
|
||||
*/
|
||||
void SetPropertyTabLayoutData();
|
||||
|
||||
/**
|
||||
* @brief SetDoubleSpinBoxValue sets the given spinbox to the given value.
|
||||
* the signals are blocked before changing the value and unblocked after
|
||||
* @param spinBox pointer to spinbox
|
||||
* @param value spinbox value
|
||||
*/
|
||||
void SetDoubleSpinBoxValue(QDoubleSpinBox *spinBox, qreal value);
|
||||
|
||||
/**
|
||||
* @brief SetCheckBoxValue sets the given checkbox to the given value.
|
||||
* the signals are blocked before changing the value and unblocked after
|
||||
* @param checkbox pointer to checkbox
|
||||
* @param value checkbox value
|
||||
*/
|
||||
void SetCheckBoxValue(QCheckBox *checkbox, bool value);
|
||||
|
||||
void UpdateWindowTitle();
|
||||
|
||||
void ReadSettings();
|
||||
void WriteSettings();
|
||||
|
||||
bool MaybeSave();
|
||||
|
||||
/**
|
||||
* @brief generateTiledPdf Generates the tiled Pdf in the given filename
|
||||
* @param fileName output file name
|
||||
*/
|
||||
void generateTiledPdf(QString fileName);
|
||||
|
||||
void CreateWindowMenu(QMenu *menu);
|
||||
};
|
||||
|
||||
#endif // VPMAINWINDOW_H
|
||||
|
|
|
@ -175,6 +175,9 @@
|
|||
</property>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidgetProperties">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
|
@ -1561,7 +1564,8 @@
|
|||
</widget>
|
||||
<action name="actionOpen">
|
||||
<property name="icon">
|
||||
<iconset theme="document-open"/>
|
||||
<iconset theme="document-open">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Open</string>
|
||||
|
@ -1572,10 +1576,11 @@
|
|||
</action>
|
||||
<action name="actionSave">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="document-save"/>
|
||||
<iconset theme="document-save">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Save</string>
|
||||
|
@ -1586,10 +1591,11 @@
|
|||
</action>
|
||||
<action name="actionSaveAs">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="document-save-as"/>
|
||||
<iconset theme="document-save-as">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save &As</string>
|
||||
|
@ -1600,7 +1606,7 @@
|
|||
</action>
|
||||
<action name="actionCloseLayout">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Close Layout</string>
|
||||
|
@ -1608,7 +1614,7 @@
|
|||
</action>
|
||||
<action name="actionImportRawLayout">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Import Raw Layout Data</string>
|
||||
|
@ -1634,7 +1640,8 @@
|
|||
</action>
|
||||
<action name="actionNew">
|
||||
<property name="icon">
|
||||
<iconset theme="document-new"/>
|
||||
<iconset theme="document-new">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&New</string>
|
||||
|
@ -1653,7 +1660,8 @@
|
|||
</action>
|
||||
<action name="actionAboutPuzzle">
|
||||
<property name="icon">
|
||||
<iconset theme="help-about"/>
|
||||
<iconset theme="help-about">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>About &Puzzle</string>
|
||||
|
@ -1669,6 +1677,9 @@
|
|||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Properties</string>
|
||||
</property>
|
||||
|
@ -1677,6 +1688,9 @@
|
|||
</property>
|
||||
</action>
|
||||
<action name="actionZoomIn">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="zoom-in">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
|
@ -1686,6 +1700,9 @@
|
|||
</property>
|
||||
</action>
|
||||
<action name="actionZoomOut">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="zoom-out">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
|
@ -1695,6 +1712,9 @@
|
|||
</property>
|
||||
</action>
|
||||
<action name="actionZoomOriginal">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="zoom-original">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
|
@ -1704,6 +1724,9 @@
|
|||
</property>
|
||||
</action>
|
||||
<action name="actionZoomFitBest">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="zoom-fit-best">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
|
|
|
@ -70,8 +70,6 @@ class VPSheet : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
|
||||
explicit VPSheet(VPLayout* layout);
|
||||
|
||||
~VPSheet();
|
||||
|
|
|
@ -388,13 +388,6 @@ bool TMainWindow::LoadFile(const QString &path)
|
|||
return true;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void TMainWindow::ShowToolTip(const QString &toolTip)
|
||||
{
|
||||
Q_UNUSED(toolTip)
|
||||
// do nothing
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void TMainWindow::FileNew()
|
||||
{
|
||||
|
@ -597,7 +590,7 @@ void TMainWindow::changeEvent(QEvent *event)
|
|||
{
|
||||
if (event->type() == QEvent::LanguageChange)
|
||||
{
|
||||
VAbstractApplication::VApp()->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
|
||||
WindowsLocale();
|
||||
|
||||
// retranslate designer form (single inheritance approach)
|
||||
ui->retranslateUi(this);
|
||||
|
@ -2410,7 +2403,6 @@ void TMainWindow::SetupMenu()
|
|||
m_separatorAct->setVisible(false);
|
||||
ui->menuFile->insertAction(ui->actionPreferences, m_separatorAct );
|
||||
|
||||
|
||||
connect(ui->actionQuit, &QAction::triggered, this, &TMainWindow::close);
|
||||
ui->actionQuit->setShortcuts(QKeySequence::Quit);
|
||||
|
||||
|
@ -3653,7 +3645,7 @@ void TMainWindow::CreateWindowMenu(QMenu *menu)
|
|||
window->isWindowModified() ? title.replace(index, 3, QChar('*')) : title.replace(index, 3, QString());
|
||||
}
|
||||
|
||||
QAction *action = menu->addAction(title, this, SLOT(ShowWindow()));
|
||||
QAction *action = menu->addAction(title, this, &TMainWindow::ShowWindow);
|
||||
action->setData(i);
|
||||
action->setCheckable(true);
|
||||
action->setMenuRole(QAction::NoRole);
|
||||
|
|
|
@ -65,9 +65,6 @@ public:
|
|||
|
||||
bool LoadFile(const QString &path);
|
||||
|
||||
public slots:
|
||||
virtual void ShowToolTip(const QString &toolTip) override;
|
||||
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent *event) override;
|
||||
virtual void changeEvent(QEvent* event) override;
|
||||
|
|
|
@ -134,6 +134,13 @@ VAbstractMainWindow::VAbstractMainWindow(QWidget *parent)
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractMainWindow::ShowToolTip(const QString &toolTip)
|
||||
{
|
||||
Q_UNUSED(toolTip)
|
||||
// do nothing
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VAbstractMainWindow::ContinueFormatRewrite(const QString ¤tFormatVersion,
|
||||
const QString &maxFormatVersion)
|
||||
|
@ -197,6 +204,16 @@ QString VAbstractMainWindow::CSVFilePath()
|
|||
return fileName;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractMainWindow::ExportToCSVData(const QString &fileName, bool withHeader, int mib, const QChar &separator)
|
||||
{
|
||||
Q_UNUSED(fileName)
|
||||
Q_UNUSED(withHeader)
|
||||
Q_UNUSED(mib)
|
||||
Q_UNUSED(separator)
|
||||
// do nothing
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractMainWindow::UpdateRecentFileActions()
|
||||
{
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
virtual ~VAbstractMainWindow() Q_DECL_EQ_DEFAULT;
|
||||
|
||||
public slots:
|
||||
virtual void ShowToolTip(const QString &toolTip)=0;
|
||||
virtual void ShowToolTip(const QString &toolTip);
|
||||
virtual void UpdateVisibilityGroups();
|
||||
virtual void UpdateDetailsList();
|
||||
virtual void ZoomFitBestCurrent();
|
||||
|
@ -66,7 +66,7 @@ protected:
|
|||
|
||||
QString CSVFilePath();
|
||||
|
||||
virtual void ExportToCSVData(const QString &fileName, bool withHeader, int mib, const QChar &separator)=0;
|
||||
virtual void ExportToCSVData(const QString &fileName, bool withHeader, int mib, const QChar &separator);
|
||||
|
||||
virtual QStringList RecentFileList() const =0;
|
||||
void UpdateRecentFileActions();
|
||||
|
|
Loading…
Reference in New Issue
Block a user