Skip to content

Commit

Permalink
Merge pull request #1394 from xiaoyifang/opt/portable
Browse files Browse the repository at this point in the history
opt: allow add directory in portable mode
  • Loading branch information
xiaoyifang authored Feb 1, 2024
2 parents a7e07ea + 85333df commit 92ad684
Showing 1 changed file with 7 additions and 26 deletions.
33 changes: 7 additions & 26 deletions src/dict/sources.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,32 +131,6 @@ Sources::Sources( QWidget * parent, Config::Class const & cfg ):
ui.tabWidget->addTab( textToSpeechSource, QIcon( ":/icons/text2speech.svg" ), tr( "Text to Speech" ) );
}
#endif

if ( Config::isPortableVersion() ) {
// Paths

ui.paths->setEnabled( false );
ui.addPath->setEnabled( false );
ui.removePath->setEnabled( false );

// Sound dirs

{
QStandardItemModel * model = new QStandardItemModel( this );
model->setHorizontalHeaderLabels( QStringList() << " " );
model->invisibleRootItem()->appendRow( new QStandardItem( tr( "(not available in portable version)" ) ) );
ui.soundDirs->setModel( model );
ui.soundDirs->setEnabled( false );

ui.addSoundDir->setEnabled( false );
ui.removeSoundDir->setEnabled( false );
}

// Morpho

ui.hunspellPath->setEnabled( false );
ui.changeHunspellPath->setEnabled( false );
}
}

void Sources::fitPathsColumns()
Expand Down Expand Up @@ -1137,6 +1111,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;

Expand Down

0 comments on commit 92ad684

Please sign in to comment.