Skip to content

Commit f07d180

Browse files
authored
Merge pull request #92 from yanagiragi/58-add-window-title-and-icon
Support custom icon and title of the window
2 parents 8bb2420 + b89bb47 commit f07d180

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

cpp/binary/viewer/CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ set(CMAKE_AUTOMOC ON)
1010
set(CMAKE_AUTORCC ON)
1111
set(CMAKE_AUTOUIC ON)
1212

13+
# get the root of the modmdesh project
14+
set(PROJECT_ROOT_DIR ${PROJECT_SOURCE_DIR}/../../../)
15+
1316
if(NOT DEFINED INSTALL_VIEWERDIR)
14-
set(INSTALL_VIEWERDIR "viewer")
17+
set(INSTALL_VIEWERDIR "viewer")
1518
endif()
1619

1720
find_package(Qt6 COMPONENTS Core)
@@ -31,6 +34,13 @@ qt_add_executable(
3134
${MODMESH_SOURCES} # FIXME: This duplicates in two binaries and will cause duplicated symbols.
3235
)
3336

37+
qt_add_resources(viewer "app_icon"
38+
PREFIX "/"
39+
BASE ${PROJECT_ROOT_DIR}/resources/viewer
40+
FILES
41+
${PROJECT_ROOT_DIR}/resources/viewer/icon.ico
42+
)
43+
3444
if(HIDE_SYMBOL)
3545
set_target_properties(viewer PROPERTIES CXX_VISIBILITY_PRESET "hidden")
3646
else()

cpp/modmesh/view/RApplication.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ RApplication::RApplication(int & argc, char ** argv)
7373
menuBar->addMenu(fileMenu);
7474
m_main->setMenuBar(menuBar);
7575

76+
// Setup main window
77+
m_main->setWindowTitle(m_title);
78+
m_main->setWindowIcon(QIcon(m_iconFilePath));
79+
7680
// Show main window.
7781
m_main->show();
7882
}

cpp/modmesh/view/RApplication.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ class RApplication
5555

5656
RMainWindow * m_main = nullptr;
5757

58+
const QString m_title = "Modmesh Viewer";
59+
const QString m_iconFilePath = ":/icon.ico";
5860
}; /* end class RApplication */
5961

6062
} /* end namespace modmesh */

resources/viewer/icon.ico

1.12 KB
Binary file not shown.

0 commit comments

Comments
 (0)