fix(color): Duplicate selected theme, update color list (#3122)
* fix(color): Duplicate selected, not current theme * fix: Update color list if theme edited
This commit is contained in:
@@ -500,7 +500,7 @@ void ThemeSetupPage::displayThemeMenu(Window *window, ThemePersistance *tp)
|
|||||||
{
|
{
|
||||||
auto menu = new Menu(listBox,false);
|
auto menu = new Menu(listBox,false);
|
||||||
|
|
||||||
// you cant activate the active theme
|
// you can't activate the active theme
|
||||||
if (listBox->getSelected() != tp->getThemeIndex()) {
|
if (listBox->getSelected() != tp->getThemeIndex()) {
|
||||||
menu->addLine(STR_ACTIVATE, [=]() {
|
menu->addLine(STR_ACTIVATE, [=]() {
|
||||||
auto idx = listBox->getSelected();
|
auto idx = listBox->getSelected();
|
||||||
@@ -512,7 +512,7 @@ void ThemeSetupPage::displayThemeMenu(Window *window, ThemePersistance *tp)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// you cant edit the default theme
|
// you can't edit the default theme
|
||||||
if (listBox->getSelected() != 0) {
|
if (listBox->getSelected() != 0) {
|
||||||
menu->addLine(STR_EDIT, [=]() {
|
menu->addLine(STR_EDIT, [=]() {
|
||||||
auto themeIdx = listBox->getSelected();
|
auto themeIdx = listBox->getSelected();
|
||||||
@@ -530,6 +530,7 @@ void ThemeSetupPage::displayThemeMenu(Window *window, ThemePersistance *tp)
|
|||||||
setAuthor(&theme);
|
setAuthor(&theme);
|
||||||
nameText->setText(theme.getName());
|
nameText->setText(theme.getName());
|
||||||
listBox->setName(currentTheme, theme.getName());
|
listBox->setName(currentTheme, theme.getName());
|
||||||
|
themeColorPreview->setColorList(theme.getColorList());
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the active theme changed, re-apply it
|
// if the active theme changed, re-apply it
|
||||||
@@ -546,14 +547,20 @@ void ThemeSetupPage::displayThemeMenu(Window *window, ThemePersistance *tp)
|
|||||||
menu->addLine(STR_DUPLICATE, [=] () {
|
menu->addLine(STR_DUPLICATE, [=] () {
|
||||||
ThemeFile newTheme;
|
ThemeFile newTheme;
|
||||||
|
|
||||||
new ThemeDetailsDialog(window, newTheme, [=] (ThemeFile theme) {
|
new ThemeDetailsDialog(window, newTheme, [=](ThemeFile theme) {
|
||||||
if (strlen(theme.getName()) != 0) {
|
if (strlen(theme.getName()) != 0) {
|
||||||
char name[NAME_LENGTH + 20];
|
char name[NAME_LENGTH + 20];
|
||||||
strncpy(name, theme.getName(), NAME_LENGTH + 19);
|
strncpy(name, theme.getName(), NAME_LENGTH + 19);
|
||||||
removeAllWhiteSpace(name);
|
removeAllWhiteSpace(name);
|
||||||
// use the current themes color list to make the new theme
|
|
||||||
auto curTheme = tp->getCurrentTheme();
|
// use the selected themes color list to make the new theme
|
||||||
for (auto color : curTheme->getColorList())
|
auto themeIdx = listBox->getSelected();
|
||||||
|
if (themeIdx < 0) return;
|
||||||
|
|
||||||
|
auto selTheme = tp->getThemeByIndex(themeIdx);
|
||||||
|
if (selTheme == nullptr) return;
|
||||||
|
|
||||||
|
for (auto color : selTheme->getColorList())
|
||||||
theme.setColor(color.colorNumber, color.colorValue);
|
theme.setColor(color.colorNumber, color.colorValue);
|
||||||
|
|
||||||
tp->createNewTheme(name, theme);
|
tp->createNewTheme(name, theme);
|
||||||
|
|||||||
Reference in New Issue
Block a user