cg_disasm: fixerinno

This commit is contained in:
Megamouse 2017-07-20 10:24:16 +02:00 committed by Ivan
parent 96dfa9b526
commit f69e252c7a

View File

@ -71,7 +71,7 @@ void cg_disasm_window::ShowContextMenu(const QPoint &pos)
connect(open, &QAction::triggered, [=] { connect(open, &QAction::triggered, [=] {
QString filePath = QFileDialog::getOpenFileName(this, tr("Select Cg program object"), m_path_last, tr("Cg program objects (*.fpo;*.vpo);;")); QString filePath = QFileDialog::getOpenFileName(this, tr("Select Cg program object"), m_path_last, tr("Cg program objects (*.fpo;*.vpo);;"));
if (filePath == NULL) return; if (filePath == NULL) return;
m_path_last = QFileInfo(filePath).path(); m_path_last = filePath;
ShowDisasm(); ShowDisasm();
}); });
@ -81,6 +81,8 @@ void cg_disasm_window::ShowContextMenu(const QPoint &pos)
void cg_disasm_window::ShowDisasm() void cg_disasm_window::ShowDisasm()
{ {
xgui_settings->SetValue(GUI::fd_cg_disasm, m_path_last);
if (QFileInfo(m_path_last).isFile()) if (QFileInfo(m_path_last).isFile())
{ {
CgBinaryDisasm disasm(sstr(m_path_last)); CgBinaryDisasm disasm(sstr(m_path_last));
@ -96,21 +98,22 @@ void cg_disasm_window::ShowDisasm()
bool cg_disasm_window::IsValidFile(const QMimeData& md, bool save) bool cg_disasm_window::IsValidFile(const QMimeData& md, bool save)
{ {
for (auto url : md.urls()) const QList<QUrl> urls = md.urls();
{
for (QString suff : {"fpo", "vpo"})
{
if (QFileInfo(url.fileName()).suffix().toLower() == suff)
{
if (save)
{
m_path_last = url.toLocalFile();
xgui_settings->SetValue(GUI::fd_cg_disasm, m_path_last);
}
return true; if (urls.count() > 1)
} {
return false;
}
const QString suff = QFileInfo(urls[0].fileName()).suffix().toLower();
if (suff == "fpo" || suff == "vpo")
{
if (save)
{
m_path_last = urls[0].toLocalFile();
} }
return true;
} }
return false; return false;
} }