QtIFW: Added new options to QtIFW cpack generator for modifying wizard style

This commit is contained in:
Alexander Voitenko 2017-01-17 14:12:02 +03:00
parent 7bd1d53505
commit 3fc4a2b71a
4 changed files with 176 additions and 3 deletions

View File

@ -0,0 +1,7 @@
cpack-ifw-package-options
-------------------------
* The :module:`CPackIFW` module gained new :variable:`CPACK_IFW_PACKAGE_WATERMARK`, :variable:`CPACK_IFW_PACKAGE_BANNER`,
:variable:`CPACK_IFW_PACKAGE_BACKGROUND`, :variable:`CPACK_IFW_PACKAGE_WIZARD_STYLE`, :variable:`CPACK_IFW_PACKAGE_WIZARD_DEFAULT_WIDTH`,
:variable:`CPACK_IFW_PACKAGE_WIZARD_DEFAULT_HEIGHT` and :variable:`CPACK_IFW_PACKAGE_TITLE_COLOR`
variables to customize a QtIFW installer look.

View File

@ -76,6 +76,34 @@
# #
# Filename for a logo is used as QWizard::LogoPixmap. # Filename for a logo is used as QWizard::LogoPixmap.
# #
# .. variable:: CPACK_IFW_PACKAGE_WATERMARK
#
# Filename for a watermark is used as QWizard::WatermarkPixmap.
#
# .. variable:: CPACK_IFW_PACKAGE_BANNER
#
# Filename for a banner is used as QWizard::BannerPixmap.
#
# .. variable:: CPACK_IFW_PACKAGE_BACKGROUND
#
# Filename for an image used as QWizard::BackgroundPixmap (only used by MacStyle).
#
# .. variable:: CPACK_IFW_PACKAGE_WIZARD_STYLE
#
# Wizard style to be used ("Modern", "Mac", "Aero" or "Classic").
#
# .. variable:: CPACK_IFW_PACKAGE_WIZARD_DEFAULT_WIDTH
#
# Default width of the wizard in pixels. Setting a banner image will override this.
#
# .. variable:: CPACK_IFW_PACKAGE_WIZARD_DEFAULT_HEIGHT
#
# Default height of the wizard in pixels. Setting a watermark image will override this.
#
# .. variable:: CPACK_IFW_PACKAGE_TITLE_COLOR
#
# Color of the titles and subtitles (takes an HTML color code, such as "#88FF33").
#
# .. variable:: CPACK_IFW_PACKAGE_START_MENU_DIRECTORY # .. variable:: CPACK_IFW_PACKAGE_START_MENU_DIRECTORY
# #
# Name of the default program group for the product in the Windows Start menu. # Name of the default program group for the product in the Windows Start menu.

View File

@ -60,6 +60,16 @@ bool cmCPackIFWInstaller::IsVersionEqual(const char* version)
return Generator ? Generator->IsVersionEqual(version) : false; return Generator ? Generator->IsVersionEqual(version) : false;
} }
void cmCPackIFWInstaller::printSkippedOptionWarning(
const std::string& optionName, const std::string& optionValue)
{
cmCPackLogger(
cmCPackLog::LOG_WARNING, "Option "
<< optionName << " is set to \"" << optionValue
<< "\" but will be skipped because the specified file does not exist."
<< std::endl);
}
void cmCPackIFWInstaller::ConfigureFromOptions() void cmCPackIFWInstaller::ConfigureFromOptions()
{ {
// Name; // Name;
@ -110,7 +120,7 @@ void cmCPackIFWInstaller::ConfigureFromOptions()
if (cmSystemTools::FileExists(option)) { if (cmSystemTools::FileExists(option)) {
InstallerApplicationIcon = option; InstallerApplicationIcon = option;
} else { } else {
// TODO: implement warning printSkippedOptionWarning("CPACK_IFW_PACKAGE_ICON", option);
} }
} }
@ -119,7 +129,7 @@ void cmCPackIFWInstaller::ConfigureFromOptions()
if (cmSystemTools::FileExists(option)) { if (cmSystemTools::FileExists(option)) {
InstallerWindowIcon = option; InstallerWindowIcon = option;
} else { } else {
// TODO: implement warning printSkippedOptionWarning("CPACK_IFW_PACKAGE_WINDOW_ICON", option);
} }
} }
@ -128,10 +138,69 @@ void cmCPackIFWInstaller::ConfigureFromOptions()
if (cmSystemTools::FileExists(option)) { if (cmSystemTools::FileExists(option)) {
Logo = option; Logo = option;
} else { } else {
// TODO: implement warning printSkippedOptionWarning("CPACK_IFW_PACKAGE_LOGO", option);
} }
} }
// Watermark
if (const char* option = GetOption("CPACK_IFW_PACKAGE_WATERMARK")) {
if (cmSystemTools::FileExists(option)) {
Watermark = option;
} else {
printSkippedOptionWarning("CPACK_IFW_PACKAGE_WATERMARK", option);
}
}
// Banner
if (const char* option = GetOption("CPACK_IFW_PACKAGE_BANNER")) {
if (cmSystemTools::FileExists(option)) {
Banner = option;
} else {
printSkippedOptionWarning("CPACK_IFW_PACKAGE_BANNER", option);
}
}
// Background
if (const char* option = GetOption("CPACK_IFW_PACKAGE_BACKGROUND")) {
if (cmSystemTools::FileExists(option)) {
Background = option;
} else {
printSkippedOptionWarning("CPACK_IFW_PACKAGE_BACKGROUND", option);
}
}
// WizardStyle
if (const char* option = GetOption("CPACK_IFW_PACKAGE_WIZARD_STYLE")) {
if (WizardStyle.compare("Modern") == 0 &&
WizardStyle.compare("Aero") == 0 && WizardStyle.compare("Mac") == 0 &&
WizardStyle.compare("Classic") == 0) {
cmCPackLogger(
cmCPackLog::LOG_WARNING,
"Option CPACK_IFW_PACKAGE_WIZARD_STYLE has unknown value \""
<< option << "\". Expected values are: Modern, Aero, Mac, Classic."
<< std::endl);
}
WizardStyle = option;
}
// WizardDefaultWidth
if (const char* option =
GetOption("CPACK_IFW_PACKAGE_WIZARD_DEFAULT_WIDTH")) {
WizardDefaultWidth = option;
}
// WizardDefaultHeight
if (const char* option =
GetOption("CPACK_IFW_PACKAGE_WIZARD_DEFAULT_HEIGHT")) {
WizardDefaultHeight = option;
}
// TitleColor
if (const char* option = GetOption("CPACK_IFW_PACKAGE_TITLE_COLOR")) {
TitleColor = option;
}
// Start menu // Start menu
if (const char* optIFW_START_MENU_DIR = if (const char* optIFW_START_MENU_DIR =
this->GetOption("CPACK_IFW_PACKAGE_START_MENU_DIRECTORY")) { this->GetOption("CPACK_IFW_PACKAGE_START_MENU_DIRECTORY")) {
@ -313,6 +382,50 @@ void cmCPackIFWInstaller::GenerateInstallerFile()
xout.Element("Logo", name); xout.Element("Logo", name);
} }
// Banner
if (!Banner.empty()) {
std::string name = cmSystemTools::GetFilenameName(Banner);
std::string path = Directory + "/config/" + name;
cmsys::SystemTools::CopyFileIfDifferent(Banner.data(), path.data());
xout.Element("Banner", name);
}
// Watermark
if (!Watermark.empty()) {
std::string name = cmSystemTools::GetFilenameName(Watermark);
std::string path = Directory + "/config/" + name;
cmsys::SystemTools::CopyFileIfDifferent(Watermark.data(), path.data());
xout.Element("Watermark", name);
}
// Background
if (!Background.empty()) {
std::string name = cmSystemTools::GetFilenameName(Background);
std::string path = Directory + "/config/" + name;
cmsys::SystemTools::CopyFileIfDifferent(Background.data(), path.data());
xout.Element("Background", name);
}
// WizardStyle
if (!WizardStyle.empty()) {
xout.Element("WizardStyle", WizardStyle);
}
// WizardDefaultWidth
if (!WizardDefaultWidth.empty()) {
xout.Element("WizardDefaultWidth", WizardDefaultWidth);
}
// WizardDefaultHeight
if (!WizardDefaultHeight.empty()) {
xout.Element("WizardDefaultHeight", WizardDefaultHeight);
}
// TitleColor
if (!TitleColor.empty()) {
xout.Element("TitleColor", TitleColor);
}
// Start menu // Start menu
if (!IsVersionLess("2.0")) { if (!IsVersionLess("2.0")) {
xout.Element("StartMenuDir", StartMenuDir); xout.Element("StartMenuDir", StartMenuDir);

View File

@ -60,6 +60,27 @@ public:
/// Filename for a logo /// Filename for a logo
std::string Logo; std::string Logo;
/// Filename for a watermark
std::string Watermark;
/// Filename for a banner
std::string Banner;
/// Filename for a background
std::string Background;
/// Wizard style name
std::string WizardStyle;
/// Wizard width
std::string WizardDefaultWidth;
/// Wizard height
std::string WizardDefaultHeight;
/// Title color
std::string TitleColor;
/// Name of the default program group in the Windows Start menu /// Name of the default program group in the Windows Start menu
std::string StartMenuDir; std::string StartMenuDir;
@ -110,6 +131,10 @@ public:
protected: protected:
void WriteGeneratedByToStrim(cmXMLWriter& xout); void WriteGeneratedByToStrim(cmXMLWriter& xout);
private:
void printSkippedOptionWarning(const std::string& optionName,
const std::string& optionValue);
}; };
#endif // cmCPackIFWInstaller_h #endif // cmCPackIFWInstaller_h