Esempio n. 1
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();
}
Esempio n. 2
0
bool GlobalState::loop( void )
{ 
  const ino::StdButtonEvent openEvent   = m_buttonOpen.check();
  const ino::StdButtonEvent closeEvent  = m_buttonClose.check();
  uint8_t next_pos                      = 255;
  m_idle_time                           = ( m_blind.on() || (m_on_off_count>=OTA_ENABLE_ON_OFF_COUNT) ) ? BLIND_IDLE_TIME : 1000;
  m_now                                 = millis();
  
#ifdef LIGHT01_RELAY
  switch ( m_buttonLight01.check() ) {
    case ino::EV_NONE:
      break;
    default:
      m_relayLight01.toggle();
      break;
  }
#endif

#ifdef LIGHT02_RELAY
  switch ( m_buttonLight02.check() ) {
    case ino::EV_NONE:
      break;
    default:
      m_relayLight02.toggle();
      break;
  }
#endif
 
  if ( ino::EV_NONE!=openEvent ) {
      next_pos = (ino::EV_TIMEOUT==openEvent)  ? BLIND_CMD_DISABLE : BLIND_OPEN_POSITION;
  }
  else if ( ino::EV_NONE!=closeEvent ) {
      next_pos = (ino::EV_TIMEOUT==closeEvent) ? BLIND_CMD_DISABLE : BLIND_CLOSE_POSITION;
  }
  
  moveTo( next_pos );
  
  const bool active = m_blind.loop();
  
  if ( active ) {
#ifdef BLIND_VERBOSE
    Serial.print("Blind Position : ");
    Serial.print(m_blind.currentPosition());
    Serial.println("% Closed");
#endif
    m_idle_time = 0;
  }

#ifdef BLIND_SENSOR1_TEMPERATURE_PIN
  m_temperature1.loop();
#endif

#ifdef BLIND_SENSOR2_TEMPERATURE_PIN
  m_temperature2.loop();
#endif

  m_cloud.loop();

  updateState();

  updateIdleTime();
      
  return active;
}