mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
Embed translations and icons for mapeditor
This commit is contained in:
parent
2288acef69
commit
d8c4d3654f
@ -107,24 +107,59 @@ set(editor_FORMS
|
||||
inspector/portraitwidget.ui
|
||||
)
|
||||
|
||||
set(editor_TS
|
||||
translation/chinese.ts
|
||||
translation/czech.ts
|
||||
translation/english.ts
|
||||
translation/french.ts
|
||||
translation/german.ts
|
||||
translation/polish.ts
|
||||
translation/portuguese.ts
|
||||
translation/russian.ts
|
||||
translation/spanish.ts
|
||||
translation/ukrainian.ts
|
||||
translation/vietnamese.ts
|
||||
set(editor_RESOURCES
|
||||
resources.qrc
|
||||
)
|
||||
|
||||
assign_source_group(${editor_SRCS} ${editor_HEADERS} mapeditor.rc)
|
||||
set(translationsDir "translation")
|
||||
set(editor_TS
|
||||
"${translationsDir}/chinese.ts"
|
||||
"${translationsDir}/czech.ts"
|
||||
"${translationsDir}/english.ts"
|
||||
"${translationsDir}/french.ts"
|
||||
"${translationsDir}/german.ts"
|
||||
"${translationsDir}/polish.ts"
|
||||
"${translationsDir}/portuguese.ts"
|
||||
"${translationsDir}/russian.ts"
|
||||
"${translationsDir}/spanish.ts"
|
||||
"${translationsDir}/ukrainian.ts"
|
||||
"${translationsDir}/vietnamese.ts"
|
||||
)
|
||||
if(ENABLE_TRANSLATIONS)
|
||||
if(TARGET Qt5::Core)
|
||||
set_source_files_properties(${editor_TS} PROPERTIES OUTPUT_LOCATION translation)
|
||||
qt5_add_translation(editor_QM ${editor_TS})
|
||||
|
||||
# Tell CMake to run moc when necessary:
|
||||
set(translationsResource "${CMAKE_CURRENT_BINARY_DIR}/translations.qrc")
|
||||
list(APPEND editor_RESOURCES "${translationsResource}")
|
||||
|
||||
set(rccQmFiles "")
|
||||
foreach(qmFile ${editor_QM})
|
||||
string(APPEND rccQmFiles "<file>${qmFile}</file>\n")
|
||||
endforeach()
|
||||
file(WRITE "${translationsResource}"
|
||||
"<!DOCTYPE RCC>
|
||||
<RCC version=\"1.0\">
|
||||
<qresource prefix=\"/\">
|
||||
${rccQmFiles}
|
||||
</qresource>
|
||||
</RCC>"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
set(editor_ICON mapeditor.rc)
|
||||
endif()
|
||||
|
||||
assign_source_group(${editor_SRCS} ${editor_HEADERS} ${editor_RESOURCES} ${editor_TS} ${editor_ICON})
|
||||
|
||||
# TODO: enabling AUTORCC breaks msvc build on CI
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
if(NOT (MSVC AND "$ENV{GITHUB_ACTIONS}" STREQUAL true))
|
||||
set(CMAKE_AUTORCC ON)
|
||||
endif()
|
||||
|
||||
if(POLICY CMP0071)
|
||||
cmake_policy(SET CMP0071 NEW)
|
||||
@ -134,33 +169,28 @@ endif()
|
||||
# to always look for includes there:
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
if(TARGET Qt6::Core)
|
||||
qt_wrap_ui(editor_UI_HEADERS ${editor_FORMS})
|
||||
if(ENABLE_SINGLE_APP_BUILD OR ANDROID)
|
||||
add_library(vcmieditor OBJECT ${editor_QM})
|
||||
else()
|
||||
qt5_wrap_ui(editor_UI_HEADERS ${editor_FORMS})
|
||||
if(ENABLE_TRANSLATIONS)
|
||||
set_source_files_properties(${editor_TS} PROPERTIES OUTPUT_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/translation)
|
||||
qt5_add_translation( editor_QM ${editor_TS} )
|
||||
endif()
|
||||
add_executable(vcmieditor WIN32 ${editor_QM} ${editor_SRCS} ${editor_HEADERS} ${editor_UI_HEADERS} ${editor_ICON})
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
set(editor_ICON mapeditor.rc)
|
||||
endif()
|
||||
|
||||
add_executable(vcmieditor WIN32 ${editor_QM} ${editor_SRCS} ${editor_HEADERS} ${editor_UI_HEADERS} ${editor_ICON})
|
||||
|
||||
if(TARGET Qt6::Core)
|
||||
if(ENABLE_TRANSLATIONS)
|
||||
set_source_files_properties(${editor_TS} PROPERTIES OUTPUT_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/translation)
|
||||
if(ENABLE_TRANSLATIONS)
|
||||
if(TARGET Qt6::Core)
|
||||
qt_add_translations(vcmieditor
|
||||
TS_FILES ${editor_TS}
|
||||
QM_FILES_OUTPUT_VARIABLE editor_QM
|
||||
RESOURCE_PREFIX "/${translationsDir}"
|
||||
INCLUDE_DIRECTORIES
|
||||
${CMAKE_CURRENT_BINARY_DIR})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_sources(vcmieditor PRIVATE
|
||||
${editor_SRCS}
|
||||
${editor_HEADERS}
|
||||
${editor_RESOURCES}
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
set_target_properties(vcmieditor
|
||||
PROPERTIES
|
||||
@ -189,23 +219,9 @@ target_include_directories(vcmieditor
|
||||
vcmi_set_output_dir(vcmieditor "")
|
||||
enable_pch(vcmieditor)
|
||||
|
||||
# Copy to build directory for easier debugging
|
||||
add_custom_command(TARGET vcmieditor POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/mapeditor/
|
||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_SOURCE_DIR}/cmake_modules/create_link.cmake ${CMAKE_SOURCE_DIR}/mapeditor/icons ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/mapeditor/icons
|
||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_SOURCE_DIR}/cmake_modules/create_link.cmake ${CMAKE_CURRENT_BINARY_DIR}/translation ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/mapeditor/translation
|
||||
)
|
||||
|
||||
install(TARGETS vcmieditor DESTINATION ${BIN_DIR})
|
||||
# copy whole directory
|
||||
install(DIRECTORY icons DESTINATION ${DATA_DIR}/mapeditor)
|
||||
install(FILES ${editor_QM} DESTINATION ${DATA_DIR}/mapeditor/translation)
|
||||
# Install icons and desktop file on Linux
|
||||
|
||||
# Install desktop file on Linux
|
||||
if(NOT WIN32 AND NOT APPLE)
|
||||
install(FILES "vcmieditor.desktop" DESTINATION share/applications)
|
||||
install(FILES "icons/mapeditor.32x32.png" DESTINATION share/icons/hicolor/32x32/apps RENAME vcmieditor.png)
|
||||
install(FILES "icons/mapeditor.48x48.png" DESTINATION share/icons/hicolor/48x48/apps RENAME vcmieditor.png)
|
||||
install(FILES "icons/mapeditor.64x64.png" DESTINATION share/icons/hicolor/64x64/apps RENAME vcmieditor.png)
|
||||
install(FILES "icons/mapeditor.128x128.png" DESTINATION share/icons/hicolor/128x128/apps RENAME vcmieditor.png)
|
||||
install(FILES "icons/mapeditor.256x256.png" DESTINATION share/icons/hicolor/256x256/apps RENAME vcmieditor.png)
|
||||
endif()
|
||||
|
@ -163,13 +163,9 @@ MainWindow::MainWindow(QWidget* parent) :
|
||||
// Set current working dir to executable folder.
|
||||
// This is important on Mac for relative paths to work inside DMG.
|
||||
QDir::setCurrent(QApplication::applicationDirPath());
|
||||
|
||||
for(auto & string : VCMIDirs::get().dataPaths())
|
||||
QDir::addSearchPath("icons", pathToQString(string / "mapeditor" / "icons"));
|
||||
QDir::addSearchPath("icons", pathToQString(VCMIDirs::get().userDataPath() / "mapeditor" / "icons"));
|
||||
|
||||
|
||||
new QShortcut(QKeySequence("Backspace"), this, SLOT(on_actionErase_triggered()));
|
||||
|
||||
|
||||
ExtractionOptions extractionOptions;
|
||||
parseCommandLine(extractionOptions);
|
||||
|
||||
@ -206,6 +202,8 @@ MainWindow::MainWindow(QWidget* parent) :
|
||||
loadTranslation();
|
||||
|
||||
ui->setupUi(this);
|
||||
setWindowIcon(QIcon{":/icons/menu-game.png"});
|
||||
|
||||
loadUserSettings(); //For example window size
|
||||
setTitle();
|
||||
|
||||
|
@ -511,10 +511,6 @@
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:brush-1.png</normaloff>icons:brush-1.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
@ -558,10 +554,6 @@
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:brush-2.png</normaloff>icons:brush-2.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
@ -605,10 +597,6 @@
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:brush-4.png</normaloff>icons:brush-4.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
@ -652,10 +640,6 @@
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:brush-3.png</normaloff>icons:brush-3.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@ -697,10 +681,6 @@
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:brush-7.png</normaloff>icons:brush-7.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@ -732,10 +712,6 @@
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:brush-5.png</normaloff>icons:brush-5.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@ -770,10 +746,6 @@
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:brush-6.png</normaloff>icons:brush-6.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@ -808,10 +780,6 @@
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:brush-0.png</normaloff>icons:brush-0.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@ -1044,10 +1012,6 @@
|
||||
</widget>
|
||||
</widget>
|
||||
<action name="actionOpen">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:document-open.png</normaloff>icons:document-open.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open</string>
|
||||
</property>
|
||||
@ -1056,10 +1020,6 @@
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSave">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:document-save.png</normaloff>icons:document-save.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
@ -1068,10 +1028,6 @@
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionNew">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:document-new.png</normaloff>icons:document-new.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>New</string>
|
||||
</property>
|
||||
@ -1088,10 +1044,6 @@
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionLevel">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:toggle-underground.png</normaloff>icons:toggle-underground.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>U/G</string>
|
||||
</property>
|
||||
@ -1106,10 +1058,6 @@
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:toggle-pass.png</normaloff>icons:toggle-pass.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Pass</string>
|
||||
</property>
|
||||
@ -1118,10 +1066,6 @@
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCut">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:edit-cut.png</normaloff>icons:edit-cut.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Cut</string>
|
||||
</property>
|
||||
@ -1130,10 +1074,6 @@
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCopy">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:edit-copy.png</normaloff>icons:edit-copy.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Copy</string>
|
||||
</property>
|
||||
@ -1142,10 +1082,6 @@
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionPaste">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:edit-paste.png</normaloff>icons:edit-paste.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Paste</string>
|
||||
</property>
|
||||
@ -1154,10 +1090,6 @@
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionFill">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:fill-obstacles.png</normaloff>icons:fill-obstacles.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Fill</string>
|
||||
</property>
|
||||
@ -1172,10 +1104,6 @@
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:toggle-grid.png</normaloff>icons:toggle-grid.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Grid</string>
|
||||
</property>
|
||||
@ -1212,10 +1140,6 @@
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:edit-undo.png</normaloff>icons:edit-undo.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Undo</string>
|
||||
</property>
|
||||
@ -1233,10 +1157,6 @@
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:edit-redo.png</normaloff>icons:edit-redo.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Redo</string>
|
||||
</property>
|
||||
@ -1251,10 +1171,6 @@
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:edit-clear.png</normaloff>icons:edit-clear.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Erase</string>
|
||||
</property>
|
||||
@ -1400,10 +1316,6 @@
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:translations.png</normaloff>icons:translations.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Translations</string>
|
||||
</property>
|
||||
@ -1420,10 +1332,6 @@
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionLock">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:lock-closed.png</normaloff>icons:lock-closed.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Lock</string>
|
||||
</property>
|
||||
@ -1435,10 +1343,6 @@
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionUnlock">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:lock-open.png</normaloff>icons:lock-open.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Unlock</string>
|
||||
</property>
|
||||
@ -1450,10 +1354,6 @@
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionZoom_in">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:zoom_plus.png</normaloff>icons:zoom_plus.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Zoom in</string>
|
||||
</property>
|
||||
@ -1462,10 +1362,6 @@
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionZoom_out">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:zoom_minus.png</normaloff>icons:zoom_minus.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Zoom out</string>
|
||||
</property>
|
||||
@ -1474,10 +1370,6 @@
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionZoom_reset">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:zoom_zero.png</normaloff>icons:zoom_zero.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Zoom reset</string>
|
||||
</property>
|
||||
|
45
mapeditor/resources.qrc
Normal file
45
mapeditor/resources.qrc
Normal file
@ -0,0 +1,45 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>icons/toggle-grid.png</file>
|
||||
<file>icons/lock-open.png</file>
|
||||
<file>icons/brush-3.png</file>
|
||||
<file>icons/mod-download.png</file>
|
||||
<file>icons/toggle-pass.png</file>
|
||||
<file>icons/mapeditor.256x256.png</file>
|
||||
<file>icons/mapeditor.64x64.png</file>
|
||||
<file>icons/edit-clear.png</file>
|
||||
<file>icons/document-open.png</file>
|
||||
<file>icons/brush-5.png</file>
|
||||
<file>icons/document-new.png</file>
|
||||
<file>icons/mapeditor.128x128.png</file>
|
||||
<file>icons/lock-closed.png</file>
|
||||
<file>icons/toggle-underground.png</file>
|
||||
<file>icons/zoom_zero.png</file>
|
||||
<file>icons/brush-1.png</file>
|
||||
<file>icons/edit-redo.png</file>
|
||||
<file>icons/edit-copy.png</file>
|
||||
<file>icons/edit-undo.png</file>
|
||||
<file>icons/mapeditor.32x32.png</file>
|
||||
<file>icons/brush-6.png</file>
|
||||
<file>icons/edit-cut.png</file>
|
||||
<file>icons/menu-settings.png</file>
|
||||
<file>icons/fill-obstacles.png</file>
|
||||
<file>icons/mod-delete.png</file>
|
||||
<file>icons/mod-enabled.png</file>
|
||||
<file>icons/mod-disabled.png</file>
|
||||
<file>icons/menu-game.png</file>
|
||||
<file>icons/mod-update.png</file>
|
||||
<file>icons/brush-7.png</file>
|
||||
<file>icons/zoom_minus.png</file>
|
||||
<file>icons/zoom_base.png</file>
|
||||
<file>icons/menu-mods.png</file>
|
||||
<file>icons/edit-paste.png</file>
|
||||
<file>icons/translations.png</file>
|
||||
<file>icons/zoom_plus.png</file>
|
||||
<file>icons/brush-4.png</file>
|
||||
<file>icons/mapeditor.48x48.png</file>
|
||||
<file>icons/document-save.png</file>
|
||||
<file>icons/brush-2.png</file>
|
||||
<file>icons/brush-0.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
@ -29,7 +29,7 @@ Validator::Validator(const CMap * map, QWidget *parent) :
|
||||
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
std::array<QString, 2> icons{"mapeditor/icons/mod-update.png", "mapeditor/icons/mod-delete.png"};
|
||||
std::array<QString, 2> icons{":/icons/mod-update.png", ":/icons/mod-delete.png"};
|
||||
|
||||
for(auto & issue : Validator::validate(map))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user