29#include <QCoreApplication>
45#define LOC QString("MythControls: ")
46#define LOC_ERR QString("MythControls, Error: ")
85 LOG(VB_GENERAL, LOG_ERR,
"Theme is missing critical theme elements.");
104 (
GetChild(QString(
"action_%1").arg(i)));
108 LOG(VB_GENERAL, LOG_ERR,
LOC +
109 QString(
"Unable to load action button action_%1").arg(i));
170 QString label = tr(
"Modify Action");
197 QString label = tr(
"Change View");
218 QString label = tr(
"Options");
241 QString label = tr(
"Save changes?");
248 if (confirmPopup->Create())
251 confirmPopup->SetReturnEvent(
this,
"exit");
291 for (
const auto &
content : std::as_const(contents))
294 item->setDrawArrow(arrows);
309 QString rtstr = item->
GetText();
347 for (
int i = 0; (i < keys.count()) &&
371 int loc = desc.indexOf(
" => ");
376 return desc.left(loc);
378 return desc.mid(loc + 4);
412 int loc = desc.indexOf(
" => ");
417 return desc.left(loc);
419 QString rv = desc.mid(loc+4);
436 if (uitype == button)
456 if (currentButton !=
nullptr)
457 return currentButton->
GetText();
470 if (b < (
uint)keys.count())
479 desc = currentButton->
GetText();
481 int loc = desc.indexOf(
" => ");
487 return desc.left(loc);
489 return desc.mid(loc + 4);
531 if (context.isEmpty() || key.isEmpty() ||
action.isEmpty())
533 LOG(VB_GENERAL, LOG_ERR,
534 "Unable to delete binding, missing information");
544 QString label = tr(
"This action is mandatory and needs at least one key "
545 "bound to it. Instead, try rebinding with another key.");
552 if (confirmPopup->Create())
554 confirmPopup->SetReturnEvent(
this,
"mandatorydelete");
579 label = tr(
"This key binding conflicts with %1 in the %2 context. "
580 "Unable to bind key.")
585 label = tr(
"This key binding conflicts with %1 in the %2 context. "
586 "Do you want to bind it anyway?")
597 confirmPopup->SetData(QVariant::fromValue(key));
598 confirmPopup->SetReturnEvent(
this,
"conflict");
601 if (confirmPopup->Create())
615 if (keyGrabPopup->Create())
616 popupStack->
AddScreen(keyGrabPopup,
false);
620 Qt::QueuedConnection);
640 ((binding_index < keys.size()) && (keys[binding_index] == key)))
658 if (binding_index < keys.count())
661 keys[binding_index]);
682 QString resultid = dce->GetId();
683 int buttonnum = dce->GetResult();
685 if (resultid ==
"action")
689 else if (buttonnum == 1)
692 else if (resultid ==
"option")
696 else if (buttonnum == 1)
698 else if (buttonnum == 2)
701 else if (resultid ==
"exit")
710 else if (resultid ==
"view")
712 QStringList contents;
714 QString rightcaption;
718 leftcaption = tr(
"Contexts");
719 rightcaption = tr(
"Actions");
723 else if (buttonnum == 1)
725 leftcaption = tr(
"Contexts");
726 rightcaption = tr(
"Keys");
730 else if (buttonnum == 2)
732 leftcaption = tr(
"Keys");
733 rightcaption = tr(
"Contexts");
752 else if (resultid ==
"conflict")
756 QString key = dce->GetData().toString();
A class that uniquely identifies an action.
QString GetAction(void) const
Returns the action name.
QString GetContext(void) const
Returns the context name.
static const QString kJumpContext
The statically assigned context for jump point actions.
static const QString kGlobalContext
The name of global actions.
static const unsigned int kMaximumNumberOfBindings
The maximum number of keys that can be bound to an action.
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
static const Type kEventType
Encapsulates information about the current keybindings.
QStringList GetKeys(void) const
Returns a list of all keys bound to an action.
bool AddActionKey(const QString &context_name, const QString &action_name, const QString &key)
Add a key to an action.
QString GetActionDescription(const QString &context_name, const QString &action_name) const
Get an action's description.
bool HasChanges(void) const
QStringList GetActionKeys(const QString &context_name, const QString &action_name) const
Get an action's keys.
QStringList GetContexts(void) const
Returns a list of the context names.
QStringList GetKeyContexts(const QString &key) const
Get the context names in which a key is bound.
bool RemoveActionKey(const QString &context_name, const QString &action_name, const QString &key)
Unbind a key from an action.
QStringList GetActions(const QString &context) const
Get a list of the actions in a context.
QStringList GetContextKeys(const QString &context) const
Get the keys within a context.
ActionID * GetConflict(const QString &context_name, const QString &key, int &level) const
Determine if adding a key would cause a conflict.
void ReplaceActionKey(const QString &context_name, const QString &action_name, const QString &newkey, const QString &oldkey)
Replace a key in an action.
Dialog asking for user confirmation.
void DeleteKey(void)
Delete the currently active key to action mapping.
void ActionButtonPressed()
Slot handling a button being pressed in the left list.
MythUIButtonList * m_leftList
QList< MythUIButton * > m_actionButtons
KeyBindings::Filter m_filters
MythUIText * m_leftDescription
void UpdateRightList(void)
Update the right list.
QString GetCurrentAction(void)
Get the currently selected action string.
MythDialogBox * m_menuPopup
void ResolveConflict(ActionID *conflict, int error_level, const QString &key)
Resolve a potential conflict.
static void SetListContents(MythUIButtonList *uilist, const QStringList &contents, bool arrows=false)
Set the contents of a list.
MythUIButtonList * m_rightList
uint GetCurrentButton(void)
Returns the focused button, or Action::kMaximumNumberOfBindings if no buttons are focued.
void RefreshKeyInformation(void)
Updates the list of keys that are shown and the description of the action.
void LeftSelected(MythUIButtonListItem *item)
Refreshes the right list when an item in the left list is selected.
void customEvent(QEvent *event) override
QStringList m_sortedContexts
sorted list of contexts
void Close(void) override
void ChangeView(void)
Change the view.
bool Create(void) override
Loads UI elements from theme.
void RightPressed(MythUIButtonListItem *item)
Slot handling a button being pressed in the left list.
void AddKeyToAction(const QString &key, bool ignoreconflict)
Add a key to the currently selected action.
void RightSelected(MythUIButtonListItem *item)
Refreshes key information when an item in the right list is selected.
void ChangeButtonFocus(int direction)
Change button focus in a particular direction.
QHash< QString, QStringList > m_contexts
actions for a given context
MythUIText * m_rightDescription
QString GetCurrentKey(void)
Get the currently selected key string.
void LeftPressed(MythUIButtonListItem *item)
Slot handling a button being pressed in the left list.
QString GetCurrentContext(void)
Get the currently selected context string.
void ShowMenu(void) override
void LoadData(const QString &hostname)
Load the settings for a particular host.
MythUIText * m_description
QString GetHostName(void)
Basic menu dialog, message and a list of options.
void AddButton(const QString &title)
void SetReturnEvent(QObject *retobject, const QString &resultid)
bool Create(void) override
void JumpTo(const QString &Destination, bool Pop=true)
MythScreenStack * GetStack(const QString &Stackname)
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
virtual bool NextPrevWidgetFocus(bool up_or_down)
void BuildFocusList(void)
MythUIType * GetFocusWidget(void) const
bool SetFocusWidget(MythUIType *widget=nullptr)
All purpose text widget, displays a text string.
void Reset(void) override
Reset the widget to it's original state, should not reset changes made by the theme.
virtual void SetText(const QString &text)
The base class on which all widgets and screens are based.
MythUIType * GetChild(const QString &name) const
Get a named child of this UIType.
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
Main header for mythcontrols.
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
MythMainWindow * GetMythMainWindow(void)