Skip to content

Commit

Permalink
UI improvements (#54)
Browse files Browse the repository at this point in the history
* adjust About dialog

* actually enable translations

* fix application icon on Windows #52, add more WIX customizations

* add wrapper for qt_add_translations for qt5
  • Loading branch information
Neverous authored Feb 26, 2023
1 parent cf40431 commit 482de3e
Show file tree
Hide file tree
Showing 14 changed files with 2,355 additions and 100 deletions.
70 changes: 65 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,21 @@ if(NOT ("$ENV{BUILD_VERSION}" STREQUAL ""))
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" VERSION $ENV{BUILD_VERSION})
endif()

string(REGEX MATCH "([0-9]+)\\.([0-9]+)\\.([0-9]+)" _version_match ${VERSION})
set(VERSION_MAJOR ${CMAKE_MATCH_1})
set(VERSION_MINOR ${CMAKE_MATCH_2})
set(VERSION_PATCH ${CMAKE_MATCH_3})

project(efibooteditor
VERSION ${VERSION}
DESCRIPTION "Boot Editor for (U)EFI based systems"
DESCRIPTION "Boot Editor for (U)EFI based systems."
LANGUAGES C CXX
)

set(PROJECT_NAME_CAPITALIZED "EFIBootEditor")
set(PROJECT_HOMEPAGE_URL "https://github.com/Neverous/efibooteditor")
set(APPLICATION_NAME "EFI Boot Editor")
set(APPLICATION_ICON "${CMAKE_SOURCE_DIR}/icons/Tango/256/categories/preferences-system.ico")

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
Expand Down Expand Up @@ -51,6 +59,7 @@ find_package(Qt${QT_VERSION_MAJOR}
Gui
Network
Widgets
LinguistTools
REQUIRED)

add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE
Expand All @@ -71,12 +80,39 @@ if(${QT_VERSION_MAJOR} GREATER 5)
target_link_libraries(${PROJECT_NAME} PRIVATE
Qt::Core5Compat
)
else()
if(NOT COMMAND qt_add_translations)
function(qt_add_translations TARGET)
cmake_parse_arguments(arg "" "" "TS_FILES;INCLUDE_DIRECTORIES" ${ARGN})
qt5_add_translation(QM_FILES ${arg_TS_FILES})

get_target_property(BINARY_DIR ${TARGET} BINARY_DIR)
set(QRC ${BINARY_DIR}/translations.qrc)
file(WRITE ${QRC} "<RCC><qresource prefix=\"/i18n\">\n")
foreach (QM_PATH ${QM_FILES})
file(RELATIVE_PATH QM_FILE ${BINARY_DIR} ${QM_PATH})
file(APPEND ${QRC} "<file>${QM_FILE}</file>\n")
endforeach (QM)
file(APPEND ${QRC} "</qresource></RCC>")

qt_add_resources(RESOURCES ${QRC})
target_sources(${PROJECT_NAME} PRIVATE ${RESOURCES})
endfunction()
endif()
endif()

target_compile_definitions(${PROJECT_NAME} PRIVATE
APPLICATION_NAME="${APPLICATION_NAME}"
VERSION="${VERSION}"
VERSION_MAJOR=${VERSION_MAJOR}
VERSION_MINOR=${VERSION_MINOR}
VERSION_PATCH=${VERSION_PATCH}
PROJECT_NAME="${PROJECT_NAME}"
PROJECT_DESCRIPTION="${PROJECT_DESCRIPTION}"
PROJECT_HOMEPAGE_URL="${PROJECT_HOMEPAGE_URL}"
APPLICATION_ICON="${APPLICATION_ICON}"
QT_DEPRECATED_WARNINGS
QT_DISABLE_DEPRECATED_BEFORE=0xFFFFFF
VERSION="$ENV{BUILD_VERSION}"
)

# GCC
Expand Down Expand Up @@ -143,12 +179,16 @@ if(WIN32)
# Enable all warnings in application code
/Wall /permissive- /WX
# Disable some warnings
# C4464: relative include path contains '..
/wd4464
# C4702: unreachable code
/wd4702
# C4710: 'function' : function not inlined
/wd4710
# C4711: function 'function' selected for inline expansion
/wd4711
# C4820: 'bytes' bytes padding added after construct 'member_name'
/wd4820
# C4866: compiler may not enforce left-to-right evaluation order for call to 'C++17 operator'
/wd4866
# C5045: Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified
Expand Down Expand Up @@ -189,6 +229,7 @@ if(WIN32)
src/efivar-lite.c
src/efivar-lite.common.h
src/efivar-lite.win32.c
windows.rc
)
endif()

Expand Down Expand Up @@ -236,6 +277,15 @@ target_sources(${PROJECT_NAME} PRIVATE
qt_add_resources(RESOURCES icons.qrc)
target_sources(${PROJECT_NAME} PRIVATE ${RESOURCES})

# Translations
FILE(GLOB TRANSLATIONS
${CMAKE_SOURCE_DIR}/translations/${PROJECT_NAME}_*.ts
)

qt_add_translations(${PROJECT_NAME}
TS_FILES ${TRANSLATIONS}
INCLUDE_DIRECTORIES "include")

if(APPLE)
target_link_libraries(${PROJECT_NAME} PRIVATE
"-framework CoreFoundation"
Expand Down Expand Up @@ -290,13 +340,21 @@ if(WIN32)
install(DIRECTORY "${CMAKE_BINARY_DIR}/qt/"
TYPE BIN
COMPONENT Runtime
PATTERN "*.pdb" EXCLUDE
)

if(("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") OR ("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo"))
install(FILES "$<TARGET_PDB_FILE:${PROJECT_NAME}>"
TYPE BIN
COMPONENT Debug
)

install(DIRECTORY "${CMAKE_BINARY_DIR}/qt/"
TYPE BIN
COMPONENT Debug
FILES_MATCHING
PATTERN "*.pdb"
)
endif()

elseif(APPLE)
Expand Down Expand Up @@ -333,14 +391,14 @@ set(CPACK_PACKAGE_CONTACT "Maciej Szeptuch <[email protected]>")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_DESCRIPTION}")
set(CPACK_PACKAGE_DIRECTORY dist)
set(CPACK_PACKAGE_EXECUTABLES ${PROJECT_NAME} "${PROJECT_NAME_CAPITALIZED}")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/Neverous/efibooteditor")
set(CPACK_PACKAGE_HOMEPAGE_URL ${PROJECT_HOMEPAGE_URL})
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME_CAPITALIZED}")
set(CPACK_PACKAGE_NAME "${PROJECT_NAME_CAPITALIZED}")
set(CPACK_PACKAGE_NAME "${APPLICATION_NAME}")
set(CPACK_PACKAGE_VENDOR ${PROJECT_NAME_CAPITALIZED})
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE.txt")
set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/icons/Tango/scalable/categories/preferences-desktop.svg")
set(CPACK_PACKAGE_ICON "${APPLICATION_ICON}")

if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
set(CPACK_STRIP_FILES TRUE)
Expand All @@ -352,6 +410,8 @@ if(WIN32)

set(CPACK_WIX_LIGHT_EXTRA_FLAGS "-dcl:high")
set(CPACK_WIX_PRODUCT_ICON ${CPACK_PACKAGE_ICON})
set(CPACK_WIX_UI_BANNER "${CMAKE_SOURCE_DIR}/misc/wix_banner.png")
set(CPACK_WIX_UI_DIALOG "${CMAKE_SOURCE_DIR}/misc/wix_dialog.png")
set(CPACK_WIX_PROPERTY_ARPHELPLINK "${CPACK_PACKAGE_HOMEPAGE_URL}")
set(CPACK_WIX_PROPERTY_ARPURLINFOABOUT "${CPACK_PACKAGE_HOMEPAGE_URL}")
set(CPACK_WIX_ROOT_FEATURE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# EFI Boot Editor

GUI for managing EFI Boot Manager configuration.
Boot Editor for (U)EFI based systems.

![EFIBootEditor](doc/efibooteditor.png)
![Device path dialog](doc/devicepathdialog.png)
Expand Down
Binary file added icons/Tango/256/categories/preferences-system.ico
Binary file not shown.
Binary file added misc/wix_banner.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 misc/wix_dialog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/bootentryform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void BootEntryForm::optionalDataFormatChanged(int format)

if(!success)
{
QMessageBox::critical(this, qApp->applicationName(), tr("Couldn't change Optional data format!"));
QMessageBox::critical(this, qApp->applicationName(), tr("Couldn't change optional data format!"));
ui->optional_data_format_combo->setCurrentIndex(static_cast<int>(current_item->optional_data_format));
}
}
Expand Down
36 changes: 21 additions & 15 deletions src/efibooteditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ void EFIBootEditor::saveBootConfiguration()

void EFIBootEditor::import()
{
const auto file_name = QFileDialog::getOpenFileName(this, tr("Open Boot Configuration Dump"), "", tr("JSON Documents (*.json)"));
const auto file_name = QFileDialog::getOpenFileName(this, tr("Open boot configuration dump"), "", tr("JSON documents (*.json)"));
if(!file_name.isEmpty())
importBootConfiguration(file_name);
}
Expand Down Expand Up @@ -341,7 +341,7 @@ void EFIBootEditor::importJSONEFIData(const QJsonObject &input)
const auto &name = QString("BootOrder[%1]").arg(i);
if(!index.isDouble())
{
errors.push_back(tr("%1: number expected").arg(name));
errors.push_back(tr("%1: %2 expected").arg(name,tr("number")));
continue;
}

Expand All @@ -354,7 +354,7 @@ void EFIBootEditor::importJSONEFIData(const QJsonObject &input)
// clang-format on

if(!input["Boot"].isObject())
errors.push_back(tr("%1: object expected").arg("Boot"));
errors.push_back(tr("%1: %2 expected").arg("Boot", tr("object")));

else
{
Expand All @@ -367,7 +367,7 @@ void EFIBootEditor::importJSONEFIData(const QJsonObject &input)
const uint16_t index = static_cast<uint16_t>(name.toULong(&success, HEX_BASE));
if(!success)
{
errors.push_back(tr("%1: hexadecimal number expected").arg(prefix_ + name));
errors.push_back(tr("%1: %2 expected").arg(prefix_ + name, tr("hexadecimal number")));
continue;
}

Expand Down Expand Up @@ -430,14 +430,14 @@ void EFIBootEditor::importRawEFIData(const QJsonObject &input)
showProgressBar(step++, total_steps, tr("Importing EFI Boot Manager entries (%1)...").arg(full_name));
if(!root[name].isObject())
{
errors.push_back(tr("%1: object expected").arg(full_name));
errors.push_back(tr("%1: %2 expected").arg(full_name, tr("object")));
return;
}

const auto obj = root[name].toObject();
if(!obj["raw_data"].isString() || !obj["efi_attributes"].isDouble())
{
errors.push_back(tr("%1: object(raw_data: string, efi_attributes: number) expected").arg(full_name));
errors.push_back(tr("%1: %2 expected").arg(full_name).arg(tr("object(raw_data: string, efi_attributes: number)")));
return;
}

Expand Down Expand Up @@ -472,7 +472,7 @@ void EFIBootEditor::importRawEFIData(const QJsonObject &input)
// clang-format on

if(!input["Boot"].isObject())
errors.push_back(tr("%1: object expected").arg("Boot"));
errors.push_back(tr("%1: %2 expected").arg("Boot", tr("object")));

else
{
Expand All @@ -485,7 +485,7 @@ void EFIBootEditor::importRawEFIData(const QJsonObject &input)
const uint16_t index = static_cast<uint16_t>(name.toULong(&success, HEX_BASE));
if(!success)
{
errors.push_back(tr("%1: hexadecimal number expected").arg(prefix_ + name));
errors.push_back(tr("%1: %2 expected").arg(prefix_ + name, tr("hexadecimal number")));
continue;
}

Expand Down Expand Up @@ -522,7 +522,7 @@ void EFIBootEditor::importRawEFIData(const QJsonObject &input)

void EFIBootEditor::export_()
{
QString file_name = QFileDialog::getSaveFileName(this, tr("Save Boot Configuration Dump"), "", tr("JSON documents (*.json)"));
QString file_name = QFileDialog::getSaveFileName(this, tr("Save boot configuration dump"), "", tr("JSON documents (*.json)"));
if(!file_name.isEmpty())
exportBootConfiguration(file_name);
}
Expand Down Expand Up @@ -577,7 +577,7 @@ void EFIBootEditor::exportBootConfiguration(const QString &file_name)

void EFIBootEditor::dump()
{
const QString file_name = QFileDialog::getSaveFileName(this, tr("Save Raw EFI Dump"), "", tr("JSON documents (*.json)"));
const QString file_name = QFileDialog::getSaveFileName(this, tr("Save raw EFI dump"), "", tr("JSON documents (*.json)"));
if(!file_name.isEmpty())
dumpRawEFIData(file_name);
}
Expand Down Expand Up @@ -657,15 +657,21 @@ void EFIBootEditor::dumpRawEFIData(const QString &file_name)
void EFIBootEditor::showAboutBox()
{
auto *about = new QMessageBox(QMessageBox::Information,
qApp->applicationName(),
QString("<h1>EFI Boot Editor</h1><p><b>%1</b></p>").arg(QCoreApplication::applicationVersion()),
tr("About %1").arg(qApp->applicationName()),
QString("<h1>%1</h1>"
"<p><b>%2</b></p>"
"<p>%3</p>")
.arg(qApp->applicationName(), QCoreApplication::applicationVersion(), PROJECT_DESCRIPTION),
QMessageBox::Close,
this);
about->setIconPixmap(QIcon::fromTheme("preferences-system").pixmap(128, 128));
about->setInformativeText(tr(
"<p>License: <a href='http://www.gnu.org/licenses/lgpl.html'>GNU LGPL Version 3</a></p>"
"<p><a href='%1'>Website</a></p>"
"<p>The program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.</p>"
"<p>License: <a href='https://www.gnu.org/licenses/lgpl.html'>GNU LGPL Version 3</a></p>"
"<p>On Linux uses <a href='https://github.com/rhboot/efivar'>efivar</a> for EFI variables access.</p>"
"<p>Uses Tango Icons as fallback icons</p>"
"<p>The program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.</p>"));
"<p>Uses Tango Icons as fallback icons.</p>")
.arg(PROJECT_HOMEPAGE_URL));
QObject::connect(about->button(QMessageBox::Close), &QAbstractButton::clicked, about, &QObject::deleteLater);
QObject::connect(qApp, &QApplication::aboutToQuit, about, &QObject::deleteLater);
about->show();
Expand Down
20 changes: 14 additions & 6 deletions src/form/bootentryform.ui
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@
<string/>
</property>
<property name="icon">
<iconset theme="up"></iconset>
<iconset theme="up">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="default">
<bool>false</bool>
Expand Down Expand Up @@ -185,7 +186,8 @@
<string/>
</property>
<property name="icon">
<iconset theme="down"></iconset>
<iconset theme="down">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="default">
<bool>false</bool>
Expand Down Expand Up @@ -216,7 +218,8 @@
<string/>
</property>
<property name="icon">
<iconset theme="remove"></iconset>
<iconset theme="remove">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="default">
<bool>false</bool>
Expand Down Expand Up @@ -247,7 +250,8 @@
<string/>
</property>
<property name="icon">
<iconset theme="edit"></iconset>
<iconset theme="edit">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="default">
<bool>false</bool>
Expand Down Expand Up @@ -278,7 +282,8 @@
<string/>
</property>
<property name="icon">
<iconset theme="add"></iconset>
<iconset theme="add">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="default">
<bool>false</bool>
Expand Down Expand Up @@ -530,7 +535,10 @@
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Order&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="inputMask">
<string>&gt;\0\xHHHH;_</string>
<string notr="true">&gt;\0\xHHHH;_</string>
</property>
<property name="text">
<string notr="true">0x</string>
</property>
</widget>
</item>
Expand Down
Loading

0 comments on commit 482de3e

Please sign in to comment.