SoundButton::SoundButton(QWidget *parent, SoundFile *soundFile) :
    QPushButton(parent)
{
    this->soundFile = soundFile;
    setText(soundFile->getDescription());

    addActions();
    addMenu();

    connect(this, SIGNAL(clicked()), this, SLOT(play()));
    connect(soundFile, SIGNAL(changed()), this, SLOT(fileChanged()));

    player = new AudioPlayer();
    connect(player, SIGNAL(finished()), this, SIGNAL(playingStopped()), Qt::QueuedConnection);
}
/*
 * Description : constructor
 */
IRNowPlayingView::IRNowPlayingView(IRApplication* aApplication, TIRViewId aViewId) :
    IRBaseView(aApplication, aViewId),
    iStatisticsReporter(NULL),
    iStationShare(NULL),
    iPlayStopAction(NULL),
    iLogoDownloadState(EIdle),    
    iSongNameLabel(NULL),
    iSongNameMarquee(NULL),
    iArtistName(NULL),
    iStationName(NULL),
    iStationLogo(NULL),
    iLogoNeedUpdate(true),    
    iFindinNmsAllowed(false),
    iSongNameAvailable(false)
#ifdef ADV_ENABLED
    ,iAdvImage(NULL)
    ,iAdvImageNeedUpdate(true)
    ,iAdvUrl(KDefaultAdvLink)    
#endif
{
    LOG_METHOD;
    
    iLaunchActionNeeded = (0 == getViewManager()->views().count()); // this is the starting view
        
    initialize();
    
    iStatisticsReporter = IRQStatisticsReporter::openInstance();
        
    connect(iPlayController, SIGNAL(metaDataAvailable(IRQMetaData*)), this, SLOT(updateMetaData(IRQMetaData*)));
    connect(iPlayController, SIGNAL(playingStarted()), this, SLOT(handlePlayStarted()));
    connect(iPlayController, SIGNAL(playingStopped()), this, SLOT(handlePlayStopped()));

    connect(iNetworkController, SIGNAL(networkRequestNotified(IRQNetworkEvent)),
            this, SLOT(handleNetworkEvent(IRQNetworkEvent)));
    connect(iApplication->getMediaKeyObserver(), SIGNAL(playPausePressed()), 
            this, SLOT(handlePlayPauseMediaKey()));
    connect(iApplication->getMediaKeyObserver(), SIGNAL(stopPressed()), 
            this, SLOT(handleStopMediaKey()));
    connect( getViewManager(), SIGNAL( orientationChanged(Qt::Orientation) ),
             this, SLOT( handleOrientationChanged(Qt::Orientation) ) );
    
    setFlag(EViewFlag_StickyViewEnabled);
}
Example #3
0
KDE_NO_EXPORT void KlashPart::processStopped (int, QProcess::ExitStatus) {
    QTimer::singleShot (0, this, SLOT (playingStopped ()));
}
InformationPanelContent::InformationPanelContent(QWidget* parent) :
    QWidget(parent),
    m_item(),
    m_pendingPreview(false),
    m_outdatedPreviewTimer(0),
    m_preview(0),
    m_phononWidget(0),
    m_nameLabel(0),
    m_metaDataWidget(0),
    m_metaDataArea(0)
{
    parent->installEventFilter(this);

    // Initialize timer for disabling an outdated preview with a small
    // delay. This prevents flickering if the new preview can be generated
    // within a very small timeframe.
    m_outdatedPreviewTimer = new QTimer(this);
    m_outdatedPreviewTimer->setInterval(300);
    m_outdatedPreviewTimer->setSingleShot(true);
    connect(m_outdatedPreviewTimer, SIGNAL(timeout()),
            this, SLOT(markOutdatedPreview()));

    QVBoxLayout* layout = new QVBoxLayout(this);
    layout->setSpacing(KDialog::spacingHint());

    // preview
    const int minPreviewWidth = KIconLoader::SizeEnormous + KIconLoader::SizeMedium;

    m_preview = new PixmapViewer(parent);
    m_preview->setMinimumWidth(minPreviewWidth);
    m_preview->setMinimumHeight(KIconLoader::SizeEnormous);

    m_phononWidget = new PhononWidget(parent);
    m_phononWidget->hide();
    m_phononWidget->setMinimumWidth(minPreviewWidth);
    connect(m_phononWidget, SIGNAL(playingStarted()),
            this, SLOT(slotPlayingStarted()));
    connect(m_phononWidget, SIGNAL(playingStopped()),
            this, SLOT(slotPlayingStopped()));

    // name
    m_nameLabel = new QLabel(parent);
    QFont font = m_nameLabel->font();
    font.setBold(true);
    m_nameLabel->setFont(font);
    m_nameLabel->setAlignment(Qt::AlignHCenter);
    m_nameLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);

    const bool showPreview = InformationPanelSettings::showPreview();
    m_preview->setVisible(showPreview);

    m_metaDataWidget = new KFileMetaDataWidget(parent);
    m_metaDataWidget->setFont(KGlobalSettings::smallestReadableFont());
    m_metaDataWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
    connect(m_metaDataWidget, SIGNAL(urlActivated(KUrl)), this, SIGNAL(urlActivated(KUrl)));

    // Encapsulate the MetaDataWidget inside a container that has a dummy widget
    // at the bottom. This prevents that the meta data widget gets vertically stretched
    // in the case where the height of m_metaDataArea > m_metaDataWidget.
    QWidget* metaDataWidgetContainer = new QWidget(parent);
    QVBoxLayout* containerLayout = new QVBoxLayout(metaDataWidgetContainer);
    containerLayout->setContentsMargins(0, 0, 0, 0);
    containerLayout->setSpacing(0);
    containerLayout->addWidget(m_metaDataWidget);
    containerLayout->addStretch();

    m_metaDataArea = new QScrollArea(parent);
    m_metaDataArea->setWidget(metaDataWidgetContainer);
    m_metaDataArea->setWidgetResizable(true);
    m_metaDataArea->setFrameShape(QFrame::NoFrame);

    QWidget* viewport = m_metaDataArea->viewport();
    viewport->installEventFilter(this);

    QPalette palette = viewport->palette();
    palette.setColor(viewport->backgroundRole(), QColor(Qt::transparent));
    viewport->setPalette(palette);

    layout->addWidget(m_preview);
    layout->addWidget(m_phononWidget);
    layout->addWidget(m_nameLabel);
    layout->addWidget(new KSeparator());
    layout->addWidget(m_metaDataArea);
}