Skip to content

Commit

Permalink
Merge pull request #1429 from xiaoyifang/staged
Browse files Browse the repository at this point in the history
sync staged to dev
  • Loading branch information
xiaoyifang authored Mar 20, 2024
2 parents 1e261ac + be22cb2 commit 4f905c7
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/macos-arm-homebrew.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
brew install autoconf
brew install libtool
brew install opencc
brew install automake git lame libass libtool shtool texi2html theora wget xvid nasm
brew install automake libtool
brew install libiconv
brew install lzo bzip2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos-homebrew.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
brew install autoconf
brew install libtool
brew install opencc
brew install automake git lame libass libtool shtool texi2html theora wget xvid nasm
brew install automake libtool
brew install libiconv
brew install lzo bzip2
Expand Down
5 changes: 5 additions & 0 deletions src/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,11 @@ Class load()
Path( nl.item( x ).toElement().text(), nl.item( x ).toElement().attribute( "recursive" ) == "1" ) );
}

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() ) {
Expand Down
20 changes: 19 additions & 1 deletion src/dict/sounddir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <set>
#include <QDir>
#include <QFileInfo>
#include <QDirIterator>

namespace SoundDir {

Expand Down Expand Up @@ -438,7 +439,24 @@ vector< sptr< Dictionary::Class > > makeDictionaries( Config::SoundDirs const &

string indexFile = indicesDir + dictId;

if ( Dictionary::needToRebuildIndex( dictFiles, indexFile ) || indexIsOldOrBad( indexFile ) ) {
// Check if the soundDir and its subdirs' modification date changed, that means the user modified the sound files inside

bool soundDirModified = false;
{
QDateTime indexFileModifyTime = QFileInfo( QString::fromStdString( indexFile ) ).lastModified();
QDirIterator it( dir.path(),
QDir::AllDirs | QDir::NoDotAndDotDot | QDir::NoSymLinks,
QDirIterator::Subdirectories );
while ( it.hasNext() ) {
it.next();
if ( it.fileInfo().lastModified() > indexFileModifyTime ) {
soundDirModified = true;
break;
}
}
}

if ( Dictionary::needToRebuildIndex( dictFiles, indexFile ) || indexIsOldOrBad( indexFile ) || soundDirModified ) {
// Building the index

qDebug() << "Sounds: Building the index for directory: " << soundDir.path;
Expand Down
7 changes: 0 additions & 7 deletions src/dict/sources.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1115,13 +1115,6 @@ 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;

Expand Down

0 comments on commit 4f905c7

Please sign in to comment.