Palette file pathing fixes for Qt GUI.
This commit is contained in:
parent
df315f8e9c
commit
0768579faa
|
@ -324,7 +324,7 @@ void PaletteConfDialog_t::openPaletteFile(void)
|
||||||
{
|
{
|
||||||
int ret, useNativeFileDialogVal;
|
int ret, useNativeFileDialogVal;
|
||||||
QString filename;
|
QString filename;
|
||||||
std::string last;
|
std::string last, iniPath;
|
||||||
char dir[512];
|
char dir[512];
|
||||||
char exePath[512];
|
char exePath[512];
|
||||||
QFileDialog dialog(this, tr("Open NES Palette") );
|
QFileDialog dialog(this, tr("Open NES Palette") );
|
||||||
|
@ -345,6 +345,7 @@ void PaletteConfDialog_t::openPaletteFile(void)
|
||||||
if ( d.exists() )
|
if ( d.exists() )
|
||||||
{
|
{
|
||||||
urls << QUrl::fromLocalFile( d.absolutePath() );
|
urls << QUrl::fromLocalFile( d.absolutePath() );
|
||||||
|
iniPath = d.absolutePath().toStdString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
@ -355,6 +356,7 @@ void PaletteConfDialog_t::openPaletteFile(void)
|
||||||
if ( d.exists() )
|
if ( d.exists() )
|
||||||
{
|
{
|
||||||
urls << QUrl::fromLocalFile( d.absolutePath() );
|
urls << QUrl::fromLocalFile( d.absolutePath() );
|
||||||
|
iniPath = d.absolutePath().toStdString();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -370,7 +372,7 @@ void PaletteConfDialog_t::openPaletteFile(void)
|
||||||
|
|
||||||
if ( last.size() == 0 )
|
if ( last.size() == 0 )
|
||||||
{
|
{
|
||||||
last.assign( "/usr/share/fceux/palettes" );
|
last.assign( iniPath );
|
||||||
}
|
}
|
||||||
|
|
||||||
getDirFromFile( last.c_str(), dir );
|
getDirFromFile( last.c_str(), dir );
|
||||||
|
@ -397,10 +399,10 @@ void PaletteConfDialog_t::openPaletteFile(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( filename.isNull() )
|
if ( filename.isNull() )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qDebug() << "selected file path : " << filename.toUtf8();
|
qDebug() << "selected file path : " << filename.toUtf8();
|
||||||
|
|
||||||
if ( fceuWrapperTryLock() )
|
if ( fceuWrapperTryLock() )
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
#include "Qt/keyscan.h"
|
#include "Qt/keyscan.h"
|
||||||
#include "Qt/fceuWrapper.h"
|
#include "Qt/fceuWrapper.h"
|
||||||
#include "Qt/PaletteEditor.h"
|
#include "Qt/PaletteEditor.h"
|
||||||
|
#include "Qt/ConsoleUtilities.h"
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
PaletteEditorDialog_t::PaletteEditorDialog_t(QWidget *parent)
|
PaletteEditorDialog_t::PaletteEditorDialog_t(QWidget *parent)
|
||||||
|
@ -146,7 +147,41 @@ void PaletteEditorDialog_t::openPaletteFileDialog(void)
|
||||||
{
|
{
|
||||||
int ret, useNativeFileDialogVal;
|
int ret, useNativeFileDialogVal;
|
||||||
QString filename;
|
QString filename;
|
||||||
|
char dir[512];
|
||||||
|
char exePath[512];
|
||||||
|
std::string last, iniPath;
|
||||||
QFileDialog dialog(this, tr("Open Palette From File") );
|
QFileDialog dialog(this, tr("Open Palette From File") );
|
||||||
|
QList<QUrl> urls;
|
||||||
|
QDir d;
|
||||||
|
|
||||||
|
fceuExecutablePath( exePath, sizeof(exePath) );
|
||||||
|
|
||||||
|
//urls = dialog.sidebarUrls();
|
||||||
|
urls << QUrl::fromLocalFile( QDir::rootPath() );
|
||||||
|
urls << QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first());
|
||||||
|
urls << QUrl::fromLocalFile( QDir( FCEUI_GetBaseDirectory() ).absolutePath() );
|
||||||
|
|
||||||
|
if ( exePath[0] != 0 )
|
||||||
|
{
|
||||||
|
d.setPath( QString(exePath) + "/../palettes" );
|
||||||
|
|
||||||
|
if ( d.exists() )
|
||||||
|
{
|
||||||
|
urls << QUrl::fromLocalFile( d.absolutePath() );
|
||||||
|
iniPath = d.absolutePath().toStdString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifdef WIN32
|
||||||
|
|
||||||
|
#else
|
||||||
|
d.setPath("/usr/share/fceux/palettes");
|
||||||
|
|
||||||
|
if ( d.exists() )
|
||||||
|
{
|
||||||
|
urls << QUrl::fromLocalFile( d.absolutePath() );
|
||||||
|
iniPath = d.absolutePath().toStdString();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
const QStringList filters(
|
const QStringList filters(
|
||||||
{
|
{
|
||||||
|
@ -162,12 +197,21 @@ void PaletteEditorDialog_t::openPaletteFileDialog(void)
|
||||||
dialog.setFilter( QDir::AllEntries | QDir::AllDirs | QDir::Hidden );
|
dialog.setFilter( QDir::AllEntries | QDir::AllDirs | QDir::Hidden );
|
||||||
dialog.setLabelText( QFileDialog::Accept, tr("Open") );
|
dialog.setLabelText( QFileDialog::Accept, tr("Open") );
|
||||||
|
|
||||||
dialog.setDirectory( tr("/usr/share/fceux/palettes") );
|
g_config->getOption ("SDL.Palette", &last );
|
||||||
|
|
||||||
|
if ( last.size() == 0 )
|
||||||
|
{
|
||||||
|
last.assign( iniPath );
|
||||||
|
}
|
||||||
|
getDirFromFile( last.c_str(), dir );
|
||||||
|
|
||||||
|
dialog.setDirectory( tr(dir) );
|
||||||
|
|
||||||
// Check config option to use native file dialog or not
|
// Check config option to use native file dialog or not
|
||||||
g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal);
|
g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal);
|
||||||
|
|
||||||
dialog.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal);
|
dialog.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal);
|
||||||
|
dialog.setSidebarUrls(urls);
|
||||||
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
ret = dialog.exec();
|
ret = dialog.exec();
|
||||||
|
@ -190,6 +234,7 @@ void PaletteEditorDialog_t::openPaletteFileDialog(void)
|
||||||
qDebug() << "selected file path : " << filename.toUtf8();
|
qDebug() << "selected file path : " << filename.toUtf8();
|
||||||
|
|
||||||
palView->loadFromFile( filename.toStdString().c_str() );
|
palView->loadFromFile( filename.toStdString().c_str() );
|
||||||
|
g_config->setOption ("SDL.Palette", filename.toStdString().c_str() );
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue