Пример #1
0
void CGUIDialogAddonInfo::OnChangeLog()
{
  CGUIDialogTextViewer* pDlgInfo = (CGUIDialogTextViewer*)g_windowManager.GetWindow(WINDOW_DIALOG_TEXT_VIEWER);
  CStdString name;
  if (m_addon)
    name = m_addon->Name();
  else if (m_localAddon)
    name = m_localAddon->Name();
  pDlgInfo->SetHeading(g_localizeStrings.Get(24054)+" - "+name);
  if (m_item->GetProperty("Addon.Changelog").empty())
  {
    pDlgInfo->SetText(g_localizeStrings.Get(13413));
    CFileItemList items;
    if (m_localAddon && 
        !m_item->GetProperty("Addon.UpdateAvail").asBoolean())
    {
      items.Add(CFileItemPtr(new CFileItem(m_localAddon->ChangeLog(),false)));
    }
    else
      items.Add(CFileItemPtr(new CFileItem(m_addon->ChangeLog(),false)));
    items[0]->Select(true);
    m_jobid = CJobManager::GetInstance().AddJob(
      new CFileOperationJob(CFileOperationJob::ActionCopy,items,
                            "special://temp/"),this);
  }
  else
    pDlgInfo->SetText(m_item->GetProperty("Addon.Changelog").asString());

  m_changelog = true;
  pDlgInfo->DoModal();
  m_changelog = false;
}
Пример #2
0
void CGUIDialogAddonInfo::OnJobComplete(unsigned int jobID, bool success,
                                        CJob* job)
{
  if (!m_changelog)
    return;

  CGUIDialogTextViewer* pDlgInfo = (CGUIDialogTextViewer*)g_windowManager.GetWindow(WINDOW_DIALOG_TEXT_VIEWER);

  m_jobid = 0;
  if (!success)
  {
    pDlgInfo->SetText(g_localizeStrings.Get(195));
  }
  else
  {
    CFile file;
    if (file.Open("special://temp/"+
      URIUtils::GetFileName(((CFileOperationJob*)job)->GetItems()[0]->GetPath())))
    {
      char* temp = new char[(size_t)file.GetLength()+1];
      file.Read(temp,file.GetLength());
      temp[file.GetLength()] = '\0';
      m_item->SetProperty("Addon.Changelog",temp);
      pDlgInfo->SetText(temp);
      delete[] temp;
    }
  }
  CGUIMessage msg(GUI_MSG_NOTIFY_ALL, WINDOW_DIALOG_TEXT_VIEWER, 0, GUI_MSG_UPDATE);
  g_windowManager.SendThreadMessage(msg);
}
Пример #3
0
void CGUIDialogAddonInfo::OnJobComplete(unsigned int jobID, bool success,
                                        CJob* job)
{
  if (!m_changelog)
    return;

  CGUIDialogTextViewer* pDlgInfo = (CGUIDialogTextViewer*)g_windowManager.GetWindow(WINDOW_DIALOG_TEXT_VIEWER);

  m_jobid = 0;
  if (!success)
  {
    pDlgInfo->SetText(g_localizeStrings.Get(195));
  }
  else
  {
    CFile file;
    XFILE::auto_buffer buf;
    if (file.LoadFile("special://temp/" +
      URIUtils::GetFileName(((CFileOperationJob*)job)->GetItems()[0]->GetPath()), buf) > 0)
    {
      std::string str(buf.get(), buf.length());
      m_item->SetProperty("Addon.Changelog", str);
      pDlgInfo->SetText(str);
    }
  }
  CGUIMessage msg(GUI_MSG_NOTIFY_ALL, WINDOW_DIALOG_TEXT_VIEWER, 0, GUI_MSG_UPDATE);
  g_windowManager.SendThreadMessage(msg);
}
Пример #4
0
    void Dialog::textviewer(const String& heading, const String& text)
    {
      DelayedCallGuard dcguard(languageHook);
      const int window = WINDOW_DIALOG_TEXT_VIEWER;

      CGUIDialogTextViewer* pDialog = (CGUIDialogTextViewer*)g_windowManager.GetWindow(window);
      if (pDialog == NULL)
        throw WindowException("Error: Window is NULL, this is not possible :-)");
      if (!heading.empty())
        pDialog->SetHeading(heading);
      if (!text.empty())
        pDialog->SetText(text);
      pDialog->Open();
    }
Пример #5
0
void Interface_GUIDialogTextViewer::open(void* kodiBase, const char *heading, const char *text)
{
  CAddonDll* addon = static_cast<CAddonDll*>(kodiBase);
  if (!addon)
  {
    CLog::Log(LOGERROR, "Interface_GUIDialogTextViewer::%s - invalid data", __FUNCTION__);
    return;
  }

  CGUIDialogTextViewer* dialog = g_windowManager.GetWindow<CGUIDialogTextViewer>(WINDOW_DIALOG_TEXT_VIEWER);
  if (!heading || !text || !dialog)
  {
    CLog::Log(LOGERROR, "Interface_GUIDialogTextViewer::%s - invalid handler data (heading='%p', text='%p', dialog='%p') on addon '%s'", __FUNCTION__,
                            heading, text, dialog, addon->ID().c_str());
    return;
  }

  dialog->SetHeading(heading);
  dialog->SetText(text);
  dialog->Open();
}
Пример #6
0
bool CGUIDialogAudioDSPManager::OnContextButton(int itemNumber, CONTEXT_BUTTON button, int listType)
{
    CFileItemPtr pItem;
    int listSize = 0;
    if (listType == LIST_ACTIVE)
    {
        pItem = m_activeItems[m_iCurrentType]->Get(itemNumber);
        listSize = m_activeItems[m_iCurrentType]->Size();
    }
    else if (listType == LIST_AVAILABLE)
    {
        pItem = m_availableItems[m_iCurrentType]->Get(itemNumber);
        listSize = m_availableItems[m_iCurrentType]->Size();
    }

    /* Check file item is in list range and get his pointer */
    if (!pItem || itemNumber < 0 || itemNumber >= listSize)
    {
        return false;
    }

    if (button == CONTEXT_BUTTON_HELP)
    {
        /*!
        * Open audio dsp addon mode help text dialog
        */
        AE_DSP_ADDON addon;
        if (CServiceBroker::GetADSP().GetAudioDSPAddon((int)pItem->GetProperty("AddonId").asInteger(), addon))
        {
            CGUIDialogTextViewer* pDlgInfo = (CGUIDialogTextViewer*)g_windowManager.GetWindow(WINDOW_DIALOG_TEXT_VIEWER);
            pDlgInfo->SetHeading(g_localizeStrings.Get(15062) + " - " + pItem->GetProperty("Name").asString());
            pDlgInfo->SetText(g_localizeStrings.GetAddonString(addon->ID(), (uint32_t)pItem->GetProperty("Help").asInteger()));
            pDlgInfo->Open();
        }
    }
    else if (button == CONTEXT_BUTTON_ACTIVATE)
    {
        /*!
        * Deactivate selected processing mode
        */
        if (pItem->GetProperty("ActiveMode").asBoolean())
        {
            // remove mode from active mode list and add it to available mode list
            CFileItemPtr newItem(dynamic_cast<CFileItem*>(pItem->Clone()));
            newItem->SetProperty("ActiveMode", false);
            newItem->SetProperty("Changed", true);
            m_activeItems[m_iCurrentType]->Remove(itemNumber);
            m_availableItems[m_iCurrentType]->Add(newItem);
        }
        else
        {
            /*!
            * Activate selected processing mode
            */
            if ((m_iCurrentType == AE_DSP_MODE_TYPE_INPUT_RESAMPLE || m_iCurrentType == AE_DSP_MODE_TYPE_OUTPUT_RESAMPLE) && m_activeItems[m_iCurrentType]->Size() > 0)
            {   // if there is already an active resampler, now we remove it
                CFileItemPtr activeResampler = m_activeItems[m_iCurrentType]->Get(0);
                if (activeResampler)
                {
                    CFileItemPtr newItem(dynamic_cast<CFileItem*>(activeResampler->Clone()));
                    newItem->SetProperty("ActiveMode", false);
                    newItem->SetProperty("Changed", true);

                    m_availableItems[m_iCurrentType]->Add(newItem);
                    // clear active list, because only one active resampling mode is supported by ActiveAEDSP
                    m_activeItems[m_iCurrentType]->Clear();
                }
            }

            // remove mode from available mode list and add it to active mode list
            CFileItemPtr newItem(dynamic_cast<CFileItem*>(pItem->Clone()));

            newItem->SetProperty("Number", (int)m_activeItems[m_iCurrentType]->Size() +1);
            newItem->SetProperty("Changed", true);
            newItem->SetProperty("ActiveMode", true);

            m_availableItems[m_iCurrentType]->Remove(itemNumber);
            m_activeItems[m_iCurrentType]->Add(newItem);
        }

        m_bContainsChanges = true;
        if (m_bContinousSaving)
        {
            SaveList();
        }

        // reorder available mode list, so that the mode order is always consistent
        m_availableItems[m_iCurrentType]->ClearSortState();
        m_availableItems[m_iCurrentType]->Sort(SortByLabel, SortOrderAscending);

        // update active and available mode list
        Renumber();
        m_availableViewControl.SetItems(*m_availableItems[m_iCurrentType]);
        m_activeViewControl.SetItems(*m_activeItems[m_iCurrentType]);
    }
    else if (button == CONTEXT_BUTTON_MOVE)
    {
        m_bMovingMode = true;
        pItem->Select(true);

        CGUIListContainer *modeList = dynamic_cast<CGUIListContainer*>(GetControl(CONTROL_LIST_MODE_SELECTION));
        CGUIButtonControl *applyButton = dynamic_cast<CGUIButtonControl*>(GetControl(CONTROL_BUTTON_APPLY_CHANGES));
        CGUIButtonControl *clearActiveModesButton = dynamic_cast<CGUIButtonControl*>(GetControl(CONTROL_BUTTON_CLEAR_ACTIVE_MODES));
        if (!modeList || !applyButton || !clearActiveModesButton)
        {
            helper_LogError(__FUNCTION__);
            return false;
        }

        // if we are in MovingMode all buttons and mode selection list will be disabled!
        modeList->SetEnabled(false);
        clearActiveModesButton->SetEnabled(false);
        if (!m_bContinousSaving)
        {
            applyButton->SetEnabled(false);
        }
    }
    else if (button == CONTEXT_BUTTON_SETTINGS)
    {
        int hookId = (int)pItem->GetProperty("SettingsDialog").asInteger();
        if (hookId > 0)
        {
            AE_DSP_ADDON addon;
            if (CServiceBroker::GetADSP().GetAudioDSPAddon((int)pItem->GetProperty("AddonId").asInteger(), addon))
            {
                AE_DSP_MENUHOOK       hook;
                AE_DSP_MENUHOOK_DATA  hookData;

                hook.category           = AE_DSP_MENUHOOK_ALL;
                hook.iHookId            = hookId;
                hook.iRelevantModeId    = (unsigned int)pItem->GetProperty("AddonModeNumber").asInteger();
                hookData.category       = AE_DSP_MENUHOOK_ALL;
                hookData.data.iStreamId = -1;

                /*!
                 * @note the addon dialog becomes always opened on the back of Kodi ones for this reason a
                 * "<animation effect="fade" start="100" end="0" time="400" condition="Window.IsVisible(Addon)">Conditional</animation>"
                 * on skin is needed to hide dialog.
                 */
                addon->CallMenuHook(hook, hookData);
            }
        }
        else
        {
            CGUIDialogOK::ShowAndGetInput(19033, 0, 15040, 0);
        }
    }

    return true;
}
Пример #7
0
bool CGUIWindowSettingsCategory::OnAction(const CAction &action)
{
  switch (action.GetID())
  {
    case ACTION_SETTINGS_RESET:
    {
      if (CGUIDialogYesNo::ShowAndGetInput(10041, 0, 10042, 0))
      {
        for(vector<BaseSettingControlPtr>::iterator it = m_settingControls.begin(); it != m_settingControls.end(); it++)
        {
          CSetting *setting = (*it)->GetSetting();
          if (setting != NULL)
            setting->Reset();
        }
      }
      return true;
    }

    case ACTION_SETTINGS_LEVEL_CHANGE:
    {
      CViewStateSettings::Get().CycleSettingLevel();
      CSettings::Get().Save();

      // try to keep the current position
      std::string oldCategory;
      if (m_iCategory >= 0 && m_iCategory < (int)m_categories.size())
        oldCategory = m_categories[m_iCategory]->GetId();

      SET_CONTROL_LABEL(CONTRL_BTN_LEVELS, 10036 + (int)CViewStateSettings::Get().GetSettingLevel());
      // only re-create the categories, the settings will be created later
      SetupControls(false);

      m_iCategory = 0;
      // try to find the category that was previously selected
      if (!oldCategory.empty())
      {
        for (int i = 0; i < (int)m_categories.size(); i++)
        {
          if (m_categories[i]->GetId() == oldCategory)
          {
            m_iCategory = i;
            break;
          }
        }
      }

      CreateSettings();
      return true;
    }

    case ACTION_SHOW_INFO:
    {
      int label = -1;
      int help = -1;
      int focusedControl = GetFocusedControlID();
      // check if we are focusing a category
      if (focusedControl >= CONTROL_START_BUTTONS && focusedControl < (int)(CONTROL_START_BUTTONS + m_categories.size()))
      {
        CSettingCategory *category = m_categories[focusedControl - CONTROL_START_BUTTONS];
        label = category->GetLabel();
        help = category->GetHelp();
      }
      else if (focusedControl >= CONTROL_START_CONTROL && focusedControl < (int)(CONTROL_START_CONTROL + m_settingControls.size()))
      {
        CSetting *setting = GetSettingControl(focusedControl)->GetSetting();
        if (setting != NULL)
        {
          label = setting->GetLabel();
          help = setting->GetHelp();
        }
      }
      else
        break;

      if (help >= 0)
      {
        CGUIDialogTextViewer *dialog = (CGUIDialogTextViewer*)g_windowManager.GetWindow(WINDOW_DIALOG_TEXT_VIEWER);
        if (dialog != NULL)
        {
          if (label < 0)
            label = 10043; // "Help"
          dialog->SetHeading(g_localizeStrings.Get(label));
          dialog->SetText(g_localizeStrings.Get(help));
          dialog->DoModal();
        }
      }
      else
        CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(10043), g_localizeStrings.Get(10044), 2000U);
      return true;
    }

    default:
      break;
  }

  return CGUIWindow::OnAction(action);
}