diff options
author | ormorph <roma251078@mail.ru> | 2023-12-18 18:28:37 +0300 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2023-12-22 10:05:20 +0900 |
commit | 6a86ef7adca7ad984696f053f34361ce3716bdda (patch) | |
tree | ddcc0882d41a7ce192c104c9edf92149c85f0f6a | |
parent | 248e67ea4400ec149d60162a8bc7b571d2d803bd (diff) | |
download | kstreamripper-6a86ef7adca7ad984696f053f34361ce3716bdda.tar.gz kstreamripper-6a86ef7adca7ad984696f053f34361ce3716bdda.zip |
Added context menu
Signed-off-by: ormorph <roma251078@mail.ru>
(cherry picked from commit 0d4db05e52daaf999aa78bab91671c83644398e3)
-rw-r--r-- | src/kstreamripper.cpp | 27 | ||||
-rw-r--r-- | src/kstreamripper.h | 5 |
2 files changed, 32 insertions, 0 deletions
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 <tdemessagebox.h> #include <kstandarddirs.h> #include <tdeversion.h> +#include <ntqpopupmenu.h> #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 |