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));
169 QString label = tr(
"Modify Action");
194 QString label = tr(
"Change View");
215 QString label = tr(
"Options");
238 QString label = tr(
"Save changes?");
245 if (confirmPopup->Create())
248 confirmPopup->SetReturnEvent(
this,
"exit");
286 for (
const auto &
content : qAsConst(contents))
289 item->setDrawArrow(arrows);
304 QString rtstr = item->
GetText();
342 for (
int i = 0; (i < keys.count()) &&
366 int loc = desc.indexOf(
" => ");
371 return desc.left(loc);
373 return desc.mid(loc + 4);
407 int loc = desc.indexOf(
" => ");
412 return desc.left(loc);
414 QString rv = desc.mid(loc+4);
431 if (uitype == button)
451 return currentButton->
GetText();
464 if (b < (
uint)keys.count())
473 desc = currentButton->
GetText();
475 int loc = desc.indexOf(
" => ");
481 return desc.left(loc);
483 return desc.mid(loc + 4);
525 if (context.isEmpty() || key.isEmpty() ||
action.isEmpty())
527 LOG(VB_GENERAL, LOG_ERR,
528 "Unable to delete binding, missing information");
538 QString label = tr(
"This action is mandatory and needs at least one key "
539 "bound to it. Instead, try rebinding with another key.");
546 if (confirmPopup->Create())
548 confirmPopup->SetReturnEvent(
this,
"mandatorydelete");
571 label = tr(
"This key binding conflicts with %1 in the %2 context. "
572 "Unable to bind key.")
577 label = tr(
"This key binding conflicts with %1 in the %2 context. "
578 "Do you want to bind it anyway?")
589 confirmPopup->SetData(QVariant::fromValue(key));
590 confirmPopup->SetReturnEvent(
this,
"conflict");
593 if (confirmPopup->Create())
607 if (keyGrabPopup->Create())
608 popupStack->
AddScreen(keyGrabPopup,
false);
612 Qt::QueuedConnection);
632 ((binding_index < keys.size()) && (keys[binding_index] == key)))
650 if (binding_index < keys.count())
653 keys[binding_index]);
674 QString resultid = dce->GetId();
675 int buttonnum = dce->GetResult();
677 if (resultid ==
"action")
681 else if (buttonnum == 1)
684 else if (resultid ==
"option")
688 else if (buttonnum == 1)
690 else if (buttonnum == 2)
693 else if (resultid ==
"exit")
702 else if (resultid ==
"view")
704 QStringList contents;
706 QString rightcaption;
710 leftcaption = tr(
"Contexts");
711 rightcaption = tr(
"Actions");
715 else if (buttonnum == 1)
717 leftcaption = tr(
"Contexts");
718 rightcaption = tr(
"Keys");
722 else if (buttonnum == 2)
724 leftcaption = tr(
"Keys");
725 rightcaption = tr(
"Contexts");
742 else if (resultid ==
"conflict")
746 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.
static const Type kEventType
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