Go to the documentation of this file.
29 #include <QCoreApplication>
30 #include <QStringList>
44 #define LOC QString("MythControls: ")
45 #define LOC_ERR QString("MythControls, Error: ")
84 LOG(VB_GENERAL, LOG_ERR,
"Theme is missing critical theme elements.");
103 (
GetChild(QString(
"action_%1").arg(i)));
107 LOG(VB_GENERAL, LOG_ERR,
LOC +
108 QString(
"Unable to load action button action_%1").arg(i));
171 QString label = tr(
"Modify Action");
196 QString label = tr(
"Change View");
217 QString label = tr(
"Options");
240 QString label = tr(
"Save changes?");
247 if (confirmPopup->Create())
250 confirmPopup->SetReturnEvent(
this,
"exit");
288 for (
const auto &
content : qAsConst(contents))
291 item->setDrawArrow(arrows);
306 QString rtstr = item->
GetText();
344 for (
int i = 0; (i < keys.count()) &&
368 int loc = desc.indexOf(
" => ");
373 return desc.left(loc);
375 return desc.mid(loc + 4);
409 int loc = desc.indexOf(
" => ");
414 return desc.left(loc);
416 QString rv = desc.mid(loc+4);
433 if (uitype == button)
453 return currentButton->
GetText();
466 if (b < (
uint)keys.count())
475 desc = currentButton->
GetText();
477 int loc = desc.indexOf(
" => ");
483 return desc.left(loc);
485 return desc.mid(loc + 4);
527 if (context.isEmpty() || key.isEmpty() ||
action.isEmpty())
529 LOG(VB_GENERAL, LOG_ERR,
530 "Unable to delete binding, missing information");
540 QString label = tr(
"This action is mandatory and needs at least one key "
541 "bound to it. Instead, try rebinding with another key.");
548 if (confirmPopup->Create())
550 confirmPopup->SetReturnEvent(
this,
"mandatorydelete");
573 label = tr(
"This key binding conflicts with %1 in the %2 context. "
574 "Unable to bind key.")
579 label = tr(
"This key binding conflicts with %1 in the %2 context. "
580 "Do you want to bind it anyway?")
591 confirmPopup->SetData(QVariant::fromValue(key));
592 confirmPopup->SetReturnEvent(
this,
"conflict");
595 if (confirmPopup->Create())
609 if (keyGrabPopup->Create())
610 popupStack->
AddScreen(keyGrabPopup,
false);
614 Qt::QueuedConnection);
634 ((binding_index < keys.size()) && (keys[binding_index] == key)))
652 if (binding_index < keys.count())
655 keys[binding_index]);
676 QString resultid = dce->GetId();
677 int buttonnum = dce->GetResult();
679 if (resultid ==
"action")
683 else if (buttonnum == 1)
686 else if (resultid ==
"option")
690 else if (buttonnum == 1)
692 else if (buttonnum == 2)
695 else if (resultid ==
"exit")
704 else if (resultid ==
"view")
706 QStringList contents;
708 QString rightcaption;
712 leftcaption = tr(
"Contexts");
713 rightcaption = tr(
"Actions");
717 else if (buttonnum == 1)
719 leftcaption = tr(
"Contexts");
720 rightcaption = tr(
"Keys");
724 else if (buttonnum == 2)
726 leftcaption = tr(
"Keys");
727 rightcaption = tr(
"Contexts");
744 else if (resultid ==
"conflict")
748 QString key = dce->GetData().toString();
QStringList GetKeys(void) const
Returns a list of all keys bound to an action.
void SetReturnEvent(QObject *retobject, const QString &resultid)
virtual bool NextPrevWidgetFocus(bool up_or_down)
QHash< QString, QStringList > m_contexts
actions for a given context
void Reset(void) override
Reset the widget to it's original state, should not reset changes made by the theme.
static void error(const char *str,...)
QList< MythUIButton * > m_actionButtons
MythUIType * GetChild(const QString &name) const
Get a named child of this UIType.
void JumpTo(const QString &Destination, bool Pop=true)
void DeleteKey(void)
Delete the currently active key to action mapping.
void ChangeView(void)
Change the view.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
QStringList GetActions(const QString &context) const
Get a list of the actions in a context.
static void SetListContents(MythUIButtonList *uilist, const QStringList &contents, bool arrows=false)
Set the contents of a list.
QString GetCurrentContext(void)
Get the currently selected context string.
void ResolveConflict(ActionID *conflict, int error_level, const QString &key)
Resolve a potential conflict.
MythUIType * GetFocusWidget(void) const
void ChangeButtonFocus(int direction)
Change button focus in a particular direction.
QString GetAction(void) const
Returns the action name.
Encapsulates information about the current keybindings.
QString GetCurrentKey(void)
Get the currently selected key string.
void ReplaceActionKey(const QString &context_name, const QString &action_name, const QString &newkey, const QString &oldkey)
Replace a key in an action.
MythDialogBox * m_menuPopup
static const unsigned int kMaximumNumberOfBindings
The maximum number of keys that can be bound to an action.
void RefreshKeyInformation(void)
Updates the list of keys that are shown and the description of the action.
bool SetFocusWidget(MythUIType *widget=nullptr)
void AddButton(const QString &title)
Basic menu dialog, message and a list of options.
void LeftPressed(MythUIButtonListItem *item)
Slot handling a button being pressed in the left list.
bool Create(void) override
Main header for mythcontrols.
KeyBindings::Filter m_filters
void BuildFocusList(void)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
QStringList GetKeyContexts(const QString &key) const
Get the context names in which a key is bound.
MythUIText * m_leftDescription
MythUIText * m_description
The base class on which all widgets and screens are based.
void AddKeyToAction(const QString &key, bool ignoreconflict)
Add a key to the currently selected action.
static const QString kJumpContext
The statically assigned context for jump point actions.
uint GetCurrentButton(void)
Returns the focused button, or Action::kMaximumNumberOfBindings if no buttons are focued.
All purpose text widget, displays a text string.
bool RemoveActionKey(const QString &context_name, const QString &action_name, const QString &key)
Unbind a key from an action.
QString GetCurrentAction(void)
Get the currently selected action string.
Dialog asking for user confirmation. Ok and optional Cancel button.
void RightSelected(MythUIButtonListItem *item)
Refreshes key information when an item in the right list is selected.
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
QStringList GetActionKeys(const QString &context_name, const QString &action_name) const
Get an action's keys.
QStringList m_sortedContexts
sorted list of contexts
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
virtual void SetText(const QString &text)
void RightPressed(MythUIButtonListItem *item)
Slot handling a button being pressed in the left list.
static const QString kGlobalContext
The name of global actions.
MythMainWindow * GetMythMainWindow(void)
QStringList GetContexts(void) const
Returns a list of the context names.
QStringList GetContextKeys(const QString &context) const
Get the keys within a context.
bool Create(void) override
Loads UI elements from theme.
MythScreenStack * GetStack(const QString &Stackname)
A class that uniquely identifies an action.
QString GetHostName(void)
QString GetActionDescription(const QString &context_name, const QString &action_name) const
Get an action's description.
void UpdateRightList(void)
Update the right list.
bool AddActionKey(const QString &context_name, const QString &action_name, const QString &key)
Add a key to an action.
void customEvent(QEvent *event) override
MythUIButtonList * m_rightList
void ShowMenu(void) override
void LeftSelected(MythUIButtonListItem *item)
Refreshes the right list when an item in the left list is selected.
void LoadData(const QString &hostname)
Load the settings for a particular host.
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
ActionID * GetConflict(const QString &context_name, const QString &key, int &level) const
Determine if adding a key would cause a conflict.
MythUIButtonList * m_leftList
void ActionButtonPressed()
Slot handling a button being pressed in the left list.
bool HasChanges(void) const
MythUIText * m_rightDescription
QString GetContext(void) const
Returns the context name.
void Close(void) override