diff options
author | mio <stigma@disroot.org> | 2025-01-21 17:00:36 +1000 |
---|---|---|
committer | mio <stigma@disroot.org> | 2025-03-07 10:23:58 +1000 |
commit | 5e57ab35afe0d5ddd960921a76ea11f22561f287 (patch) | |
tree | ab13fde0e97d135d828dd426445b1818da8c4aa7 | |
parent | adb9e2e081098d645141dc53a92f3060691a6497 (diff) | |
download | codeine-5e57ab35afe0d5ddd960921a76ea11f22561f287.tar.gz codeine-5e57ab35afe0d5ddd960921a76ea11f22561f287.zip |
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>
-rw-r--r-- | src/app/mainWindow.cpp | 32 | ||||
-rw-r--r-- | src/app/mainWindow.h | 6 | ||||
-rw-r--r-- | src/app/stateChange.cpp | 2 |
3 files changed, 39 insertions, 1 deletions
diff --git a/src/app/mainWindow.cpp b/src/app/mainWindow.cpp index 78bf592..54204e9 100644 --- a/src/app/mainWindow.cpp +++ b/src/app/mainWindow.cpp @@ -11,6 +11,7 @@ #include <kcursor.h> #include <tdefiledialog.h> //::open() #include <tdeglobalsettings.h> //::timerEvent() +#include <tdepopupmenu.h> #include <tdeio/netaccess.h> #include <ksqueezedtextlabel.h> #include <kstatusbar.h> @@ -108,6 +109,9 @@ MainWindow::MainWindow() 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! + m_showAnalyzer = config("MainWindow")->readBoolEntry("showAnalyzer", true); + m_analyzer->setShown(m_showAnalyzer); + // only show dvd button when playing a dvd { struct KdeIsTehSuck : public TQObject @@ -241,6 +245,9 @@ MainWindow::~MainWindow() bool MainWindow::queryExit() { + config("MainWindow")->writeEntry("showAnalyzer", m_showAnalyzer); + config("MainWindow")->sync(); + if( toggleAction( "fullscreen" )->isChecked() ) { // there seems to be no other way to stop TDEMainWindow // saving the window state without any controls @@ -312,6 +319,24 @@ MainWindow::readProperties( TDEConfig *config ) } 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 MainWindow::timerEvent( TQTimerEvent* ) { static int counter = 0; @@ -361,6 +386,13 @@ MainWindow::showTime( int pos ) } void +MainWindow::toggleAnalyzer() +{ + m_showAnalyzer = !m_showAnalyzer; + m_analyzer->setShown(m_showAnalyzer); +} + +void MainWindow::engineMessage( const TQString &message ) { statusBar()->message( message, 3500 ); diff --git a/src/app/mainWindow.h b/src/app/mainWindow.h index 3dae1e8..fbb6be4 100644 --- a/src/app/mainWindow.h +++ b/src/app/mainWindow.h @@ -46,6 +46,7 @@ namespace Codeine void fullScreenToggled( bool ); void setAudioChannels(const TQStringList&) const; void setSubtitleChannels(const TQStringList&) const; + void toggleAnalyzer(); private: void setupActions(); @@ -55,6 +56,7 @@ namespace Codeine TQPopupMenu *menu(const TQString&); + void contextMenuEvent(TQContextMenuEvent *event) override; virtual void timerEvent( TQTimerEvent* ); virtual void dragEnterEvent( TQDragEnterEvent* ); virtual void dropEvent( TQDropEvent* ); @@ -73,6 +75,10 @@ namespace Codeine TQWidgetStack *m_widgetStack; 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 MainWindow( const MainWindow& ); MainWindow &operator=( const MainWindow& ); diff --git a/src/app/stateChange.cpp b/src/app/stateChange.cpp index 73f77d0..2418209 100644 --- a/src/app/stateChange.cpp +++ b/src/app/stateChange.cpp @@ -106,7 +106,7 @@ MainWindow::engineStateChanged( Engine::State state ) /// update statusBar { 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)); } |