示例#1
0
void AdBlockIcon::popupBlocked(const QString &ruleString, const QUrl &url)
{
    int index = ruleString.lastIndexOf(QLatin1String(" ("));

    const QString &subscriptionName = ruleString.left(index);
    const QString &filter = ruleString.mid(index + 2, ruleString.size() - index - 3);
    AdBlockSubscription* subscription = AdBlockManager::instance()->subscriptionByName(subscriptionName);
    if (filter.isEmpty() || !subscription) {
        return;
    }

    AdBlockRule rule(filter, subscription);

    QPair<AdBlockRule, QUrl> pair;
    pair.first = rule;
    pair.second = url;
    m_blockedPopups.append(pair);

    mApp->desktopNotifications()->showNotification(QPixmap(":html/adblock_big.png"), tr("Blocked popup window"), tr("AdBlock blocked unwanted popup window."));

    if (!m_flashTimer) {
        m_flashTimer = new QTimer(this);
    }

    if (m_flashTimer->isActive()) {
        stopAnimation();
    }

    m_flashTimer->setInterval(500);
    m_flashTimer->start();

    connect(m_flashTimer, SIGNAL(timeout()), this, SLOT(animateIcon()));
}
示例#2
0
void AdBlockIcon::popupBlocked(const QString &rule, const QUrl &url)
{
    QPair<QString, QUrl> pair;
    pair.first = rule;
    pair.second = url;

    m_blockedPopups.append(pair);

    mApp->desktopNotifications()->showNotifications(QPixmap(":html/adblock_big.png"), tr("Blocked popup window"), tr("AdBlock blocked unwanted popup window."));

    if (!m_flashTimer) {
        m_flashTimer = new QTimer(this);
    }

    if (m_flashTimer->isActive()) {
        stopAnimation();
    }

    m_flashTimer->setInterval(500);
    m_flashTimer->start();

    connect(m_flashTimer, SIGNAL(timeout()), this, SLOT(animateIcon()));
}
示例#3
0
bool Application::configure()
{
    if ( !QSystemTrayIcon::isSystemTrayAvailable() )
    {
        LOG_ERROR( "application", tr( "No system tray available!" ) );
        QMessageBox::critical( 0, tr( "Error" ), tr( "No system tray available!" ) );
        return false;
    }

    if ( !QSystemTrayIcon::supportsMessages() )
    {
        LOG_ERROR( "application", tr( "System tray not support messages!" ) );
        QMessageBox::critical( 0, tr( "Error" ), tr( "System tray not support messages!" ) );
        return false;
    }

    // Tray icons set.
    trayIconList.append( ":/images/radio-active-2.png" );
    trayIconList.append( ":/images/radio-active-1.png" );
    trayIconList.append( ":/images/radio-active.png"   );
    currTrayIcon = 0;

    // Setup player.    
    connect( &player, SIGNAL( playerTick( quint64 ) ), SLOT( animateIcon( quint64 ) ) );
    connect( &player, SIGNAL( playing() ), SLOT( onPlayerPlay() ) );
    connect( &player, SIGNAL( paused() ), SLOT( onPlayerPause() ) );
    connect( &player, SIGNAL( stopped() ), SLOT( onPlayerStop() ) );
    connect( &player, SIGNAL( errorOccured() ), SLOT( onPlayerError() ) );
    connect( &player, SIGNAL( buffering( int ) ), SLOT( onPlayerBuffering( int ) ) );
    connect( &player, SIGNAL( volumeChanged( int ) ), SLOT( onPlayerVolumeChanged( int ) ) );
    connect( &player, SIGNAL( metaDataChanged( const QMultiMap< QString, QString > ) ),
                      SLOT ( onMetaDataChange( const QMultiMap< QString, QString > ) ) );

    // Setup global shortcuts.
    QxtGlobalShortcut * globalShortcut;
    globalShortcut = new QxtGlobalShortcut( &trayItem );
    if ( globalShortcut )
    {
        globalShortcut->setShortcut( QKeySequence( pauseHotkey ) );
        connect( globalShortcut, SIGNAL( activated() ), &player, SLOT( playOrPause() ) );
    }
    globalShortcut = new QxtGlobalShortcut( &trayItem );
    if ( globalShortcut )
    {
        globalShortcut->setShortcut( QKeySequence( stopHotkey ) );
        connect( globalShortcut, SIGNAL( activated() ), &player, SLOT( stopPlay() ) );
    }
    globalShortcut = new QxtGlobalShortcut( &trayItem );
    if ( globalShortcut )
    {
        globalShortcut->setShortcut( QKeySequence( volumeUpHotkey ) );
        connect( globalShortcut, SIGNAL( activated() ), &player, SLOT( volumeUp() ) );
    }
    globalShortcut = new QxtGlobalShortcut( &trayItem );
    if ( globalShortcut )
    {
        globalShortcut->setShortcut( QKeySequence( volumeDownHotkey ) );
        connect( globalShortcut, SIGNAL( activated() ), &player, SLOT( volumeDown() ) );
    }
    globalShortcut = new QxtGlobalShortcut( &trayItem );
    if ( globalShortcut )
    {
        globalShortcut->setShortcut( QKeySequence( quitHotkey ) );
        connect( globalShortcut, SIGNAL( activated() ), this, SLOT( quit()) );
    }

    // Create stations menu.
    stationsMenu.setTitle( tr( "Stations" ) );
    stationsMenu.setIcon( QIcon( ":/images/radio-passive.png" ) );
    stationsGroup = new QActionGroup( &stationsMenu );
    if ( stationsGroup )
    {
        stationsGroup->setExclusive( true );
        updateStationsMenu();
        connect( stationsGroup, SIGNAL( triggered( QAction * ) ),
                                SLOT( processStationAction( QAction * ) ) );
    }

    // Create base menu.
    trayMenu.addMenu( &stationsMenu );
    trayMenu.addSeparator();
    QAction * action;
    action = new QAction( &trayMenu );
    if ( action )
    {
        action->setIcon( QIcon( ":/images/audio-volume-up.png" ) );
        action->setText( tr( "Volume up" ) );
        action->setShortcut( QKeySequence( volumeUpHotkey ) );
        connect( action, SIGNAL( triggered() ), &player, SLOT( volumeUp() ) );
        trayMenu.addAction( action );
    }
    action = new QAction( &trayMenu );
    if ( action )
    {
        action->setIcon( QIcon( ":/images/audio-volume-down.png" ) );
        action->setText( tr( "Volume down" ) );
        action->setShortcut( QKeySequence( volumeDownHotkey ) );
        connect( action, SIGNAL( triggered() ), &player, SLOT( volumeDown() ) );
        trayMenu.addAction( action );
    }
    trayMenu.addSeparator();
    action = new QAction( &trayMenu );
    if ( action )
    {
        action->setIcon( QIcon( ":/images/media-playback-start.png" ) );
        action->setText( tr( "Play|Pause" ) );
        action->setShortcut( QKeySequence( pauseHotkey ) );
        connect( action, SIGNAL( triggered() ), &player, SLOT( playOrPause() ) );
        trayMenu.addAction( action );
    }
    action = new QAction( &trayMenu );
    if ( action )
    {
        action->setIcon( QIcon( ":/images/media-playback-stop.png" ) );
        action->setText( tr( "Stop" ) );
        action->setShortcut( QKeySequence( stopHotkey ) );
        connect( action, SIGNAL( triggered() ), &player, SLOT( stopPlay() ) );
        trayMenu.addAction( action );
    }
    trayMenu.addSeparator();
    action = new QAction( &trayMenu );
    if ( action )
    {
        action->setIcon( QIcon( ":/images/application-info.png" ) );
        action->setText( tr( "Info" ) );
        action->setMenuRole( QAction::AboutRole );
        connect( action, SIGNAL( triggered() ), this, SLOT( about() ) );
        trayMenu.addAction( action );
    }
    action = new QAction( &trayMenu );
    if ( action )
    {
        action->setIcon( QIcon( ":/images/application-exit.png" ) );
        action->setText( tr( "Exit" ) );
        action->setShortcut( QKeySequence( quitHotkey ) );
        action->setMenuRole( QAction::QuitRole );
        connect( action, SIGNAL( triggered() ), this, SLOT( quit() ) );
        trayMenu.addAction( action );
    }

    // Create settings menu.
    action = new QAction( &trayMenu );
    if ( action )
    {
        action->setIcon( QIcon( ":/images/application-settings.png" ) );
        action->setText( tr( "Settings" ) );
        action->setMenuRole( QAction::PreferencesRole );
        connect( action, SIGNAL( triggered() ), this, SLOT( manageSettings() ) );
        settingsMenu.addAction( action );
    }
    action = new QAction( &trayMenu );
    if ( action )
    {
        action->setIcon( QIcon( ":/images/application-exit.png" ) );
        action->setText( tr( "Exit" ) );
        action->setShortcut( QKeySequence( quitHotkey ) );
        action->setMenuRole( QAction::QuitRole );
        connect( action, SIGNAL( triggered() ), this, SLOT( quit() ) );
        settingsMenu.addAction( action );
    }

    // Setup tray item.
    trayItem.setIcon( QIcon( ":/images/radio-passive.png" ) );
    trayItem.show();
    trayItem.showMessage( tr( "QRadioTray" ), tr( "Program started!" ), QSystemTrayIcon::Information );    
    connect( &trayItem, SIGNAL( activated( QSystemTrayIcon::ActivationReason ) ),
                        SLOT( processTrayActivation( QSystemTrayIcon::ActivationReason ) ) );
    return true;
}
示例#4
0
static display_t draw()
{
#if COMPILE_ANIMATIONS
	static byte usbImagePos = FRAME_HEIGHT;
	static byte chargeImagePos = FRAME_HEIGHT;
#endif

	// Draw date
	drawDate();

	// Draw time animated
	display_t busy = ticker();

	// Draw battery icon
	drawBattery();

	byte fix = 20;

	// Draw USB icon
	image_s icon = newImage(fix, FRAME_HEIGHT - 9, usbIcon, 16, 8, WHITE, NOINVERT, 0);
	draw_bitmap_set(&icon);

#if COMPILE_ANIMATIONS
	if(animateIcon(USB_CONNECTED(), &usbImagePos))
	{
		icon.y = usbImagePos;
		draw_bitmap_s2(NULL);
		icon.x += 20;
	}
#else
	if(USB_CONNECTED())
	{
		draw_bitmap_s2(NULL);
		icon.x += 20;
	}
#endif
	
	// Draw charging icon
	icon.width = 8;
#if COMPILE_ANIMATIONS
	if(animateIcon(CHARGING(), &chargeImagePos))
	{
		icon.bitmap = chargeIcon;
		icon.y = chargeImagePos;
		draw_bitmap_s2(NULL);
		icon.x += 12;
	}	
#else
	if(CHARGING())
	{
		icon.bitmap = chargeIcon;
		draw_bitmap_s2(NULL);
		icon.x += 12;
	}
#endif

	icon.y = FRAME_HEIGHT - 8;

#if COMPILE_STOPWATCH
	// Stopwatch icon
	if(stopwatch_active())
	{
		icon.bitmap = stopwatch;
		draw_bitmap_s2(&icon);
		icon.x += 12;
	}
#endif	

	// Draw next alarm
	alarm_s nextAlarm;
	if(alarm_getNext(&nextAlarm))
	{
		time_s alarmTime;
		alarmTime.hour = nextAlarm.hour;
		alarmTime.mins = nextAlarm.min;
		alarmTime.ampm = CHAR_24;
		time_timeMode(&alarmTime, appConfig.timeMode);
		
		char buff[9];
		sprintf_P(buff, PSTR("%02hhu:%02hhu%c"), alarmTime.hour, alarmTime.mins, alarmTime.ampm);
		draw_string(buff, false, icon.x, FRAME_HEIGHT - 8);
		icon.x += (alarmTime.ampm == CHAR_24) ? 35 : 42;

		icon.bitmap = dowImg[alarm_getNextDay()];
		draw_bitmap_s2(&icon);

//		icon.x += 9;
	}

	return busy;
}
示例#5
0
void AdBlockIcon::stopAnimation() {
  m_timerTicks = 0;
  m_flashTimer->stop();
  disconnect(m_flashTimer, SIGNAL(timeout()), this, SLOT(animateIcon()));
  setEnabled(m_enabled);
}