Skip to content

Commit

Permalink
revisit windows support
Browse files Browse the repository at this point in the history
  • Loading branch information
mhogomchungu committed Feb 9, 2025
1 parent 7f0681a commit 228914a
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 17 deletions.
12 changes: 8 additions & 4 deletions src/engines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,15 @@ void engines::showBanner()
m_logger.add( QObject::tr( "Download Path: %1" ).arg( m_settings.downloadFolder( m_logger ) ),id ) ;
m_logger.add( QObject::tr( "App Data Path: %1" ).arg( m_enginePaths.basePath() ),id ) ;

//if( utility::platformIsWindows() ){
m_logger.add( utility::barLine(),id ) ;

// const auto& m = m_settings.windowsOnly3rdPartyBinPath() ;
// m_logger.add( QObject::tr( "3rd Party Path: %1" ).arg( m ),id ) ;
//}
if( m_settings.printMediaPlayers() ){

for( const auto& it : utility::getMediaPlayers() ){

m_logger.add( it.name + ":" + it.exePath,id ) ;
}
}
}

void engines::setNetworkProxy( engines::proxySettings e,bool firstTime )
Expand Down
6 changes: 6 additions & 0 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ bool settings::enableLibraryTab()
return this->getOption( "EnableLibraryTab",false ) ;
}

bool settings::printMediaPlayers()
{
return m_printMediaPlayers ;
}

bool settings::checkForEnginesUpdates()
{
return this->getOption( "CheckForEnginesUpdates",true ) ;
Expand Down Expand Up @@ -382,6 +387,7 @@ QString settings::downloadLocation()
#endif

settings::settings( const utility::cliArguments& args ) :
m_printMediaPlayers( args.printMediaPlayers() ),
m_appDataPath( this->appDataLocation() ),
m_options( args,m_appDataPath ),
m_settingsP( this->init() ),
Expand Down
2 changes: 2 additions & 0 deletions src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ class settings
bool autoSavePlaylistOnExit() ;
bool useInternalArchiveFile() ;
bool enableLibraryTab() ;
bool printMediaPlayers() ;
bool checkForEnginesUpdates() ;
bool autoHideDownloadWhenCompleted() ;
bool deleteFilesOnCanceledDownload() ;
Expand Down Expand Up @@ -400,6 +401,7 @@ class settings
} ;

bool m_EnableHighDpiScaling ;
bool m_printMediaPlayers ;
QString m_appDataPath ;
QByteArray m_defaultScaleFactor ;
QByteArray m_MdScaleFactor ;
Expand Down
42 changes: 29 additions & 13 deletions src/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,15 +365,15 @@ std::vector< utility::PlayerOpts > _getMediaPlayers( REGSAM wow )
return this->endsWith( ".mp4" ) || this->endsWith( ".MP4" ) ;
}
}
operator wchar_t*()
wchar_t * data()
{
return m_buffer.data() ;
}
operator const wchar_t*() const
const wchar_t * data() const
{
return m_buffer.data() ;
}
operator QString()
QString qdata() const
{
return this->string() ;
}
Expand All @@ -400,7 +400,7 @@ std::vector< utility::PlayerOpts > _getMediaPlayers( REGSAM wow )
public:
Hkey( Hkey& hkey,const buffer& subKey ) :
m_regSam( hkey.regSam() ),
m_status( this->open( hkey,subKey ) )
m_status( this->open( hkey,subKey.data() ) )
{
}
Hkey( REGSAM r ) :
Expand Down Expand Up @@ -438,11 +438,11 @@ std::vector< utility::PlayerOpts > _getMediaPlayers( REGSAM wow )

auto path = L"shell\\open\\command" ;

auto st = RegGetValueW( m_key,path,N,RRF_RT_REG_SZ,N,subKey,subKey.size() ) ;
auto st = RegGetValueW( m_key,path,N,RRF_RT_REG_SZ,N,subKey.data(),subKey.size() ) ;

if( st == ERROR_SUCCESS ){

return subKey ;
return subKey.qdata() ;
}else{
return {} ;
}
Expand All @@ -453,7 +453,7 @@ std::vector< utility::PlayerOpts > _getMediaPlayers( REGSAM wow )

buffer subKey ;

auto st = RegEnumKeyExW( m_key,i,subKey,subKey.size(),N,N,N,N ) ;
auto st = RegEnumKeyExW( m_key,i,subKey.data(),subKey.size(),N,N,N,N ) ;

if( st == ERROR_SUCCESS ){

Expand Down Expand Up @@ -520,13 +520,24 @@ std::vector< utility::PlayerOpts > _getMediaPlayers( REGSAM wow )
continue ;
}

if( !ss.startsWith( "\"" ) ){
QStringList p ;

ss = "\"" + ss ;
ss.replace( ".exe ",".exe\" " ) ;
}
if( ss.startsWith( "\"" ) ){

p = util::splitPreserveQuotes( ss ) ;
}else{
auto e = ss.indexOf( ".exe" ) ;

if( e != -1 ){

auto m = ss.mid( 0,e + 4 ) ;

auto p = util::splitPreserveQuotes( ss ) ;
if( QFile::exists( m ) ){

p.append( m ) ;
}
}
}

if( p.size() ){

Expand All @@ -536,7 +547,7 @@ std::vector< utility::PlayerOpts > _getMediaPlayers( REGSAM wow )

s.emplace_back( m,"Windows Media Player" ) ;
}else{
auto na = util::split( subKey,"." ) ;
auto na = util::split( subKey.qdata(),"." ) ;

auto e = na.first() ;

Expand Down Expand Up @@ -1990,6 +2001,11 @@ bool utility::cliArguments::portable() const
return this->contains( "--portable" ) ;
}

bool utility::cliArguments::printMediaPlayers() const
{
return this->contains( "--print-media-players" ) ;
}

QString utility::cliArguments::dataPath() const
{
return this->value( "--dataPath" ) ;
Expand Down
1 change: 1 addition & 0 deletions src/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ namespace utility
bool contains( const char * ) const ;
bool runningUpdated() const ;
bool portable() const ;
bool printMediaPlayers() const ;
QString dataPath() const ;
QString originalPath() const ;
QString originalVersion() const ;
Expand Down

0 comments on commit 228914a

Please sign in to comment.