Permalink
Browse files

Merge pull request #4739 from jmarshallnz/control_access_cleanup

Control access cleanup
  • Loading branch information...
2 parents cb7e13a + 5bf55b2 commit 47ccc2f0edf74cd732b49ff125242c404c54e805 @jmarshallnz jmarshallnz committed Jul 4, 2014
@@ -19,9 +19,6 @@
*/
#include "GUIDialogButtonMenu.h"
-#include "guilib/GUILabelControl.h"
-#include "guilib/GUIButtonControl.h"
-
#define CONTROL_BUTTON_LABEL 3100
@@ -48,17 +45,11 @@ bool CGUIDialogButtonMenu::OnMessage(CGUIMessage &message)
void CGUIDialogButtonMenu::FrameMove()
{
- // get the label control
- CGUILabelControl *pLabel = (CGUILabelControl *)GetControl(CONTROL_BUTTON_LABEL);
- if (pLabel)
+ // get the active control, and put it's label into the label control
+ const CGUIControl *pControl = GetFocusedControl();
+ if (pControl && (pControl->GetControlType() == CGUIControl::GUICONTROL_BUTTON || pControl->GetControlType() == CGUIControl::GUICONTROL_TOGGLEBUTTON))
{
- // get the active window, and put it's label into the label control
- const CGUIControl *pControl = GetFocusedControl();
- if (pControl && (pControl->GetControlType() == CGUIControl::GUICONTROL_BUTTON || pControl->GetControlType() == CGUIControl::GUICONTROL_TOGGLEBUTTON))
- {
- CGUIButtonControl *pButton = (CGUIButtonControl *)pControl;
- pLabel->SetLabel(pButton->GetLabel());
- }
+ SET_CONTROL_LABEL(CONTROL_BUTTON_LABEL, pControl->GetDescription());
}
CGUIDialog::FrameMove();
}
@@ -163,7 +163,6 @@ void CGUIDialogExtendedProgressBar::UpdateState(unsigned int currentTime)
if (fProgress > -1.0f)
{
SET_CONTROL_VISIBLE(CONTROL_PROGRESS);
- CGUIProgressControl* pProgressCtrl=(CGUIProgressControl*)GetControl(CONTROL_PROGRESS);
- if (pProgressCtrl) pProgressCtrl->SetPercentage(fProgress);
+ CONTROL_SELECT_ITEM(CONTROL_PROGRESS, (unsigned int)fProgress);
}
}
@@ -19,7 +19,6 @@
*/
#include "GUIDialogKaiToast.h"
-#include "guilib/GUIImage.h"
#include "guilib/GUIAudioManager.h"
#include "guilib/GUIWindowManager.h"
#include "threads/SingleLock.h"
@@ -72,9 +71,8 @@ bool CGUIDialogKaiToast::OnMessage(CGUIMessage& message)
void CGUIDialogKaiToast::OnWindowLoaded()
{
CGUIDialog::OnWindowLoaded();
- CGUIImage *image = (CGUIImage *)GetControl(POPUP_ICON);
- if (image)
- m_defaultIcon = image->GetFileName();
+ CGUIMessage msg(GUI_MSG_GET_FILENAME, GetID(), POPUP_ICON);
+ m_defaultIcon = msg.GetLabel();
}
void CGUIDialogKaiToast::QueueNotification(eMessageType eType, const CStdString& aCaption, const CStdString& aDescription, unsigned int displayTime /*= TOAST_DISPLAY_TIME*/, bool withSound /*= true*/, unsigned int messageTime /*= TOAST_MESSAGE_TIME*/)
@@ -131,31 +129,29 @@ bool CGUIDialogKaiToast::DoWork()
SET_CONTROL_LABEL(POPUP_NOTIFICATION_BUTTON, toast.description);
- CGUIImage *image = (CGUIImage *)GetControl(POPUP_ICON);
- if (image)
+ // set the appropriate icon
{
- CStdString strTypeImage = toast.imagefile;
+ std::string strTypeImage = toast.imagefile;
if (strTypeImage.empty())
{
- CGUIImage *typeImage = NULL;
+ int imageControl = POPUP_ICON;
if (toast.eType == Info)
- typeImage = (CGUIImage *)GetControl(POPUP_ICON_INFO);
+ imageControl = POPUP_ICON_INFO;
else if (toast.eType == Warning)
- typeImage = (CGUIImage *)GetControl(POPUP_ICON_WARNING);
+ imageControl = POPUP_ICON_WARNING;
else if (toast.eType == Error)
- typeImage = (CGUIImage *)GetControl(POPUP_ICON_ERROR);
- else
- typeImage = image;
+ imageControl = POPUP_ICON_ERROR;
- if (typeImage)
- strTypeImage = typeImage->GetFileName();
+ CGUIMessage msg(GUI_MSG_GET_FILENAME, GetID(), imageControl);
+ if (OnMessage(msg))
+ strTypeImage = msg.GetLabel();
else
strTypeImage = m_defaultIcon;
}
- image->SetFileName(strTypeImage);
+ SET_CONTROL_FILENAME(POPUP_ICON, strTypeImage);
}
// Play the window specific init sound for each notification queued
@@ -19,7 +19,6 @@
*/
#include "GUIDialogSeekBar.h"
-#include "guilib/GUISliderControl.h"
#include "Application.h"
#include "GUIInfoManager.h"
#include "utils/TimeUtils.h"
@@ -71,23 +70,13 @@ void CGUIDialogSeekBar::FrameMove()
// update controls
if (!g_application.GetSeekHandler()->InProgress() && !g_infoManager.m_performingSeek)
{ // position the bar at our current time
- CGUISliderControl *pSlider = (CGUISliderControl*)GetControl(POPUP_SEEK_SLIDER);
- if (pSlider && g_infoManager.GetTotalPlayTime())
- pSlider->SetPercentage((float)g_infoManager.GetPlayTime()/g_infoManager.GetTotalPlayTime() * 0.1f);
-
- CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), POPUP_SEEK_LABEL);
- msg.SetLabel(g_infoManager.GetCurrentPlayTime());
- OnMessage(msg);
+ CONTROL_SELECT_ITEM(POPUP_SEEK_LABEL, (unsigned int)(g_infoManager.GetPlayTime()/g_infoManager.GetTotalPlayTime() * 0.1f));
+ SET_CONTROL_LABEL(POPUP_SEEK_LABEL, g_infoManager.GetCurrentPlayTime());
}
else
{
- CGUISliderControl *pSlider = (CGUISliderControl*)GetControl(POPUP_SEEK_SLIDER);
- if (pSlider)
- pSlider->SetPercentage(g_application.GetSeekHandler()->GetPercent());
-
- CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), POPUP_SEEK_LABEL);
- msg.SetLabel(g_infoManager.GetCurrentSeekTime());
- OnMessage(msg);
+ CONTROL_SELECT_ITEM(POPUP_SEEK_LABEL, (unsigned int)g_application.GetSeekHandler()->GetPercent());
+ SET_CONTROL_LABEL(POPUP_SEEK_LABEL, g_infoManager.GetCurrentSeekTime());
}
CGUIDialog::FrameMove();
@@ -315,39 +315,19 @@ void CGUIDialogSmartPlaylistEditor::UpdateButtons()
}
// sort out the order fields
- {
- CGUIMessage msg(GUI_MSG_LABEL_RESET, GetID(), CONTROL_ORDER_FIELD);
- OnMessage(msg);
- }
+ std::vector< std::pair<std::string, int> > labels;
vector<SortBy> orders = CSmartPlaylistRule::GetOrders(m_playlist.GetType());
for (unsigned int i = 0; i < orders.size(); i++)
- {
- CGUIMessage msg(GUI_MSG_LABEL_ADD, GetID(), CONTROL_ORDER_FIELD, orders[i]);
- msg.SetLabel(SortUtils::GetSortLabel(orders[i]));
- OnMessage(msg);
- }
- {
- CGUIMessage msg(GUI_MSG_ITEM_SELECT, GetID(), CONTROL_ORDER_FIELD, m_playlist.m_orderField);
- OnMessage(msg);
- }
+ labels.push_back(make_pair(g_localizeStrings.Get(SortUtils::GetSortLabel(orders[i])), orders[i]));
+ SET_CONTROL_LABELS(CONTROL_ORDER_FIELD, m_playlist.m_orderField, &labels);
// setup groups
- {
- CGUIMessage msg(GUI_MSG_LABEL_RESET, GetID(), CONTROL_GROUP_BY);
- OnMessage(msg);
- }
+ labels.clear();
vector<Field> groups = CSmartPlaylistRule::GetGroups(m_playlist.GetType());
Field currentGroup = CSmartPlaylistRule::TranslateGroup(m_playlist.GetGroup());
for (unsigned int i = 0; i < groups.size(); i++)
- {
- CGUIMessage msg(GUI_MSG_LABEL_ADD, GetID(), CONTROL_GROUP_BY, groups[i]);
- msg.SetLabel(CSmartPlaylistRule::GetLocalizedGroup(groups[i]));
- OnMessage(msg);
- }
- {
- CGUIMessage msg(GUI_MSG_ITEM_SELECT, GetID(), CONTROL_GROUP_BY, currentGroup);
- OnMessage(msg);
- }
+ labels.push_back(make_pair(CSmartPlaylistRule::GetLocalizedGroup(groups[i]), groups[i]));
+ SET_CONTROL_LABELS(CONTROL_GROUP_BY, currentGroup, &labels);
if (m_playlist.IsGroupMixed())
CONTROL_SELECT(CONTROL_GROUP_MIXED);
@@ -383,33 +363,21 @@ void CGUIDialogSmartPlaylistEditor::UpdateRuleControlButtons()
void CGUIDialogSmartPlaylistEditor::OnWindowLoaded()
{
CGUIDialog::OnWindowLoaded();
+
SendMessage(GUI_MSG_SET_TYPE, CONTROL_NAME, 0, 16012);
// setup the match spinner
- {
- CGUIMessage msg(GUI_MSG_LABEL_ADD, GetID(), CONTROL_MATCH, 0);
- msg.SetLabel(21425);
- OnMessage(msg);
- }
- {
- CGUIMessage msg(GUI_MSG_LABEL_ADD, GetID(), CONTROL_MATCH, 1);
- msg.SetLabel(21426);
- OnMessage(msg);
- }
- SendMessage(GUI_MSG_ITEM_SELECT, CONTROL_MATCH, m_playlist.m_ruleCombination.GetType() == CSmartPlaylistRuleCombination::CombinationAnd ? 0 : 1);
+ std::vector< std::pair<std::string, int> > labels;
+ labels.push_back(make_pair(g_localizeStrings.Get(21425), 0));
+ labels.push_back(make_pair(g_localizeStrings.Get(21426), 1));
+ SET_CONTROL_LABELS(CONTROL_MATCH, m_playlist.m_ruleCombination.GetType() == CSmartPlaylistRuleCombination::CombinationAnd ? 0 : 1, &labels);
+
// and now the limit spinner
- {
- CGUIMessage msg(GUI_MSG_LABEL_ADD, GetID(), CONTROL_LIMIT, 0);
- msg.SetLabel(21428);
- OnMessage(msg);
- }
+ labels.clear();
+ labels.push_back(make_pair(g_localizeStrings.Get(21428), 0));
const int limits[] = { 10, 25, 50, 100, 250, 500, 1000 };
for (unsigned int i = 0; i < sizeof(limits) / sizeof(int); i++)
- {
- CGUIMessage msg(GUI_MSG_LABEL_ADD, GetID(), CONTROL_LIMIT, limits[i]);
- CStdString label = StringUtils::Format(g_localizeStrings.Get(21436).c_str(), limits[i]);
- msg.SetLabel(label);
- OnMessage(msg);
- }
+ labels.push_back(make_pair(StringUtils::Format(g_localizeStrings.Get(21436).c_str(), limits[i]), limits[i]));
+ SET_CONTROL_LABELS(CONTROL_LIMIT, 0, &labels);
}
void CGUIDialogSmartPlaylistEditor::OnInitWindow()
@@ -445,12 +413,9 @@ void CGUIDialogSmartPlaylistEditor::OnInitWindow()
allowedTypes.push_back(TYPE_MIXED);
}
// add to the spinner
+ std::vector< std::pair<std::string, int> > labels;
for (unsigned int i = 0; i < allowedTypes.size(); i++)
- {
- CGUIMessage msg(GUI_MSG_LABEL_ADD, GetID(), CONTROL_TYPE, allowedTypes[i]);
- msg.SetLabel(GetLocalizedType(allowedTypes[i]));
- OnMessage(msg);
- }
+ labels.push_back(make_pair(GetLocalizedType(allowedTypes[i]), allowedTypes[i]));
// check our playlist type is allowed
PLAYLIST_TYPE type = ConvertType(m_playlist.GetType());
bool allowed = false;
@@ -460,7 +425,7 @@ void CGUIDialogSmartPlaylistEditor::OnInitWindow()
if (!allowed && allowedTypes.size())
type = allowedTypes[0];
- SendMessage(GUI_MSG_ITEM_SELECT, CONTROL_TYPE, type);
+ SET_CONTROL_LABELS(CONTROL_TYPE, type, &labels);
m_playlist.SetType(ConvertType(type));
UpdateButtons();
@@ -484,13 +449,13 @@ CGUIDialogSmartPlaylistEditor::PLAYLIST_TYPE CGUIDialogSmartPlaylistEditor::Conv
return TYPE_SONGS;
}
-int CGUIDialogSmartPlaylistEditor::GetLocalizedType(PLAYLIST_TYPE type)
+std::string CGUIDialogSmartPlaylistEditor::GetLocalizedType(PLAYLIST_TYPE type)
{
for (unsigned int i = 0; i < NUM_TYPES; i++)
if (types[i].type == type)
- return types[i].localizedString;
+ return g_localizeStrings.Get(types[i].localizedString);
assert(false);
- return 0;
+ return "";
}
CStdString CGUIDialogSmartPlaylistEditor::ConvertType(PLAYLIST_TYPE type)
@@ -61,7 +61,7 @@ class CGUIDialogSmartPlaylistEditor :
void HighlightItem(int item);
PLAYLIST_TYPE ConvertType(const CStdString &type);
CStdString ConvertType(PLAYLIST_TYPE type);
- int GetLocalizedType(PLAYLIST_TYPE type);
+ std::string GetLocalizedType(PLAYLIST_TYPE type);
CSmartPlaylist m_playlist;
Oops, something went wrong.

0 comments on commit 47ccc2f

Please sign in to comment.