mirror of
https://github.com/isledecomp/SIEdit.git
synced 2025-04-01 23:49:44 -04:00
Merge 07cb8ad89b
into 420eee4e98
This commit is contained in:
commit
ac5d3cbde4
3 changed files with 33 additions and 6 deletions
|
@ -40,6 +40,7 @@ int main(int argc, char *argv[])
|
|||
qInstallMessageHandler(DebugHandler);
|
||||
|
||||
QApplication a(argc, argv);
|
||||
a.setApplicationName(QCoreApplication::translate("main", "SI Editor"));
|
||||
|
||||
MainWindow w;
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
@ -176,6 +177,12 @@ void MainWindow::SetPanel(Panel *panel, si::Object *chunk)
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::UpdateWindowTitle(QString filename)
|
||||
{
|
||||
TrimOffDirectory(filename);
|
||||
setWindowTitle(QStringLiteral("%1 - %2[*]").arg(QApplication::applicationName(), filename));
|
||||
}
|
||||
|
||||
void MainWindow::ExtractObject(si::Object *obj)
|
||||
{
|
||||
QString filename = QString::fromStdString(obj->filename());
|
||||
|
@ -183,11 +190,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);
|
||||
|
@ -216,6 +219,8 @@ void MainWindow::ReplaceObject(si::Object *obj)
|
|||
#endif
|
||||
)) {
|
||||
static_cast<Panel*>(config_stack_->currentWidget())->ResetData();
|
||||
setWindowModified(true);
|
||||
|
||||
} else {
|
||||
QMessageBox::critical(this, QString(), tr("Failed to open to file \"%1\".").arg(s));
|
||||
}
|
||||
|
@ -278,11 +283,26 @@ 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()
|
||||
{
|
||||
tree_->clearSelection();
|
||||
SetPanel(panel_blank_, nullptr);
|
||||
model_.SetCore(nullptr);
|
||||
interleaf_.Clear();
|
||||
model_.SetCore(&interleaf_);
|
||||
|
||||
UpdateWindowTitle(tr("UNTITLED.SI"));
|
||||
}
|
||||
|
||||
void MainWindow::OpenFile()
|
||||
|
@ -290,6 +310,7 @@ void MainWindow::OpenFile()
|
|||
QString s = GetOpenFileName();
|
||||
if (!s.isEmpty()) {
|
||||
OpenFilename(s);
|
||||
UpdateWindowTitle(s);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -307,6 +328,7 @@ bool MainWindow::SaveFile()
|
|||
);
|
||||
|
||||
if (r == Interleaf::ERROR_SUCCESS) {
|
||||
UpdateWindowTitle(current_filename_);
|
||||
return true;
|
||||
} else {
|
||||
QMessageBox::critical(this, QString(), tr("Failed to write SI file: %1").arg(r));
|
||||
|
|
|
@ -39,6 +39,10 @@ private:
|
|||
|
||||
bool ExtractAllRecursiveInternal(const QDir &dir, const si::Core *obj);
|
||||
|
||||
void TrimOffDirectory(QString &s);
|
||||
|
||||
void UpdateWindowTitle(QString filename);
|
||||
|
||||
static const QString kFileFilter;
|
||||
|
||||
QStackedWidget *config_stack_;
|
||||
|
|
Loading…
Add table
Reference in a new issue