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");
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");
290 for (
const auto &
content : std::as_const(contents))
293 item->setDrawArrow(arrows);
308 QString rtstr = item->
GetText();
346 for (
int i = 0; (i < keys.count()) &&
370 int loc = desc.indexOf(
" => ");
375 return desc.left(loc);
377 return desc.mid(loc + 4);
411 int loc = desc.indexOf(
" => ");
416 return desc.left(loc);
418 QString rv = desc.mid(loc+4);
435 if (uitype == button)
455 if (currentButton !=
nullptr)
456 return currentButton->
GetText();
469 if (b < (
uint)keys.count())
478 desc = currentButton->
GetText();
480 int loc = desc.indexOf(
" => ");
486 return desc.left(loc);
488 return desc.mid(loc + 4);
530 if (context.isEmpty() || key.isEmpty() ||
action.isEmpty())
532 LOG(VB_GENERAL, LOG_ERR,
533 "Unable to delete binding, missing information");
543 QString label = tr(
"This action is mandatory and needs at least one key "
544 "bound to it. Instead, try rebinding with another key.");
551 if (confirmPopup->Create())
553 confirmPopup->SetReturnEvent(
this,
"mandatorydelete");
578 label = tr(
"This key binding conflicts with %1 in the %2 context. "
579 "Unable to bind key.")
584 label = tr(
"This key binding conflicts with %1 in the %2 context. "
585 "Do you want to bind it anyway?")
596 confirmPopup->SetData(QVariant::fromValue(key));
597 confirmPopup->SetReturnEvent(
this,
"conflict");
600 if (confirmPopup->Create())
614 if (keyGrabPopup->Create())
615 popupStack->
AddScreen(keyGrabPopup,
false);
619 Qt::QueuedConnection);
639 ((binding_index < keys.size()) && (keys[binding_index] == key)))
657 if (binding_index < keys.count())
660 keys[binding_index]);
681 QString resultid = dce->GetId();
682 int buttonnum = dce->GetResult();
684 if (resultid ==
"action")
688 else if (buttonnum == 1)
691 else if (resultid ==
"option")
695 else if (buttonnum == 1)
697 else if (buttonnum == 2)
700 else if (resultid ==
"exit")
709 else if (resultid ==
"view")
711 QStringList contents;
713 QString rightcaption;
717 leftcaption = tr(
"Contexts");
718 rightcaption = tr(
"Actions");
722 else if (buttonnum == 1)
724 leftcaption = tr(
"Contexts");
725 rightcaption = tr(
"Keys");
729 else if (buttonnum == 2)
731 leftcaption = tr(
"Keys");
732 rightcaption = tr(
"Contexts");
751 else if (resultid ==
"conflict")
755 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