Skip to content

Commit

Permalink
Fixes for MythUI settings
Browse files Browse the repository at this point in the history
- New Edit / Delete menu that supports all settings.
- Remove obsolete unused channelgroupsettings.cpp and channelgroupsettings.h
- Remove non-working unneeded Add / Delete from Recording Profile Groups.
- Remove now superfluous class VideoSourceDialog
- Fixed many MythUI Setup bugs.

Refs #13046
  • Loading branch information
bennettpeter committed May 26, 2017
1 parent 3af397f commit 420a1ea
Show file tree
Hide file tree
Showing 20 changed files with 276 additions and 646 deletions.
83 changes: 83 additions & 0 deletions mythtv/libs/libmyth/standardsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1005,10 +1005,15 @@ void StandardSettingDialog::Close(void)
MythScreenType::Close();
}

static QKeyEvent selectEvent
(QKeyEvent(QEvent::KeyPress,0,Qt::NoModifier,"SELECT"));
static QKeyEvent deleteEvent
(QKeyEvent(QEvent::KeyPress,0,Qt::NoModifier,"DELETE"));

bool StandardSettingDialog::keyPressEvent(QKeyEvent *e)
{
QStringList actions;

bool handled = m_buttonList->keyPressEvent(e);
if (handled)
return true;
Expand Down Expand Up @@ -1041,10 +1046,88 @@ bool StandardSettingDialog::keyPressEvent(QKeyEvent *e)
}
else if (action == "RIGHT")
LevelDown();
else if (action == "EDIT")
{
keyPressEvent(&selectEvent);
}
else if (action == "DELETE")
deleteEntry();
else
handled = MythScreenType::keyPressEvent(e);
}

return handled;
}

void StandardSettingDialog::ShowMenu()
{
MythUIButtonListItem *item = m_buttonList->GetItemCurrent();
if (!item)
return;

GroupSetting *source = item->GetData().value<GroupSetting*>();
if (!source)
return;
// m_title->GetText() for screen title
MythMenu *menu = new MythMenu(source->getLabel(), this, "mainmenu");
menu->AddItem(tr("Edit"), SLOT(editEntry()));
if (source->canDelete())
menu->AddItem(tr("Delete"), SLOT(deleteSelected()));

MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");

MythDialogBox *menuPopup = new MythDialogBox(menu, popupStack,
"menudialog");
menuPopup->SetReturnEvent(this, "mainmenu");

if (menuPopup->Create())
popupStack->AddScreen(menuPopup);
else
delete menuPopup;
}

void StandardSettingDialog::editEntry()
{
keyPressEvent(&selectEvent);
}

void StandardSettingDialog::deleteSelected()
{
keyPressEvent(&deleteEvent);
}

void StandardSettingDialog::deleteEntry()
{
MythUIButtonListItem *item = m_buttonList->GetItemCurrent();
if (!item)
return;

GroupSetting *source = item->GetData().value<GroupSetting*>();
if (!source)
return;

if (source->canDelete())
{
QString message = tr("Do you want to delete the '%1' entry?")
.arg(source->getLabel());
ShowOkPopup(message, this, SLOT(deleteEntryConfirmed(bool)), true);
}
}

void StandardSettingDialog::deleteEntryConfirmed(bool ok)
{
if (ok)
{
MythUIButtonListItem *item = m_buttonList->GetItemCurrent();
if (!item)
return;
GroupSetting *source = item->GetData().value<GroupSetting*>();
if (!source)
return;
source->deleteEntry();
// m_settingsTree->removeChild(source);
source->getParent()->removeChild(source);
m_buttonList->RemoveItem(item);
}

}
9 changes: 9 additions & 0 deletions mythtv/libs/libmyth/standardsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,8 @@ class MPUBLIC GlobalCheckBoxSetting: public MythUICheckBoxSetting

class MPUBLIC GroupSetting : public StandardSetting
{
Q_OBJECT

public:
GroupSetting();

Expand All @@ -400,6 +402,8 @@ class MPUBLIC GroupSetting : public StandardSetting
virtual void applyChange() {}
virtual void updateButton(MythUIButtonListItem *item);
virtual StandardSetting* byName(const QString &name);
virtual bool canDelete(void) {return false;}
virtual void deleteEntry(void) {}
};

class MPUBLIC ButtonStandardSetting : public StandardSetting
Expand Down Expand Up @@ -432,10 +436,15 @@ class MPUBLIC StandardSettingDialog : public MythScreenType
bool Create(void);
virtual void customEvent(QEvent *event);
virtual bool keyPressEvent(QKeyEvent *);
virtual void ShowMenu(void);
void deleteEntry(void);

public slots:
void Close(void);
void updateSettings(StandardSetting *selectedSetting = NULL);
void editEntry(void);
void deleteSelected(void);
void deleteEntryConfirmed(bool ok);

protected:
virtual void Load(void);
Expand Down
50 changes: 44 additions & 6 deletions mythtv/libs/libmyth/storagegroupeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,15 @@ bool StorageGroupEditor::keyPressEvent(QKeyEvent *e)
ShowDeleteDialog();
}
}
return handled;
if (handled)
return handled;
else
return GroupSetting::keyPressEvent(e);
}

bool StorageGroupEditor::canDelete(void)
{
return true;
}

void StorageGroupEditor::ShowDeleteDialog()
Expand Down Expand Up @@ -235,8 +243,6 @@ void StorageGroupEditor::Load(void)
connect(button, SIGNAL(clicked()), SLOT(ShowFileBrowser()));
addChild(button);

if (!m_group.startsWith("__CREATE_NEW_STORAGE_GROUP__"))
{
MSqlQuery query(MSqlQuery::InitCon());
query.prepare("SELECT dirname, id FROM storagegroup "
"WHERE groupname = :NAME AND hostname = :HOSTNAME "
Expand Down Expand Up @@ -268,7 +274,6 @@ void StorageGroupEditor::Load(void)
{
SetLabel();
}
}
}

StandardSetting::Load();
Expand Down Expand Up @@ -435,8 +440,12 @@ void StorageGroupListEditor::Load(void)
}

if (isMaster)
AddSelection(tr("(Create new group)"),
"__CREATE_NEW_STORAGE_GROUP__");
{
ButtonStandardSetting *newGroup =
new ButtonStandardSetting(tr("(Create new group)"));
connect(newGroup, SIGNAL(clicked()), SLOT(ShowNewGroupDialog()));
addChild(newGroup);
}
else
{
curName = 0;
Expand All @@ -455,4 +464,33 @@ void StorageGroupListEditor::Load(void)
StandardSetting::Load();
}


void StorageGroupListEditor::ShowNewGroupDialog()
{
MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
MythTextInputDialog *settingdialog =
new MythTextInputDialog(popupStack,
tr("Enter the name of the new storage group"));

if (settingdialog->Create())
{
connect(settingdialog, SIGNAL(haveResult(QString)),
SLOT(CreateNewGroup(QString)));
popupStack->AddScreen(settingdialog);
}
else
{
delete settingdialog;
}
}

void StorageGroupListEditor::CreateNewGroup(QString name)
{
StorageGroupEditor *button = new StorageGroupEditor(name);
button->setLabel(name + tr(" Storage Group Directories"));
button->Load();
addChild(button);
emit settingsChanged(this);
}

/* vim: set expandtab tabstop=4 shiftwidth=4: */
5 changes: 5 additions & 0 deletions mythtv/libs/libmyth/storagegroupeditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class MPUBLIC StorageGroupEditor :
public:
explicit StorageGroupEditor(QString group);
virtual void Load(void);
virtual bool canDelete(void);

protected slots:
void DoDeleteSlot(bool doDelete);
Expand All @@ -35,6 +36,10 @@ class MPUBLIC StorageGroupListEditor :
StorageGroupListEditor(void);
virtual void Load(void);
void AddSelection(const QString &label, const QString &value);

public slots:
void ShowNewGroupDialog(void);
void CreateNewGroup(QString name);
};

class StorageGroupDirStorage : public SimpleDBStorage
Expand Down
Loading

0 comments on commit 420a1ea

Please sign in to comment.