Skip to content

Commit

Permalink
code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
mhogomchungu committed Jul 18, 2024
1 parent 6bc3b51 commit 4707a47
Show file tree
Hide file tree
Showing 14 changed files with 137 additions and 188 deletions.
2 changes: 1 addition & 1 deletion src/filemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fileManager::fileManager( QWidget * parent,QString& e,bool s ) :
{
m_ui->setupUi( this ) ;

connect( m_ui->pushButton,SIGNAL( clicked( bool ) ),this,SLOT( set() ) ) ;
connect( m_ui->pushButton,&QPushButton::clicked,this,&fileManager::set ) ;

this->setFixedSize( this->size() ) ;
this->setFont( parent->font() ) ;
Expand Down
3 changes: 1 addition & 2 deletions src/filemanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ class fileManager : public QDialog
}
explicit fileManager( QWidget * parent,QString&,bool ) ;
~fileManager();
private slots:
void set( void ) ;
private:
void set() ;
void closeEvent( QCloseEvent * ) ;
Ui::fileManager * m_ui ;
QString& m_fileManager ;
Expand Down
45 changes: 17 additions & 28 deletions src/keydialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,30 +223,19 @@ void keyDialog::setUpInitUI()

m_ui->tbVisibleKey->setIcon( QIcon( ":/icons/password_show.png" ) ) ;

connect( m_ui->pbCancel,SIGNAL( clicked() ),
this,SLOT( pbCancel() ) ) ;
connect( m_ui->pbOpen,SIGNAL( clicked() ),
this,SLOT( pbOpen() ) ) ;
connect( m_ui->pbkeyOption,SIGNAL( clicked() ),
this,SLOT( pbkeyOption() ) ) ;
connect( m_ui->pbOpenFolderPath,SIGNAL( clicked() ),
this,SLOT( pbFolderPath() ) ) ;
connect( m_ui->pbMountPoint,SIGNAL( clicked() ),
this,SLOT( pbMountPointPath() ) ) ;
connect( m_ui->checkBoxOpenReadOnly,SIGNAL( stateChanged( int ) ),
this,SLOT( cbMountReadOnlyStateChanged( int ) ) ) ;
connect( m_ui->pbOK,SIGNAL( clicked( bool ) ),
this,SLOT( pbOK() ) ) ;
connect( m_ui->tbVisibleKey,SIGNAL( clicked() ),
this,SLOT( cbVisibleKeyclicked() ) ) ;
connect( m_ui->pbOptions,SIGNAL( clicked() ),
this,SLOT( pbOptions() ) ) ;
connect( m_ui->pbSetKeyKeyFile,SIGNAL( clicked() ),
this,SLOT( pbSetKeyKeyFile() ) ) ;
connect( m_ui->pbSetKey,SIGNAL( clicked() ),
this,SLOT( pbSetKey() ) ) ;
connect( m_ui->pbSetKeyCancel,SIGNAL( clicked() ),
this,SLOT( pbSetKeyCancel() ) ) ;
connect( m_ui->checkBoxOpenReadOnly,&QCheckBox::stateChanged,
this,&keyDialog::cbMountReadOnlyStateChanged ) ;
connect( m_ui->pbCancel,&QPushButton::clicked,this,&keyDialog::pbCancel ) ;
connect( m_ui->pbOpen,&QPushButton::clicked,this,&keyDialog::pbOpen ) ;
connect( m_ui->pbkeyOption,&QPushButton::clicked,this,&keyDialog::pbkeyOption ) ;
connect( m_ui->pbOpenFolderPath,&QPushButton::clicked,this,&keyDialog::pbFolderPath ) ;
connect( m_ui->pbMountPoint,&QPushButton::clicked,this,&keyDialog::pbMountPointPath ) ;
connect( m_ui->pbOK,&QPushButton::clicked,this,&keyDialog::pbOK ) ;
connect( m_ui->tbVisibleKey,&QToolButton::clicked,this,&keyDialog::cbVisibleKeyclicked ) ;
connect( m_ui->pbOptions,&QPushButton::clicked,this,&keyDialog::pbOptions ) ;
connect( m_ui->pbSetKeyKeyFile,&QPushButton::clicked,this,&keyDialog::pbSetKeyKeyFile ) ;
connect( m_ui->pbSetKey,&QPushButton::clicked,this,&keyDialog::pbSetKey ) ;
connect( m_ui->pbSetKeyCancel,&QPushButton::clicked,this,&keyDialog::pbSetKeyCancel ) ;

connect( m_ui->pbMountPoint_1,&QPushButton::clicked,[ this ](){

Expand All @@ -268,8 +257,8 @@ void keyDialog::setUpInitUI()

m_ui->pbMountPoint_1->setVisible( false ) ;

connect( m_ui->lineEditMountPoint,SIGNAL( textChanged( QString ) ),
this,SLOT( textChanged( QString ) ) ) ;
connect( m_ui->lineEditMountPoint,&QLineEdit::textChanged,
this,&keyDialog::textChanged ) ;

m_ui->pbOpen->setText( tr( "&Create" ) ) ;

Expand Down Expand Up @@ -320,8 +309,8 @@ void keyDialog::setUpInitUI()

if( m_keyStrength ){

connect( m_ui->lineEditKey,SIGNAL( textChanged( QString ) ),
this,SLOT( passWordTextChanged( QString ) ) ) ;
connect( m_ui->lineEditKey,&QLineEdit::textChanged,
this,&keyDialog::passWordTextChanged ) ;
}

m_ui->lineEditMountPoint->setFocus() ;
Expand Down
55 changes: 27 additions & 28 deletions src/keydialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,53 +268,52 @@ class keyDialog : public QDialog
signals:
void mounted( QString ) ;
void cryptoOpen( QString ) ;
private slots:
void cbVisibleKeyclicked() ;
private:
void cbVisibleKeyclicked() ;
void textChanged( QString ) ;
void passWordTextChanged( QString ) ;
void pbOptions( void ) ;
void pbkeyOption( void ) ;
void pbMountPointPath( void ) ;
void pbFolderPath( void ) ;
void pbOK( void ) ;
void pbOpen( void ) ;
void pbCancel( void ) ;
void pbOptions();
void pbkeyOption();
void pbMountPointPath();
void pbFolderPath();
void pbOK();
void pbOpen();
void cbMountReadOnlyStateChanged( int ) ;
void encryptedFolderMount( void ) ;
void encryptedFolderCreate( void ) ;
void pbSetKeyKeyFile( void ) ;
void pbSetKey( void ) ;
void pbSetKeyCancel( void ) ;
private :
void key( void ) ;
void yubiKey( void ) ;
void secretStorage( void ) ;
void encryptedFolderMount();
void encryptedFolderCreate();
void pbSetKeyKeyFile();
void pbSetKey();
void pbSetKeyCancel();
void pbCancel();
void key();
void yubiKey();
void secretStorage();
void autoMount( const keyDialog::entry& ee ) ;
void unlockVolume( void ) ;
void unlockVolume();
void setVolumeToUnlock() ;
void setUpVolumeProperties( const keyDialog::entry& e ) ;
void setUpInitUI() ;
void setKeyEnabled( bool ) ;
void setDefaultUI( void ) ;
void setDefaultUI();
void SetUISetKey( bool ) ;
void ShowUI( void ) ;
void HideUI( void ) ;
void ShowUI();
void HideUI();
void setKeyInWallet() ;
void setKeyInWallet( const QString& volumeType,const QString& title ) ;
void showErrorMessage( const engines::engine::cmdStatus& ) ;
void showErrorMessage( const QString& ) ;
void reportErrorMessage( const engines::engine::cmdStatus& ) ;
void openMountPoint( const QString& ) ;
void keyFile( void ) ;
void keyFile();
void setUIVisible( bool ) ;
void openVolume( void ) ;
void enableAll( void ) ;
void disableAll( void ) ;
void openVolume();
void enableAll();
void disableAll();
void windowSetTitle( const QString& = QString() ) ;
void closeEvent( QCloseEvent * ) ;

bool upgradingFileSystem( void ) ;
bool replaceFileSystem( void ) ;
bool upgradingFileSystem();
bool replaceFileSystem();

void keyTypeChanged() ;

Expand Down
36 changes: 10 additions & 26 deletions src/mountinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ static mountinfo::List _processManager_volumes()

volumeInfo aa{ std::move( mm ),e.mountPointPath,std::move( fs ),e.mode } ;

s.emplace_back( mountinfo::volumeEntry{ e.engine,std::move( aa ) } ) ;
s.emplace_back( e.engine,std::move( aa ) ) ;
}

return s ;
Expand Down Expand Up @@ -190,11 +190,13 @@ mountinfo::mountinfo( QObject * parent,
m_linuxMonitorExit( false ),
m_folderMonitorExit( false ),
m_oldMountList( _unlocked_volumes() ),
m_dbusMonitor( [ this ]( const QString& e ){ this->autoMount( e ) ; },m_debug )
m_dbusMonitor( [ this ]( const QString& e ){ emit this->autoMount( e ) ; },m_debug )
{
connect( this,&mountinfo::updateVolume,this,&mountinfo::volumeUpdate,Qt::QueuedConnection ) ;

processManager::get().updateVolumeList( [ this ](){

this->updateVolume() ;
emit this->updateVolume() ;
} ) ;

if( utility::platformIsLinux() ){
Expand Down Expand Up @@ -399,15 +401,15 @@ void mountinfo::volumeUpdate()

if( m_announceEvents ){

this->pbUpdate() ;
emit this->pbUpdate() ;

if( _volumeWasMounted() ){

for( const auto& it : m_newMountList ){

if( _mountedVolume( it.cipherPath() ) ){

this->autoMount( it.mountPoint() ) ;
emit this->autoMount( it.mountPoint() ) ;
}
}
}
Expand All @@ -416,24 +418,6 @@ void mountinfo::volumeUpdate()
m_oldMountList = std::move( m_newMountList ) ;
}

void mountinfo::updateVolume()
{
QMetaObject::invokeMethod( this,"volumeUpdate",Qt::QueuedConnection ) ;
}

void mountinfo::pbUpdate()
{
QMetaObject::invokeMethod( m_parent,"pbUpdate",Qt::QueuedConnection ) ;
}

void mountinfo::autoMount( const QString& e )
{
QMetaObject::invokeMethod( m_parent,
"autoMountFavoritesOnAvailable",
Qt::QueuedConnection,
Q_ARG( QString,e ) ) ;
}

void mountinfo::announceEvents( bool s )
{
m_announceEvents = s ;
Expand All @@ -455,7 +439,7 @@ void mountinfo::linuxMonitor()

}else if( a > 0 ){

this->updateVolume() ;
emit this->updateVolume() ;

}else if( a == 0 ){

Expand Down Expand Up @@ -507,7 +491,7 @@ void mountinfo::linuxMonitor()
}else{
entries.created( [ this ]( const QString& e ){

this->autoMount( e ) ;
emit this->autoMount( e ) ;
} ) ;
}

Expand Down Expand Up @@ -547,7 +531,7 @@ void mountinfo::pollForUpdates()

if( now != previous ){

this->updateVolume() ;
emit this->updateVolume() ;
}

previous = std::move( now ) ;
Expand Down
23 changes: 14 additions & 9 deletions src/mountinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,16 @@ private slots:
std::function< void( const QString& ) >& m_debug ;
} ;

class mountinfo : private QObject
class mountinfo : public QObject
{
Q_OBJECT
public:
struct volumeEntry{

volumeEntry( const engines::engine& e,volumeInfo v ) :
engine( e ),vInfo( std::move( v ) )
{
}
const engines::engine& engine ;
volumeInfo vInfo ;
} ;
Expand Down Expand Up @@ -374,16 +378,17 @@ class mountinfo : private QObject
void announceEvents( bool ) ;

~mountinfo() ;
private slots:
void volumeUpdate( void ) ;
private:
void windowsMonitor( void ) ;
void linuxMonitor( void ) ;
void qtMonitor( void ) ;
void updateVolume( void ) ;
void pbUpdate( void ) ;
signals:
void updateVolume() ;
void pbUpdate() ;
void autoMount( const QString& ) ;
void pollForUpdates( void ) ;
private:
void volumeUpdate() ;
void windowsMonitor() ;
void linuxMonitor() ;
void qtMonitor() ;
void pollForUpdates() ;

QObject * m_parent ;

Expand Down
6 changes: 3 additions & 3 deletions src/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ plugin::plugin( QWidget * parent,
this->setFixedSize( this->size() ) ;
this->setFont( parent->font() ) ;

connect( m_ui->pbSetKey,SIGNAL( clicked() ),this,SLOT( pbSetKey() ) ) ;
connect( m_ui->pbCancel,SIGNAL( clicked() ),this,SLOT( pbClose() ) ) ;
connect( m_ui->pbKeyFile,SIGNAL( clicked() ),this,SLOT( pbSelectKeyFile() ) ) ;
connect( m_ui->pbSetKey,&QPushButton::clicked,this,&plugin::pbSetKey ) ;
connect( m_ui->pbCancel,&QPushButton::clicked,this,&plugin::pbClose ) ;
connect( m_ui->pbKeyFile,&QPushButton::clicked,this,&plugin::pbSelectKeyFile ) ;

m_ui->pbKeyFile->setIcon( QIcon( ":/file.png" ) ) ;

Expand Down
3 changes: 1 addition & 2 deletions src/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,10 @@ class plugin : public QDialog
const QString&,
std::function< void( const QByteArray& ) > ) ;
~plugin() ;
private slots:
private:
void pbSetKey() ;
void pbSelectKeyFile() ;
void pbClose() ;
private:
void ShowUI() ;
void HideUI() ;
void enableAll() ;
Expand Down
Loading

0 comments on commit 4707a47

Please sign in to comment.