Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New theme option: Lyrics all uppercase #246

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Quelea/icons/uppercase-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Quelea/icons/uppercase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 32 additions & 6 deletions Quelea/src/main/java/org/quelea/data/ThemeDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class ThemeDTO implements Serializable {
public static final Color DEFAULT_TRANSLATE_FONT_COLOR = Color.WHITESMOKE;
public static final SerializableDropShadow DEFAULT_SHADOW = new SerializableDropShadow(Color.BLACK, 0, 0, 2, 0, true);
public static final ColourBackground DEFAULT_BACKGROUND = new ColourBackground(Color.BLACK);
public static final ThemeDTO DEFAULT_THEME = new ThemeDTO(DEFAULT_FONT, DEFAULT_FONT_COLOR, DEFAULT_FONT, DEFAULT_TRANSLATE_FONT_COLOR, DEFAULT_BACKGROUND, DEFAULT_SHADOW, DEFAULT_FONT.getFont().getStyle().toLowerCase().contains("bold"), DEFAULT_FONT.getFont().getStyle().toLowerCase().contains("italic"), DEFAULT_FONT.getFont().getStyle().toLowerCase().contains("bold"), true, -1, 0);
public static final ThemeDTO DEFAULT_THEME = new ThemeDTO(DEFAULT_FONT, DEFAULT_FONT_COLOR, DEFAULT_FONT, DEFAULT_TRANSLATE_FONT_COLOR, DEFAULT_BACKGROUND, DEFAULT_SHADOW, DEFAULT_FONT.getFont().getStyle().toLowerCase().contains("bold"), DEFAULT_FONT.getFont().getStyle().toLowerCase().contains("italic"), false, DEFAULT_FONT.getFont().getStyle().toLowerCase().contains("bold"), true, false, -1, 0);
private final SerializableFont font;
private final SerializableColor fontColor;
private final SerializableFont translateFont;
Expand All @@ -58,8 +58,10 @@ public class ThemeDTO implements Serializable {
private File file;
private Boolean isFontBold = false;
private Boolean isFontItalic = false;
private Boolean isFontUppercase = false;
private Boolean isTranslateFontBold = false;
private Boolean isTranslateFontItalic = false;
private Boolean isTranslateFontUppercase = false;
private int textPosition = -1;
private int textAlignment = 0;

Expand All @@ -71,7 +73,7 @@ public class ThemeDTO implements Serializable {
* @param background the background to use for the page.
*/
public ThemeDTO(SerializableFont font, Color fontPaint, SerializableFont translatefont, Color translatefontPaint, Background background,
SerializableDropShadow shadow, Boolean isFontBold, Boolean isFontItalic, Boolean isTranslateFontBold, Boolean isTranslateFontItalic,
SerializableDropShadow shadow, Boolean isFontBold, Boolean isFontItalic, Boolean isFontUppercase, Boolean isTranslateFontBold, Boolean isTranslateFontItalic, Boolean isTranslateFontUppercase,
Integer textPosition, Integer textAlignment) {
this.font = font;
this.translateFont = translatefont;
Expand All @@ -82,8 +84,10 @@ public ThemeDTO(SerializableFont font, Color fontPaint, SerializableFont transla
this.textShadow = shadow;
this.isFontBold = isFontBold;
this.isFontItalic = isFontItalic;
this.isFontUppercase = isFontUppercase;
this.isTranslateFontBold = isTranslateFontBold;
this.isTranslateFontItalic = isTranslateFontItalic;
this.isTranslateFontUppercase = isTranslateFontUppercase;
this.textPosition = textPosition;
this.textAlignment = textAlignment;
}
Expand Down Expand Up @@ -292,7 +296,7 @@ public Theme getTheme() {
final TextShadow shadow = new TextShadow(textShadow.getColor().toString(),
textShadow.getOffsetX(), textShadow.getOffsetY(), textShadow.getRadius(), textShadow.getSpread(), textShadow.getUse());
final Theme theme = new Theme(themeName, font.getFont().getName(), fontColor.toString(), translateFont.getFont().getName(), translateFontColor.toString(), backgroundColor,
backgroundVideo, backgroundImage, shadow, isFontBold, isFontItalic, isTranslateFontBold, isTranslateFontItalic, vidHue, vidStretch, textPosition, textAlignment);
backgroundVideo, backgroundImage, shadow, isFontBold, isFontItalic, isFontUppercase, isTranslateFontBold, isTranslateFontItalic, isTranslateFontUppercase,vidHue, vidStretch, textPosition, textAlignment);
return theme;
}

Expand All @@ -317,7 +321,7 @@ public static ThemeDTO getDTO(Theme theme) {
SerializableDropShadow shadow = new SerializableDropShadow(Utils.parseColour(givenShadow.getShadowColor()),
givenShadow.getOffsetX(), givenShadow.getOffsetY(), givenShadow.getRadius(), givenShadow.getSpread(), givenShadow.getUse());
ThemeDTO ret = new ThemeDTO(font, Utils.parseColour(theme.getFontcolour()), translateFont, Utils.parseColour(theme.getTranslateFontcolour()),
background, shadow, theme.isFontBold(), theme.isFontItalic(), theme.isTranslateFontBold(), theme.isTranslateFontItalic(), theme.getTextPosition(), theme.getTextAlignment());
background, shadow, theme.isFontBold(), theme.isFontItalic(), theme.isFontUppercase(), theme.isTranslateFontBold(), theme.isTranslateFontItalic(), theme.isTranslateFontUppercase(),theme.getTextPosition(), theme.getTextAlignment());
ret.themeName = theme.getName();
return ret;
}
Expand All @@ -343,8 +347,10 @@ public String asString() {
}
ret.append("$isFontBold:").append(isFontBold);
ret.append("$isFontItalic:").append(isFontItalic);
ret.append("$isFontUppercase:").append(isFontUppercase);
ret.append("$isTranslateFontBold:").append(isTranslateFontBold);
ret.append("$isTranslateFontItalic:").append(isTranslateFontItalic);
ret.append("$isTranslateFontUppercase:").append(isTranslateFontUppercase);
if (background instanceof VideoBackground) {
ret.append("$backgroundvideo:").append(((VideoBackground) background).getString());
ret.append("$vidhue:").append(((VideoBackground) background).getHue());
Expand Down Expand Up @@ -385,8 +391,10 @@ public static ThemeDTO fromString(String content) {
String translatefontcolour = "";
String isFontBold = "";
String isFontItalic = "";
String isFontUppercase = "";
String isTranslateFontBold = "";
String isTranslateFontItalic = "";
String isTranslateFontUppercase = "";
String backgroundcolour = "";
String backgroundvid = "";
String backgroundimage = "";
Expand Down Expand Up @@ -420,8 +428,12 @@ public static ThemeDTO fromString(String content) {
isTranslateFontBold = parts[1];
} else if (parts[0].equalsIgnoreCase("isTranslateFontItalic")) {
isTranslateFontItalic = parts[1];
} else if (parts[0].equalsIgnoreCase("isTranslateFontUppercase")) {
isTranslateFontUppercase = parts[1];
} else if (parts[0].equalsIgnoreCase("isFontItalic")) {
isFontItalic = parts[1];
} else if (parts[0].equalsIgnoreCase("isFontUppercase")) {
isFontUppercase = parts[1];
} else if (parts[0].equalsIgnoreCase("backgroundcolour")) {
backgroundcolour = parts[1];
} else if (parts[0].equalsIgnoreCase("backgroundimage")) {
Expand Down Expand Up @@ -475,8 +487,8 @@ public static ThemeDTO fromString(String content) {
}
SerializableDropShadow shadow = new SerializableDropShadow(Utils.parseColour(shadowColor), Double.parseDouble(shadowOffsetX), Double.parseDouble(shadowOffsetY), Double.parseDouble(shadowRadius), Double.parseDouble(shadowSpread), Boolean.parseBoolean(shadowUse));
ThemeDTO ret = new ThemeDTO(font, Utils.parseColour(fontcolour), translateFont, Utils.parseColour(translatefontcolour),
background, shadow, Boolean.valueOf(isFontBold), Boolean.valueOf(isFontItalic),
Boolean.valueOf(isTranslateFontBold), Boolean.valueOf(isTranslateFontItalic), Integer.parseInt(textPosition), Integer.parseInt(textAlignment.trim()));
background, shadow, Boolean.valueOf(isFontBold), Boolean.valueOf(isFontItalic), Boolean.valueOf(isFontUppercase),
Boolean.valueOf(isTranslateFontBold), Boolean.valueOf(isTranslateFontItalic), Boolean.valueOf(isTranslateFontUppercase), Integer.parseInt(textPosition), Integer.parseInt(textAlignment.trim()));
ret.themeName = themeName;
return ret;
}
Expand Down Expand Up @@ -512,6 +524,13 @@ public boolean isBold() {
return isFontBold;
}

/**
* @return the uppercase
*/
public boolean isUppercase() {
return isFontUppercase;
}

/**
* @return the italic
*/
Expand All @@ -526,6 +545,13 @@ public boolean isTranslateBold() {
return isTranslateFontBold;
}

/**
* @return the uppercase
*/
public boolean isTranslateUppercase() {
return isTranslateFontUppercase;
}

@Override
public String toString() {
return themeName;
Expand Down
67 changes: 66 additions & 1 deletion Quelea/src/main/java/org/quelea/data/db/model/Theme.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ public class Theme {
private String backgroundimage;
private Boolean fontBold;
private Boolean fontItalic;
private Boolean fontUpperCase;
private Boolean translateFontBold;
private Boolean translateFontItalic;
private Boolean translateFontUppercase;
private Double videoHue;
private Boolean videoStretch;
private Integer textPosition;
Expand All @@ -44,7 +46,7 @@ public Theme() {

public Theme(String name, String fontname, String fontcolour, String translateFontname, String translateFontcolour,
String backgroundcolour, String backgroundvid, String backgroundimage,
TextShadow shadow, boolean isFontBold, boolean isFontitalic, boolean isTranslateFontBold, boolean isTranslateFontitalic, double videoHue, boolean videoStretch, int textPosition, int textAlignment) {
TextShadow shadow, boolean isFontBold, boolean isFontitalic, boolean isFontUpperCase, boolean isTranslateFontBold, boolean isTranslateFontitalic, boolean isTranslateFontUppercase, double videoHue, boolean videoStretch, int textPosition, int textAlignment) {
this.name = name;
this.fontname = fontname;
this.fontcolour = fontcolour;
Expand All @@ -56,14 +58,45 @@ public Theme(String name, String fontname, String fontcolour, String translateFo
this.textShadow = shadow;
this.fontBold = isFontBold;
this.fontItalic = isFontitalic;
this.fontUpperCase = isFontUpperCase;
this.translateFontBold = isTranslateFontBold;
this.translateFontItalic = isTranslateFontitalic;
this.translateFontUppercase = isTranslateFontUppercase;
this.videoHue = videoHue;
this.videoStretch = videoStretch;
this.textPosition = textPosition;
this.textAlignment = textAlignment;
}

/**This is the original constructer, just for backwards compatibily
* Sets fontUppercase and translateFontUppercase to false
*/
public Theme(String name, String fontname, String fontcolour, String translateFontname, String translateFontcolour,
String backgroundcolour, String backgroundvid, String backgroundimage,
TextShadow shadow, boolean isFontBold, boolean isFontitalic, boolean isTranslateFontBold, boolean isTranslateFontitalic, double videoHue, boolean videoStretch, int textPosition, int textAlignment) {
this.name = name;
this.fontname = fontname;
this.fontcolour = fontcolour;
this.translateFontname = translateFontname;
this.translateFontcolour = translateFontcolour;
this.backgroundcolour = backgroundcolour;
this.backgroundvid = backgroundvid;
this.backgroundimage = backgroundimage;
this.textShadow = shadow;
this.fontBold = isFontBold;
this.fontItalic = isFontitalic;
this.fontUpperCase = false;
this.translateFontBold = isTranslateFontBold;
this.translateFontItalic = isTranslateFontitalic;
this.translateFontUppercase = false;
this.videoHue = videoHue;
this.videoStretch = videoStretch;
this.textPosition = textPosition;
this.textAlignment = textAlignment;
}



public Theme(Theme theme) {
this.name = theme.name;
this.fontname = theme.fontname;
Expand All @@ -76,8 +109,10 @@ public Theme(Theme theme) {
this.textShadow = theme.textShadow;
this.fontBold = theme.fontBold;
this.fontItalic = theme.fontItalic;
this.fontUpperCase = theme.fontUpperCase;
this.translateFontBold = theme.translateFontBold;
this.translateFontItalic = theme.translateFontItalic;
this.translateFontUppercase = theme.translateFontUppercase;
this.videoHue = theme.videoHue;
this.videoStretch = theme.videoStretch;
this.textPosition = theme.textPosition;
Expand Down Expand Up @@ -314,6 +349,21 @@ public void setFontItalic(Boolean isFontItalic) {
this.fontItalic = isFontItalic;
}

/**
* @return the isFontUpperCase
*/
@Column(name = "isfontuppercase")
public Boolean isFontUppercase() {
return fontUpperCase == null ? false : fontUpperCase;
}

/**
* @param isFontUppercase the isFontUppercase to set
*/
public void setFontUppercase(Boolean isFontUppercase) {
this.fontUpperCase = isFontUppercase;
}

/**
* @return the isFontBold
*/
Expand Down Expand Up @@ -344,6 +394,21 @@ public void setTranslateFontItalic(Boolean translateFontItalic) {
this.translateFontItalic = translateFontItalic;
}

/**
* @return the isTranslateFontUppercase
*/
@Column(name = "istranslatefontuppercase")
public Boolean isTranslateFontUppercase() {
return translateFontUppercase == null ? false : translateFontUppercase;
}

/**
* @param translateFontUppercase the translateFontUppercase to set
*/
public void setTranslateFontUppercase(Boolean translateFontUppercase) {
this.translateFontUppercase = translateFontUppercase;
}

@Override
public String toString() {
return ThemeDTO.getDTO(this).asString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class BiblePassage implements TextDisplayable, Serializable {
public BiblePassage(String biblename, String location, BibleVerse[] verses, boolean multi) {
this(location + "\n" + biblename, verses, new ThemeDTO(ThemeDTO.DEFAULT_FONT,
ThemeDTO.DEFAULT_FONT_COLOR, ThemeDTO.DEFAULT_FONT, ThemeDTO.DEFAULT_TRANSLATE_FONT_COLOR,
ThemeDTO.DEFAULT_BACKGROUND, ThemeDTO.DEFAULT_SHADOW, false, false, false, true, 3, -1), multi);
ThemeDTO.DEFAULT_BACKGROUND, ThemeDTO.DEFAULT_SHADOW, false, false, false,false, true, false, 3, -1), multi);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public SongDisplayable(SongDisplayable song) {
public SongDisplayable(String title, String author) {
this(title, author, new ThemeDTO(ThemeDTO.DEFAULT_FONT,
ThemeDTO.DEFAULT_FONT_COLOR, ThemeDTO.DEFAULT_FONT, ThemeDTO.DEFAULT_TRANSLATE_FONT_COLOR,
ThemeDTO.DEFAULT_BACKGROUND, ThemeDTO.DEFAULT_SHADOW, false, false, false, true, -1, 0));
ThemeDTO.DEFAULT_BACKGROUND, ThemeDTO.DEFAULT_SHADOW, false, false, false, false, true, false, -1, 0));
}

/**
Expand Down Expand Up @@ -684,6 +684,7 @@ public String getLyrics(boolean chords, boolean comments) {
}
ret.append("\n");
}

return ret.toString().replaceAll("\\s+$", "").replace(" ", "<>");
}

Expand Down Expand Up @@ -1100,7 +1101,7 @@ public static SongDisplayable parseXML(Node song) {
}
SongDisplayable ret = new SongDisplayable(title, author,
new ThemeDTO(ThemeDTO.DEFAULT_FONT, ThemeDTO.DEFAULT_FONT_COLOR, ThemeDTO.DEFAULT_FONT, ThemeDTO.DEFAULT_TRANSLATE_FONT_COLOR,
ThemeDTO.DEFAULT_BACKGROUND, ThemeDTO.DEFAULT_SHADOW, false, false, false, true, -1, 0));
ThemeDTO.DEFAULT_BACKGROUND, ThemeDTO.DEFAULT_SHADOW, false, false, false,false, true, false, -1, 0));
if (!updateInDB) {
ret.setNoDBUpdate();
}
Expand Down
12 changes: 10 additions & 2 deletions Quelea/src/main/java/org/quelea/windows/lyrics/LyricDrawer.java
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,11 @@ private List<LyricLine> sanctifyText(String[] linesArr, String[] translationArr)
List<LyricLine> finalLines = new ArrayList<>();
int translationOffset = 0;
for (int i = 0; i < linesArr.length; i++) {
finalLines.add(new LyricLine(linesArr[i]));
if(this.theme.isUppercase()) {
finalLines.add(new LyricLine(linesArr[i].toUpperCase()));
} else {
finalLines.add(new LyricLine(linesArr[i]));
}
if (new LineTypeChecker(linesArr[i]).getLineType() == Type.NONBREAK) {
continue;
}
Expand All @@ -466,7 +470,11 @@ private List<LyricLine> sanctifyText(String[] linesArr, String[] translationArr)
translationOffset++;
}
if (i + translationOffset < translationArr.length && new LineTypeChecker(translationArr[i + translationOffset]).getLineType() == Type.NORMAL) {
finalLines.add(new LyricLine(true, translationArr[i + translationOffset]));
if(this.theme.isTranslateUppercase()) {
finalLines.add(new LyricLine(true, translationArr[i + translationOffset].toUpperCase()));
} else {
finalLines.add(new LyricLine(true, translationArr[i + translationOffset]));
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ public void run() {
if (dropShadow == null || (dropShadow.getColor().equals(Color.WHITE) && dropShadow.getOffsetX() == 0 && dropShadow.getOffsetY() == 0)) {
dropShadow = new SerializableDropShadow(Color.BLACK, 3, 3, 2, 0, true);
}
ThemeDTO newTheme = new ThemeDTO(theme.getSerializableFont(), theme.getFontPaint(), theme.getTranslateSerializableFont(), theme.getTranslateFontPaint(), new ImageBackground(new File(imageLocation).getName()), dropShadow, theme.getSerializableFont().isBold(), theme.getSerializableFont().isItalic(), theme.getTranslateSerializableFont().isBold(), theme.getTranslateSerializableFont().isItalic(), theme.getTextPosition(), theme.getTextAlignment());
ThemeDTO newTheme = new ThemeDTO(theme.getSerializableFont(), theme.getFontPaint(), theme.getTranslateSerializableFont(), theme.getTranslateFontPaint(), new ImageBackground(new File(imageLocation).getName()), dropShadow, theme.getSerializableFont().isBold(), theme.getSerializableFont().isItalic(), theme.isUppercase(), theme.getTranslateSerializableFont().isBold(), theme.getTranslateSerializableFont().isItalic(), theme.isTranslateUppercase(),theme.getTextPosition(), theme.getTextAlignment());
for (TextSection section : textDisplayable.getSections()) {
section.setTheme(newTheme);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public ThemeDTO getTheme() {
public void setTheme(ThemeDTO theme) {
if (theme == null) {
theme = new ThemeDTO(ThemeDTO.DEFAULT_FONT, ThemeDTO.DEFAULT_FONT_COLOR, ThemeDTO.DEFAULT_FONT, ThemeDTO.DEFAULT_TRANSLATE_FONT_COLOR,
ThemeDTO.DEFAULT_BACKGROUND, ThemeDTO.DEFAULT_SHADOW, false, false, false, true, -1, 0);
ThemeDTO.DEFAULT_BACKGROUND, ThemeDTO.DEFAULT_SHADOW, false, false, false,false, true, false,-1, 0);
theme.setThemeName("");
}
if (theme.getFile() == null) {
Expand Down
Loading