Exemplo n.º 1
0
/**
  * @brief  Pause recording
  * @param  None
  * @retval None
  */
static void RECORDER_Pause (void)
{
  GL_PageControls_TypeDef* item;

  /* Pause/Resume recording */
  AudioRecorder_PauseResume(REC_GL_State);

  /* Update GUI */
  if (REC_GL_State == REC_GL_RECORDING)
  {
    REC_GL_State = REC_GL_IDLE;

    DestroyPageControl (RecordPage, REC_PAUSE_ID);
    RefreshPageControl(RecordPage, REC_PAUSE_ID);

    item = NewIcon (REC_STRT_ID, rec_start_icon, 40, 40, RECORDER_Pause);
    AddPageControlObj(110,135,item, RecordPage);
    RefreshPageControl(RecordPage, REC_STRT_ID);
  }
  else
  {
    REC_GL_State = REC_GL_RECORDING;

    DestroyPageControl (RecordPage, REC_STRT_ID);
    RefreshPageControl(RecordPage, REC_STRT_ID);

    item = NewIcon (REC_PAUSE_ID, rec_pause_icon, 40, 40, RECORDER_Pause);
    AddPageControlObj(110,135,item, RecordPage);
    RefreshPageControl(RecordPage, REC_PAUSE_ID);
  }
}
Exemplo n.º 2
0
void SNIProxy::update()
{
    const QImage image = getImageNonComposite();

    bool isTransparentImage = true;

    int sum = 0;
    for (int x = 0; x < image.width(); ++x) {
        for (int y = 0; y < image.height(); ++y) {
            sum += qAlpha(image.pixel(x, y));
            if (sum >= 255) {
                // There is enough amount of opaque pixels.
                isTransparentImage = false;
                break;
            }
        }
    }

    // Update icon only if it is at least partially opaque.
    // This is just a workaround for X11 bug: xembed icon may suddenly
    // become transparent for a one or few frames. Reproducible at least
    // with WINE applications.
    if (!isTransparentImage) {
        m_pixmap = QPixmap::fromImage(image);
        emit NewIcon();
    }
    else {
        qCDebug(SNIPROXY) << "Skip transparent xembed icon";
    }
}
Exemplo n.º 3
0
/**
  * @brief  Update module icon.
  * @param  new_icon: New icon
  * @retval None
  */
void ETHERNET_UpdateIcon(const uint8_t *new_icon)
{
  GL_PageControls_TypeDef* item;

  if((EthernetCurrentPage->Page_ID == ETHERNET_WEBSERVER_PAGE)||
     (EthernetCurrentPage->Page_ID == ETHERNET_DISTANTCONTROL_PAGE))
  {
    DestroyPageControl(EthernetCurrentPage, 1);
    item = NewIcon (1,new_icon,50,50,MOD_NullFunc);
    AddPageControlObj(185,40,item,EthernetCurrentPage);
    RefreshPageControl(EthernetCurrentPage, 1);
  }
}
Exemplo n.º 4
0
/**
  * @brief  Stop recording and save the recorded file
  * @param  None
  * @retval None
  */
static void RECORDER_Stop (void)
{
  GL_PageControls_TypeDef* item;


  Recorder_UsedStorage = 0xFF;

  if (REC_GL_State == REC_GL_RECORDING)
  {
    AudioRecorder_Stop();

    AudioRecorder_Close();

    DestroyPageControl (RecordPage, REC_STOP_ID);
    RefreshPageControl(RecordPage, REC_STOP_ID);

    DestroyPageControl (RecordPage, REC_PAUSE_ID);
    RefreshPageControl(RecordPage, REC_PAUSE_ID);

    DestroyPageControl (RecordPage, REC_STRT_ID);
    RefreshPageControl(RecordPage, REC_STRT_ID);

    DestroyPageControl (RecordPage, REC_CANCEL_ID);
    RefreshPageControl(RecordPage, REC_CANCEL_ID);

    /* Restore old icons */
    item = NewIcon (REC_STRT_ID, rec_start_icon, 40, 40, RECORDER_Start);
    AddPageControlObj(170,135,item, RecordPage);
    RefreshPageControl(RecordPage, REC_STRT_ID);

    item = NewIcon (REC_PAUSE_ID, rec_pause_icon, 40, 40, MOD_NullFunc);
    AddPageControlObj(110,135,item, RecordPage);
    RefreshPageControl(RecordPage, REC_PAUSE_ID);

    item = NewIcon (REC_PLAY_ID, rec_play_icon, 40, 40, RECORDER_Play);
    AddPageControlObj(50,135,item, RecordPage);
    RefreshPageControl(RecordPage, REC_PLAY_ID);
  }
}
Exemplo n.º 5
0
StatusNotifierButton::StatusNotifierButton(QString service, QString objectPath, ILXQtPanelPlugin* plugin, QWidget *parent)
    : QToolButton(parent),
    mMenu(NULL),
    mStatus(Passive),
    mValid(true),
    mFallbackIcon(QIcon::fromTheme("application-x-executable")),
    mPlugin(plugin)
{
    interface = new org::kde::StatusNotifierItem(service, objectPath, QDBusConnection::sessionBus(), this);

    QString menuPath = interface->menu().path();
    if (!menuPath.isEmpty())
    {
        mMenu = (new DBusMenuImporter(service, interface->menu().path(), this))->menu();
        dynamic_cast<QObject &>(*mMenu).setParent(this);
        mMenu->setObjectName(QStringLiteral("StatusNotifierMenu"));
    }

    // HACK: sni-qt creates some invalid items (like one for konversarion 1.5)
    if (interface->title().isEmpty() && interface->id().isEmpty())
        mValid = false;

    if (mValid)
    {
        newToolTip();
        refetchIcon(Active);
        refetchIcon(Passive);
        refetchIcon(NeedsAttention);
        newStatus(interface->status());
        resetIcon();

        connect(interface, SIGNAL(NewIcon()), this, SLOT(newIcon()));
        connect(interface, SIGNAL(NewOverlayIcon()), this, SLOT(newOverlayIcon()));
        connect(interface, SIGNAL(NewAttentionIcon()), this, SLOT(newAttentionIcon()));
        connect(interface, SIGNAL(NewToolTip()), this, SLOT(newToolTip()));
        connect(interface, SIGNAL(NewStatus(QString)), this, SLOT(newStatus(QString)));
    }
}
Exemplo n.º 6
0
/**
* @brief  Display the main menu
* @param  None
* @retval None
*/
void GL_ShowMainMenu(void)
{
  uint8_t TempStr[25];
  RTC_TimeTypeDef   RTC_TimeStructure;
  RTC_DateTypeDef   RTC_DateStructure;

  GL_PageControls_TypeDef  *Icon , *LabelTime , *LabelDate, *LabelBkgnd;
  uint8_t sec, min, hour, day, month;
  uint16_t year;


  GL_Clear(White);

  GL_HomePage = malloc(sizeof(GL_Page_TypeDef));
  Create_PageObj( GL_HomePage, HOME_PAGE_ID );

  /* Add group icons */

  Icon = NewIcon(2 , Group_Connectivity_icon, BF_XSIZE, BF_YSIZE ,GL_ShowConnectivityGroup );
  AddPageControlObj(305, 40, Icon, GL_HomePage );

  Icon = NewIcon(3 , Group_Multimedia_icon, BF_XSIZE, BF_YSIZE ,GL_ShowMultimediaGroup );
  AddPageControlObj(305, 103, Icon, GL_HomePage );

  Icon = NewIcon(4 , Group_System_icon, BF_XSIZE, BF_YSIZE ,GL_ShowUtilitiesGroup );
  AddPageControlObj(305, 166, Icon, GL_HomePage );


  Icon = NewIcon(32 , STLogo, 40, 22 ,MOD_NullFunc );
  AddPageControlObj(240, 216, Icon, GL_HomePage );

  LabelBkgnd  = NewLabel(33, (uint8_t *)"",GL_HORIZONTAL,GL_FONT_SMALL,GL_Red, GL_FALSE);
  AddPageControlObj(195, 227, LabelBkgnd, GL_HomePage);

  /* add modules */
  switch(GL_Group)
  {
  case CONNECTIVITY_GROUP :
    GL_ShowConnectivityGroup();
    break;

  case MULTIMEDIA_GROUP : 
    GL_ShowMultimediaGroup();
    break;

  case UTILITIES_GROUP : 
    GL_ShowUtilitiesGroup();
    break;

  }

  GL_HomePage->CustomPreDraw = DrawBackgroundZone;
  /* time section */

  /* Get info from RTC here */
  RTC_GetTime(RTC_Format_BIN, &RTC_TimeStructure);

  sec    =  RTC_TimeStructure.RTC_Seconds;
  min    =  RTC_TimeStructure.RTC_Minutes;
  hour   =  RTC_TimeStructure.RTC_Hours;

  sprintf((char *)TempStr, "%02d:%02d:%02d", hour , min, sec);

  LabelTime  = NewLabel(30,TempStr,GL_HORIZONTAL,GL_FONT_SMALL,0x1253, GL_FALSE);
  AddPageControlObj(60, 215, LabelTime, GL_HomePage);


  RTC_GetDate(RTC_Format_BIN, &RTC_DateStructure);

  year =  RTC_DateStructure.RTC_Year + 2000;
  month =  RTC_DateStructure.RTC_Month;
  day =  RTC_DateStructure.RTC_Date;

  sprintf((char *)TempStr, "%02d %s %04d", day , strMonth[month-1], year);
  LabelDate  = NewLabel(31,TempStr,GL_HORIZONTAL,GL_FONT_SMALL,0x1253, GL_FALSE);
  AddPageControlObj(88, 227, LabelDate, GL_HomePage); 


  RefreshPage(GL_HomePage);
  vTaskResume(Core_Time_Task_Handle); 

  Global_Config.b.Force_Background_Refresh = 1;

}
Exemplo n.º 7
0
/**
   * @brief  Create a child sub-page
   * @param  Page: Page handler
   * @retval None
  */
static void ETHERNET_CreatePage(uint8_t Page)
{
  GL_PageControls_TypeDef* item;
  GL_PageControls_TypeDef* BackButton;
  GL_PageControls_TypeDef* ConfirmButton;
  GL_PageControls_TypeDef* Message;
  GL_ComboBoxGrp_TypeDef* pTmp;
  uint8_t str_address[64];

  GL_SetBackColor( GL_White );
  GL_SetTextColor( GL_Blue );

  switch (Page)
  {
    case ETHERNET_MAIN_PAGE:
    {
      EthernetMainPage = malloc(sizeof(GL_Page_TypeDef));
      Create_PageObj( EthernetMainPage, ETHERNET_MAIN_PAGE );
      item = NewIcon (5, ethernet_icon,50,50,MOD_NullFunc);
      AddPageControlObj(185,40,item,EthernetMainPage);

      if((Global_Config.b.DistantControlEnabled != 0) && (Global_Config.b.BackgroundModeEnabled != 0))
      {
        GL_SetMenuItem(EthernetMainPage, (uint8_t *)"Web Server",0,goto_webserver );
        GL_SetMenuItem(EthernetMainPage, (uint8_t *)"Distant Control",1,goto_distantcontrol);
        GL_SetMenuItem(EthernetMainPage, (uint8_t *)"Settings",2,goto_EthernetSettingss );
        GL_SetMenuItem(EthernetMainPage, (uint8_t *)"Return",3,return_to_menu );
      }
      else
      {
        GL_SetMenuItem(EthernetMainPage, (uint8_t *)"Web Server",0,goto_webserver );
        GL_SetMenuItem(EthernetMainPage, (uint8_t *)"Settings",1,goto_EthernetSettingss );
        GL_SetMenuItem(EthernetMainPage, (uint8_t *)"Return",2,return_to_menu );
      }
      GL_SetPageHeader(EthernetMainPage , (uint8_t *)"Ethernet Menu");
    }
    break;

    case ETHERNET_WEBSERVER_PAGE:
    {
      EthernetWebServerPage = malloc(sizeof(GL_Page_TypeDef));
      Create_PageObj( EthernetWebServerPage, ETHERNET_WEBSERVER_PAGE );

      GL_SetPageHeader(EthernetWebServerPage , (uint8_t *)"Web Server");

      item = NewIcon (1,ethernet_disconn_icon,50,50,MOD_NullFunc);
      AddPageControlObj(185,40,item,EthernetWebServerPage);

      BackButton= NewButton(2, (uint8_t *)" Return ",return_from_webserver);
      AddPageControlObj(195, 212, BackButton, EthernetWebServerPage);

      Message  = NewLabel(3, (uint8_t *)" ",GL_HORIZONTAL,GL_FONT_SMALL,GL_Black,GL_FALSE);
      AddPageControlObj(290,113,Message,EthernetWebServerPage);

      Message  = NewLabel(4, (uint8_t *)" ",GL_HORIZONTAL,GL_FONT_SMALL,GL_Black,GL_FALSE);
      AddPageControlObj(290,126,Message,EthernetWebServerPage);

      Message  = NewLabel(5, (uint8_t *)" ",GL_HORIZONTAL,GL_FONT_SMALL,GL_Black,GL_FALSE);
      AddPageControlObj(290,139,Message,EthernetWebServerPage);

      Message  = NewLabel(6, (uint8_t *)" ",GL_HORIZONTAL,GL_FONT_SMALL,GL_Black,GL_FALSE);
      AddPageControlObj(290,160,Message,EthernetWebServerPage);

      Message  = NewLabel(7, (uint8_t *)" ",GL_HORIZONTAL,GL_FONT_SMALL,GL_Black,GL_FALSE);
      AddPageControlObj(290,173,Message,EthernetWebServerPage);

      Message  = NewLabel(8, (uint8_t *)" ",GL_HORIZONTAL,GL_FONT_SMALL,GL_Black,GL_FALSE);
      AddPageControlObj(290,186,Message,EthernetWebServerPage);

      EthernetWebServerPage->CustomPostDraw = InitEthernet;
    }
    break;

    case ETHERNET_DISTANTCONTROL_PAGE:
    {
      EthernetDistantControlPage = malloc(sizeof(GL_Page_TypeDef));
      Create_PageObj( EthernetDistantControlPage, ETHERNET_DISTANTCONTROL_PAGE );

      GL_SetPageHeader(EthernetDistantControlPage , (uint8_t *)"Distant Control");

      item = NewIcon (1,ethernet_conn_icon,50,50,MOD_NullFunc);
      AddPageControlObj(185,40,item,EthernetDistantControlPage);

      BackButton= NewButton(2, (uint8_t *)" Return ",return_from_distantcontrol);
      AddPageControlObj(195, 212, BackButton, EthernetDistantControlPage);

      Message  = NewLabel(3, (uint8_t *)" ",GL_HORIZONTAL,GL_FONT_SMALL,GL_Black,GL_FALSE);
      AddPageControlObj(290,113,Message,EthernetDistantControlPage);

      Message  = NewLabel(4, (uint8_t *)" ",GL_HORIZONTAL,GL_FONT_SMALL,GL_Black,GL_FALSE);
      AddPageControlObj(290,126,Message,EthernetDistantControlPage);

      Message  = NewLabel(5, (uint8_t *)" ",GL_HORIZONTAL,GL_FONT_SMALL,GL_Black,GL_FALSE);
      AddPageControlObj(290,139,Message,EthernetDistantControlPage);

      Message  = NewLabel(6, (uint8_t *)" ",GL_HORIZONTAL,GL_FONT_SMALL,GL_Black,GL_FALSE);
      AddPageControlObj(290,160,Message,EthernetDistantControlPage);

      EthernetDistantControlPage->CustomPostDraw = InitEthernet;
    }
    break;

    case ETHERNET_SETTINGS:
    {
      EthernetSettingssPage = malloc(sizeof(GL_Page_TypeDef));
      Create_PageObj( EthernetSettingssPage, ETHERNET_SETTINGS );
      item = NewIcon (1,ethernet_settings_icon,50,50,MOD_NullFunc);
      AddPageControlObj(185,40,item,EthernetSettingssPage);
      BackButton= NewButton(2, (uint8_t *)" Return ",return_from_settings);
      AddPageControlObj(195, 212, BackButton, EthernetSettingssPage);

      item= NewCheckbox(3 , (uint8_t *)"Enable DHCP Client", GL_TRUE, MOD_NullFunc);
      AddPageControlObj(260, 105, item, EthernetSettingssPage);

      item  = NewLabel(4, (uint8_t *)"Image Format:",GL_HORIZONTAL,GL_FONT_SMALL,GL_Black,GL_FALSE);
      AddPageControlObj(260,145,item,EthernetSettingssPage);

      item = NewComboBoxGrp(5);
      AddComboOption (item->objPTR, (uint8_t *)"BMP QQVGA", MOD_NullFunc);
      AddComboOption (item->objPTR, (uint8_t *)"BMP QVGA", MOD_NullFunc);
      AddPageControlObj( 260, 160, item, EthernetSettingssPage);

      GL_SetPageHeader(EthernetSettingssPage , (uint8_t *)"Ethernet Settings Menu");

      MOD_GetParam(3, &EthCfg.d32);
      
      if(EthCfg.b.DHCPEnable == 1)
      {
        GL_SetChecked(EthernetSettingssPage, 3, EthCfg.b.DHCPEnable);
      }

      pTmp = (GL_ComboBoxGrp_TypeDef*)(item->objPTR);
      if((EthCfg.b.SelectedImageFormat > 0) && (EthCfg.b.SelectedImageFormat < 3))
      {
        pTmp->ComboOptions[0]->IsActive = GL_FALSE;
        pTmp->ComboOptions[EthCfg.b.SelectedImageFormat -1]->IsActive = GL_TRUE;
      }
    }
    break;
  case ETHERNET_WARNING_PAGE:
    {
      EthernetWarningPage = malloc(sizeof(GL_Page_TypeDef));
      Create_PageObj( EthernetWarningPage, ETHERNET_WARNING_PAGE );


      BackButton= NewButton(2, (uint8_t *)" Cancel ",return_from_warning);
      AddPageControlObj(230, 212,BackButton,EthernetWarningPage);

      ConfirmButton= NewButton(3, (uint8_t *)"Disable",disable_distant_control);
      AddPageControlObj(150, 212,ConfirmButton,EthernetWarningPage);

      item = NewIcon (4,error_icon,50,50,MOD_NullFunc);
      AddPageControlObj(185, 40, item, EthernetWarningPage);

      GL_SetPageHeader(EthernetWarningPage , (uint8_t *)"Ethernet : warning");
      item  = NewLabel(5, (uint8_t *)"The Distant control feature is currently",GL_HORIZONTAL,GL_FONT_SMALL,GL_Black, GL_TRUE);
      AddPageControlObj(310,100,item,EthernetWarningPage);

      item  = NewLabel(6, (uint8_t *)"enabled. You need to disable the used",GL_HORIZONTAL,GL_FONT_SMALL,GL_Black, GL_TRUE);
      AddPageControlObj(310,113,item,EthernetWarningPage);

      item  = NewLabel(7, (uint8_t *)"processes and try later. do you want to",GL_HORIZONTAL,GL_FONT_SMALL,GL_Black, GL_TRUE);
      AddPageControlObj(310,126,item,EthernetWarningPage);

      item  = NewLabel(8, (uint8_t *)"disable the Distant control feature?",GL_HORIZONTAL,GL_FONT_SMALL,GL_Black, GL_TRUE);
      AddPageControlObj(310,139,item,EthernetWarningPage);

      if(ETHERNET_CableConnectionStatus == 0)
      {
        sprintf((char *)str_address, "[IP Address : %s]",IPAddressAssigned);

        item  = NewLabel(9,str_address,GL_HORIZONTAL,GL_FONT_SMALL,GL_Black, GL_FALSE);
      }
      else
      {
         item  = NewLabel(9, (uint8_t *)"Network Cable is unplugged !!!",GL_HORIZONTAL,GL_FONT_SMALL,GL_Black, GL_FALSE);
      }
      AddPageControlObj(310,160,item,EthernetWarningPage); 

      EthernetWarningPage->CustomPostDraw = wUpdateConnectionStatus;

    }
    break;

  case ETHERNET_BCKMSG_PAGE:
    {
      EthernetWarningPage = malloc(sizeof(GL_Page_TypeDef));
      Create_PageObj( EthernetWarningPage, ETHERNET_BCKMSG_PAGE );

      item= NewButton(2, (uint8_t *)"  OK  ",return_bkgnd_from_errorpage);
      AddPageControlObj(185,212,item,EthernetWarningPage);

      item = NewIcon (3,error_icon,50,50,MOD_NullFunc);
      AddPageControlObj(185, 40, item, EthernetWarningPage);

      GL_SetPageHeader(EthernetWarningPage , (uint8_t *)"System : Warning");
      item  = NewLabel(4, (uint8_t *)"A Background process is already running, (uint8_t *)",GL_HORIZONTAL,GL_FONT_SMALL,GL_Black, GL_TRUE);
      AddPageControlObj(310,100,item,EthernetWarningPage);

      item  = NewLabel(5, (uint8_t *)"Background mode can not be disabled.",GL_HORIZONTAL,GL_FONT_SMALL,GL_Black, GL_TRUE);
      AddPageControlObj(310,113,item,EthernetWarningPage);
    }
    default:
    break;
  }
}
Exemplo n.º 8
0
/**
  * @brief  Start recording
  * @param  None
  * @retval None
  */
static void RECORDER_Start (void)
{
  GL_PageControls_TypeDef* item;
  uint8_t time[6];
  RTC_TimeTypeDef   RTC_TimeStructure;
  RTC_DateTypeDef   RTC_DateStructure;

  /*Create file name */
  if ( RTC_Error == 0)
  {
    RTC_GetTime(RTC_Format_BIN, &RTC_TimeStructure);
    RTC_GetDate(RTC_Format_BIN, &RTC_DateStructure);

    sprintf((char *)RecFileName, "Rec_%02d%02d%d%02d%02d%02d.wav", RTC_DateStructure.RTC_Date,
            RTC_DateStructure.RTC_Month,
            RTC_DateStructure.RTC_Year + 2000,
            RTC_TimeStructure.RTC_Hours,
            RTC_TimeStructure.RTC_Minutes,
            RTC_TimeStructure.RTC_Seconds);
  }
  else
  {
    /* Wait until one RNG number is ready */
    while(RNG_GetFlagStatus(RNG_FLAG_DRDY)== RESET)
    {
    }
    RecoveryRecorderCounter = RNG_GetRandomNumber() & 0x7FFFFFFF;
    sprintf((char *)RecFileName, "Rec_%014d.wav", (int)RecoveryRecorderCounter);
  }

  RECORDER_GetDefaultDirectory();
  strcat ((char *)REC_DefaultPath,"/");
  strcat((char *)REC_DefaultPath, (char *)RecFileName);
  RefreshLabel(RecordPage , REC_FILNAME_ID, (uint8_t *)"                                  ");


  if (AudioRecorder_Open(REC_DefaultPath))
  {
    memset (RecFileName, 0, sizeof(RecFileName));
    RefreshLabel(RecordPage , REC_FILNAME_ID, (uint8_t *)"Error Open File !");
    return;
  }
  else
  {
    RefreshLabel(RecordPage , REC_FILNAME_ID, RecFileName);
  }
  
  /* Graphical update */
  DestroyPageControl (RecordPage, REC_STRT_ID);
  RefreshPageControl(RecordPage, REC_STRT_ID);

  DestroyPageControl (RecordPage, REC_PLAY_ID);
  RefreshPageControl(RecordPage, REC_PLAY_ID);

  DestroyPageControl (RecordPage, REC_PAUSE_ID);
  RefreshPageControl(RecordPage, REC_PAUSE_ID);

  item = NewIcon (REC_STOP_ID, rec_stop_icon, 40, 40, RECORDER_Stop);
  AddPageControlObj(170,135,item, RecordPage);
  RefreshPageControl(RecordPage, REC_STOP_ID);

  item = NewIcon (REC_PAUSE_ID, rec_pause_icon, 40, 40, RECORDER_Pause);
  AddPageControlObj(110,135,item, RecordPage);
  RefreshPageControl(RecordPage, REC_PAUSE_ID);

  item = NewIcon (REC_CANCEL_ID, rec_cancel_icon, 40, 40, RECORDER_Cancel);
  AddPageControlObj(50,135,item, RecordPage);
  RefreshPageControl(RecordPage, REC_CANCEL_ID);

  sprintf((char *)time, "%02d:%02d", 0, 0);
  RefreshLabel(RecordPage, REC_TIME_ID, time);

  REC_GL_State = REC_GL_RECORDING;
  Recorder_UsedStorage = REC_DefaultPath[0];
  AudioRecorder_Start();
}
Exemplo n.º 9
0
static void RECORDER_CreatePage(uint8_t Page)
{

  GL_PageControls_TypeDef* item;
  GL_PageControls_TypeDef* TimeInfo;
  GL_PageControls_TypeDef* ExitEventButton;
  GL_ComboBoxGrp_TypeDef* pTmp;

  uint8_t path[129];

  GL_SetBackColor( GL_White );
  GL_SetTextColor( GL_Blue );

  switch (Page)
  {
  case RECORDER_MAIN_PAGE:
    {
      RecorderMainPage = malloc(sizeof(GL_Page_TypeDef));
      Create_PageObj( RecorderMainPage, RECORDER_MAIN_PAGE ); 
      item = NewIcon (REC_MAINICON_ID, recorder_icon,50,50,MOD_NullFunc);
      AddPageControlObj(185,40,item,RecorderMainPage);
      
      GL_SetMenuItem(RecorderMainPage, (uint8_t *)"Start Recorder",0, go_to_record_page );
      GL_SetMenuItem(RecorderMainPage,(uint8_t *)"Settings",1, go_to_settings_page );
      GL_SetMenuItem(RecorderMainPage,(uint8_t *)"Return",2, return_to_menu );
      GL_SetPageHeader(RecorderMainPage , (uint8_t *)"Recorder Menu");
    }
    break;


  case RECORDER_RECORD_PAGE:
    {

      RECORDER_GetDefaultDirectory();

      /* Store selected settings */
      MOD_GetParam(RECORDER_SETTINGS_MEM , &RecCfg.d32);

      switch (RecCfg.b.SampleRate)
      {
      case 0:
      case 1:
        RecorderSampleRate = 8000;
        break;

      case 2:
        RecorderSampleRate = 16000;
        break;
      }
      
      /* Deinit */
      AudioRecorder_DeInit();

      /* Initialize the recorder */
      AudioRecorder_Init(RecorderSampleRate);

      RecordPage = malloc(sizeof(GL_Page_TypeDef));
      Create_PageObj( RecordPage, RECORDER_RECORD_PAGE );

      GL_SetPageHeader(RecorderMainPage , (uint8_t *)"Recorder");

      /* Static display */
      item = NewIcon (REC_MICLOGO_ID , rec_mic_logo, 110, 180, MOD_NullFunc);
      AddPageControlObj(300, 30, item, RecordPage);

      /*------------- Control icons */
      ExitEventButton = NewButton(REC_RECEXIT_ID, (uint8_t *)" Return ", Exit_recorder);
      AddPageControlObj(195, 212, ExitEventButton, RecordPage);

      TimeInfo = NewLabel(REC_TIME_ID, (uint8_t *)"00:00", GL_HORIZONTAL, GL_FONT_BIG, GL_Red, GL_FALSE);
      AddPageControlObj(130,80, TimeInfo, RecordPage); 

      item= NewLabel(REC_FILNAME_ID,(uint8_t *)"Press Record to start",GL_HORIZONTAL,GL_FONT_SMALL,GL_Black, GL_FALSE);
      AddPageControlObj(170,40, item, RecordPage);

      item = NewIcon (REC_STRT_ID, rec_start_icon, 40, 40, RECORDER_Start);
      AddPageControlObj(170,135,item, RecordPage);

      item = NewIcon (REC_PAUSE_ID, rec_pause_icon, 40, 40, MOD_NullFunc);
      AddPageControlObj(110,135,item, RecordPage);
      
      item = NewIcon (REC_PLAY_ID, rec_play_icon, 40, 40, RECORDER_Play);
      AddPageControlObj(50,135,item, RecordPage);
    }
    break;

  case RECORDER_SETTINGS_PAGE:
    {
      MOD_GetParam(RECORDER_SETTINGS_MEM , &RecCfg.d32);

      SettingsPage = malloc(sizeof(GL_Page_TypeDef));
      Create_PageObj( SettingsPage, RECORDER_RECORD_PAGE );

      GL_SetPageHeader( SettingsPage , (uint8_t *)"Recorder Settings");

      /* Exit button */
      ExitEventButton = NewButton(1, (uint8_t *)"  OK  ", return_from_settings);
      AddPageControlObj(195, 212, ExitEventButton, SettingsPage);

      item  = NewLabel(2, (uint8_t *)"Storage :", GL_HORIZONTAL, GL_FONT_SMALL, GL_Black, GL_FALSE);
      AddPageControlObj(260, 140, item, SettingsPage);

      item  = NewButton(3, (uint8_t *)"...", Sel_folder);
      AddPageControlObj(120 , 150, item, SettingsPage);

      Check_DefaultPath((char *)path);

      if(strlen((char *)path) > REC_DST_PATH_LENGTH)
      {
        path[REC_DST_PATH_LENGTH - 2] = '.';
        path[REC_DST_PATH_LENGTH - 1] = '.';
        path[REC_DST_PATH_LENGTH]     =  0;
      }

      item  = NewLabel(4, path, GL_HORIZONTAL, GL_FONT_SMALL, GL_Blue, GL_FALSE);
      AddPageControlObj(260, 155, item, SettingsPage);


      /* Format selection settings */
      item  = NewLabel(4, (uint8_t *)"Audio Format: ", GL_HORIZONTAL, GL_FONT_SMALL, GL_Black, GL_FALSE);
      AddPageControlObj(260, 50, item, SettingsPage);

      item = NewComboBoxGrp(5);

      AddComboOption (item->objPTR, (uint8_t *)"  PCM Wav  ", set_encoder_wav);
      AddPageControlObj( 260, 65, item, SettingsPage);

      /* Sample Rate selection settings */
      item  = NewLabel(6, (uint8_t *)"Sample Rate:", GL_HORIZONTAL, GL_FONT_SMALL, GL_Black, GL_FALSE);
      AddPageControlObj(260, 95, item, SettingsPage);

      item = NewComboBoxGrp(7);

      AddComboOption (item->objPTR, (uint8_t *)"  8000 Hz  ", MOD_NullFunc);
      AddComboOption (item->objPTR, (uint8_t *)" 16000 Hz  ", MOD_NullFunc);
      AddPageControlObj( 260, 110, item, SettingsPage);

      pTmp = (GL_ComboBoxGrp_TypeDef*)(item->objPTR);

      if ((RecCfg.b.SampleRate > 0) && (RecCfg.b.SampleRate < 3))
      {
        pTmp->ComboOptions[0]->IsActive = GL_FALSE;
        pTmp->ComboOptions[RecCfg.b.SampleRate -1]->IsActive = GL_TRUE;
      }

    }
    break;

  case RECORDER_ERROR_PAGE:
    {
      RecorderErrorPage = malloc(sizeof(GL_Page_TypeDef));
      Create_PageObj( RecorderErrorPage, RECORDER_ERROR_PAGE );

      ExitEventButton= NewButton(2, (uint8_t *)"  OK  ",return_from_errorpage);
      AddPageControlObj(185,212,ExitEventButton,RecorderErrorPage);

      item = NewIcon (3,error_icon,50,50,MOD_NullFunc);
      AddPageControlObj(185, 40, item, RecorderErrorPage);

      GL_SetPageHeader(RecorderErrorPage , (uint8_t *)"Audio Recorder : Error");
      item  = NewLabel(4,(uint8_t *)"An Audio process is already running in ",GL_HORIZONTAL,GL_FONT_SMALL,GL_Black, GL_TRUE);
      AddPageControlObj(310,100,item,RecorderErrorPage); 

      item  = NewLabel(5,(uint8_t *)"background, Please stop it and try again.",GL_HORIZONTAL,GL_FONT_SMALL,GL_Black, GL_TRUE);
      AddPageControlObj(310,113,item,RecorderErrorPage);
    }
    break;

  default:
    break;
  }
}
Exemplo n.º 10
0
StatusNotifierItem::StatusNotifierItem(QWidget *parent)
    : StatusNotifierItemParent(parent)
#if QT_VERSION >= 0x050000
    , _iconThemeDir{QDir::tempPath() + QLatin1String{"/quassel-sni-XXXXXX"}}
#endif
{
    static bool registered = []() -> bool {
        qDBusRegisterMetaType<DBusImageStruct>();
        qDBusRegisterMetaType<DBusImageVector>();
        qDBusRegisterMetaType<DBusToolTipStruct>();
        return true;
    }();
    Q_UNUSED(registered)

    setMode(Mode::StatusNotifier);

    connect(this, SIGNAL(visibilityChanged(bool)), this, SLOT(onVisibilityChanged(bool)));
    connect(this, SIGNAL(modeChanged(Mode)), this, SLOT(onModeChanged(Mode)));
    connect(this, SIGNAL(stateChanged(State)), this, SLOT(onStateChanged(State)));

    trayMenu()->installEventFilter(this);

    // Create a temporary directory that holds copies of the tray icons. That way, visualizers can find our icons.
    // For Qt4 the relevant icons are installed in hicolor already, so nothing to be done.
#if QT_VERSION >= 0x050000
    if (_iconThemeDir.isValid()) {
        _iconThemePath = _iconThemeDir.path();
    }
    else {
        qWarning() << "Could not create temporary directory for themed tray icons!";
    }
#endif

    connect(this, SIGNAL(iconsChanged()), this, SLOT(refreshIcons()));
    refreshIcons();

    // Our own SNI service
    _statusNotifierItemDBus = new StatusNotifierItemDBus(this);
    connect(this, SIGNAL(currentIconNameChanged()), _statusNotifierItemDBus, SIGNAL(NewIcon()));
    connect(this, SIGNAL(currentIconNameChanged()), _statusNotifierItemDBus, SIGNAL(NewAttentionIcon()));
    connect(this, SIGNAL(toolTipChanged(QString, QString)), _statusNotifierItemDBus, SIGNAL(NewToolTip()));

    // Service watcher to keep track of the StatusNotifierWatcher service
    QDBusServiceWatcher *watcher = new QDBusServiceWatcher(kSniWatcherService,
                                                           QDBusConnection::sessionBus(),
                                                           QDBusServiceWatcher::WatchForOwnerChange,
                                                           this);
    connect(watcher, SIGNAL(serviceOwnerChanged(QString, QString, QString)), SLOT(serviceChange(QString, QString, QString)));

    // Client instance for StatusNotifierWatcher
    _statusNotifierWatcher = new org::kde::StatusNotifierWatcher(kSniWatcherService,
                                                                 kSniWatcherPath,
                                                                 QDBusConnection::sessionBus(),
                                                                 this);
    connect(_statusNotifierWatcher, SIGNAL(StatusNotifierHostRegistered()), SLOT(checkForRegisteredHosts()));
    connect(_statusNotifierWatcher, SIGNAL(StatusNotifierHostUnregistered()), SLOT(checkForRegisteredHosts()));

    // Client instance for notifications
    _notificationsClient = new org::freedesktop::Notifications(kXdgNotificationsService,
                                                               kXdgNotificationsPath,
                                                               QDBusConnection::sessionBus(),
                                                               this);
    connect(_notificationsClient, SIGNAL(NotificationClosed(uint, uint)), SLOT(notificationClosed(uint, uint)));
    connect(_notificationsClient, SIGNAL(ActionInvoked(uint, QString)), SLOT(notificationInvoked(uint, QString)));

    if (_notificationsClient->isValid()) {
        QStringList desktopCapabilities = _notificationsClient->GetCapabilities();
        _notificationsClientSupportsMarkup = desktopCapabilities.contains("body-markup");
        _notificationsClientSupportsActions = desktopCapabilities.contains("actions");
    }

#ifdef HAVE_DBUSMENU
    new QuasselDBusMenuExporter(menuObjectPath(), trayMenu(), _statusNotifierItemDBus->dbusConnection()); // will be added as menu child
#endif
}