mirror of
https://github.com/isledecomp/SIEdit.git
synced 2025-04-01 23:49:44 -04:00
app: append open filename to window title
This commit is contained in:
parent
1caf9b76b4
commit
45f887c201
2 changed files with 19 additions and 6 deletions
|
@ -1,5 +1,6 @@
|
|||
#include "mainwindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QFileDialog>
|
||||
#include <QLineEdit>
|
||||
#include <QMenuBar>
|
||||
|
@ -104,7 +105,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
|
||||
splitter->setSizes({99999, 99999});
|
||||
|
||||
setWindowTitle(tr("SI Editor"));
|
||||
setWindowTitle(QApplication::applicationName());
|
||||
}
|
||||
|
||||
void MainWindow::OpenFilename(const QString &s)
|
||||
|
@ -183,11 +184,7 @@ void MainWindow::ExtractObject(si::Object *obj)
|
|||
filename = QString::fromStdString(obj->name());
|
||||
filename.append(QStringLiteral(".bin"));
|
||||
} else {
|
||||
// Strip off directory
|
||||
int index = filename.lastIndexOf('\\');
|
||||
if (index != -1) {
|
||||
filename = filename.mid(index+1);
|
||||
}
|
||||
TrimOffDirectory(filename);
|
||||
}
|
||||
|
||||
QString s = QFileDialog::getSaveFileName(this, tr("Export Object"), filename);
|
||||
|
@ -278,6 +275,17 @@ bool MainWindow::ExtractAllRecursiveInternal(const QDir &dir, const si::Core *ob
|
|||
return true;
|
||||
}
|
||||
|
||||
void MainWindow::TrimOffDirectory(QString& s)
|
||||
{
|
||||
int bSlashIndex = s.lastIndexOf('\\');
|
||||
int fSlashIndex = s.lastIndexOf('/');
|
||||
int lastIndex = (bSlashIndex > fSlashIndex) ? bSlashIndex : fSlashIndex;
|
||||
|
||||
if (lastIndex != -1) {
|
||||
s = s.mid(lastIndex + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::NewFile()
|
||||
{
|
||||
model_.SetCore(nullptr);
|
||||
|
@ -290,6 +298,9 @@ void MainWindow::OpenFile()
|
|||
QString s = GetOpenFileName();
|
||||
if (!s.isEmpty()) {
|
||||
OpenFilename(s);
|
||||
TrimOffDirectory(s);
|
||||
|
||||
setWindowTitle(QStringLiteral("%1 - %2").arg(QApplication::applicationName(), s));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,8 @@ private:
|
|||
|
||||
bool ExtractAllRecursiveInternal(const QDir &dir, const si::Core *obj);
|
||||
|
||||
void TrimOffDirectory(QString &s);
|
||||
|
||||
static const QString kFileFilter;
|
||||
|
||||
QStackedWidget *config_stack_;
|
||||
|
|
Loading…
Add table
Reference in a new issue