Skip to content

Commit

Permalink
Revert "Add option to force utf8 filenames (nickbnf#223)"
Browse files Browse the repository at this point in the history
This reverts commit c10b30e.
  • Loading branch information
variar committed Oct 28, 2020
1 parent c10b30e commit 8339be0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 64 deletions.
44 changes: 17 additions & 27 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ struct CliParameters {
bool follow_file = false;
int64_t log_level = static_cast<int64_t>( logWARNING );

std::vector<std::string> filenames;
std::vector<QString> filenames;

CliParameters() = default;

Expand Down Expand Up @@ -154,9 +154,19 @@ struct CliParameters {
[this]( auto count ) { log_level = static_cast<int64_t>( logWARNING ) + count; },
"output more debug (include multiple times for more verbosity e.g. -dddd)" );

options.add_option( "files", filenames, "files to open" );
std::vector<std::string> raw_filenames;
options.add_option( "files", raw_filenames, "files to open" );

options.parse( argc, argv );

for ( const auto& file : raw_filenames ) {
const auto rawName = QByteArray{ file.data(), static_cast<int>( file.size() ) };
const auto decodedName = QFile::decodeName( rawName );
if ( !decodedName.isEmpty() ) {
const auto fileInfo = QFileInfo( decodedName );
filenames.emplace_back( fileInfo.absoluteFilePath() );
}
}
}
};

Expand All @@ -181,35 +191,15 @@ int main( int argc, char* argv[] )

LOG( logINFO ) << "Klogg instance " << app.instanceId();

Configuration::getSynced();
const auto& config = Configuration::get();

const auto decodeFilename
= [assumeUtf8 = config.assumeUtf8Filenames()]( const QByteArray& rawName ) {
#ifdef Q_OS_LINUX
return assumeUtf8 ? QString::fromUtf8( rawName ) : QFile::decodeName( rawName );
#else
Q_UNUSED(assumeUtf8)
return QFile::decodeName( rawName );
#endif
};

std::vector<QString> initialFiles;
for ( const auto& file : parameters.filenames ) {
const auto rawName = QByteArray{ file.data(), static_cast<int>( file.size() ) };
const auto decodedName = decodeFilename( rawName );
if ( !decodedName.isEmpty() ) {
const auto fileInfo = QFileInfo( decodedName );
initialFiles.emplace_back( fileInfo.absoluteFilePath() );
}
}

if ( !parameters.multi_instance && app.isSecondary() ) {
LOG( logINFO ) << "Found another klogg, pid " << app.primaryPid();
app.sendFilesToPrimaryInstance( initialFiles );
app.sendFilesToPrimaryInstance( parameters.filenames );
}
else {
Configuration::getSynced();

// Load the existing session if needed
const auto& config = Configuration::get();
plog::EnableLogging( config.enableLogging(), config.loggingLevel() );

MainWindow* mw = nullptr;
Expand All @@ -225,7 +215,7 @@ int main( int argc, char* argv[] )
mw->show();
}

for ( const auto& filename : initialFiles ) {
for ( const auto& filename : parameters.filenames ) {
mw->loadInitialFile( filename, parameters.follow_file );
}

Expand Down
16 changes: 0 additions & 16 deletions src/ui/include/optionsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -432,22 +432,6 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="fileSettingsBox">
<property name="title">
<string>Misc</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_16">
<item>
<widget class="QCheckBox" name="assumeUtf8FilenamesCheckBox">
<property name="text">
<string>Assume utf-8 filenames</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
Expand Down
6 changes: 1 addition & 5 deletions src/ui/src/optionsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ void OptionsDialog::updateDialogFromConfig()
if ( familyIndex != -1 )
fontFamilyBox->setCurrentIndex( familyIndex );

updateFontSize( fontInfo.family() );
updateFontSize(fontInfo.family());

int sizeIndex = fontSizeBox->findText( QString::number( fontInfo.pointSize() ) );
if ( sizeIndex != -1 )
Expand Down Expand Up @@ -262,8 +262,6 @@ void OptionsDialog::updateDialogFromConfig()

// downloads
verifySslCheckBox->setChecked( config.verifySslPeers() );

assumeUtf8FilenamesCheckBox->setChecked( config.assumeUtf8Filenames() );
}

//
Expand Down Expand Up @@ -338,8 +336,6 @@ void OptionsDialog::updateConfigFromDialog()

config.setVerifySslPeers( verifySslCheckBox->isChecked() );

config.setAssumeUtf8Filenames( assumeUtf8FilenamesCheckBox->isChecked() );

config.setStyle( styleComboBox->currentText() );

config.save();
Expand Down
11 changes: 0 additions & 11 deletions src/utils/include/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,15 +374,6 @@ class Configuration final : public Persistable<Configuration> {
scaleFactorRounding_ = rounding;
}

bool assumeUtf8Filenames() const
{
return assumeUtf8Filenames_;
}
void setAssumeUtf8Filenames( bool enable )
{
assumeUtf8Filenames_ = enable;
}

// Reads/writes the current config in the QSettings object passed
void saveToStorage( QSettings& settings ) const;
void retrieveFromStorage( QSettings& settings );
Expand Down Expand Up @@ -446,8 +437,6 @@ class Configuration final : public Persistable<Configuration> {
bool enableQtHighDpi_ = true;

int scaleFactorRounding_ = 1;

bool assumeUtf8Filenames_ = false;
};

#endif
5 changes: 0 additions & 5 deletions src/utils/src/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ void Configuration::retrieveFromStorage( QSettings& settings )
.value( "filewatch.fastModificationDetection", Default.fastModificationDetection_ )
.toBool();

assumeUtf8Filenames_
= settings.value( "file.utf8Filenames", Default.assumeUtf8Filenames_ ).toBool();

loadLastSession_ = settings.value( "session.loadLast", Default.loadLastSession_ ).toBool();
allowMultipleWindows_
= settings.value( "session.multipleWindows", Default.allowMultipleWindows_ ).toBool();
Expand Down Expand Up @@ -219,8 +216,6 @@ void Configuration::saveToStorage( QSettings& settings ) const

settings.setValue( "versionchecker.enabled", enableVersionChecking_ );

settings.setValue( "file.utf8Filenames", assumeUtf8Filenames_ );

settings.setValue( "archives.extract", extractArchives_ );
settings.setValue( "archives.extractAlways", extractArchivesAlways_ );

Expand Down

0 comments on commit 8339be0

Please sign in to comment.