diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/app/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/app/analyzer.cpp | 7 | ||||
-rw-r--r-- | src/app/audioView.cpp | 31 | ||||
-rw-r--r-- | src/app/audioView.h | 24 | ||||
-rw-r--r-- | src/app/mainWindow.cpp | 15 | ||||
-rw-r--r-- | src/app/mainWindow.h | 5 | ||||
-rw-r--r-- | src/app/stateChange.cpp | 22 | ||||
-rw-r--r-- | src/app/volumeAction.cpp | 30 | ||||
-rw-r--r-- | src/app/volumeAction.h | 5 |
9 files changed, 119 insertions, 21 deletions
diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 60a21e4..eb10736 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -35,6 +35,7 @@ tde_add_executable( ${PROJECT_NAME} AUTOMOC playDialog.cpp listView.cpp adjustSizeButton.cpp + audioView.cpp fullScreenAction.cpp insertAspectRatioMenuItems.cpp playlistFile.cpp diff --git a/src/app/analyzer.cpp b/src/app/analyzer.cpp index 7a80872..97b9aa3 100644 --- a/src/app/analyzer.cpp +++ b/src/app/analyzer.cpp @@ -585,7 +585,12 @@ void Analyzer::Block::determineStep() // I calculated the value 30 based on some trial and error const double fallTime = 30 * m_rows; - m_step = double(m_rows * 80) / fallTime; // 80 = ~milliseconds between signals with audio data + + // The number of milliseconds between signals with audio data is about 80, + // however, basing the step off of that value causes some undersireable + // effects in the analyzer (high-end blocks constantly appearing/disappearing). + // 44 seems to be a good mid-point. + m_step = double(m_rows * 44) / fallTime; } void Analyzer::Block::drawBackground() diff --git a/src/app/audioView.cpp b/src/app/audioView.cpp new file mode 100644 index 0000000..ec97217 --- /dev/null +++ b/src/app/audioView.cpp @@ -0,0 +1,31 @@ +// SPDX-FileCopyrightText: 2024 mio <[email protected]> +// +// SPDX-License-Identifier: GPL-3.0-only. + +#include "audioView.h" + +#include <tqlayout.h> + +#include "analyzer.h" + +namespace Codeine +{ + +AudioView::AudioView(TQWidget *parent, const char *name) + : TQFrame(parent, name) +{ + auto *layout = new TQHBoxLayout(this); + m_analyzer = new Analyzer::Block(this); + + // We subtract one from the below to remove excess padding. + // 36 blocks for the max/min height is arbitrary, but looks okay. + m_analyzer->setMaximumSize((Analyzer::Block::MAX_COLUMNS / 2) * (Analyzer::Block::WIDTH + 1) - 1, + 36 * (Analyzer::Block::HEIGHT + 1) - 1); + + m_analyzer->setMinimumSize(Analyzer::Block::WIDTH * Analyzer::Block::MIN_COLUMNS, + 36 * (Analyzer::Block::HEIGHT + 1) - 1); + + layout->addWidget(m_analyzer); +} + +} diff --git a/src/app/audioView.h b/src/app/audioView.h new file mode 100644 index 0000000..bd5c7f6 --- /dev/null +++ b/src/app/audioView.h @@ -0,0 +1,24 @@ +// SPDX-FileCopyrightText: 2024 mio <[email protected]> +// +// SPDX-License-Identifier: GPL-3.0-only. + +#ifndef CODEINE_AUDIOVIEW_H +#define CODEINE_AUDIOVIEW_H + +#include <tqframe.h> + +namespace Codeine +{ + +class AudioView : public TQFrame +{ + public: + AudioView(TQWidget *parent, const char *name = nullptr); + + private: + TQWidget *m_analyzer; +}; + +} + +#endif /* CODEINE_AUDIOVIEW_H */ diff --git a/src/app/mainWindow.cpp b/src/app/mainWindow.cpp index 9409d85..ab8da70 100644 --- a/src/app/mainWindow.cpp +++ b/src/app/mainWindow.cpp @@ -22,11 +22,13 @@ #include <tqlayout.h> //ctor #include <tqpopupmenu.h> //because XMLGUI is poorly designed #include <tqobjectlist.h> +#include <tqwidgetstack.h> #include "../debug.h" #include "../mxcl.library.h" #include "actions.h" #include "analyzer.h" +#include "audioView.h" #include "codeineConfig.h" #include "extern.h" //dialog creation function definitions #include "fullScreenAction.h" @@ -70,8 +72,19 @@ MainWindow::MainWindow() kapp->setMainWidget( this ); + m_widgetStack = new TQWidgetStack(this, "m_widgetStack"); + new VideoWindow( this ); - setCentralWidget( videoWindow() ); + + m_audioView = new AudioView(this, "m_audioView"); + + // videoWindow() will be the initial widget. + // m_audioView is raised when no video track is present. + m_widgetStack->addWidget(videoWindow()); + m_widgetStack->addWidget(m_audioView); + + setCentralWidget(m_widgetStack); + setFocusProxy( videoWindow() ); // essential! See VideoWindow::event(), TQEvent::FocusOut // these have no affect beccause "KDE Knows Best" FFS diff --git a/src/app/mainWindow.h b/src/app/mainWindow.h index 634d444..3dae1e8 100644 --- a/src/app/mainWindow.h +++ b/src/app/mainWindow.h @@ -11,11 +11,14 @@ class KURL; class TQLabel; class TQPopupMenu; class TQSlider; +class TQWidgetStack; class VolumeAction; namespace Codeine { + class AudioView; + class MainWindow : public TDEMainWindow { TQ_OBJECT @@ -66,6 +69,8 @@ namespace Codeine TQLabel *m_timeLabel; TQLabel *m_titleLabel; TQWidget *m_analyzer; + AudioView *m_audioView; + TQWidgetStack *m_widgetStack; VolumeAction *m_volumeAction; //undefined diff --git a/src/app/stateChange.cpp b/src/app/stateChange.cpp index 9322a13..c01d8ba 100644 --- a/src/app/stateChange.cpp +++ b/src/app/stateChange.cpp @@ -13,6 +13,8 @@ #include <tqlabel.h> #include <tqpopupmenu.h> #include <tqslider.h> +#include <tqwidgetstack.h> +#include "audioView.h" #include "theStream.h" #include "videoSettings.h" //FIXME unfortunate #include "xineEngine.h" @@ -63,7 +65,7 @@ MainWindow::engineStateChanged( Engine::State state ) toggleAction( "play" )->setChecked( state == Playing ); //FIXME bad design to do this way - m_volumeAction->sliderMoved( engine()->volume() ); + m_volumeAction->setVolume(engine()->volume()); } @@ -104,8 +106,22 @@ MainWindow::engineStateChanged( Engine::State state ) /// update statusBar { using namespace Engine; - m_analyzer->setShown( state & (Playing | Paused) && TheStream::hasAudio() ); - m_timeLabel->setShown( state & (Playing | Paused) ); + m_analyzer->setShown(state & (Playing | Paused) && (TheStream::hasVideo() && TheStream::hasAudio())); + m_timeLabel->setShown(state & (Playing | Paused)); + } + + // Update the current widget shown. + if (TheStream::hasVideo() || (state & (Engine::Empty))) + { + m_widgetStack->raiseWidget(videoWindow()); + videoWindow()->setUpdatesEnabled(true); + m_audioView->setUpdatesEnabled(false); + } + else if (TheStream::hasAudio()) + { + m_widgetStack->raiseWidget(m_audioView); + m_audioView->setUpdatesEnabled(true); + videoWindow()->setUpdatesEnabled(false); } diff --git a/src/app/volumeAction.cpp b/src/app/volumeAction.cpp index ad585ef..b628ba1 100644 --- a/src/app/volumeAction.cpp +++ b/src/app/volumeAction.cpp @@ -54,9 +54,8 @@ VolumeAction::VolumeAction( TDEToolBar *bar, TDEActionCollection *ac ) m_widget = new VolumeSlider( bar->topLevelWidget() ); connect( this, TQ_SIGNAL(toggled( bool )), TQ_SLOT(toggled( bool )) ); - connect( m_widget->slider, TQ_SIGNAL(sliderMoved( int )), TQ_SLOT(sliderMoved( int )) ); - connect( m_widget->slider, TQ_SIGNAL(sliderMoved( int )), Codeine::engine(), TQ_SLOT(setStreamParameter( int )) ); - connect( m_widget->slider, TQ_SIGNAL(sliderReleased()), TQ_SLOT(sliderReleased()) ); + connect(m_widget->slider, TQ_SIGNAL(valueChanged(int)), Codeine::engine(), TQ_SLOT(setStreamParameter(int))); + connect(m_widget->slider, TQ_SIGNAL(valueChanged(int)), TQ_SLOT(sliderMoved(int))); } int @@ -75,25 +74,28 @@ VolumeAction::plug( TQWidget *bar, int index ) void VolumeAction::toggled( bool const b ) { - DEBUG_BLOCK - - TQString t = TQString::number(100 - m_widget->slider->value()) + "%"; - setToolTip( i18n( "Volume: %1" ).arg( t ) ); - m_widget->label->setText( t ); - m_widget->raise(); m_widget->setShown( b ); } void -VolumeAction::sliderMoved( int v ) +VolumeAction::sliderMoved(int v) { - v = 100 - v; //TQt sliders are wrong way round when vertical + // TQt sliders are wrong way round when vertical + v = 100 - v; - TQString t = TQString::number( v ) + '%'; + auto vol = TQString("%1%").arg(v); + m_widget->label->setText(vol); + setToolTip(i18n("Volume %1").arg(vol)); +} + +void +VolumeAction::setVolume(int volume) +{ + TQString vol = TQString("%1%").arg(volume); - setToolTip( i18n( "Volume: %1" ).arg( t ) ); - m_widget->label->setText( t ); + // TQt sliders are the wrong way round when vertical. + m_widget->slider->setValue(100 - volume); } bool diff --git a/src/app/volumeAction.h b/src/app/volumeAction.h index 67cfad0..2645355 100644 --- a/src/app/volumeAction.h +++ b/src/app/volumeAction.h @@ -18,11 +18,12 @@ class VolumeAction : public TDEToggleAction virtual int plug( TQWidget*, int ); public slots: - void sliderMoved( int ); + // Update Slider and Label to \a volume + void setVolume(int volume); private slots: void toggled( bool ); - void sliderReleased() { setChecked( false ); toggled( false ); } + void sliderMoved(int); public: VolumeAction( TDEToolBar *anchor, TDEActionCollection *ac ); |