From 6a86ef7adca7ad984696f053f34361ce3716bdda Mon Sep 17 00:00:00 2001 From: ormorph Date: Mon, 18 Dec 2023 18:28:37 +0300 Subject: Added context menu Signed-off-by: ormorph (cherry picked from commit 0d4db05e52daaf999aa78bab91671c83644398e3) --- src/kstreamripper.cpp | 27 +++++++++++++++++++++++++++ src/kstreamripper.h | 5 +++++ 2 files changed, 32 insertions(+) diff --git a/src/kstreamripper.cpp b/src/kstreamripper.cpp index 15e827e..1c8c53d 100644 --- a/src/kstreamripper.cpp +++ b/src/kstreamripper.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include "kstreamripper.h" #include "streampropertiesdlg.h" @@ -61,6 +62,16 @@ KStreamRipper::KStreamRipper( TQWidget* parent, const char* name ) m_streamsListView->addColumn( "Status" ); m_streamsListView->addColumn( "Size" ); + // Create context menu + contextMenu = new TQPopupMenu( m_streamsListView ); + contextMenu->insertItem( i18n("&Add Stream"), this, TQT_SLOT(addStreamButtonClicked()), CTRL+Key_A ); + contextMenu->insertItem( i18n("&Edit Stream"), this, TQT_SLOT(editStreamButtonClicked()), CTRL+Key_E ); + contextMenu->insertItem( i18n("&Delete Stream"), this, TQT_SLOT(deleteStreamButtonClicked()), Key_Delete ); + contextMenu->insertSeparator(); + contextMenu->insertItem( i18n("&Rip Stream"), this, TQT_SLOT(ripButtonClicked()), CTRL+Key_R, 2 ); + contextMenu->insertItem( i18n("&Stop Rip"), this, TQT_SLOT(stopRipButtonClicked()), CTRL+Key_S, 3 ); + contextMenu->insertItem( i18n("&Tune in"), this, TQT_SLOT(tuneInButtonClicked()), CTRL+Key_T ); + //app config TDEConfig *appConfig = TDEGlobal::config(); @@ -107,6 +118,8 @@ KStreamRipper::KStreamRipper( TQWidget* parent, const char* name ) connect(m_helpButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(helpButtonClicked())); connect(m_aboutButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(aboutButtonClicked())); connect(m_quitButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(quitButtonClicked())); + connect(m_streamsListView, TQT_SIGNAL( contextMenuRequested( TQListViewItem *, const TQPoint& , int ) ), + this, TQT_SLOT( slotContextMenu( TQListViewItem *, const TQPoint &, int ) ) ); //other connect( m_streamsListView, TQT_SIGNAL(selectionChanged()), this, TQT_SLOT( selectedNewListItem()) ); @@ -162,6 +175,7 @@ void KStreamRipper::closeEvent( TQCloseEvent *e ) appConfig->sync(); e->accept(); + delete contextMenu; } @@ -202,6 +216,13 @@ void KStreamRipper::deleteStreamButtonClicked() } } +void KStreamRipper::slotContextMenu( TQListViewItem* Item, const TQPoint & point, int) +{ + if( Item ) { + contextMenu->popup( point ); + } +} + void KStreamRipper::tuneInButtonClicked() { if( m_streamsListView->currentItem() ) @@ -252,6 +273,8 @@ void KStreamRipper::ripButtonClicked() ProcItem->getProcessController()->startRip(m_destEdit->text(), m_timeEdit->text(), m_unicodeCheckbox->isChecked()); m_ripButton->setEnabled( false ); + contextMenu->setItemEnabled(2, false); + contextMenu->setItemEnabled(3, true); m_stopRipButton->setEnabled( true ); } else { KMessageBox::error(this, "The streamripper executable wasn't found. Make sure " @@ -265,6 +288,8 @@ void KStreamRipper::ripStopped(ProcessController *curProc) if (curProc == proc) { m_ripButton->setEnabled( true ); + contextMenu->setItemEnabled(2, true); + contextMenu->setItemEnabled(3, false); m_stopRipButton->setEnabled( false ); } } @@ -318,7 +343,9 @@ void KStreamRipper::selectedNewListItem() // reconfigure what the user is allowed to do based on if this process is ripping m_ripButton->setEnabled( !ProcCtl->getStatus() ); + contextMenu->setItemEnabled(2, !ProcCtl->getStatus() ); m_stopRipButton->setEnabled( ProcCtl->getStatus() ); + contextMenu->setItemEnabled(3, ProcCtl->getStatus() ); m_tuneInButton->setEnabled( true ); m_editStreamButton->setEnabled( !ProcCtl->getAutomatic() ); m_deleteStreamButton->setEnabled( !ProcCtl->getAutomatic() ); diff --git a/src/kstreamripper.h b/src/kstreamripper.h index 8ec9812..6752625 100644 --- a/src/kstreamripper.h +++ b/src/kstreamripper.h @@ -36,6 +36,7 @@ namespace DNSSD { namespace RemoteService { typedef int Ptr; } } #endif +class TQPopupMenu; class StreamPropertiesDlg; class TQString; @@ -59,6 +60,7 @@ protected slots: void addStreamButtonClicked(); void editStreamButtonClicked(); void deleteStreamButtonClicked(); + void slotContextMenu( TQListViewItem*, const TQPoint &, int ); void tuneInButtonClicked(); void ripButtonClicked(); void ripStopped(ProcessController*); @@ -80,6 +82,9 @@ protected slots: void serviceAdded(DNSSD::RemoteService::Ptr) {}; void serviceRemoved(DNSSD::RemoteService::Ptr) {}; #endif +private: + + TQPopupMenu* contextMenu; }; #endif -- cgit v1.2.1