Recently Opened Files.

This commit is contained in:
Roman Telezhynskyi 2021-05-21 18:26:00 +03:00
parent 6efa26ffe3
commit 05645ca7df
2 changed files with 55 additions and 21 deletions

View File

@ -230,7 +230,7 @@ void VPMainWindow::SetCurrentFile(const QString &fileName)
curFile = fileName; curFile = fileName;
if (not curFile.isEmpty()) if (not curFile.isEmpty())
{ {
auto settings = VPApplication::VApp()->PuzzleSettings(); auto *settings = VPApplication::VApp()->PuzzleSettings();
QStringList files = settings->GetRecentFileList(); QStringList files = settings->GetRecentFileList();
files.removeAll(fileName); files.removeAll(fileName);
files.prepend(fileName); files.prepend(fileName);
@ -362,6 +362,35 @@ void VPMainWindow::SetupMenu()
QAction* actionDockWidgetToolOptions = ui->dockWidgetProperties->toggleViewAction(); QAction* actionDockWidgetToolOptions = ui->dockWidgetProperties->toggleViewAction();
ui->menuEdit->addAction(actionDockWidgetToolOptions); ui->menuEdit->addAction(actionDockWidgetToolOptions);
// File
m_recentFileActs.fill(nullptr);
for (auto & recentFileAct : m_recentFileActs)
{
auto *action = new QAction(this);
recentFileAct = action;
connect(action, &QAction::triggered, this, [this]()
{
if (auto *senderAction = qobject_cast<QAction *>(sender()))
{
const QString filePath = senderAction->data().toString();
if (not filePath.isEmpty())
{
LoadFile(filePath);
}
}
});
ui->menuFile->insertAction(ui->actionPreferences, recentFileAct);
recentFileAct->setVisible(false);
}
m_separatorAct = new QAction(this);
m_separatorAct->setSeparator(true);
m_separatorAct->setVisible(false);
ui->menuFile->insertAction(ui->actionPreferences, m_separatorAct);
// Actions for recent files loaded by a puzzle window application.
UpdateRecentFileActions();
// Window // Window
connect(ui->menuWindow, &QMenu::aboutToShow, this, [this]() connect(ui->menuWindow, &QMenu::aboutToShow, this, [this]()
{ {

View File

@ -14,7 +14,7 @@
<string>Puzzle</string> <string>Puzzle</string>
</property> </property>
<property name="windowIcon"> <property name="windowIcon">
<iconset resource="share/resources/puzzleicon.qrc"> <iconset>
<normaloff>:/puzzleicon/64x64/logo.png</normaloff>:/puzzleicon/64x64/logo.png</iconset> <normaloff>:/puzzleicon/64x64/logo.png</normaloff>:/puzzleicon/64x64/logo.png</iconset>
</property> </property>
<property name="layoutDirection"> <property name="layoutDirection">
@ -53,6 +53,8 @@
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionImportRawLayout"/> <addaction name="actionImportRawLayout"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionPreferences"/>
<addaction name="separator"/>
<addaction name="actionExit"/> <addaction name="actionExit"/>
</widget> </widget>
<widget class="QMenu" name="menuEdit"> <widget class="QMenu" name="menuEdit">
@ -205,7 +207,7 @@
<string notr="true"/> <string notr="true"/>
</property> </property>
<attribute name="icon"> <attribute name="icon">
<iconset resource="share/resources/puzzleicon.qrc"> <iconset>
<normaloff>:/puzzleicon/64x64/iconCurrentPiece.png</normaloff>:/puzzleicon/64x64/iconCurrentPiece.png</iconset> <normaloff>:/puzzleicon/64x64/iconCurrentPiece.png</normaloff>:/puzzleicon/64x64/iconCurrentPiece.png</iconset>
</attribute> </attribute>
<attribute name="title"> <attribute name="title">
@ -406,7 +408,7 @@
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="share/resources/puzzleicon.qrc"> <iconset>
<normaloff>:/puzzleicon/64x64/iconRotate90Clockwise.png</normaloff>:/puzzleicon/64x64/iconRotate90Clockwise.png</iconset> <normaloff>:/puzzleicon/64x64/iconRotate90Clockwise.png</normaloff>:/puzzleicon/64x64/iconRotate90Clockwise.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
@ -426,7 +428,7 @@
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="share/resources/puzzleicon.qrc"> <iconset>
<normaloff>:/puzzleicon/64x64/iconRotate90Anticlockwise.png</normaloff>:/puzzleicon/64x64/iconRotate90Anticlockwise.png</iconset> <normaloff>:/puzzleicon/64x64/iconRotate90Anticlockwise.png</normaloff>:/puzzleicon/64x64/iconRotate90Anticlockwise.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
@ -446,7 +448,7 @@
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="share/resources/puzzleicon.qrc"> <iconset>
<normaloff>:/puzzleicon/64x64/iconRotateGrainlineVertical.png</normaloff>:/puzzleicon/64x64/iconRotateGrainlineVertical.png</iconset> <normaloff>:/puzzleicon/64x64/iconRotateGrainlineVertical.png</normaloff>:/puzzleicon/64x64/iconRotateGrainlineVertical.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
@ -466,7 +468,7 @@
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="share/resources/puzzleicon.qrc"> <iconset>
<normaloff>:/puzzleicon/64x64/iconRotateGrainlineHorizontal.png</normaloff>:/puzzleicon/64x64/iconRotateGrainlineHorizontal.png</iconset> <normaloff>:/puzzleicon/64x64/iconRotateGrainlineHorizontal.png</normaloff>:/puzzleicon/64x64/iconRotateGrainlineHorizontal.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
@ -626,7 +628,7 @@
</widget> </widget>
<widget class="QWidget" name="tabSheetProperty"> <widget class="QWidget" name="tabSheetProperty">
<attribute name="icon"> <attribute name="icon">
<iconset resource="share/resources/puzzleicon.qrc"> <iconset>
<normaloff>:/puzzleicon/64x64/iconLayout.png</normaloff>:/puzzleicon/64x64/iconLayout.png</iconset> <normaloff>:/puzzleicon/64x64/iconLayout.png</normaloff>:/puzzleicon/64x64/iconLayout.png</iconset>
</attribute> </attribute>
<attribute name="title"> <attribute name="title">
@ -778,7 +780,7 @@
<string notr="true"/> <string notr="true"/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="share/resources/puzzleicon.qrc"> <iconset>
<normaloff>:/puzzleicon/64x64/iconPortrait.png</normaloff>:/puzzleicon/64x64/iconPortrait.png</iconset> <normaloff>:/puzzleicon/64x64/iconPortrait.png</normaloff>:/puzzleicon/64x64/iconPortrait.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
@ -801,7 +803,7 @@
<string notr="true"/> <string notr="true"/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="share/resources/puzzleicon.qrc"> <iconset>
<normaloff>:/puzzleicon/64x64/iconLandscape.png</normaloff>:/puzzleicon/64x64/iconLandscape.png</iconset> <normaloff>:/puzzleicon/64x64/iconLandscape.png</normaloff>:/puzzleicon/64x64/iconLandscape.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
@ -985,7 +987,7 @@
<string notr="true"/> <string notr="true"/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="share/resources/puzzleicon.qrc"> <iconset>
<normaloff>:/puzzleicon/64x64/iconGrainlineVertical.png</normaloff>:/puzzleicon/64x64/iconGrainlineVertical.png</iconset> <normaloff>:/puzzleicon/64x64/iconGrainlineVertical.png</normaloff>:/puzzleicon/64x64/iconGrainlineVertical.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
@ -1005,7 +1007,7 @@
<string notr="true"/> <string notr="true"/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="share/resources/puzzleicon.qrc"> <iconset>
<normaloff>:/puzzleicon/64x64/iconGrainlineHorizontal.png</normaloff>:/puzzleicon/64x64/iconGrainlineHorizontal.png</iconset> <normaloff>:/puzzleicon/64x64/iconGrainlineHorizontal.png</normaloff>:/puzzleicon/64x64/iconGrainlineHorizontal.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
@ -1091,7 +1093,7 @@
</widget> </widget>
<widget class="QWidget" name="tabTilesProperty"> <widget class="QWidget" name="tabTilesProperty">
<attribute name="icon"> <attribute name="icon">
<iconset resource="share/resources/puzzleicon.qrc"> <iconset>
<normaloff>:/puzzleicon/64x64/iconTiles.png</normaloff>:/puzzleicon/64x64/iconTiles.png</iconset> <normaloff>:/puzzleicon/64x64/iconTiles.png</normaloff>:/puzzleicon/64x64/iconTiles.png</iconset>
</attribute> </attribute>
<attribute name="title"> <attribute name="title">
@ -1133,7 +1135,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>356</width> <width>356</width>
<height>706</height> <height>700</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
@ -1201,7 +1203,7 @@
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="share/resources/puzzleicon.qrc"> <iconset>
<normaloff>:/puzzleicon/64x64/iconPortrait.png</normaloff>:/puzzleicon/64x64/iconPortrait.png</iconset> <normaloff>:/puzzleicon/64x64/iconPortrait.png</normaloff>:/puzzleicon/64x64/iconPortrait.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
@ -1221,7 +1223,7 @@
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="share/resources/puzzleicon.qrc"> <iconset>
<normaloff>:/puzzleicon/64x64/iconLandscape.png</normaloff>:/puzzleicon/64x64/iconLandscape.png</iconset> <normaloff>:/puzzleicon/64x64/iconLandscape.png</normaloff>:/puzzleicon/64x64/iconLandscape.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
@ -1379,7 +1381,7 @@
</widget> </widget>
<widget class="QWidget" name="tabLayoutProperty"> <widget class="QWidget" name="tabLayoutProperty">
<attribute name="icon"> <attribute name="icon">
<iconset resource="share/resources/puzzleicon.qrc"> <iconset>
<normaloff>:/puzzleicon/64x64/iconProperties.png</normaloff>:/puzzleicon/64x64/iconProperties.png</iconset> <normaloff>:/puzzleicon/64x64/iconProperties.png</normaloff>:/puzzleicon/64x64/iconProperties.png</iconset>
</attribute> </attribute>
<attribute name="title"> <attribute name="title">
@ -1421,7 +1423,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>356</width> <width>356</width>
<height>706</height> <height>700</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
@ -1746,6 +1748,11 @@
<string>Zoom sheet</string> <string>Zoom sheet</string>
</property> </property>
</action> </action>
<action name="actionPreferences">
<property name="text">
<string>Preferences</string>
</property>
</action>
</widget> </widget>
<layoutdefault spacing="6" margin="11"/> <layoutdefault spacing="6" margin="11"/>
<tabstops> <tabstops>
@ -1795,8 +1802,6 @@
<tabstop>checkBoxLayoutWarningPiecesSuperposition</tabstop> <tabstop>checkBoxLayoutWarningPiecesSuperposition</tabstop>
<tabstop>checkBoxLayoutWarningPiecesOutOfBound</tabstop> <tabstop>checkBoxLayoutWarningPiecesOutOfBound</tabstop>
</tabstops> </tabstops>
<resources> <resources/>
<include location="share/resources/puzzleicon.qrc"/>
</resources>
<connections/> <connections/>
</ui> </ui>