Skip to content

Commit

Permalink
add support for CTRL+D and CTRL+A key combo for selecting all rows an…
Browse files Browse the repository at this point in the history
…d deleting selected rows
  • Loading branch information
mhogomchungu committed Jan 7, 2025
1 parent 1ad6d0a commit 82a5875
Show file tree
Hide file tree
Showing 17 changed files with 88 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/about.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ void about::textAlignmentChanged( Qt::LayoutDirection )
{
}

void about::keyPressed( utility::mainWindowKeyCombo )
{
}

void about::init_done()
{
}
1 change: 1 addition & 0 deletions src/about.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class about
{
public:
about( const Context& ) ;
void keyPressed( utility::mainWindowKeyCombo ) ;
void init_done() ;
void enableAll() ;
void disableAll() ;
Expand Down
4 changes: 4 additions & 0 deletions src/basicdownloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ basicdownloader::basicdownloader( const Context& ctx ) :
} ) ;
}

void basicdownloader::keyPressed( utility::mainWindowKeyCombo )
{
}

void basicdownloader::init_done()
{
}
Expand Down
1 change: 1 addition & 0 deletions src/basicdownloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class basicdownloader : public QObject
Q_OBJECT
public:
basicdownloader( const Context& ) ;
void keyPressed( utility::mainWindowKeyCombo ) ;
void init_done() ;
void tabEntered() ;
void tabExited() ;
Expand Down
5 changes: 5 additions & 0 deletions src/batchdownloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,11 @@ batchdownloader::batchdownloader( const Context& ctx ) :
} ) ;
}

void batchdownloader::keyPressed( utility::mainWindowKeyCombo m )
{
utility::keyPressed( m_table,m ) ;
}

void batchdownloader::showCustomContext()
{
auto row = m_table.currentRow() ;
Expand Down
1 change: 1 addition & 0 deletions src/batchdownloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ class batchdownloader : public QObject
public:

batchdownloader( const Context& ) ;
void keyPressed( utility::mainWindowKeyCombo ) ;
void init_done() ;
void enableAll() ;
void disableAll() ;
Expand Down
4 changes: 4 additions & 0 deletions src/configure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,10 @@ configure::configure( const Context& ctx ) :
this->showOptions() ;
}

void configure::keyPressed( utility::mainWindowKeyCombo )
{
}

void configure::updateProxySettings( settings::proxySettings::Type s )
{
m_ui.lineEditCustormProxyAddress->setEnabled( false ) ;
Expand Down
1 change: 1 addition & 0 deletions src/configure.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class configure : public QObject
public:
static QString defaultDownloadOption() ;
configure( const Context& ) ;
void keyPressed( utility::mainWindowKeyCombo ) ;
void init_done() ;
void enableAll() ;
void textAlignmentChanged( Qt::LayoutDirection ) ;
Expand Down
4 changes: 4 additions & 0 deletions src/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ void library::init_done()
}
}

void library::keyPressed( utility::mainWindowKeyCombo )
{
}

void library::enableAll()
{
m_ui.cbLibraryTabEnable->setEnabled( true ) ;
Expand Down
1 change: 1 addition & 0 deletions src/library.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class library : public QObject
Q_OBJECT
public:
library( const Context& ) ;
void keyPressed( utility::mainWindowKeyCombo ) ;
void init_done() ;
void enableAll() ;
void disableAll() ;
Expand Down
18 changes: 18 additions & 0 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,24 @@ MainWindow::MainWindow( QApplication& app,

auto dm = m_settings.mainWindowDimenstions( this->window()->geometry() ) ;

auto shortcut1 = new QShortcut( this ) ;

shortcut1->setKey( Qt::CTRL | Qt::Key_D ) ;

connect( shortcut1,&QShortcut::activated,[ this ](){

m_tabManager.keyPressed( utility::mainWindowKeyCombo::CTRL_D ) ;
} ) ;

auto shortcut2 = new QShortcut( this ) ;

shortcut2->setKey( Qt::CTRL | Qt::Key_A ) ;

connect( shortcut2,&QShortcut::activated,[ this ](){

m_tabManager.keyPressed( utility::mainWindowKeyCombo::CTRL_A ) ;
} ) ;

this->window()->setGeometry( dm ) ;

this->window()->setFixedSize( this->window()->size() ) ;
Expand Down
5 changes: 5 additions & 0 deletions src/playlistdownloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,11 @@ void playlistdownloader::disableAll()
m_ui.labelPLEnterUrl->setEnabled( false ) ;
}

void playlistdownloader::keyPressed( utility::mainWindowKeyCombo m )
{
utility::keyPressed( m_table,m ) ;
}

void playlistdownloader::resetMenu()
{
utility::setMenuOptions( m_ctx,{},false,true,m_ui.pbPLOptions,[ this ]( QAction * aa ){
Expand Down
1 change: 1 addition & 0 deletions src/playlistdownloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class playlistdownloader : public QObject
Q_OBJECT
public:
playlistdownloader( Context& ) ;
void keyPressed( utility::mainWindowKeyCombo ) ;
void init_done() ;
void enableAll() ;
void disableAll() ;
Expand Down
10 changes: 10 additions & 0 deletions src/tabmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,16 @@ tabManager& tabManager::exiting()
return *this ;
}

void tabManager::keyPressed( utility::mainWindowKeyCombo m )
{
m_about.keyPressed( m ) ;
m_configure.keyPressed( m ) ;
m_basicdownloader.keyPressed( m ) ;
m_batchdownloader.keyPressed( m ) ;
m_playlistdownloader.keyPressed( m ) ;
m_library.keyPressed( m ) ;
}

void tabManager::textAlignmentChanged( Qt::LayoutDirection m )
{
m_about.textAlignmentChanged( m ) ;
Expand Down
1 change: 1 addition & 0 deletions src/tabmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class tabManager : public QObject
tabManager& resetMenu() ;
tabManager& reTranslateUi() ;
tabManager& exiting() ;
void keyPressed( utility::mainWindowKeyCombo ) ;
basicdownloader& basicDownloader()
{
return m_basicdownloader ;
Expand Down
22 changes: 22 additions & 0 deletions src/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2448,6 +2448,28 @@ bool utility::Qt6Version()
#endif
}

void utility::keyPressed( tableWidget& table,utility::mainWindowKeyCombo m )
{
if( m == utility::mainWindowKeyCombo::CTRL_A ){

auto& t = table.get() ;

auto first = table.startPosition() ;

for( int row = 0 ; row < t.rowCount() ; row++ ){

for( int column = first ; column < t.columnCount() ; column++ ){

t.item( row,column )->setSelected( true ) ;
}
}

}else if( m == utility::mainWindowKeyCombo::CTRL_D ){

table.removeAllSelected() ;
}
}

QString utility::OSXApplicationDirPath()
{
return QCoreApplication::applicationDirPath() ;
Expand Down
5 changes: 5 additions & 0 deletions src/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,11 @@ namespace utility
QString homePath() ;
QString clipboardText() ;
QString fromSecsSinceEpoch( qint64 ) ;

enum class mainWindowKeyCombo{ CTRL_D,CTRL_A } ;

void keyPressed( tableWidget&,utility::mainWindowKeyCombo ) ;

struct downLoadOptions
{
downLoadOptions()
Expand Down

0 comments on commit 82a5875

Please sign in to comment.