Skip to content

Commit

Permalink
code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
mhogomchungu committed Sep 10, 2024
1 parent f38acae commit 23eba7e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/checkforupdates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ void checkUpdates::networkReply( int position,

checkforupdateswindow::args args ;

args.engineName = s.known() ? s.name() : "SiriKali" ; ;
args.engineName = s.known() ? s.name() : "SiriKali" ;

auto ss = QString::number( m_timeOut / 1000 ) ;
args.error = QObject::tr( "Network Request Failed To Respond Within %1 Seconds." ).arg( ss ) ;
Expand Down
61 changes: 36 additions & 25 deletions src/checkforupdateswindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void checkforupdateswindow::add( const checkforupdateswindow::args& e )
{
auto txt = e.engineName ;

m_opts.emplace_back( e.data,e.engineName ) ;
m_opts.emplace_back( e.data,e.engineName,e.error.isEmpty() ) ;

if( e.error.isEmpty() ){

Expand Down Expand Up @@ -251,7 +251,29 @@ void checkforupdateswindow::currentItemChanged( QTableWidgetItem * c, QTableWidg

void checkforupdateswindow::tableUpdate( int row,const QString& s )
{
m_ui->tableWidget->item( row,0 )->setText( s ) ;
if( m_opts[ row ].noError() ){

m_ui->tableWidget->item( row,0 )->setText( s ) ;
}
}

QString checkforupdateswindow::archiveName( int row )
{
if( m_opts[ row ].name() == "Securefs" ){

if( utility::platformIsLinux() ){

return "securefs-linux-amd64-release.zip" ;

}else if( utility::platformIsWindows() ){

return "securefs-windows-amd64-release.zip" ;
}else{
return "securefs-macos-amd64-release.zip" ;
}
}else{
return "linux-static_amd64.tar.gz" ;
}
}

QString checkforupdateswindow::tableText( int row )
Expand Down Expand Up @@ -420,39 +442,28 @@ void checkforupdateswindow::extracted( Ctx ctx,const utils::qprocess::outPut& p

void checkforupdateswindow::update( int row )
{
const auto array = m_opts[ row ].data().value( "assets" ).toArray() ;

QString name ;
if( m_opts[ row ].noError() ){

if( m_opts[ row ].name() == "Securefs" ){
const auto array = m_opts[ row ].data().value( "assets" ).toArray() ;

if( utility::platformIsLinux() ){
auto name = this->archiveName( row ) ;

name = "securefs-linux-amd64-release.zip" ;
for( const auto& it : array ){

}else if( utility::platformIsWindows() ){

name = "securefs-windows-amd64-release.zip" ;
}else{
name = "securefs-macos-amd64-release.zip" ;
}
}else{
name = "linux-static_amd64.tar.gz" ;
}
auto obj = it.toObject() ;

for( const auto& it : array ){
auto url = obj.value( "browser_download_url" ).toString() ;

auto obj = it.toObject() ;
if( url.endsWith( name ) ){

auto url = obj.value( "browser_download_url" ).toString() ;
return this->download( row,url,name ) ;
}
}

if( url.endsWith( name ) ){
auto mm = tr( "Failed To Find Archive To Download" ) ;

return this->download( row,url,name ) ;
}
this->tableUpdate( row,tr( "Error" ) + "\n" + mm ) ;
}

this->tableUpdate( row,tr( "Error" ) + "\n" + tr( "Failed To Find Archive To Download" ) ) ;
}

void checkforupdateswindow::closeEvent( QCloseEvent * e )
Expand Down
10 changes: 8 additions & 2 deletions src/checkforupdateswindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class checkforupdateswindow : public QDialog
void extracted( Ctx,const utils::qprocess::outPut& ) ;
void currentItemChanged( QTableWidgetItem * ,QTableWidgetItem * ) ;
void tableUpdate( int,const QString& ) ;
QString archiveName( int ) ;
QString tableText( int ) ;
QString exePath( int ) ;
QString exeName( int ) ;
Expand All @@ -135,8 +136,8 @@ class checkforupdateswindow : public QDialog
class opts
{
public:
opts( const QJsonObject& s,const QString& m ) :
m_data( s ),m_name( m )
opts( const QJsonObject& s,const QString& m,bool e ) :
m_data( s ),m_name( m ),m_noError( e )
{
}
const QJsonObject& data() const
Expand All @@ -147,9 +148,14 @@ class checkforupdateswindow : public QDialog
{
return m_name ;
}
bool noError() const
{
return m_noError ;
}
private:
QJsonObject m_data ;
QString m_name ;
bool m_noError ;
} ;

class locale
Expand Down

0 comments on commit 23eba7e

Please sign in to comment.