Add context menu to status bar

It adds an item which toggles the visibility of the Analyzer when
watching videos.

Signed-off-by: mio <stigma@disroot.org>
pull/32/head
mio 6 months ago
parent adb9e2e081
commit 5e57ab35af

@ -11,6 +11,7 @@
#include <kcursor.h> #include <kcursor.h>
#include <tdefiledialog.h> //::open() #include <tdefiledialog.h> //::open()
#include <tdeglobalsettings.h> //::timerEvent() #include <tdeglobalsettings.h> //::timerEvent()
#include <tdepopupmenu.h>
#include <tdeio/netaccess.h> #include <tdeio/netaccess.h>
#include <ksqueezedtextlabel.h> #include <ksqueezedtextlabel.h>
#include <kstatusbar.h> #include <kstatusbar.h>
@ -108,6 +109,9 @@ MainWindow::MainWindow()
setStandardToolBarMenuEnabled( false ); //bah to setupGUI()! setStandardToolBarMenuEnabled( false ); //bah to setupGUI()!
toolBar()->show(); //it's possible it would be hidden, but we don't want that as no UI way to show it! toolBar()->show(); //it's possible it would be hidden, but we don't want that as no UI way to show it!
m_showAnalyzer = config("MainWindow")->readBoolEntry("showAnalyzer", true);
m_analyzer->setShown(m_showAnalyzer);
// only show dvd button when playing a dvd // only show dvd button when playing a dvd
{ {
struct KdeIsTehSuck : public TQObject struct KdeIsTehSuck : public TQObject
@ -241,6 +245,9 @@ MainWindow::~MainWindow()
bool bool
MainWindow::queryExit() MainWindow::queryExit()
{ {
config("MainWindow")->writeEntry("showAnalyzer", m_showAnalyzer);
config("MainWindow")->sync();
if( toggleAction( "fullscreen" )->isChecked() ) { if( toggleAction( "fullscreen" )->isChecked() ) {
// there seems to be no other way to stop TDEMainWindow // there seems to be no other way to stop TDEMainWindow
// saving the window state without any controls // saving the window state without any controls
@ -311,6 +318,24 @@ MainWindow::readProperties( TDEConfig *config )
engine()->play( config->readNumEntry( "time" ) ); engine()->play( config->readNumEntry( "time" ) );
} }
void
MainWindow::contextMenuEvent(TQContextMenuEvent *ev)
{
TQRect statusBarRect(mapTo(this, statusBar()->pos()), statusBar()->size());
if (statusBarRect.contains(ev->pos()) && TheStream::hasVideo())
{
ev->accept();
TDEPopupMenu menu;
menu.setCheckable(true);
int id = menu.insertItem(i18n("Toggle Analyzer"), this, TQ_SLOT(toggleAnalyzer()));
menu.setItemChecked(id, m_analyzer->isVisible());
menu.exec(ev->globalPos());
}
}
void void
MainWindow::timerEvent( TQTimerEvent* ) MainWindow::timerEvent( TQTimerEvent* )
{ {
@ -360,6 +385,13 @@ MainWindow::showTime( int pos )
m_timeLabel->setText( time ); m_timeLabel->setText( time );
} }
void
MainWindow::toggleAnalyzer()
{
m_showAnalyzer = !m_showAnalyzer;
m_analyzer->setShown(m_showAnalyzer);
}
void void
MainWindow::engineMessage( const TQString &message ) MainWindow::engineMessage( const TQString &message )
{ {

@ -46,6 +46,7 @@ namespace Codeine
void fullScreenToggled( bool ); void fullScreenToggled( bool );
void setAudioChannels(const TQStringList&) const; void setAudioChannels(const TQStringList&) const;
void setSubtitleChannels(const TQStringList&) const; void setSubtitleChannels(const TQStringList&) const;
void toggleAnalyzer();
private: private:
void setupActions(); void setupActions();
@ -55,6 +56,7 @@ namespace Codeine
TQPopupMenu *menu(const TQString&); TQPopupMenu *menu(const TQString&);
void contextMenuEvent(TQContextMenuEvent *event) override;
virtual void timerEvent( TQTimerEvent* ); virtual void timerEvent( TQTimerEvent* );
virtual void dragEnterEvent( TQDragEnterEvent* ); virtual void dragEnterEvent( TQDragEnterEvent* );
virtual void dropEvent( TQDropEvent* ); virtual void dropEvent( TQDropEvent* );
@ -73,6 +75,10 @@ namespace Codeine
TQWidgetStack *m_widgetStack; TQWidgetStack *m_widgetStack;
VolumeAction *m_volumeAction; VolumeAction *m_volumeAction;
// Keep track of Analyzer visibility separately so swapping between
// Video & Audio correctly restores the state without re-reading the config.
bool m_showAnalyzer;
//undefined //undefined
MainWindow( const MainWindow& ); MainWindow( const MainWindow& );
MainWindow &operator=( const MainWindow& ); MainWindow &operator=( const MainWindow& );

@ -106,7 +106,7 @@ MainWindow::engineStateChanged( Engine::State state )
/// update statusBar /// update statusBar
{ {
using namespace Engine; using namespace Engine;
m_analyzer->setShown(state & (Playing | Paused) && (TheStream::hasVideo() && TheStream::hasAudio())); m_analyzer->setShown(m_showAnalyzer && (TheStream::hasVideo() && TheStream::hasAudio()));
m_timeLabel->setShown(state & (Playing | Paused)); m_timeLabel->setShown(state & (Playing | Paused));
} }

Loading…
Cancel
Save