### Install DtkWidget Source: https://github.com/linuxdeepin/dtkwidget/blob/master/README.md Installs the compiled DtkWidget components to the system. This command should be run with superuser privileges. ```bash cd build sudo make install ``` -------------------------------- ### Build and Install DtkWidget Designer Plugin Source: https://github.com/linuxdeepin/dtkwidget/blob/master/README.md Configures, builds, and installs the DtkWidget designer plugin. This process involves using CMake for configuration and Make for building and installation. ```bash cmake ./plugin/dtkuiplugin -B build -DINSTALL_PLUGIN=ON -DCMAKE_INSTALL_PREFIX=/usr cmake --build build -j$(nproc) cd build sudo make install ``` -------------------------------- ### Install Qt Tools for Designer Plugin Source: https://github.com/linuxdeepin/dtkwidget/blob/master/README.md Installs the Qt tools required for the designer plugin. This is a prerequisite for building and using the plugin. ```bash sudo apt install qttools5-dev ``` -------------------------------- ### Install Build Dependencies Source: https://github.com/linuxdeepin/dtkwidget/blob/master/README.md Installs necessary build dependencies for the project using apt. Ensure you have the correct package lists updated. ```bash sudo apt build-dep ./ ``` -------------------------------- ### Define Plugin Name and Find Qt Source: https://github.com/linuxdeepin/dtkwidget/blob/master/examples/PrintPreviewSettingsPlugin/CMakeLists.txt Sets the plugin name and finds the required Qt components. Ensure Qt is installed and discoverable by CMake. ```cmake set(PLUGIN_NAME PrintPreviewSettingsPlugin) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core) ``` -------------------------------- ### Get Application Menu Source: https://github.com/linuxdeepin/dtkwidget/blob/master/docs/widgets/dtitlebar.zh_CN.dox Retrieves the application query menu associated with the title bar. If no menu is set, it might return an empty menu, especially if Dtk::Widget::DApplication is used, which typically creates a program menu automatically. ```APIDOC ## QMenu Dtk::Widget::DTitlebar::menu() ### Description Gets the application query menu associated with the title bar. Returns an empty menu if none is set, but usually a program menu is automatically created when using Dtk::Widget::DApplication. ### Return Value QMenu* - The associated application menu, or an empty menu if none is set. ``` -------------------------------- ### Get Custom Widget Source: https://github.com/linuxdeepin/dtkwidget/blob/master/docs/widgets/dtitlebar.zh_CN.dox Retrieves the custom widget bound to the title bar. This allows for displaying complex composite widgets within the title bar. ```APIDOC ## QWidget *Dtk::Widget::DTitlebar::customWidget() const ### Description Gets the custom widget bound to the title bar. This allows for displaying complex composite widgets within the title bar. ### Return Value QWidget* - The custom widget. ``` -------------------------------- ### Get Button Area Width Source: https://github.com/linuxdeepin/dtkwidget/blob/master/docs/widgets/dtitlebar.zh_CN.dox Returns the width of the button area, which can be useful for manually positioning custom widgets. ```APIDOC ## int Dtk::Widget::DTitlebar::buttonAreaWidth() const ### Description Returns the width of the button area, useful for manual positioning of custom widgets. ### Return Value int - The width of the button area. ``` -------------------------------- ### Get Disabled Flags Source: https://github.com/linuxdeepin/dtkwidget/blob/master/docs/widgets/dtitlebar.zh_CN.dox Retrieves the current window flags for disabled buttons. ```APIDOC ## Qt::WindowFlags Dtk::Widget::DTitlebar::disableFlags() const ### Description Retrieves the current window flags for disabled buttons. ### Return Value Qt::WindowFlags - The window flags for disabled buttons. ``` -------------------------------- ### Build DtkWidget from Source Source: https://github.com/linuxdeepin/dtkwidget/blob/master/README.md Configures the build process for DtkWidget using CMake. This command prepares the project for compilation. ```bash cmake -B build ``` -------------------------------- ### Basic DTitlebar Configuration Source: https://github.com/linuxdeepin/dtkwidget/blob/master/docs/widgets/dtitlebar.zh_CN.dox Demonstrates how to access and modify the default DTitlebar of a DMainWindow. It shows how to add menus, separators, actions, and customize the visibility and state of built-in menus like 'File' and 'Theme Switch'. ```cpp #include #include #include #include #include DWIDGET_USE_NAMESPACE //使用DTK widget命名空间 int main(int argc, char *argv[]){ DApplication app(argc, argv); DMainWindow win; win.resize(400,250); DTitlebar *bar = win.titlebar(); //窗口会自带一个titlebar,直接调用 DMenu *menu = bar->menu()->addMenu("文件"); //新建一个文件菜单,并用一个 menu 指针来接收这个菜单并管理 bar->menu()->addSeparator(); //添加一个分隔符 menu->addAction("新建"); //menu菜单下添加可选项 “新建” menu->addAction("打开"); menu->addAction("关闭"); menu->setIcon(menu->style()->standardIcon(DStyle::SP_DirIcon)); //给文件菜单添加一个自带图标 bar->setQuitMenuDisabled(true); //设置退出菜单为不可用 bar->setSwitchThemeMenuVisible(false); //设置主题更换菜单为不可见 win.show(); return app.exec(); } ``` -------------------------------- ### Show Application Menu Source: https://github.com/linuxdeepin/dtkwidget/blob/master/docs/widgets/dtitlebar.zh_CN.dox Displays the application menu. This function is used to show the menu, potentially with options for centering the position. ```APIDOC ## void Dtk::Widget::DTitlebar::showMenu(QWidget *w, bool fixCenterPos) ### Description Displays the application menu. This function is used to show the menu, potentially with options for centering the position. ### Parameters * w (QWidget *) - The widget to be displayed. * fixCenterPos (bool) - Whether to automatically adjust the position to keep the widget centered. ``` -------------------------------- ### Link Libraries for the Executable Source: https://github.com/linuxdeepin/dtkwidget/blob/master/tests/CMakeLists.txt Links a comprehensive set of Qt libraries, Dtk libraries, testing frameworks, and system libraries to the main executable. ```cmake target_link_libraries(${BINNAME} PRIVATE Qt${QT_VERSION_MAJOR}::Test Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::WidgetsPrivate Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::GuiPrivate Qt${QT_VERSION_MAJOR}::DBus Qt${QT_VERSION_MAJOR}::PrintSupport Qt${QT_VERSION_MAJOR}::PrintSupportPrivate Qt${QT_VERSION_MAJOR}::Concurrent Qt${QT_VERSION_MAJOR}::Network PkgConfig::StartupNotification PkgConfig::Xext PkgConfig::Xi PkgConfig::X11 PkgConfig::XcbUtil Dtk${DTK_NAME_SUFFIX}::Gui Dtk${DTK_NAME_SUFFIX}::Core GTest::GTest gmock pthread m gcov ) ``` -------------------------------- ### Set Application Menu Source: https://github.com/linuxdeepin/dtkwidget/blob/master/docs/widgets/dtitlebar.zh_CN.dox Sets a custom application menu for the title bar. ```APIDOC ## void Dtk::Widget::DTitlebar::setMenu(QMenu *menu) ### Description Sets a custom application menu for the title bar. ### Parameters * menu (QMenu *) - The menu to be set. ``` -------------------------------- ### Define Executable and Source Files Source: https://github.com/linuxdeepin/dtkwidget/blob/master/tests/CMakeLists.txt Defines the main executable for the project and lists all its source files, including C++ files, resources, utilities, widgets, widget tests, and public headers. ```cmake add_executable(${BINNAME} main.cpp ${RESCOUCES} ${UTIL} ${WIDGETS} ${WIDGET_TEST} ${PUBLIC_HEADERS} ) ``` -------------------------------- ### Set Include Directories Source: https://github.com/linuxdeepin/dtkwidget/blob/master/tests/CMakeLists.txt Specifies the private include directories for the project, pointing to various widget, utility, and global header locations. ```cmake target_include_directories(${BINNAME} PRIVATE ${PROJECT_SOURCE_DIR}/src/widgets ${PROJECT_SOURCE_DIR}/include/DWidget ${PROJECT_SOURCE_DIR}/include/util ${PROJECT_SOURCE_DIR}/include/widgets ${PROJECT_SOURCE_DIR}/include/global ${PROJECT_SOURCE_DIR}/include ${CONFIG_INCLUDE} ) ``` -------------------------------- ### Link Additional Libraries for Qt5 Source: https://github.com/linuxdeepin/dtkwidget/blob/master/tests/CMakeLists.txt Conditionally links additional libraries, PkgConfig::QGSettings and Qt5::X11Extras, when the Qt major version is 5. ```cmake if("${QT_VERSION_MAJOR}" STREQUAL "5") target_link_libraries(${BINNAME} PRIVATE PkgConfig::QGSettings Qt5::X11Extras ) endif() ``` -------------------------------- ### Set Switch Theme Menu Visible Source: https://github.com/linuxdeepin/dtkwidget/blob/master/docs/widgets/dtitlebar.zh_CN.dox Sets the visibility of the switch theme menu option in the title bar. ```APIDOC ## void Dtk::Widget::DTitlebar::setSwitchThemeMenuVisible(bool visible) ### Description Sets the visibility of the switch theme menu option in the title bar. ### Parameters * visible (bool) - True to make the switch theme menu visible, false to hide it. ``` -------------------------------- ### Set Menu Visibility Source: https://github.com/linuxdeepin/dtkwidget/blob/master/docs/widgets/dtitlebar.zh_CN.dox Sets the visibility of the menu button in the title bar. ```APIDOC ## void Dtk::Widget::DTitlebar::setMenuVisible(bool visible) ### Description Sets the visibility of the menu button in the title bar. ### Parameters * visible (bool) - True to make the menu visible, false to hide it. ``` -------------------------------- ### Customizing Window Button Visibility Source: https://github.com/linuxdeepin/dtkwidget/blob/master/docs/widgets/dtitlebar.zh_CN.dox Illustrates how to control which standard window buttons (minimize, maximize, close) are displayed on the title bar. This is achieved by setting window flags, allowing for scenarios where certain buttons should be hidden, such as the close button when preventing accidental exits. ```cpp win.setWindowFlags(Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint); ``` -------------------------------- ### Add Shared Library for Plugin Source: https://github.com/linuxdeepin/dtkwidget/blob/master/examples/PrintPreviewSettingsPlugin/CMakeLists.txt Creates a shared library for the plugin using its source files. This is a standard way to build plugins in C++. ```cmake add_library(${PLUGIN_NAME} SHARED settingsplugin.h settingsplugin.cpp ) ``` -------------------------------- ### Set Compile Options for GNU Source: https://github.com/linuxdeepin/dtkwidget/blob/master/tests/CMakeLists.txt Applies specific compile options for GNU compiler to enable profiling and coverage. ```cmake if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") target_compile_options(${BINNAME} PRIVATE -fprofile-arcs -ftest-coverage) endif() ``` -------------------------------- ### Set Title Text Source: https://github.com/linuxdeepin/dtkwidget/blob/master/docs/widgets/dtitlebar.zh_CN.dox Sets the text displayed in the title bar. ```APIDOC ## void Dtk::Widget::DTitlebar::setTitle(const QString &title) ### Description Sets the text for the title bar. ### Parameters * title (const QString &) - The text to set. ``` -------------------------------- ### Set Compile Options for Clang Source: https://github.com/linuxdeepin/dtkwidget/blob/master/tests/CMakeLists.txt Applies specific compile options for Clang compiler to enable profiling and coverage. ```cmake if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") target_compile_options(${BINNAME} PRIVATE -fprofile-instr-generate -ftest-coverage) endif() ``` -------------------------------- ### Set General Compile Options Source: https://github.com/linuxdeepin/dtkwidget/blob/master/tests/CMakeLists.txt Sets a general compile option to disable access control. ```cmake target_compile_options(${BINNAME} PRIVATE -fno-access-control) ``` -------------------------------- ### Set Quit Menu Visibility Source: https://github.com/linuxdeepin/dtkwidget/blob/master/docs/widgets/dtitlebar.zh_CN.dox Sets the visibility of the quit menu option in the title bar. ```APIDOC ## void Dtk::Widget::DTitlebar::setQuitMenuVisible(bool visible) ### Description Sets the visibility of the quit menu option in the title bar. ### Parameters * visible (bool) - True to make the quit menu visible, false to hide it. ``` -------------------------------- ### Add Test Case Source: https://github.com/linuxdeepin/dtkwidget/blob/master/tests/CMakeLists.txt Adds a test case to the build system named after the executable, which will run the executable itself. ```cmake add_test(NAME ${BINNAME} COMMAND ${BINNAME}) ``` -------------------------------- ### Configure DTK SVG Compiler Executable Source: https://github.com/linuxdeepin/dtkwidget/blob/master/tools/svgc/CMakeLists.txt Defines the target name and executable name for the DTK SVG Compiler tool. It also finds necessary packages like Dtk and Qt, adds the main source file, and links required libraries. ```cmake set(TARGET_NAME dtk${DTK_NAME_SUFFIX}-svgc) set(BIN_NAME ${TARGET_NAME}) find_package(Dtk${DTK_NAME_SUFFIX} REQUIRED COMPONENTS Gui) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Svg) add_executable( ${BIN_NAME} main.cpp ) target_link_libraries( ${BIN_NAME} PRIVATE Qt${QT_VERSION_MAJOR}::Svg Dtk${DTK_NAME_SUFFIX}::Gui ) install(TARGETS ${BIN_NAME} DESTINATION "${TOOL_INSTALL_DIR}") ``` -------------------------------- ### Compile DtkWidget Source: https://github.com/linuxdeepin/dtkwidget/blob/master/README.md Compiles the DtkWidget project using the build system generated by CMake. The -j flag allows for parallel compilation. ```bash cmake --build build -j$(nproc) ``` -------------------------------- ### Is Switch Theme Menu Visible Source: https://github.com/linuxdeepin/dtkwidget/blob/master/docs/widgets/dtitlebar.zh_CN.dox Checks if the switch theme menu option in the title bar is visible. ```APIDOC ## bool Dtk::Widget::DTitlebar::switchThemeMenuIsVisible() const ### Description Checks if the switch theme menu option in the title bar is visible. ### Return Value bool - True if the switch theme menu is visible, false otherwise. ``` -------------------------------- ### Set Titlebar Icon Source: https://github.com/linuxdeepin/dtkwidget/blob/master/docs/widgets/dtitlebar.zh_CN.dox Sets the icon displayed in the title bar. ```APIDOC ## void Dtk::Widget::DTitlebar::setIcon(const QIcon &icon) ### Description Sets the icon for the title bar. ### Parameters * icon (const QIcon &) - The icon to set. ``` -------------------------------- ### Set Compile Definitions Source: https://github.com/linuxdeepin/dtkwidget/blob/master/tests/CMakeLists.txt Sets private compile definitions for the executable, including API freezing status, multimedia support, translation directory, and deprecation handling. ```cmake target_compile_definitions(${BINNAME} PRIVATE SN_API_NOT_YET_FROZEN DTK_NO_MULTIMEDIA DWIDGET_TRANSLATIONS_DIR="dtk${PROJECT_VERSION_MAJOR}/DWidget/translations" D_IGNORE_DEPRECATIONS ) ``` -------------------------------- ### DTitlebar Constructor Source: https://github.com/linuxdeepin/dtkwidget/blob/master/docs/widgets/dtitlebar.zh_CN.dox Constructor for DTitlebar. Creates a DTitlebar object with default window buttons. ```APIDOC ## Dtk::Widget::DTitlebar::DTitlebar(QWidget *parent) ### Description Constructor for DTitlebar. Creates a DTitlebar object with default window buttons. ### Parameters * parent (QWidget *) - Parent widget pointer. ``` -------------------------------- ### Set Background Transparency Source: https://github.com/linuxdeepin/dtkwidget/blob/master/docs/widgets/dtitlebar.zh_CN.dox Configures whether the title bar's background is transparent. When transparent, the title bar overlays the content of the widget below it. ```APIDOC ## void Dtk::Widget::DTitlebar::setBackgroundTransparent(bool transparent) ### Description Sets whether the title bar background is transparent. When transparent, the title bar directly overlays the underlying widget. ### Parameters * transparent (bool) - True to make the background transparent, false otherwise. ``` -------------------------------- ### Set Embed Mode Source: https://github.com/linuxdeepin/dtkwidget/blob/master/docs/widgets/dtitlebar.zh_CN.dox Sets the title bar to embed mode, which replaces the system title bar. This is useful for platforms that do not support dxcb. ```APIDOC ## void Dtk::Widget::DTitlebar::setEmbedMode(bool visible) ### Description Sets the title bar to embed mode, replacing the system title bar. This is used for platforms that do not support dxcb. ### Parameters * visible (bool) - True to replace the system title bar, false to hide the system title bar. ``` -------------------------------- ### Is Menu Visible Source: https://github.com/linuxdeepin/dtkwidget/blob/master/docs/widgets/dtitlebar.zh_CN.dox Checks if the menu button in the title bar is currently visible. ```APIDOC ## bool Dtk::Widget::DTitlebar::menuIsVisible() const ### Description Checks if the menu button in the title bar is visible. ### Return Value bool - True if the menu is visible, false otherwise. ``` -------------------------------- ### Set Titlebar Height Source: https://github.com/linuxdeepin/dtkwidget/blob/master/docs/widgets/dtitlebar.zh_CN.dox Sets the height of the title bar. The default height is 50. ```APIDOC ## void Dtk::Widget::DTitlebar::setFixedHeight(int h) ### Description Sets the height of the title bar. The default height is 50. ### Parameters * h (int) - The height to set. ``` -------------------------------- ### Is Quit Menu Disabled Source: https://github.com/linuxdeepin/dtkwidget/blob/master/docs/widgets/dtitlebar.zh_CN.dox Checks if the quit menu option in the title bar is disabled. ```APIDOC ## bool Dtk::Widget::DTitlebar::quitMenuIsDisabled() const ### Description Checks if the quit menu option in the title bar is disabled. ### Return Value bool - True if the quit menu is disabled, false otherwise. ``` -------------------------------- ### Link Plugin Library Source: https://github.com/linuxdeepin/dtkwidget/blob/master/examples/PrintPreviewSettingsPlugin/CMakeLists.txt Links the plugin's shared library against other necessary libraries. Use 'PRIVATE' to ensure symbols are not exported unnecessarily. ```cmake target_link_libraries(${PLUGIN_NAME} PRIVATE ${LIB_NAME} ) ``` -------------------------------- ### Is Separator Visible Source: https://github.com/linuxdeepin/dtkwidget/blob/master/docs/widgets/dtitlebar.zh_CN.dox Checks if the separator line below the menu is currently visible. ```APIDOC ## bool Dtk::Widget::DTitlebar::separatorVisible() const ### Description Checks if the separator line below the menu is currently visible. ### Return Value bool - True if the separator is visible, false otherwise. ``` -------------------------------- ### Set Separator Visibility Source: https://github.com/linuxdeepin/dtkwidget/blob/master/docs/widgets/dtitlebar.zh_CN.dox Controls the visibility of the separator line below the menu. The separator is visible by default. ```APIDOC ## void Dtk::Widget::DTitlebar::setSeparatorVisible(bool visible) ### Description Sets whether the separator line below the menu is visible. By default, it is visible. ### Parameters * visible (bool) - True to make the separator visible, false to hide it. ``` -------------------------------- ### Set Address Sanitizer for Debug Builds Source: https://github.com/linuxdeepin/dtkwidget/blob/master/tests/CMakeLists.txt Enables the address sanitizer for compile and link options when the build type is Debug. ```cmake if (CMAKE_BUILD_TYPE STREQUAL "Debug") target_compile_options(${BINNAME} PRIVATE -fsanitize=address) target_link_options(${BINNAME} PRIVATE -fsanitize=address) endif() ``` -------------------------------- ### Set Menu Disabled Source: https://github.com/linuxdeepin/dtkwidget/blob/master/docs/widgets/dtitlebar.zh_CN.dox Disables the menu button in the title bar, preventing user interaction. ```APIDOC ## void Dtk::Widget::DTitlebar::setMenuDisabled(bool disabled) ### Description Disables the menu button in the title bar. ### Parameters * disabled (bool) - True to disable the menu, false to enable it. ``` -------------------------------- ### Set Auto Hide on Fullscreen Source: https://github.com/linuxdeepin/dtkwidget/blob/master/docs/widgets/dtitlebar.zh_CN.dox Configures whether the title bar should automatically hide when the application is in fullscreen mode. ```APIDOC ## void Dtk::Widget::DTitlebar::setAutoHideOnFullscreen(bool autohide) ### Description Sets whether the title bar should automatically hide in fullscreen mode. ### Parameters * autohide (bool) - True to enable auto-hide, false to disable. ``` -------------------------------- ### Set Disabled Flags Source: https://github.com/linuxdeepin/dtkwidget/blob/master/docs/widgets/dtitlebar.zh_CN.dox Sets the window flags for buttons that should be disabled. This affects the UI state of the buttons but may still allow programmatic access. ```APIDOC ## void Dtk::Widget::DTitlebar::setDisableFlags(Qt::WindowFlags flags) ### Description Sets the window flags for buttons that should be disabled. This affects the UI state of the buttons but may still allow programmatic access. ### Parameters * flags (Qt::WindowFlags) - The window flags for the buttons to be disabled. ``` -------------------------------- ### Auto Hide on Fullscreen Source: https://github.com/linuxdeepin/dtkwidget/blob/master/docs/widgets/dtitlebar.zh_CN.dox Determines if the title bar automatically hides when the application is in fullscreen mode. ```APIDOC ## bool Dtk::Widget::DTitlebar::autoHideOnFullscreen() const ### Description Checks if the title bar automatically hides in fullscreen mode. ### Return Value bool - True if auto-hide is enabled, false otherwise. ``` -------------------------------- ### Set Quit Menu Disabled Source: https://github.com/linuxdeepin/dtkwidget/blob/master/docs/widgets/dtitlebar.zh_CN.dox Disables the quit menu option in the title bar, preventing the user from closing the application via the menu. ```APIDOC ## void Dtk::Widget::DTitlebar::setQuitMenuDisabled(bool disabled) ### Description Disables the quit menu option in the title bar. ### Parameters * disabled (bool) - True to disable the quit menu, false to enable it. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.