mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
fix: default content
directory in portable mode (#1872)
* fix: default `content` directory in portable mode * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
939e786331
commit
7229faeec7
|
@ -554,9 +554,13 @@ Class load()
|
|||
|
||||
if ( QDir( "/usr/share/myspell/dicts" ).exists() )
|
||||
c.hunspell.dictionariesPath = "/usr/share/myspell/dicts";
|
||||
|
||||
#endif
|
||||
|
||||
// Put portable hard-code directory the the config for the first time.
|
||||
if ( isPortableVersion() ) {
|
||||
// For portable version, hardcode some settings
|
||||
c.paths.push_back( Path( getPortableVersionDictionaryDir(), true ) );
|
||||
}
|
||||
|
||||
#ifndef Q_OS_WIN32
|
||||
c.preferences.audioPlaybackProgram = "mplayer";
|
||||
|
@ -625,6 +629,13 @@ Class load()
|
|||
|
||||
Class c;
|
||||
|
||||
// Put the hard-code portable directory to the first.
|
||||
// To allow additional directories, this path should not be saved.
|
||||
if ( isPortableVersion() ) {
|
||||
// For portable version, hardcode some settings
|
||||
c.paths.push_back( Path( getPortableVersionDictionaryDir(), true ) );
|
||||
}
|
||||
|
||||
QDomNode paths = root.namedItem( "paths" );
|
||||
|
||||
if ( !paths.isNull() ) {
|
||||
|
@ -636,11 +647,6 @@ Class load()
|
|||
}
|
||||
}
|
||||
|
||||
if ( Config::isPortableVersion() && c.paths.empty() ) {
|
||||
// For portable version, hardcode some settings
|
||||
c.paths.push_back( Config::Path( Config::getPortableVersionDictionaryDir(), true ) );
|
||||
}
|
||||
|
||||
QDomNode soundDirs = root.namedItem( "sounddirs" );
|
||||
|
||||
if ( !soundDirs.isNull() ) {
|
||||
|
@ -1391,7 +1397,11 @@ void save( Class const & c )
|
|||
QDomElement paths = dd.createElement( "paths" );
|
||||
root.appendChild( paths );
|
||||
|
||||
for ( const auto & i : c.paths ) {
|
||||
// Save all paths except the hard-code portable path,
|
||||
// which is stored in the first element of list.
|
||||
qsizetype pos = Config::isPortableVersion();
|
||||
|
||||
for ( const auto & i : c.paths.mid( pos ) ) {
|
||||
QDomElement path = dd.createElement( "path" );
|
||||
paths.appendChild( path );
|
||||
|
||||
|
|
|
@ -1171,6 +1171,13 @@ Qt::ItemFlags PathsModel::flags( QModelIndex const & index ) const
|
|||
{
|
||||
Qt::ItemFlags result = QAbstractItemModel::flags( index );
|
||||
|
||||
if ( Config::isPortableVersion() ) {
|
||||
if ( index.isValid() && index.row() == 0 ) {
|
||||
result &= ~Qt::ItemIsSelectable;
|
||||
result &= ~Qt::ItemIsEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
if ( index.isValid() && index.column() == 1 ) {
|
||||
result |= Qt::ItemIsUserCheckable;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue