Go to the documentation of this file.
26 template <
typename T,
typename Inst,
typename FuncType>
49 m_fa.extension = new_extension;
53 m_fa(std::move(fa)) {}
55 unsigned int GetIDx(
void)
const {
return m_fa.id; }
57 QString
GetCommand(
void)
const {
return m_fa.playcommand; }
95 std::mem_fn(&FileAssociationWrap::SetChanged));
101 std::mem_fn(&FileAssociationWrap::SetChanged));
107 std::mem_fn(&FileAssociationWrap::SetChanged));
123 o->blockSignals(
true);
124 m_objects.push_back(o);
129 for (
auto & obj : m_objects)
130 obj->blockSignals(
false);
147 m_uid(uid), m_fileAssoc(assoc) {}
186 fa.second->CommitChanges();
189 bool AddExtension(
const QString& newExtension, UIDToFAPair::UID_type &new_id)
191 if (!newExtension.isEmpty())
195 new FileAssociationWrap(newExtension)));
207 p->second->MarkForDeletion();
221 auto deleted = std::remove_if(ret.begin(),
224 if (deleted != ret.end())
225 ret.erase(deleted, ret.end());
227 std::sort(ret.begin(), ret.end());
237 auto key = item->
GetData().value<UIDToFAPair>();
240 return key.m_fileAssoc;
258 using FA_collection = std::map<UIDToFAPair::UID_type, FileAssociationWrap *>;
264 const FileAssocDialogPrivate::FA_collection::value_type from)
266 return {from.first, from.second};
270 template <FileAssociationWrap::FA_State against>
275 return item.m_fileAssoc && item.m_fileAssoc->GetState() == against;
281 using tmp_fa_list = std::vector<UIDToFAPair>;
286 tmp_fa.reserve(fa_list.size());
288 auto newpair = [
this](
const auto & fa)
289 {
return UIDToFAPair(++
m_nextFAID,
new FileAssociationWrap(fa)); };
290 std::transform(fa_list.cbegin(), fa_list.cend(), std::back_inserter(tmp_fa), newpair);
292 std::shuffle(tmp_fa.begin(), tmp_fa.end(),
293 std::mt19937(std::random_device()()));
295 for (
const auto& fa : tmp_fa)
303 LOG(VB_GENERAL, LOG_ERR,
304 QString(
"%1: Couldn't get any filetypes from your database.")
318 const QString &lname) :
346 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'file_associations'");
363 "to modify or delete its settings."));
365 "of file. To use MythTV's Internal player, "
366 "use \"Internal\" as the player. For all other "
367 "players, you can use %s to substitute the filename."));
369 "to be ignored in scans of your library."));
371 "settings to override this one."));
420 auto key = item->
GetData().value<UIDToFAPair>();
432 QString message = tr(
"Enter the new extension:");
436 if (newextdialog->Create())
445 UIDToFAPair::UID_type new_sel = 0;
455 BlockSignalsGuard bsg;
464 if (tmp_list.empty())
474 UIDToFAPair::UID_type selected_id = 0;
478 auto key = current_item->
GetData().value<UIDToFAPair>();
481 selected_id = key.m_uid;
485 if (useSelectionOverride)
492 for (
auto & fad : tmp_list)
499 fad.m_fileAssoc->GetExtension(),
500 QVariant::fromValue(fad));
501 if (selected_id && fad.m_uid == selected_id)
509 auto key = current_item->
GetData().value<UIDToFAPair>();
void OnFASelected(MythUIButtonListItem *item)
bool DeleteExtension(UIDToFAPair::UID_type uid)
void UpdateScreen(bool useSelectionOverride=false)
MythUICheckBox * m_ignoreCheck
UIDToFAPair::UID_type GetSelectionOverride() const
FileAssociationWrap(const QString &new_extension)
bool AddExtension(const QString &newExtension, UIDToFAPair::UID_type &new_id)
bool GetBooleanCheckState(void) const
std::vector< UIDToFAPair > UIReadyList_type
bool remove(unsigned int id)
QString GetCommand(void) const
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
const association_list & getList() const
Screen in which all other widgets are contained and rendered.
bool GetIgnore(void) const
QString GetText(void) const
UIReadyList_type GetUIReadyList()
FileAssociationWrap(FileAssociations::file_association fa)
void SetSelectionOverride(UIDToFAPair::UID_type new_sel)
void OnNewExtensionComplete(const QString &newExtension)
UIDToFAPair operator()(const FileAssocDialogPrivate::FA_collection::value_type from)
bool GetDefault(void) const
FileAssociationWrap * m_fileAssoc
~FileAssocDialog() override
void SetText(const QString &text, bool moveCursor=true)
MythUICheckBox * m_defaultCheck
MythUIButton * m_newButton
UIDToFAPair::UID_type m_selectionOverride
FA_State GetState() const
void SetIgnore(bool yes_or_no)
Q_DECLARE_METATYPE(std::chrono::seconds)
void OnUseDefaltChanged()
class FileAssocDialogPrivate * m_private
void SaveFileAssociations()
std::vector< file_association > association_list
std::vector< QObject * > list_type
void SetHelpText(const QString &text)
void BuildFocusList(void)
unsigned int GetIDx(void) const
bool operator()(const UIDToFAPair item)
FileAssociations::file_association m_fa
~FileAssocDialogPrivate()
FileAssocDialog(MythScreenStack *screenParent, const QString &lname)
void SetDefault(bool yes_or_no)
void assign_if_changed_notify(T &oldVal, const T &newVal, Inst *inst, FuncType func)
MythUITextEdit * m_commandEdit
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
std::map< UIDToFAPair::UID_type, FileAssociationWrap * > FA_collection
static FileAssociations & getFileAssociation()
void SetCheckState(MythUIStateType::StateType state)
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
MythUIButton * m_deleteButton
void OnPlayerCommandChanged()
void SetCommand(const QString &new_command)
virtual void SetVisible(bool visible)
MythMainWindow * GetMythMainWindow(void)
FA_collection m_fileAssociations
MythScreenStack * GetStack(const QString &Stackname)
MythUIButton * m_doneButton
MythUIButtonList * m_extensionList
UIDToFAPair(UID_type uid, FileAssociationWrap *assoc)
Dialog prompting the user to enter a text string.
QString GetExtension(void) const
UIDToFAPair::UID_type m_nextFAID
void LoadFileAssociations()
bool operator<(const UIDToFAPair lhs, const UIDToFAPair rhs)
static FileAssociationWrap * GetCurrentFA(MythUIButtonList *buttonList)
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
void OnNewExtensionPressed() const