Added context menu

Signed-off-by: ormorph <roma251078@mail.ru>
pull/14/head
ormorph 11 months ago
parent 04b2afc8e6
commit 0d4db05e52

@ -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() );

@ -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

Loading…
Cancel
Save