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:
Roman Telezhynskyi 2021-05-20 18:33:53 +03:00
parent a0dba0ea25
commit dc50d24439
10 changed files with 424 additions and 185 deletions

View File

@ -353,12 +353,18 @@ auto VPApplication::MainWindows() -> QList<VPMainWindow *>
return list; return list;
} }
//---------------------------------------------------------------------------------------------------------------------
VPMainWindow *VPApplication::NewMainWindow()
{
return NewMainWindow(VPCommandLinePtr());
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPApplication::NewMainWindow(const VPCommandLinePtr &cmd) -> VPMainWindow * auto VPApplication::NewMainWindow(const VPCommandLinePtr &cmd) -> VPMainWindow *
{ {
VPMainWindow *puzzle = new VPMainWindow(cmd); VPMainWindow *puzzle = new VPMainWindow(cmd);
mainWindows.prepend(puzzle); mainWindows.prepend(puzzle);
if (cmd->IsGuiEnabled()) if (not cmd->IsTestModeEnabled())
{ {
puzzle->show(); puzzle->show();
} }

View File

@ -52,6 +52,7 @@ public:
virtual bool IsAppInGUIMode() const override; virtual bool IsAppInGUIMode() const override;
VPMainWindow *MainWindow(); VPMainWindow *MainWindow();
QList<VPMainWindow*> MainWindows(); QList<VPMainWindow*> MainWindows();
VPMainWindow *NewMainWindow();
VPMainWindow *NewMainWindow(const VPCommandLinePtr &cmd); VPMainWindow *NewMainWindow(const VPCommandLinePtr &cmd);
void InitOptions(); void InitOptions();

View File

@ -57,31 +57,31 @@ QT_WARNING_POP
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) : VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) :
QMainWindow(parent), VAbstractMainWindow(parent),
ui(new Ui::VPMainWindow), ui(new Ui::VPMainWindow),
m_cmd(cmd) m_cmd(cmd)
{ {
m_layout = new VPLayout(); m_layout = new VPLayout();
// create a standard sheet // create a standard sheet
VPSheet *sheet = new VPSheet(m_layout); auto *sheet = new VPSheet(m_layout);
sheet->SetName(QObject::tr("Sheet 1")); sheet->SetName(QObject::tr("Sheet 1"));
m_layout->AddSheet(sheet); m_layout->AddSheet(sheet);
m_layout->SetFocusedSheet(); m_layout->SetFocusedSheet();
// ----- for test purposes, to be removed------------------ // // ----- for test purposes, to be removed------------------
sheet->SetSheetMarginsConverted(1, 1, 1, 1); // sheet->SetSheetMarginsConverted(1, 1, 1, 1);
sheet->SetSheetSizeConverted(84.1, 118.9); // sheet->SetSheetSizeConverted(84.1, 118.9);
sheet->SetPiecesGapConverted(1); // sheet->SetPiecesGapConverted(1);
m_layout->SetUnit(Unit::Cm); // m_layout->SetUnit(Unit::Cm);
m_layout->SetWarningSuperpositionOfPieces(true); // m_layout->SetWarningSuperpositionOfPieces(true);
m_layout->SetTitle(QString("My Test Layout")); // m_layout->SetTitle(QString("My Test Layout"));
m_layout->SetDescription(QString("Description of my Layout")); // m_layout->SetDescription(QString("Description of my Layout"));
m_layout->SetTilesSizeConverted(21,29.7); // m_layout->SetTilesSizeConverted(21,29.7);
m_layout->SetTilesOrientation(PageOrientation::Portrait); // m_layout->SetTilesOrientation(PageOrientation::Portrait);
m_layout->SetTilesMarginsConverted(1,1,1,1); // m_layout->SetTilesMarginsConverted(1,1,1,1);
// m_layout->SetShowTiles(true); // 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 = new VPTileFactory(m_layout, VPApplication::VApp()->Settings());
m_tileFactory->refreshTileInfos(); m_tileFactory->refreshTileInfos();
InitMenuBar(); SetupMenu();
InitProperties(); InitProperties();
InitCarrousel(); InitCarrousel();
@ -102,9 +102,16 @@ VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) :
SetPropertiesData(); SetPropertiesData();
UpdateWindowTitle();
ReadSettings(); 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) // most of the actions are connected through name convention (auto-connection)
// -------------------- connects the actions for the file menu // -------------------- 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); connect(ui->actionExit, &QAction::triggered, this, &VPMainWindow::close);
ui->actionExit->setShortcuts(QKeySequence::Quit);
// -------------------- connects the actions for the edit menu // -------------------- connects the actions for the edit menu
// TODO : initialise the undo / redo // TODO : initialise the undo / redo
@ -410,6 +421,7 @@ void VPMainWindow::InitPropertyTabLayout()
void VPMainWindow::InitCarrousel() void VPMainWindow::InitCarrousel()
{ {
m_carrousel = new VPCarrousel(m_layout, ui->dockWidgetCarrousel); m_carrousel = new VPCarrousel(m_layout, ui->dockWidgetCarrousel);
m_carrousel->setDisabled(true);
ui->dockWidgetCarrousel->setWidget(m_carrousel); ui->dockWidgetCarrousel->setWidget(m_carrousel);
connect(ui->dockWidgetCarrousel, QOverload<Qt::DockWidgetArea>::of(&QDockWidget::dockLocationChanged), this, connect(ui->dockWidgetCarrousel, QOverload<Qt::DockWidgetArea>::of(&QDockWidget::dockLocationChanged), this,
@ -578,6 +590,7 @@ void VPMainWindow::SetPropertyTabLayoutData()
void VPMainWindow::InitMainGraphics() void VPMainWindow::InitMainGraphics()
{ {
m_graphicsView = new VPMainGraphicsView(m_layout, m_tileFactory, this); m_graphicsView = new VPMainGraphicsView(m_layout, m_tileFactory, this);
m_graphicsView->setDisabled(true);
ui->centralWidget->layout()->addWidget(m_graphicsView); ui->centralWidget->layout()->addWidget(m_graphicsView);
m_graphicsView->RefreshLayout(); m_graphicsView->RefreshLayout();
@ -594,10 +607,7 @@ void VPMainWindow::InitZoomToolBar()
delete m_doubleSpinBoxScale; delete m_doubleSpinBoxScale;
} }
if (m_mouseCoordinate != nullptr)
{
delete m_mouseCoordinate; delete m_mouseCoordinate;
}
// connect the zoom buttons and shortcuts to the slots // connect the zoom buttons and shortcuts to the slots
QList<QKeySequence> zoomInShortcuts; QList<QKeySequence> zoomInShortcuts;
@ -625,12 +635,13 @@ void VPMainWindow::InitZoomToolBar()
// defined the scale // defined the scale
ui->toolBarZoom->addSeparator(); ui->toolBarZoom->addSeparator();
QLabel* zoomScale = new QLabel(tr("Scale:"), this); auto* zoomScale = new QLabel(tr("Scale:"), this);
ui->toolBarZoom->addWidget(zoomScale); ui->toolBarZoom->addWidget(zoomScale);
m_doubleSpinBoxScale = new QDoubleSpinBox(this); m_doubleSpinBoxScale = new QDoubleSpinBox(this);
m_doubleSpinBoxScale->setDecimals(1); m_doubleSpinBoxScale->setDecimals(1);
m_doubleSpinBoxScale->setSuffix("%"); m_doubleSpinBoxScale->setSuffix("%");
m_doubleSpinBoxScale->setDisabled(true);
on_ScaleChanged(m_graphicsView->transform().m11()); on_ScaleChanged(m_graphicsView->transform().m11());
connect(m_doubleSpinBoxScale.data(), QOverload<double>::of(&QDoubleSpinBox::valueChanged), connect(m_doubleSpinBoxScale.data(), QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, [this](double d){m_graphicsView->Zoom(d/100.0);}); this, [this](double d){m_graphicsView->Zoom(d/100.0);});
@ -661,6 +672,62 @@ void VPMainWindow::SetCheckBoxValue(QCheckBox *checkbox, bool value)
checkbox->blockSignals(false); 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() void VPMainWindow::ReadSettings()
{ {
@ -673,6 +740,9 @@ void VPMainWindow::ReadSettings()
restoreState(settings->GetWindowState()); restoreState(settings->GetWindowState());
restoreState(settings->GetToolbarsState(), APP_VERSION); restoreState(settings->GetToolbarsState(), APP_VERSION);
// Text under tool buton icon
ToolBarStyles();
ui->dockWidgetProperties->setVisible(settings->IsDockWidgetPropertiesActive()); ui->dockWidgetProperties->setVisible(settings->IsDockWidgetPropertiesActive());
ui->dockWidgetPropertiesContents->setVisible(settings->IsDockWidgetPropertiesContentsActive()); 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() 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() void VPMainWindow::on_actionOpen_triggered()
{ {
@ -1538,3 +1665,64 @@ void VPMainWindow::on_MouseMoved(const QPointF &scenePos)
.arg(UnitsToStr(m_layout->GetUnit(), true))); .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)

View File

@ -42,13 +42,14 @@
#include "vptilefactory.h" #include "vptilefactory.h"
#include "vpcommandline.h" #include "vpcommandline.h"
#include "../vlayout/vlayoutdef.h" #include "../vlayout/vlayoutdef.h"
#include "../vwidgets/vabstractmainwindow.h"
namespace Ui namespace Ui
{ {
class VPMainWindow; class VPMainWindow;
} }
class VPMainWindow : public QMainWindow class VPMainWindow : public VAbstractMainWindow
{ {
Q_OBJECT Q_OBJECT
@ -90,142 +91,9 @@ public slots:
void on_actionNew_triggered(); void on_actionNew_triggered();
protected: protected:
enum { MaxRecentFiles = 5 };
virtual void closeEvent(QCloseEvent *event) override; virtual void closeEvent(QCloseEvent *event) override;
virtual void changeEvent(QEvent* event) override;
private: virtual QStringList RecentFileList() const override;
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);
private slots: private slots:
/** /**
@ -521,6 +389,155 @@ private slots:
* @param scenePos position mouse. * @param scenePos position mouse.
*/ */
void on_MouseMoved(const QPointF &scenePos); 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 #endif // VPMAINWINDOW_H

View File

@ -175,6 +175,9 @@
</property> </property>
<item> <item>
<widget class="QTabWidget" name="tabWidgetProperties"> <widget class="QTabWidget" name="tabWidgetProperties">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding"> <sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -1561,7 +1564,8 @@
</widget> </widget>
<action name="actionOpen"> <action name="actionOpen">
<property name="icon"> <property name="icon">
<iconset theme="document-open"/> <iconset theme="document-open">
<normaloff>.</normaloff>.</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>&amp;Open</string> <string>&amp;Open</string>
@ -1572,10 +1576,11 @@
</action> </action>
<action name="actionSave"> <action name="actionSave">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>false</bool>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="document-save"/> <iconset theme="document-save">
<normaloff>.</normaloff>.</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>&amp;Save</string> <string>&amp;Save</string>
@ -1586,10 +1591,11 @@
</action> </action>
<action name="actionSaveAs"> <action name="actionSaveAs">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>false</bool>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="document-save-as"/> <iconset theme="document-save-as">
<normaloff>.</normaloff>.</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Save &amp;As</string> <string>Save &amp;As</string>
@ -1600,7 +1606,7 @@
</action> </action>
<action name="actionCloseLayout"> <action name="actionCloseLayout">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>false</bool>
</property> </property>
<property name="text"> <property name="text">
<string>&amp;Close Layout</string> <string>&amp;Close Layout</string>
@ -1608,7 +1614,7 @@
</action> </action>
<action name="actionImportRawLayout"> <action name="actionImportRawLayout">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>false</bool>
</property> </property>
<property name="text"> <property name="text">
<string>&amp;Import Raw Layout Data</string> <string>&amp;Import Raw Layout Data</string>
@ -1634,7 +1640,8 @@
</action> </action>
<action name="actionNew"> <action name="actionNew">
<property name="icon"> <property name="icon">
<iconset theme="document-new"/> <iconset theme="document-new">
<normaloff>.</normaloff>.</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>&amp;New</string> <string>&amp;New</string>
@ -1653,7 +1660,8 @@
</action> </action>
<action name="actionAboutPuzzle"> <action name="actionAboutPuzzle">
<property name="icon"> <property name="icon">
<iconset theme="help-about"/> <iconset theme="help-about">
<normaloff>.</normaloff>.</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>About &amp;Puzzle</string> <string>About &amp;Puzzle</string>
@ -1669,6 +1677,9 @@
<property name="checked"> <property name="checked">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text"> <property name="text">
<string>Properties</string> <string>Properties</string>
</property> </property>
@ -1677,6 +1688,9 @@
</property> </property>
</action> </action>
<action name="actionZoomIn"> <action name="actionZoomIn">
<property name="enabled">
<bool>false</bool>
</property>
<property name="icon"> <property name="icon">
<iconset theme="zoom-in"> <iconset theme="zoom-in">
<normaloff>.</normaloff>.</iconset> <normaloff>.</normaloff>.</iconset>
@ -1686,6 +1700,9 @@
</property> </property>
</action> </action>
<action name="actionZoomOut"> <action name="actionZoomOut">
<property name="enabled">
<bool>false</bool>
</property>
<property name="icon"> <property name="icon">
<iconset theme="zoom-out"> <iconset theme="zoom-out">
<normaloff>.</normaloff>.</iconset> <normaloff>.</normaloff>.</iconset>
@ -1695,6 +1712,9 @@
</property> </property>
</action> </action>
<action name="actionZoomOriginal"> <action name="actionZoomOriginal">
<property name="enabled">
<bool>false</bool>
</property>
<property name="icon"> <property name="icon">
<iconset theme="zoom-original"> <iconset theme="zoom-original">
<normaloff>.</normaloff>.</iconset> <normaloff>.</normaloff>.</iconset>
@ -1704,6 +1724,9 @@
</property> </property>
</action> </action>
<action name="actionZoomFitBest"> <action name="actionZoomFitBest">
<property name="enabled">
<bool>false</bool>
</property>
<property name="icon"> <property name="icon">
<iconset theme="zoom-fit-best"> <iconset theme="zoom-fit-best">
<normaloff>.</normaloff>.</iconset> <normaloff>.</normaloff>.</iconset>

View File

@ -70,8 +70,6 @@ class VPSheet : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit VPSheet(VPLayout* layout); explicit VPSheet(VPLayout* layout);
~VPSheet(); ~VPSheet();

View File

@ -388,13 +388,6 @@ bool TMainWindow::LoadFile(const QString &path)
return true; return true;
} }
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::ShowToolTip(const QString &toolTip)
{
Q_UNUSED(toolTip)
// do nothing
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void TMainWindow::FileNew() void TMainWindow::FileNew()
{ {
@ -597,7 +590,7 @@ void TMainWindow::changeEvent(QEvent *event)
{ {
if (event->type() == QEvent::LanguageChange) if (event->type() == QEvent::LanguageChange)
{ {
VAbstractApplication::VApp()->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); WindowsLocale();
// retranslate designer form (single inheritance approach) // retranslate designer form (single inheritance approach)
ui->retranslateUi(this); ui->retranslateUi(this);
@ -2410,7 +2403,6 @@ void TMainWindow::SetupMenu()
m_separatorAct->setVisible(false); m_separatorAct->setVisible(false);
ui->menuFile->insertAction(ui->actionPreferences, m_separatorAct ); ui->menuFile->insertAction(ui->actionPreferences, m_separatorAct );
connect(ui->actionQuit, &QAction::triggered, this, &TMainWindow::close); connect(ui->actionQuit, &QAction::triggered, this, &TMainWindow::close);
ui->actionQuit->setShortcuts(QKeySequence::Quit); 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()); 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->setData(i);
action->setCheckable(true); action->setCheckable(true);
action->setMenuRole(QAction::NoRole); action->setMenuRole(QAction::NoRole);

View File

@ -65,9 +65,6 @@ public:
bool LoadFile(const QString &path); bool LoadFile(const QString &path);
public slots:
virtual void ShowToolTip(const QString &toolTip) override;
protected: protected:
virtual void closeEvent(QCloseEvent *event) override; virtual void closeEvent(QCloseEvent *event) override;
virtual void changeEvent(QEvent* event) override; virtual void changeEvent(QEvent* event) override;

View File

@ -134,6 +134,13 @@ VAbstractMainWindow::VAbstractMainWindow(QWidget *parent)
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void VAbstractMainWindow::ShowToolTip(const QString &toolTip)
{
Q_UNUSED(toolTip)
// do nothing
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VAbstractMainWindow::ContinueFormatRewrite(const QString &currentFormatVersion, bool VAbstractMainWindow::ContinueFormatRewrite(const QString &currentFormatVersion,
const QString &maxFormatVersion) const QString &maxFormatVersion)
@ -197,6 +204,16 @@ QString VAbstractMainWindow::CSVFilePath()
return fileName; 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() void VAbstractMainWindow::UpdateRecentFileActions()
{ {

View File

@ -45,7 +45,7 @@ public:
virtual ~VAbstractMainWindow() Q_DECL_EQ_DEFAULT; virtual ~VAbstractMainWindow() Q_DECL_EQ_DEFAULT;
public slots: public slots:
virtual void ShowToolTip(const QString &toolTip)=0; virtual void ShowToolTip(const QString &toolTip);
virtual void UpdateVisibilityGroups(); virtual void UpdateVisibilityGroups();
virtual void UpdateDetailsList(); virtual void UpdateDetailsList();
virtual void ZoomFitBestCurrent(); virtual void ZoomFitBestCurrent();
@ -66,7 +66,7 @@ protected:
QString CSVFilePath(); 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; virtual QStringList RecentFileList() const =0;
void UpdateRecentFileActions(); void UpdateRecentFileActions();