Example #1
0
void Executor::init()
{
   qRegisterMetaType<SettingsData>("SettingsData");
   qRegisterMetaTypeStreamOperators<SettingsData>("SettingsData");

#ifdef EXECUTOR_EXE
   //установка глобальных хоткеев
   QxtGlobalShortcut * startShortcut = new QxtGlobalShortcut(this);
   startShortcut->setShortcut(QKeySequence("Ctrl+F5"));
   connect(startShortcut, SIGNAL(activated()), 
      this, SLOT(start()));

   QxtGlobalShortcut *stopShortcut = new QxtGlobalShortcut(this);
   stopShortcut->setShortcut(QKeySequence("Ctrl+F6"));
   connect(stopShortcut, SIGNAL(activated()), 
      this, SLOT(stop()));
   
   QxtGlobalShortcut *exitShortcut = new QxtGlobalShortcut(this);
   exitShortcut->setShortcut(QKeySequence("Ctrl+F10"));
   connect(exitShortcut, SIGNAL(activated()), 
      this, SLOT(exit()));
#endif

   screen_res_x_ = GetSystemMetrics(SM_CXSCREEN);//Получить ширину экрана
   screen_res_y_ = GetSystemMetrics(SM_CYSCREEN);//Получить высоту экрана
   
   cardProc_ = new Proc770();
   alarm_ = new AlarmWidget();
}
Example #2
0
MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags)
	: QMainWindow(parent, flags)
{
	ui.setupUi(this);
	createProgressBar();
	ui.tabWidget->setTabContextMenuPolicy(Qt::ActionsContextMenu);

	connect(ui.actionQuit, SIGNAL(triggered()), this, SLOT(close()));
	connect(ui.actionAddTab, SIGNAL(triggered()), this, SLOT(addTab()));
	connect(ui.actionAboutQt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
	connect(ui.actionAboutQxtGui, SIGNAL(triggered()), this, SLOT(aboutQxtGui()));
	connect(ui.actionSwitchLayoutDirection, SIGNAL(triggered()), this, SLOT(switchLayoutDirection()));
	connect(ui.actionConfigure, SIGNAL(triggered()), this, SLOT(configure()));

    QxtGlobalShortcut* shortcut = new QxtGlobalShortcut(this);
    connect(shortcut, SIGNAL(activated()), this, SLOT(toggleVisibility()));
    QKeySequence key("Ctrl+Shift+Alt+S");
    if (shortcut->setShortcut(key))
        ui.labelVisibility->setText(ui.labelVisibility->text().arg(key.toString(QKeySequence::NativeText)));
    else
        ui.labelVisibility->hide();

    QTimer* timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(updateIdleTime()));
    timer->start(150);
    updateIdleTime();
}
Example #3
0
void GlobalAccel::bindDefault()
{
    foreach(const QKeySequence & keySequence , mapping.keys())
    {
        qDebug() << "Binding: " << keySequence << mapping.value(keySequence);

        QxtGlobalShortcut *sc = new QxtGlobalShortcut(this);
        sc->setShortcut(keySequence);
        connect(sc , SIGNAL(activated()) , SLOT(launchApp()));
    }
}
Example #4
0
bool configwidget::avalibelGlobalShortcuts(const QKeySequence& seq)
{
    bool ok = false;
    QxtGlobalShortcut tmpShortcut;
    if (tmpShortcut.setShortcut(QKeySequence(seq)) == true)
    {
	tmpShortcut.setDisabled(true);
	ok = true;
    }
    return ok;
}
Example #5
0
void NAction::setGlobalShortcuts(const QList<QKeySequence> &shortcuts)
{
	foreach (QxtGlobalShortcut *shortcut, m_globalShortcuts)
		delete shortcut;
	m_globalShortcuts.clear();

	foreach (QKeySequence seq, shortcuts) {
		QxtGlobalShortcut *s = new QxtGlobalShortcut(this);
		connect(s, SIGNAL(activated()), this, SLOT(trigger()));
		s->setShortcut(seq);
		m_globalShortcuts << s;
	}
Example #6
0
//---------------------------------------------------------
// Implementations
//---------------------------------------------------------
//-------------------------------------
HotkeysController::HotkeysController(MainWindow *parent)
    : BaseController("hotkeys", parent) {
  QAction *actions[] = {
      parent->ui()->actionPlayPause, parent->ui()->actionNext,
      parent->ui()->actionPrevious, parent->ui()->actionAdd_to_favorites,
  };
  qDebug() << "Hotkeys: Setting up Qxt global shortcuts";
  for (int i = 0; i < 4; ++i) {
    QAction *action = actions[i];
    QxtGlobalShortcut *shortcut = new QxtGlobalShortcut();
    shortcut->setObjectName(action->objectName());
    if (shortcut->setShortcut(action->shortcut()))
      qDebug() << "Global shortcut registered: " << action->shortcut()
               << "\t: " << action->objectName();
    connect(shortcut, SIGNAL(activated()), action, SLOT(trigger()));
    m_shortcuts.append(shortcut);
  }
#ifdef Q_OS_WIN
  QAction *mediaActions[] = {
      parent->ui()->actionPlayPause, parent->ui()->actionPlayPause,
      parent->ui()->actionNext, parent->ui()->actionPrevious};
  int shortcuts[] = {Qt::Key_MediaPlay, Qt::Key_MediaStop, Qt::Key_MediaNext,
                     Qt::Key_MediaPrevious};
  QStringList names;
  names << "MediaPlay"
        << "MediaStop"
        << "MediaNext"
        << "MediaPrevious";
  qDebug() << "Hotkeys: Setting up Media shortcuts";
  for (int i = 0; i < names.count(); ++i) {
    QAction *action = mediaActions[i];
    QxtGlobalShortcut *shortcut = new QxtGlobalShortcut();
    shortcut->setObjectName(names[i]);
    if (shortcut->setShortcut(shortcuts[i]))
      qDebug() << "Media shortcut registered: " << names[i];
    connect(shortcut, SIGNAL(activated()), action, SLOT(trigger()));
    m_shortcuts.append(shortcut);
  }
#endif
}
Example #7
0
void FaceTrackNoIR::bind_keyboard_shortcut(QxtGlobalShortcut& key, key_opts& k)
{
    key.setShortcut(QKeySequence::fromString(""));
    key.setDisabled();
    const int idx = k.key_index;
    if (idx > 0)
    {
        QString seq(global_key_sequences.value(idx, ""));
        if (!seq.isEmpty())
        {
            if (k.shift)
                seq = "Shift+" + seq;
            if (k.alt)
                seq = "Alt+" + seq;
            if (k.ctrl)
                seq = "Ctrl+" + seq;
            key.setShortcut(QKeySequence::fromString(seq, QKeySequence::PortableText));
            key.setEnabled();
        } else {
	    key.setDisabled();
	}
    }
}
Example #8
0
//-------------------------------------
void HotkeysController::applyPreferences() {
  QAction *actions[] = {
      m_mainWindow->ui()->actionPlayPause, m_mainWindow->ui()->actionNext,
      m_mainWindow->ui()->actionPrevious,
      m_mainWindow->ui()->actionAdd_to_favorites,
  };
  qDebug() << "Hotkeys : updating Qxt global shortcuts";
  for (int i = 0; i < 4; ++i) {
    QAction *action = actions[i];
    QxtGlobalShortcut *shortcut = m_shortcuts[i];
    if (shortcut->setShortcut(action->shortcut()))
      qDebug() << "Global shortcut updated: " << action->shortcut() << ":"
               << action->objectName();
  }
}
Example #9
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;
}