mirror of
https://github.com/LongSoft/UEFITool.git
synced 2025-05-13 14:44:47 -04:00
Track opened files, expand the first level of the item tree on file open
This commit is contained in:
parent
a072527138
commit
ebf4f83ac9
4 changed files with 85 additions and 13 deletions
|
@ -466,7 +466,7 @@ void QHexView::checkState() {
|
||||||
|
|
||||||
int doclines = static_cast<int>(this->lines()),
|
int doclines = static_cast<int>(this->lines()),
|
||||||
vislines = this->visibleLines(true);
|
vislines = this->visibleLines(true);
|
||||||
qint64 vscrollmax = doclines - vislines + 1; // UEFITool: ensure the very last line is visible on macOS
|
qint64 vscrollmax = doclines - vislines;
|
||||||
if(doclines >= vislines)
|
if(doclines >= vislines)
|
||||||
vscrollmax++;
|
vscrollmax++;
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,9 @@ markingEnabled(true)
|
||||||
|
|
||||||
// Read stored settings
|
// Read stored settings
|
||||||
readSettings();
|
readSettings();
|
||||||
|
|
||||||
|
// Update recent files list in menu
|
||||||
|
updateRecentFilesMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
UEFITool::~UEFITool()
|
UEFITool::~UEFITool()
|
||||||
|
@ -211,6 +214,38 @@ void UEFITool::updateUiForNewColorScheme(Qt::ColorScheme scheme)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void UEFITool::updateRecentFilesMenu(const QString& fileName)
|
||||||
|
{
|
||||||
|
// Update list
|
||||||
|
if (!fileName.isEmpty()) {
|
||||||
|
recentFiles.removeAll(fileName);
|
||||||
|
recentFiles.prepend(fileName);
|
||||||
|
while (recentFiles.size() > 21) {
|
||||||
|
recentFiles.removeLast();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete old actions
|
||||||
|
for (QAction* action : recentFileActions) {
|
||||||
|
ui->menuFile->removeAction(action);
|
||||||
|
delete action;
|
||||||
|
}
|
||||||
|
recentFileActions.clear();
|
||||||
|
|
||||||
|
if (!recentFiles.isEmpty()) {
|
||||||
|
// Insert new actions before "Quit"
|
||||||
|
for (const QString& path : recentFiles) {
|
||||||
|
QAction* action = new QAction(QDir::toNativeSeparators(path), this);
|
||||||
|
connect(action, SIGNAL(triggered()), this, SLOT(openRecentImageFile()));
|
||||||
|
action->setData(path);
|
||||||
|
ui->menuFile->insertAction(ui->actionQuit, action);
|
||||||
|
recentFileActions.append(action);
|
||||||
|
}
|
||||||
|
// Finally, insert a separator after the list and before "Quit"
|
||||||
|
recentFileActions.append(ui->menuFile->insertSeparator(ui->actionQuit));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void UEFITool::populateUi(const QItemSelection &selected)
|
void UEFITool::populateUi(const QItemSelection &selected)
|
||||||
{
|
{
|
||||||
if (selected.isEmpty()) {
|
if (selected.isEmpty()) {
|
||||||
|
@ -518,7 +553,7 @@ void UEFITool::extract(const UINT8 mode)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
name = QDir::toNativeSeparators(currentDir + QDir::separator() + name);
|
name = QDir::toNativeSeparators(extractDir + QDir::separator() + name);
|
||||||
|
|
||||||
//ui->statusBar->showMessage(name);
|
//ui->statusBar->showMessage(name);
|
||||||
|
|
||||||
|
@ -568,6 +603,8 @@ void UEFITool::extract(const UINT8 mode)
|
||||||
outputFile.resize(0);
|
outputFile.resize(0);
|
||||||
outputFile.write(extracted);
|
outputFile.write(extracted);
|
||||||
outputFile.close();
|
outputFile.close();
|
||||||
|
|
||||||
|
extractDir = QFileInfo(path).absolutePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UEFITool::rebuild()
|
void UEFITool::rebuild()
|
||||||
|
@ -621,18 +658,30 @@ void UEFITool::saveImageFile()
|
||||||
|
|
||||||
void UEFITool::openImageFile()
|
void UEFITool::openImageFile()
|
||||||
{
|
{
|
||||||
QString path = QFileDialog::getOpenFileName(this, tr("Open BIOS image file"), currentDir, tr("BIOS image files (*.rom *.bin *.cap *scap *.bio *.fd *.wph *.dec);;All files (*)"));
|
QString path = QFileDialog::getOpenFileName(this, tr("Open BIOS image file"), openImageDir, tr("BIOS image files (*.rom *.bin *.cap *scap *.bio *.fd *.wph *.dec);;All files (*)"));
|
||||||
openImageFile(path);
|
openImageFile(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UEFITool::openImageFileInNewWindow()
|
void UEFITool::openImageFileInNewWindow()
|
||||||
{
|
{
|
||||||
QString path = QFileDialog::getOpenFileName(this, tr("Open BIOS image file in new window"), currentDir, tr("BIOS image files (*.rom *.bin *.cap *scap *.bio *.fd *.wph *.dec);;All files (*)"));
|
QString path = QFileDialog::getOpenFileName(this, tr("Open BIOS image file in new window"), openImageDir, tr("BIOS image files (*.rom *.bin *.cap *scap *.bio *.fd *.wph *.dec);;All files (*)"));
|
||||||
if (path.trimmed().isEmpty())
|
if (path.trimmed().isEmpty())
|
||||||
return;
|
return;
|
||||||
QProcess::startDetached(currentProgramPath, QStringList(path));
|
QProcess::startDetached(currentProgramPath, QStringList(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UEFITool::openRecentImageFile()
|
||||||
|
{
|
||||||
|
QAction* action = qobject_cast<QAction*>(sender());
|
||||||
|
if (action) {
|
||||||
|
QString fileName = action->data().toString();
|
||||||
|
if (!fileName.isEmpty()) {
|
||||||
|
openImageFile(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void UEFITool::openImageFile(QString path)
|
void UEFITool::openImageFile(QString path)
|
||||||
{
|
{
|
||||||
if (path.trimmed().isEmpty())
|
if (path.trimmed().isEmpty())
|
||||||
|
@ -701,9 +750,15 @@ void UEFITool::openImageFile(QString path)
|
||||||
|
|
||||||
// Set current directory
|
// Set current directory
|
||||||
currentDir = fileInfo.absolutePath();
|
currentDir = fileInfo.absolutePath();
|
||||||
|
openImageDir = currentDir;
|
||||||
|
|
||||||
// Set current path
|
// Set current path
|
||||||
currentPath = path;
|
currentPath = path;
|
||||||
|
|
||||||
|
// Update menu
|
||||||
|
updateRecentFilesMenu(currentPath);
|
||||||
|
|
||||||
|
ui->structureTreeView->expandToDepth(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UEFITool::enableMessagesCopyActions(QListWidgetItem* item)
|
void UEFITool::enableMessagesCopyActions(QListWidgetItem* item)
|
||||||
|
@ -945,6 +1000,10 @@ void UEFITool::readSettings()
|
||||||
ui->structureTreeView->setColumnWidth(3, settings.value("tree/columnWidth3", ui->structureTreeView->columnWidth(3)).toInt());
|
ui->structureTreeView->setColumnWidth(3, settings.value("tree/columnWidth3", ui->structureTreeView->columnWidth(3)).toInt());
|
||||||
markingEnabled = settings.value("tree/markingEnabled", true).toBool();
|
markingEnabled = settings.value("tree/markingEnabled", true).toBool();
|
||||||
ui->actionToggleBootGuardMarking->setChecked(markingEnabled);
|
ui->actionToggleBootGuardMarking->setChecked(markingEnabled);
|
||||||
|
openImageDir = settings.value("paths/openImageDir", ".").toString();
|
||||||
|
openGuidDatabaseDir = settings.value("paths/openGuidDatabaseDir", ".").toString();
|
||||||
|
extractDir = settings.value("paths/extractDir", ".").toString();
|
||||||
|
recentFiles = settings.value("paths/recentFiles").toStringList();
|
||||||
|
|
||||||
// Set monospace font
|
// Set monospace font
|
||||||
QString fontName;
|
QString fontName;
|
||||||
|
@ -980,6 +1039,10 @@ void UEFITool::writeSettings()
|
||||||
settings.setValue("tree/markingEnabled", markingEnabled);
|
settings.setValue("tree/markingEnabled", markingEnabled);
|
||||||
settings.setValue("mainWindow/fontName", currentFont.family());
|
settings.setValue("mainWindow/fontName", currentFont.family());
|
||||||
settings.setValue("mainWindow/fontSize", currentFont.pointSize());
|
settings.setValue("mainWindow/fontSize", currentFont.pointSize());
|
||||||
|
settings.setValue("paths/openImageDir", openImageDir);
|
||||||
|
settings.setValue("paths/openGuidDatabaseDir", openGuidDatabaseDir);
|
||||||
|
settings.setValue("paths/extractDir", extractDir);
|
||||||
|
settings.setValue("paths/recentFiles", recentFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UEFITool::showFitTable()
|
void UEFITool::showFitTable()
|
||||||
|
@ -1044,11 +1107,12 @@ void UEFITool::currentTabChanged(int index)
|
||||||
|
|
||||||
void UEFITool::loadGuidDatabase()
|
void UEFITool::loadGuidDatabase()
|
||||||
{
|
{
|
||||||
QString path = QFileDialog::getOpenFileName(this, tr("Select GUID database file to load"), currentDir, tr("Comma-separated values files (*.csv);;All files (*)"));
|
QString path = QFileDialog::getOpenFileName(this, tr("Select GUID database file to load"), openGuidDatabaseDir, tr("Comma-separated values files (*.csv);;All files (*)"));
|
||||||
if (!path.isEmpty()) {
|
if (!path.isEmpty()) {
|
||||||
initGuidDatabase(path);
|
initGuidDatabase(path);
|
||||||
if (!currentPath.isEmpty() && QMessageBox::Yes == QMessageBox::information(this, tr("New GUID database loaded"), tr("Apply new GUID database on the opened file?\nUnsaved changes and tree position will be lost."), QMessageBox::Yes, QMessageBox::No))
|
if (!currentPath.isEmpty() && QMessageBox::Yes == QMessageBox::information(this, tr("New GUID database loaded"), tr("Apply new GUID database on the opened file?\nUnsaved changes and tree position will be lost."), QMessageBox::Yes, QMessageBox::No))
|
||||||
openImageFile(currentPath);
|
openImageFile(currentPath);
|
||||||
|
openGuidDatabaseDir = QFileInfo(path).absolutePath();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,7 @@ private slots:
|
||||||
|
|
||||||
void openImageFile();
|
void openImageFile();
|
||||||
void openImageFileInNewWindow();
|
void openImageFileInNewWindow();
|
||||||
|
void openRecentImageFile();
|
||||||
void saveImageFile();
|
void saveImageFile();
|
||||||
|
|
||||||
void search();
|
void search();
|
||||||
|
@ -144,9 +145,14 @@ private:
|
||||||
GoToBaseDialog* goToBaseDialog;
|
GoToBaseDialog* goToBaseDialog;
|
||||||
GoToAddressDialog* goToAddressDialog;
|
GoToAddressDialog* goToAddressDialog;
|
||||||
QClipboard* clipboard;
|
QClipboard* clipboard;
|
||||||
|
QStringList recentFiles;
|
||||||
|
QList<QAction*> recentFileActions;
|
||||||
QString currentDir;
|
QString currentDir;
|
||||||
QString currentPath;
|
QString currentPath;
|
||||||
QString currentProgramPath;
|
QString currentProgramPath;
|
||||||
|
QString openImageDir;
|
||||||
|
QString openGuidDatabaseDir;
|
||||||
|
QString extractDir;
|
||||||
QFont currentFont;
|
QFont currentFont;
|
||||||
const QString version;
|
const QString version;
|
||||||
bool markingEnabled;
|
bool markingEnabled;
|
||||||
|
@ -155,6 +161,7 @@ private:
|
||||||
void dragEnterEvent(QDragEnterEvent* event);
|
void dragEnterEvent(QDragEnterEvent* event);
|
||||||
void dropEvent(QDropEvent* event);
|
void dropEvent(QDropEvent* event);
|
||||||
void contextMenuEvent(QContextMenuEvent* event);
|
void contextMenuEvent(QContextMenuEvent* event);
|
||||||
|
void updateRecentFilesMenu(const QString& fileName = QString());
|
||||||
void readSettings();
|
void readSettings();
|
||||||
void showParserMessages();
|
void showParserMessages();
|
||||||
void showFinderMessages();
|
void showFinderMessages();
|
||||||
|
|
|
@ -48,11 +48,11 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QSplitter" name="messagesSplitter">
|
<widget class="QSplitter" name="messagesSplitter">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Orientation::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QSplitter" name="infoSplitter">
|
<widget class="QSplitter" name="infoSplitter">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QGroupBox" name="structureGroupBox">
|
<widget class="QGroupBox" name="structureGroupBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
@ -196,7 +196,7 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QSplitter" name="splitter">
|
<widget class="QSplitter" name="splitter">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QTableWidget" name="fitTableWidget"/>
|
<widget class="QTableWidget" name="fitTableWidget"/>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -311,7 +311,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>851</width>
|
<width>851</width>
|
||||||
<height>31</height>
|
<height>33</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuFile">
|
<widget class="QMenu" name="menuFile">
|
||||||
|
@ -329,6 +329,7 @@
|
||||||
<addaction name="actionUnloadGuidDatabase"/>
|
<addaction name="actionUnloadGuidDatabase"/>
|
||||||
<addaction name="actionExportDiscoveredGuids"/>
|
<addaction name="actionExportDiscoveredGuids"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
<addaction name="actionQuit"/>
|
<addaction name="actionQuit"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuHelp">
|
<widget class="QMenu" name="menuHelp">
|
||||||
|
@ -699,7 +700,7 @@
|
||||||
<string>F1</string>
|
<string>F1</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="menuRole">
|
<property name="menuRole">
|
||||||
<enum>QAction::AboutRole</enum>
|
<enum>QAction::MenuRole::AboutRole</enum>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionAboutQt">
|
<action name="actionAboutQt">
|
||||||
|
@ -710,7 +711,7 @@
|
||||||
<string>Shift+F1</string>
|
<string>Shift+F1</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="menuRole">
|
<property name="menuRole">
|
||||||
<enum>QAction::AboutQtRole</enum>
|
<enum>QAction::MenuRole::AboutQtRole</enum>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionQuit">
|
<action name="actionQuit">
|
||||||
|
@ -721,7 +722,7 @@
|
||||||
<string>Alt+X</string>
|
<string>Alt+X</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="menuRole">
|
<property name="menuRole">
|
||||||
<enum>QAction::QuitRole</enum>
|
<enum>QAction::MenuRole::QuitRole</enum>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionSearch">
|
<action name="actionSearch">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue