Giter Site home page Giter Site logo

czyt1988 / saribbon Goto Github PK

View Code? Open in Web Editor NEW
961.0 43.0 302.0 16.64 MB

Ribbon Control for Qt

License: MIT License

QMake 1.22% C++ 95.95% C 0.21% CMake 2.44% Python 0.15% Shell 0.03%
ribbon qt office-ui office-ribbon cpp office-framework wps wps-ui ribbon-control qt-ribbon

saribbon's Introduction

中文文档点击这里,QQ群:434014314

Windows(2019, latest) Linux ubuntu(20.04, latest) Mac(11-latest)
Qt5.12 cmake-win-qt5.12 CMake-Linux-Qt5.12 cmake-mac-qt5.12
Qt5.13 cmake-win-qt5.13 CMake-Linux-Qt5.13 cmake-mac-qt5.13
Qt5.14 cmake-win-qt5.14 CMake-Linux-Qt5.14 cmake-mac-qt5.14
Qt5.15 cmake-win-qt5.15 CMake-Linux-Qt5.15 cmake-mac-qt5.15
Qt6.0 cmake-win-qt6.0 CMake-Linux-Qt6.0 cmake-mac-qt6.0
Qt6.1 cmake-win-qt6.1 CMake-Linux-Qt6.1 cmake-mac-qt6.1
Qt6.2 cmake-win-qt6.2 CMake-Linux-Qt6.2 cmake-mac-qt6.2
Qt6.3 cmake-win-qt6.3 CMake-Linux-Qt6.3 cmake-mac-qt6.3
Qt6.4 cmake-win-qt6.4 CMake-Linux-Qt6.4 cmake-mac-qt6.4
Qt6.5 cmake-win-qt6.5 CMake-Linux-Qt6.5 cmake-mac-qt6.5
Qt6.6 cmake-win-qt6.6 CMake-Linux-Qt6.6 cmake-mac-qt6.6

Introduction to SARibbon

This is a Ribbon control under Qt framework, which provides an interface similar to that of Microsoft Office software. SARibbon is suitable for large software, industrial software, and complex software UI. SARibbon is designed with reference to the naming style of the MFC Ribbon interface, and the interface style of SARibbon refers to the Ribbon interface of Microsoft Office series software and WPS software, and combines the advantages of both. SARibbon is a ribbon widget that can define a variety of theme styles, and it can quickly define your desired theme style through qss.In order to facilitate the development of large software, SARibbon encapsulates some commonly used functional controls,such as Color Widgets

Features

  • Layout and display for Ribbon

Layout and display for Ribbon

  • Support minimization mode, ribbon only shows tabs (default double-click on the tab will switch)

SARibbon minimization mode

  • Supports quickAccessBar (word quick menu), which will have different display effects in different layout modes

SARibbon-quickAccessBar

  • Support 4 different ribbon buttons: normal buttons, delay pop-up menu buttons, menu buttons, action menu buttons

ribbon button

  • There are 4 different styles of ribbon layouts available

4 different ribbon layout

  • Support QSS to customize the ribbon, you can switch themes in real time, and there are 5 different styles of themes built-in

win7 theme: SARibbon-theme-win7 office2013 theme: SARibbon-theme-office2013 office2016 theme: SARibbon-theme-office2016 office2021 theme: SARibbon-theme-office2021 dark theme: SARibbon-theme-dark

  • Provides a Gallery control

  • Supports long scrolling and Option Action

  • Provides a centered alignment mode

  • Support 4K screen and multi-screen
  • Support linux and MacOS

MIT protocol,welcome for everyone to use and give comments

gitee - https://gitee.com/czyt1988/SARibbon

github - https://github.com/czyt1988/SARibbon

Build

SARibbon provides both qmake and cmake build methods, and provides an amalgamate SARibbon.h and SARibbon.cpp file for static embedding into a single project

SARibbon supports third-party library QWindowKit At the same time, it also supports simple frameless solutions. If you need native window support for the operating system, such as edge trimming after Windows 7 and maximizing the hovering effect of buttons in Windows 11, it is recommended to enable QWindowKit Library, QWindowKit Library can better solve the problem of multi screen movement

If you want to rely on QWindowKit Library, needs to be compiled first QWindowKit Library, QWindowKit As the submodules of the SARibbon project, if the '-- recursive' parameter is not included in the 'git clone', the 'submodules update' command needs to be executed:

git submodule update --init --recursive

Compile to dynamic libraries

For the detailed build process, refer to the document: Building SARibbon

Embedding SARibbon directly into the project

SARibbon provides amalgamate SARibbon.h file and SARibbon.cpp file, you only need to import these two files in your own project, and at the same time import resource files and third-party library files to use, no need to compile into dynamic libraries or static libraries, you can refer to the StaticExample example (located in src/example/StaticExample), static embedding will be used to SARibbon.h, SARibbon.cpp, SARibbon.pri, SARibbonBar/resource.qrc, and SARibbonBar/3rdparty, SARibbonBar/resource two folders:

Your project directory will look like this:

|-you-project-dir
|  |-you-project.pro
|  |-SARibbon.h
|  |-SARibbon.cpp
|  |-SARibbon.pri
|  |-SARibbonBar
|     |-resource.qrc
|     |-resource(Directly copy the resource under SARibbonBar in its entirety)
|        |-resource files

To compile with qmake, you can follow the steps below:

    1. Copy SARibbon.h, SARibbon.cpp, SARibbon.pri to your project directory
    1. Create a SARibbonBar folder in your project directory
    1. Copy the src/SARibbonBar/resource.qrc file in the source code to the SARibbonBar folder in your project directory
    1. Copy the resource folder under src/SARibbonBar to the SARibbonBar folder in your project directory
    1. Import the SARibbon.pri file into the pro file of your project, e.g. include($$PWD/SARibbon.pri)

If you use cmake, refer to the cmake writing method of the StaticExample example(located in src/example/StaticExample)

How to use:

Import the library

After the compilation is complete, import SARibbon as follows:

qmake

If you use qmake, you can simply copy the following files into your project in a directory structure after the compilation is complete

Create a 3rdparty folder in your project first, and then copy the entire SARibbon folder, there are already several pri files inside SARibbon that can easily allow you to import the project into your own directory, and the ./importSARibbonBarLib.pri file is used to import the SARibbon library

After completing the appeal process, you can add the following statement to your Qt project pro file

include($$PWD/3rdparty/SARibbon/importSARibbonBarLib.pri)

The compilation process of qmake will generate bin_qtx.x_xx folder under SARibbon, and the library files and dll files are in this folder, and importSARibbonBarLib.pri will automatically reference the libraries in this folder

At this point, your project directory looks like this:

|-[you-project-dir]
|  |-you-project.pro
|  |-[3rdparty]
|     |-[SARibbon](Copy SARibbon in its entirety)
|        |-importSARibbonBarLib.pri
|        |-SARibbonBar.pri
|        |-common.pri
|        |-[bin_qtx.x.x_{MSVC/GNU}_x{32/64}]
|        |-[src]
|        |   |-[SARibbonBar]

cmake

After cmake executes install, it will copy the necessary files to the installation directory, which can be used as a reference when writing cmake filessrc/example/MainWindowExample/CMakeLists.txt

Get started quickly

Ribbon is a combination of the menu bar and the toolbar, and displayed through a tab control, Ribbon can not be simply replaced by Tab+Toolbar, involving a lot of details, SARibbon refers to the naming style of the MFC Ribbon interface in the design, the tab page is called Category, and there are multiple pannel under each Category, below which manages the toolbutton, pannel is a bit like the traditional Toolbar, with a hierarchy as shown in the image below, and these names are referencing the MFC ribbon interface class

msdn ribbon

Some common nouns are explained below

  • Category, representing what a label presents, corresponding to SARibbonCategory.

  • Context Category, this is a special category. It is not displayed normally. You need to judge whether it should be displayed based on the context. The most common way is that after inserting a picture in word, a label related to picture modification will appear. If no picture is selected, the label will disappear. This is the context category, corresponding to SARibbonContextCategory.

  • Pannel, This is a collection of menus, like a Toolbar, corresponding to SARibbonPannel

  • Application Button, this is the leftmost button in the tab bar (word is the corresponding file button). This button will trigger some special pages or menus, corresponding to SARibbonApplicationButton, which can be hidden.

  • Quick Access Bar, a simple toolbar at the top for placing common actions corresponding to SARibbonQuickAccessBar.

  • Gallery Control, this is the most eye-catching control of ribbon. It displays the functions with intuitive images, and even some renders are done in real time according to the context. Typical example is the style selection in the office word. corresponding to SARibbonGallery.

The layout of SARibbonBar is shown in the figure below

Note: Different layout schemes affect the placement of the Category and Quick Access Bar

Use Ribbon in the MainWindow

To use SARibbon in MainWindow, you need to replace QMainWindow with SARibbonMainWindow, which modifies the way QMainWindow renders menubar

Note that if you use a UI file, you should delete the menu of the UI file, otherwise it may cause some exceptions

The sample code is as follows:

#include "SARibbonMainWindow.h"
class MainWindow : public SARibbonMainWindow
{
    Q_OBJECT
public:
    MainWindow(QWidget* par = nullptr);
    ...
}

SARibbonMainWindow also supports normal mode rendering with the following constructor:

SARibbonMainWindow(QWidget *parent = nullptr, bool useRibbon = true);

If the second parameter is set to false, it will use the normal menu toolbar mode, this interface is reserved for some projects that need to be able to switch between ribbon and classic menu toolbar scenes, ribbon state and classic state do not support hot switching, if you need to switch, you can set a configuration file or registry, pass false to the second parameter when the application is restarted to enter the classic menu toolbar mode

Use SARibbonBar in QWidget or QDialog

SARibbonBar can be used on QWidget or QDialog, see the example:src/example/WidgetWithRibbon

All you need to do is use SARibbonBar as a normal widget

First, declare the pointer of SARibbonBar in the header file

private:
    Ui::Widget* ui;
    SARibbonBar* mRibbonBar { nullptr };

Create a SARibbonBar in the Widget's constructor, there is a QVBoxLayout layout in the widget's ui file, place the SARibbonBar at the very top, and at the same time, since the QWidget mode, there is no need to display the title, you can call the SARibbonBar::setTitleVisible method to hide the title. applicationbutton can also be canceled in QWidget via SARibbonBar::setApplicationButton if it is not necessary, and finally since the theme of SARibbonBar is set in the SARibbonMainWindow method, the theme can be set in QWidget via the global function sa_set_ribbon_ theme

#include "SARibbonBar.h"
#include "SARibbonCategory.h"
#include "SARibbonPannel.h"
#include "SARibbonMainWindow.h"
Widget::Widget(QWidget* parent) : QWidget(parent), ui(new Ui::Widget)
{
    // Note: There is a QVBoxLayout layout in the ui file
    ui->setupUi(this);
    // Create SARibbonBar
    mRibbonBar = new SARibbonBar(this);
    // there is no need to display the title anymore on QWidget
    mRibbonBar->setTitleVisible(false);
    // it is better to use compact mode directly on QWidget
    mRibbonBar->setRibbonStyle(SARibbonBar::RibbonStyleCompactThreeRow);
    // cancel applicationbutton
    mRibbonBar->setApplicationButton(nullptr);
    // Set the theme, although SARibbonMainWindow is not used here, 
    // but the theme of the Ribbon is defined in SARibbonMainWindow, so SARibbonMainWindow.h should be introduced
    sa_set_ribbon_theme(mRibbonBar, SARibbonMainWindow::RibbonThemeOffice2013);

    // QWidgets sets a QVBoxLayout and puts the window in the second layout of the QVBoxLayout, 
    // and the first layout is given to SARibbonBar, so that SARibbonBar will be on top
    ui->verticalLayout->insertWidget(0, mRibbonBar);

    buildRibbon(mRibbonBar);
}

Here's what it looks like:

Ribbon on QWidget

Create Category and Pannel

The order of creating a ribbon is to create a Category, then a Pannel, and finally a toolbutton (action)

Use SARibbonBar::addCategoryPage to add a Category to SARibbonBar, SARibbonCategory::addPannel to add a Category, and SARibbonPannel::addAction to add an action to Pannel

The following code demonstrates an example of adding an action:

//Add main tab - The main tab is added through the addcategorypage factory function.
SARibbonCategory* categoryMain = ribbon->addCategoryPage(tr("Main"));
 //Using the addpannel function to create saribponpannel. The effect is the same as that of new saribponpannel, and then call SARibbonCategory:: addpannel.
SARibbonPannel* pannel1 = categoryMain->addPannel(("Panel 1"));
QAction* actSave = new QAction(this);
actSave->setText("save");
actSave->setIcon(QIcon(":/icon/icon/save.svg"));
actSave->setObjectName("actSave");
actSave->setShortcut(QKeySequence(QLatin1String("Ctrl+S")));
pannel1->addLargeAction(actSave);

The above operation adds a button, and the effect is shown in the following figure:

You can also directly new out of SARibbonCategory and add it to pannel, and the following code will look the same as the one above:

SARibbonCategory* categoryMain = new SARibbonCategory(tr("Main"));
ribbon->addCategoryPage(categoryMain);
SARibbonPannel* pannel1 = new SARibbonPannel("Panel 1");
categoryMain->addPannel(pannel1);
QAction* actSave = new QAction(this);
...
pannel1->addLargeAction(actSave);

Different layout styles can be combined throughaddLargeAction,addMediumAction,addSmallAction. For details, see :

./src/example/MainWindowExample/mainwindow.cpp

Context Category

The so-called Context Category refers to the label / label group that appears only under special circumstances. For example, when office word selects a picture, the Context Category of picture editing will appear, as shown in the following figure:

Context Category

The class corresponding to the Context Category in SARibbon is SARibbonContextCategory

The Context Category is usually created when the program is initialized. It is usually hidden and displayed when it needs to be displayed. The Context Category is created as follows:

Since the Context Category needs to be invoked when used, it is a good choice to save it with a member variable. Of course, you can also traverse the search (SARibbonBar::contextCategoryListcan enumerate all SARibbonContextCategory).

header file:

SARibbonContextCategory* m_contextCategory;

cpp file:

SARibbonBar* ribbon = ribbonBar();
//Create a contextCategory with random colors
m_contextCategory   = ribbon->addContextCategory(tr("context"), QColor());
SARibbonCategory* contextCategoryPage1 = m_contextCategory->addCategoryPage(tr("Page1"));
//Operate on contextCategoryPage1
......
SARibbonCategory* contextCategoryPage2 = m_contextCategory->addCategoryPage(tr("Page2"));
//Operate on contextCategoryPage2
......

The SARibbonCategory created by SARibbonContextCategory is managed by SARibbonContextCategory. Only when SARibbonContextCategory is displayed, the managed SARibbonCategory is displayed

Note: SARibbonContextCategory is not a widget.

To display a contex use

SARibbonBar::showContextCategory/SARibbonBar::hideContextCategory:

void MainWindow::onShowContextCategory(bool on)
{
    if (on) {
        this->ribbonBar()->showContextCategory(m_contextCategory);
    } else {
        this->ribbonBar()->hideContextCategory(m_contextCategory);
    }
}

**Note: ** if you want to delete contextCategory, you need to call SARibbonBar::destroyContextCategory instead of delete directly. After calling SARibbonBar::destroyContextCategory, you do not need to delete the pointer of ContextCategory.

Different contextCategory has different style. For details,see: [SARibbon style](#SARibbon style) and [Display comparison under different styles](#Display comparison under different styles).

ApplicationButton

There is a special and obvious button called ApplicationButton in the upper left corner of the ribbon interface. This button is generally used to call up menus. SARibbonBar creates ApplicationButton by default during construction. Its text can be set in the following ways:

SARibbonBar* ribbon = ribbonBar();
ribbon->applicationButton()->setText(("File"));

The default applicationButton inherits from SARibbonApplicationButton, and SARibbonApplicationButton inherits from QPushButton, so you can perform all operations on QPushButton. Of course, if you want to set your own Button as an applicationButton, you can just call the SARibbonBar::setApplicationButton function.

QuickAccessBar and RightButtonGroup

QuickAccessBar is the quick toolbar in the upper left corner and rightButtonGroup is the quick toolbar in the upper right corner. In office mode, it is divided into left and right sides. In WPS mode, the left and right sides will be combined and placed on the right.

QuickAccessBar And RightButtonGroup

In SARibbon:

  • QuickAccessBar corresponds to the SARibbonQuickAccessBar class.
  • rightButtonGroup corresponds to the SARibbonQuickAccessBar class.

During initialization, SARibbonBar will create QuickAccessBar and RightButtonGroup by default. Its pointers can be obtained through SARibbonBar::quickAccessBar and SARibbonBar::rightButtonGroup. Examples are as follows:

QAction* MainWindow::createAction(const QString& text, const QString& iconurl, const QString& objName)
{
    QAction* act = new QAction(this);
    act->setText(text);
    act->setIcon(QIcon(iconurl));
    act->setObjectName(objName);
    return act;
}

void MainWindow::initQuickAccessBar(){
    SARibbonBar* ribbon = ribbonBar();
    SARibbonQuickAccessBar* quickAccessBar = ribbon->quickAccessBar();
    quickAccessBar->addAction(createAction("save", ":/icon/icon/save.svg", "save-quickbar"));
    quickAccessBar->addSeparator();
    quickAccessBar->addAction(createAction("undo", ":/icon/icon/undo.svg"),"undo");
    quickAccessBar->addAction(createAction("redo", ":/icon/icon/redo.svg"),"redo");
    quickAccessBar->addSeparator();
}
void MainWindow::initRightButtonGroup(){
    SARibbonBar* ribbon = ribbonBar();
    SARibbonButtonGroupWidget* rightBar = ribbon->rightButtonGroup();
    QAction* actionHelp = createAction("help", ":/icon/icon/help.svg","help");
    connect(actionHelp, &QAction::triggered, this, &MainWindow::onActionHelpTriggered);
    rightBar->addAction(actionHelp);
}

SARibbonBar layout style

SARibbon supports switching between four ribbon styles. Here, the ribbon style of office and WPS is referred. Online style switching can be realized throughvoid SARibbonBar::setRibbonStyle(RibbonStyle v).

The office mode is the most common ribbon mode, the tab and title bar occupy more space, the ribbon mode designed by WPS has been improved, it reduces the height of the ribbon, the label and the title bar are set together, so as to reduce the height of a title bar, effectively use the vertical space, and at the same time, the button layout of the pannel is changed from a maximum of 3 to 2, further compressing the vertical space

Screenshot comparison between the word interface of office and the word interface of WPS

office

Wps

Under the normal screen, the WPS style will reduce the vertical height by at least 30 pixels compared with the Office style, which is equivalent to saving nearly 3% of the vertical space compared with the 1920*1080 screen.

In SARibbon, the one with the title bar is called Loose, and the elements of the loose layout are arranged as shown below:

Loose

This layout is consistent with the default layout of Office

In SARibbon, the layout with a title bar and tab is called a compact layout, and the elements of the compact layout are arranged as follows:

compact

SARibbonBar provides a setRibbonStyle function that defines the current layout style, and enumerating SARibbonBar::RibbonStyle defines four layout schemes:

  • SARibbonBar::RibbonStyleLooseThreeRowLoose With Three Row(The v0.x version is SARibbonBar::OfficeStyle)

SARibbonBar::RibbonStyleLooseThreeRow

  • SARibbonBar::RibbonStyleLooseTwoRowLoose With Two Row(The v0.x version is SARibbonBar::OfficeStyleTwoRow)

SARibbonBar::RibbonStyleLooseTwoRow

  • SARibbonBar::RibbonStyleCompactThreeRowCompact With Three Row(The v0.x version is SARibbonBar::WpsLiteStyle)

SARibbonBar::RibbonStyleCompactThreeRow

  • SARibbonBar::RibbonStyleCompactTwoRowCompact With Two Row(The v0.x version is SARibbonBar::WpsLiteStyleTwoRow)

SARibbonBar::RibbonStyleCompactTwoRow

Text wrapping, and icon size

The SARibbonBar::setEnableWordWrap function allows you to control whether the text of the SARibbonBar wraps or not, the height of the SARibbonBar is fixed, and whether the text wraps or not will affect the size of the icon display, so if you want the icon to look bigger, you can set the text to not wrap

In SARibbonBar::RibbonStyleCompactTwoRow layout style, the text without wrapping is displayed as follows:

SARibbonBar::RibbonStyleCompactTwoRow紧凑结构,2行模式把文字设置为不换行后(SARibbonBar::setEnableWordWrap(false))的效果如下

nowrap

When the SARibbonBar text is set to non-wrapping, the display space of the icon becomes larger

Tool Button layouts of SARibbonBar

SARibbonPannel provides three methods to add action:

  • addLargeAction
  • addMediumAction
  • addSmallAction

In the standard pannel, an action (button) has three layouts mode. Taking office word as an example, the three layouts of pannel are actually the number of lines occupied:

  • The first, which occupies the entire pannel, is called 'Large'
  • Second, 2 buttons can be placed under one pannel, which is called 'medium'
  • The third type, a pannel with 3 buttons, is called 'samll'

word pannel example

SARibbonPannelItem::RowProportion is used to represent the number of rows each form occupies in the pannel. It is commonly used in the pannel layout. This enumeration is defined as follows:

/**
 * @brief defines the proportion of rows. The ribbon has  three proportions: large, media and small.
 */
enum RowProportion {
    None            ///< to define the proportion, it will be judged according to expandingDirections. If Qt::Vertical is available, it is equal to Large, otherwise it is Small
    , Large         ///< Large proportion, the height of a widget will fill the whole pannel.
    , Medium        ///< Medium proportion will only work when @ref SARibbonPannel::pannelLayoutMode is @ref SARibbonPannel::ThreeRowMode, and will occupy two of the three rows if both of them in the same column are Medium.
    , Small         ///< Small proportion, in the line of SARibbonPannel, Medium will become Small if it does not meet the conditions, but will not become Large.
};

Each action managed in SARibbonPannel will have a private property (SARibbonPannelItem::RowProportion). This property determines the layout of this action in the pannel.

SARibbonPannel layout mode

3-line mode

The three line mode is the traditional pannel layout, as shown in the following figure:

3-line mode

In the 3-line mode, there are three kinds of placeholders, which are large, medium and small

The pannel in the 3-line mode will display the title of the pannel in the Pannel Title area, and there is another OptionAction area. This area is used to add a special trigger to this action. If OptionAction is not set, this area is hidden.

2-line mode

The two-line mode is the WPS improved layout method , as shown in the following figure:

2-line mode

In the 2-line mode, the medium and small placeholders (SARibbonPannelItem::RowProportion) are the same, and no distinction is made.

In 2-line mode, pannel does not display the title.

SARibbon Customization

Ribbon customization is a feature of ribbon. With reference to the custom interface of office and WPS, users can define a lot of content for their own ribbon, or even define an interface completely different from the original one.

The following is the custom interface of office.

office Ribbon Customization

SARibbon refers to the interface of office and WPS, and encapsulates the easy-to-use SARibbonCustomize** class, including the following five classes:

  • SARibbonCustomizeDialog
  • SARibbonCustomizeWidget
  • SARibbonCustomizeData
  • SARibbonActionsManager
  • SARibbonActionsManagerModel

Actual users can only use SARibbonActionsManager and SARibbonCustomizeDialog/SARibbonCustomizeWidget, and other users will not use them normally.

SARibbonActionsManager is used to manage QAction, add the QAction that is wanted to customize to SARibbonActionsManager for management, and classify QAction so that they can be displayed in SARibbonCustomizeDialog/SARibbonCustomizeWidget.

SARibbonCustomizeDialog/SARibbonCustomizeWidget is a specific display window. The SARibbonCustomizeDialog encapsulates the SARibbonCustomizeWidget as a dialog box. If you want to integrate it into the configuration dialog box like office, you can use the SARibbonCustomizeWidget. The effect of the SARibbonCustomizeDialog is shown in the following figure:

SARibbon Customize Dialog

Add custom functions to an interface

Here's how to add custom features.

First, define SARibbonActionsManager as the member variable of MainWindow.

//Define member variables in the MainWindow.h. 
SARibbonActionsManager* m_ribbonActionMgr;///< Manage all actions

During the initialization of MainWindow, a large number of QAction need to be created. The parent object of QAction is designated as MainWindow. In addition, ribbon layout will be generated, such as adding category, adding panel and other operations. After the above operations are completed, add the following steps to automatically let SARibbonActionsManager manage all QAction.

//Initialization of MainWindow and generation of QAction.
//Generate ribbon layout.
m_ribbonActionMgr = new SARibbonActionsManager(mainWinowPtr);
m_ribbonActionMgr->autoRegisteActions(mainWinowPtr);

The key function autoRegisteActions of SARibbonActionsManager can traverse all subobjects under SARibbonMainWindow, find and register action, and traverse all SARibbonCategory. The actions under SARibbonCategory are classified according to the title name of SARibbonCategory. This function also registers the actions under SARibbonMainWindow, but not under any category, as 'NotInRibbonCategoryTag' tags, The default name is 'not in ribbon'.

To call SARibbonCustomizeDialog as follows:

QString cfgpath = "customization.xml";
SARibbonCustomizeDialog dlg(this, this);

dlg.setupActionsManager(m_ribbonActionMgr);
dlg.fromXml(cfgpath);//This step is called to load the existing custom steps, which can be added based on the original custom steps when saving.
if (QDialog::Accepted == dlg.exec()) {
    dlg.applys();//Apply custom steps
    dlg.toXml(cfgpath);//Save custom steps to a file
}

Before the MainWindow is generated, the customized content needs to be loaded. Therefore, the following statement should be added to the constructor:

//Constructor of MainWindow
sa_apply_customize_from_xml_file("customization.xml", this, m_ribbonActionMgr);

sa_apply_customize_from_xml_file is the function provided in SARibbonCustomizeWidget.h. The customized contents in the configuration file are directly applyed in the MainWindow.

In this way, the software will be loaded according to the configuration file every time it is started.

More screenshots

  • Here is a screenshot of the software built with SARibbon

github - https://github.com/czyt1988/data-workbench

gitee - https://gitee.com/czyt1988/data-workbench

The specific ribbon generation code can be seen:

https://github.com/czyt1988/data-workbench/blob/master/src/APP/DAAppRibbonArea.cpp

FAQ

High-DPI screen display issues

There are two ways to prepare for the issue of high-DPI screen display:

  • 1 Set Qt::AA_EnableHighDpiScaling for QApplication in the main function

This attribute enables the application to automatically detect the pixel density of the display to achieve automatic scaling, such as:

int main(int argc, char* argv[])
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
    QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif
    QApplication a(argc, argv);
    ......
}
  • 2 Set the scaling policy for QApplication in the main function: QApplication::setHighDpiScaleFactorRoundingPolicy

Qt5.6 provides Qt::AA_EnableHighDpiScaling, but it cannot completely solve the problem of high-DPI screens. Qt5.14 has provided a high-dpi screen scaling policy setting called QApplication::setHighDpiScaleFactorRoundingPolicy, also needs to be set in the main function, for example:

int main(int argc, char* argv[])
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
    QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
    QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
#endif
    QApplication a(argc, argv);
    ......
}

Shortcut key problem

People often give feedback that after using SARibbonBar, the shortcut keys of inactive tab pages do not respond, and only the shortcut keys of activated tab pages respond. If it is in traditional toolbar mode, the shortcut key will remain in effect because the toolbar where the action is located is always at the forefront. However, if it is SARibbonBar, the shortcut key in the action panel will be hidden, and it will not take effect after hiding, If you want the shortcut key to take effect regardless of whether Pannel is hidden or not, setting the shortcut key's' shortcutContext 'property to Qt::ApplicationShortcut is also invalid. In this case, you can manually create the shortcut key in the place where you created the Category

example:

    ribbon build
    ...
    QShortcut* shortCut = new QShortcut(QKeySequence(QLatin1String("Ctrl+S")), this);
    connect(shortCut, &QShortcut::activated, this, [ actSave ]() {
        actSave->trigger();
    });

saribbon's People

Contributors

czyt1988 avatar haodafa avatar ice-panda avatar iveswang6 avatar jihadist avatar liuzhao071 avatar mingweiliu avatar ogretransporter avatar plugingeo avatar runinmind avatar shelltdf avatar xinchangli avatar ymfjly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

saribbon's Issues

设置主窗口的窗口图标,有两种做法,结果不一样

第一种,直接使用:
setWindowIcon(QIcon(":/icon/icon/MainIcon.png"));
结果显示:
窗口左上角显示有图标,但是有两个一模一样的,还是一大一小
image

新弹出的子窗口同样有继承
image

任务栏也有相应图标
image

第二种,使用SARibbonBar的对象设置图标
SARibbonBar *ribbon = ribbonBar();//制造一个类似的QMenuBar ribbon->setRibbonStyle(SARibbonBar::RibbonStyle::OfficeStyle);//设置标题样式 ribbon->setWindowIcon(QIcon(":/icon/icon/MainIcon.png"));
结果显示:
左上角只有一个主窗口图标
image

但是任务栏没有相应图标
image

新的子窗口也同样没有
image

求教,请问怎么解决

Changing border color of a toolbutton

Hi,
I have two themes (normal and dark), i need for each theme changing the toolbutton border color menu for example for a dark mode i want to make it white, but i can't tell to the ribbon that i'm in dark theme.

Can you please ad a function that returns the theme from the ribbon?

Thank you

Gallery尺寸缩放

Hi,如下图所示:
图片

当有Gallery时,整行会被填充,看起来像是若干个Gallery共同均分这个行空间。但是我这里每个Gallery里的图标数量不同,如上图所示,看起来不是特别好看。
请问下:怎么才能让每个Gallery的宽度按照里面图标的数量自动缩放宽度?谢谢

macosx 下不显示面板

环境:silicon M1; macos 12.4, qt 6.2.4 ;
编译成功,但是显示不对,ribbon完全没有显示。

image

窗口的最大化、最小化、和关闭按钮也没有,看起来好像是 framelesswindow 有问题。

Layout direction right to left not working

Hi,
I was using this library to create ribbons for my applications and it work well, but this time I needed to add arabic language that is a right to left direction.

When setting the qApp layout direction to right to left, the categories are moving to the right, but the pannels, the appButton, and others are still on the left side, they don't follow the layaut direction.

this example is from the git, I just add the right to left direction, and this is the results.
Screenshot 2022-08-15 205507

Any help please.

编译失败

VS2013+QT5.7.0和 VS2017+QT5.9.3均编译失败,请问您用的是什么环境
我的错误如下
1>------ 已启动生成: 项目: SARibbonBar, 配置: Release x64 ------
1> Moc'ing FramelessHelper.h...
1> Moc'ing SARibbonApplicationButton.h...
1> Moc'ing SARibbonBar.h...
1> Moc'ing SARibbonCategory.h...
1> Moc'ing SARibbonComboBox.h...
1> Moc'ing SARibbonContextCategory.h...
1> Moc'ing SARibbonControlButton.h...
1> Moc'ing SARibbonGallery.h...
1> Moc'ing SARibbonGalleryGroup.h...
1> Moc'ing SARibbonLineEdit.h...
1> Moc'ing SARibbonMainWindow.h...
1> Moc'ing SARibbonMenu.h...
1> Moc'ing SARibbonPannel.h...
1> Moc'ing SARibbonPannelOptionButton.h...
1> Moc'ing SARibbonStackedWidget.h...
1> Moc'ing SARibbonTabBar.h...
1> Moc'ing SARibbonToolButton.h...
1> Moc'ing SAWindowButtonGroup.h...
1> Rcc'ing resource.qrc...
1> FramelessHelper.cpp
1>FramelessHelper.cpp : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\FramelessHelper.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1> moc_FramelessHelper.cpp
1>c:\users\administrator\desktop\saribbon-master\src\release../FramelessHelper.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1> moc_SARibbonApplicationButton.cpp
1> moc_SARibbonBar.cpp
1>c:\users\administrator\desktop\saribbon-master\src\release../SARibbonBar.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonCategory.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonContextCategory.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1> moc_SARibbonCategory.cpp
1>c:\users\administrator\desktop\saribbon-master\src\release../SARibbonCategory.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1> moc_SARibbonComboBox.cpp
1>c:\users\administrator\desktop\saribbon-master\src\release../SARibbonComboBox.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1> moc_SARibbonContextCategory.cpp
1>c:\users\administrator\desktop\saribbon-master\src\release../SARibbonContextCategory.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonCategory.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1> moc_SARibbonControlButton.cpp
1> moc_SARibbonGallery.cpp
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonGalleryGroup.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonGalleryItem.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1> moc_SARibbonGalleryGroup.cpp
1>c:\users\administrator\desktop\saribbon-master\src\release../SARibbonGalleryGroup.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonGalleryItem.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1> moc_SARibbonLineEdit.cpp
1> moc_SARibbonMainWindow.cpp
1>c:\users\administrator\desktop\saribbon-master\src\release../SARibbonMainWindow.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1> moc_SARibbonMenu.cpp
1> moc_SARibbonPannel.cpp
1> moc_SARibbonPannelOptionButton.cpp
1>c:\users\administrator\desktop\saribbon-master\src\release../SARibbonPannelOptionButton.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1> moc_SARibbonStackedWidget.cpp
1> moc_SARibbonTabBar.cpp
1> moc_SARibbonToolButton.cpp
1> moc_SAWindowButtonGroup.cpp
1> SARibbonApplicationButton.cpp
1> 正在生成代码...
1> 正在编译...
1> SARibbonBar.cpp
1>SARibbonBar.cpp : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonBar.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonCategory.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonContextCategory.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonElementCreateDelegate.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>SARibbonBar.cpp(195): error C2039: “setContextColor”: 不是“SARibbonContextCategory”的成员
1> c:\users\administrator\desktop\saribbon-master\src\SARibbonContextCategory.h(9) : 参见“SARibbonContextCategory”的声明
1>SARibbonBar.cpp(212): error C2039: “categoryCount”: 不是“SARibbonContextCategory”的成员
1> c:\users\administrator\desktop\saribbon-master\src\SARibbonContextCategory.h(9) : 参见“SARibbonContextCategory”的声明
1>SARibbonBar.cpp(214): error C2039: “categoryPage”: 不是“SARibbonContextCategory”的成员
1> c:\users\administrator\desktop\saribbon-master\src\SARibbonContextCategory.h(9) : 参见“SARibbonContextCategory”的声明
1>SARibbonBar.cpp(287): error C2039: “createHidePannelButton”: 不是“SARibbonElementCreateDelegate”的成员
1> c:\users\administrator\desktop\saribbon-master\src\SARibbonElementCreateDelegate.h(21) : 参见“SARibbonElementCreateDelegate”的声明
1> SARibbonButtonGroupWidget.cpp
1> SARibbonCategory.cpp
1>SARibbonCategory.cpp : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonCategory.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonSeparatorWidget.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonElementCreateDelegate.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1> SARibbonCategoryLayout.cpp
1>SARibbonCategoryLayout.cpp : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonCategory.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>SARibbonCategoryLayout.cpp(122): warning C4100: “watched”: 未引用的形参
1>SARibbonCategoryLayout.cpp(279): error C2065: “j”: 未声明的标识符
1>SARibbonCategoryLayout.cpp(279): error C2228: “.second”的左边必须有类/结构/联合
1>SARibbonCategoryLayout.cpp(279): error C2228: “.adjust”的左边必须有类/结构/联合
1> SARibbonCheckBox.cpp
1> SARibbonComboBox.cpp
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonComboBox.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1> SARibbonContextCategory.cpp
1>SARibbonContextCategory.cpp : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonContextCategory.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonCategory.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonElementCreateDelegate.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>SARibbonContextCategory.cpp(30): error C2039: “addCategoryPage”: 不是“SARibbonContextCategory”的成员
1> c:\users\administrator\desktop\saribbon-master\src\SARibbonContextCategory.h(9) : 参见“SARibbonContextCategory”的声明
1>SARibbonContextCategory.cpp(33): error C3861: “parentWidget”: 找不到标识符
1>SARibbonContextCategory.cpp(36): error C2065: “m_d”: 未声明的标识符
1>SARibbonContextCategory.cpp(36): error C2227: “->categoryDataList”的左边必须指向类/结构/联合/泛型类型
1> 类型是“unknown-type”
1>SARibbonContextCategory.cpp(36): error C2228: “.append”的左边必须有类/结构/联合
1>SARibbonContextCategory.cpp(37): error C3861: “categoryPageAdded”: 找不到标识符
1>SARibbonContextCategory.cpp(41): error C2039: “categoryCount”: 不是“SARibbonContextCategory”的成员
1> c:\users\administrator\desktop\saribbon-master\src\SARibbonContextCategory.h(9) : 参见“SARibbonContextCategory”的声明
1>SARibbonContextCategory.cpp(42): error C2270: “categoryCount”: 非成员函数上不允许修饰符
1>SARibbonContextCategory.cpp(43): error C2065: “m_d”: 未声明的标识符
1>SARibbonContextCategory.cpp(43): error C2227: “->categoryDataList”的左边必须指向类/结构/联合/泛型类型
1> 类型是“unknown-type”
1>SARibbonContextCategory.cpp(43): error C2228: “.count”的左边必须有类/结构/联合
1>SARibbonContextCategory.cpp(56): error C2039: “setContextColor”: 不是“SARibbonContextCategory”的成员
1> c:\users\administrator\desktop\saribbon-master\src\SARibbonContextCategory.h(9) : 参见“SARibbonContextCategory”的声明
1>SARibbonContextCategory.cpp(58): error C2065: “m_d”: 未声明的标识符
1>SARibbonContextCategory.cpp(58): error C2227: “->contextColor”的左边必须指向类/结构/联合/泛型类型
1> 类型是“unknown-type”
1>SARibbonContextCategory.cpp(84): error C2039: “categoryPage”: 不是“SARibbonContextCategory”的成员
1> c:\users\administrator\desktop\saribbon-master\src\SARibbonContextCategory.h(9) : 参见“SARibbonContextCategory”的声明
1>SARibbonContextCategory.cpp(86): error C2065: “m_d”: 未声明的标识符
1>SARibbonContextCategory.cpp(86): error C2227: “->categoryDataList”的左边必须指向类/结构/联合/泛型类型
1> 类型是“unknown-type”
1>SARibbonContextCategory.cpp(86): error C2228: “.categoryPage”的左边必须有类/结构/联合
1> SARibbonControlButton.cpp
1> SARibbonCtrolContainer.cpp
1> SARibbonDrawHelper.cpp
1> SARibbonElementCreateDelegate.cpp
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonElementCreateDelegate.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonBar.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonCategory.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonContextCategory.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonSeparatorWidget.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonGalleryGroup.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonGalleryItem.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>SARibbonElementCreateDelegate.cpp(75): error C2039: “createHidePannelButton”: 不是“SARibbonElementCreateDelegate”的成员
1> c:\users\administrator\desktop\saribbon-master\src\SARibbonElementCreateDelegate.h(21) : 参见“SARibbonElementCreateDelegate”的声明
1> SARibbonElementManager.cpp
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonElementCreateDelegate.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1> SARibbonGallery.cpp
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonGalleryGroup.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonGalleryItem.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonElementCreateDelegate.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1> SARibbonGalleryGroup.cpp
1>SARibbonGalleryGroup.cpp : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonGalleryGroup.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonGalleryItem.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1> SARibbonGalleryItem.cpp
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonGalleryItem.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonGalleryGroup.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1> SARibbonLineEdit.cpp
1> SARibbonMainWindow.cpp
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonMainWindow.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\FramelessHelper.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonBar.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonCategory.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonContextCategory.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1> SARibbonMenu.cpp
1> SARibbonPannel.cpp
1>SARibbonPannel.cpp : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonPannelOptionButton.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonSeparatorWidget.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonGalleryGroup.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonGalleryItem.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonElementCreateDelegate.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>SARibbonPannel.cpp(40): error C2614: “SARibbonPannelPrivate”: 非法的成员初始化:“m_titleY”不是基或成员
1>SARibbonPannel.cpp(290): error C2039: “connectAction”: 不是“SARibbonPannelOptionButton”的成员
1> c:\users\administrator\desktop\saribbon-master\src\SARibbonPannelOptionButton.h(6) : 参见“SARibbonPannelOptionButton”的声明
1>SARibbonPannel.cpp(313): error C2039: “m_titleY”: 不是“SARibbonPannelPrivate”的成员
1> SARibbonPannel.cpp(18) : 参见“SARibbonPannelPrivate”的声明
1>SARibbonPannel.cpp(314): error C2661: “QPainter::drawText”: 没有重载函数接受 5 个参数
1>SARibbonPannel.cpp(318): error C2039: “m_titleY”: 不是“SARibbonPannelPrivate”的成员
1> SARibbonPannel.cpp(18) : 参见“SARibbonPannelPrivate”的声明
1>SARibbonPannel.cpp(318): error C2661: “QPainter::drawText”: 没有重载函数接受 5 个参数
1>SARibbonPannel.cpp(378): error C2039: “m_titleY”: 不是“SARibbonPannelPrivate”的成员
1> SARibbonPannel.cpp(18) : 参见“SARibbonPannelPrivate”的声明
1>SARibbonPannel.cpp(378): error C2664: “void QWidget::move(const QPoint &)”: 无法将参数 1 从“int”转换为“const QPoint &”
1> 原因如下: 无法从“int”转换为“const QPoint”
1> 无构造函数可以接受源类型,或构造函数重载决策不明确
1> SARibbonPannelOptionButton.cpp
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonPannelOptionButton.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>SARibbonPannelOptionButton.cpp(14): error C2039: “connectAction”: 不是“SARibbonPannelOptionButton”的成员
1> c:\users\administrator\desktop\saribbon-master\src\SARibbonPannelOptionButton.h(6) : 参见“SARibbonPannelOptionButton”的声明
1>SARibbonPannelOptionButton.cpp(16): error C2355: “this”: 只能在非静态成员函数或非静态数据成员初始值设定项的内部引用
1>SARibbonPannelOptionButton.cpp(16): error C3861: “connect”: 找不到标识符
1> 正在生成代码...
1> 正在编译...
1> SARibbonQuickAccessBar.cpp
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonSeparatorWidget.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1> SARibbonSeparatorWidget.cpp
1>c:\users\administrator\desktop\saribbon-master\src\SARibbonSeparatorWidget.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1> SARibbonStackedWidget.cpp
1> SARibbonTabBar.cpp
1> SARibbonToolButton.cpp
1>SARibbonToolButton.cpp : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1>SARibbonToolButton.cpp(183): error C2181: 没有匹配 if 的非法 else
1>SARibbonToolButton.cpp(200): error C2059: 语法错误:“else”
1>SARibbonToolButton.cpp(203): error C2143: 语法错误 : 缺少“;”(在“{”的前面)
1>SARibbonToolButton.cpp(203): error C2447: “{”: 缺少函数标题(是否是老式的形式表?)
1>SARibbonToolButton.cpp(215): error C2059: 语法错误:“else”
1>SARibbonToolButton.cpp(216): error C2143: 语法错误 : 缺少“;”(在“{”的前面)
1>SARibbonToolButton.cpp(216): error C2447: “{”: 缺少函数标题(是否是老式的形式表?)
1>SARibbonToolButton.cpp(234): error C2059: 语法错误:“if”
1>SARibbonToolButton.cpp(237): error C2143: 语法错误 : 缺少“;”(在“{”的前面)
1>SARibbonToolButton.cpp(237): error C2447: “{”: 缺少函数标题(是否是老式的形式表?)
1>SARibbonToolButton.cpp(244): error C2065: “p”: 未声明的标识符
1>SARibbonToolButton.cpp(244): error C2065: “opt”: 未声明的标识符
1>SARibbonToolButton.cpp(244): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>SARibbonToolButton.cpp(244): error C2078: 初始值设定项太多
1>SARibbonToolButton.cpp(246): error C2059: 语法错误:“}”
1>SARibbonToolButton.cpp(246): error C2143: 语法错误 : 缺少“;”(在“}”的前面)
1>SARibbonToolButton.cpp(249): error C2143: 语法错误 : 缺少“;”(在“{”的前面)
1>SARibbonToolButton.cpp(249): error C2447: “{”: 缺少函数标题(是否是老式的形式表?)
1>SARibbonToolButton.cpp(329): error C2059: 语法错误:“else”
1>SARibbonToolButton.cpp(332): error C2143: 语法错误 : 缺少“;”(在“{”的前面)
1>SARibbonToolButton.cpp(332): error C2447: “{”: 缺少函数标题(是否是老式的形式表?)
1>SARibbonToolButton.cpp(344): error C2059: 语法错误:“else”
1>SARibbonToolButton.cpp(345): error C2143: 语法错误 : 缺少“;”(在“{”的前面)
1>SARibbonToolButton.cpp(345): error C2447: “{”: 缺少函数标题(是否是老式的形式表?)
1>SARibbonToolButton.cpp(365): error C2059: 语法错误:“if”
1>SARibbonToolButton.cpp(368): error C2143: 语法错误 : 缺少“;”(在“{”的前面)
1>SARibbonToolButton.cpp(368): error C2447: “{”: 缺少函数标题(是否是老式的形式表?)
1>SARibbonToolButton.cpp(378): error C2447: “{”: 缺少函数标题(是否是老式的形式表?)
1>SARibbonToolButton.cpp(396): error C2065: “p”: 未声明的标识符
1>SARibbonToolButton.cpp(396): error C2065: “opt”: 未声明的标识符
1>SARibbonToolButton.cpp(396): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>SARibbonToolButton.cpp(396): error C2374: “drawIconAndLabel”: 重定义;多次初始化
1> SARibbonToolButton.cpp(244) : 参见“drawIconAndLabel”的声明
1>SARibbonToolButton.cpp(396): error C2078: 初始值设定项太多
1>SARibbonToolButton.cpp(397): error C2059: 语法错误:“}”
1>SARibbonToolButton.cpp(397): error C2143: 语法错误 : 缺少“;”(在“}”的前面)
1>SARibbonToolButton.cpp(400): error C2143: 语法错误 : 缺少“;”(在“{”的前面)
1>SARibbonToolButton.cpp(400): error C2447: “{”: 缺少函数标题(是否是老式的形式表?)
1>SARibbonToolButton.cpp(412): error C2065: “label”: 未声明的标识符
1>SARibbonToolButton.cpp(412): error C2228: “.state”的左边必须有类/结构/联合
1> 类型是“unknown-type”
1>SARibbonToolButton.cpp(413): error C2065: “label”: 未声明的标识符
1> SAWindowButtonGroup.cpp
1>SAWindowButtonGroup.cpp : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
1> 正在生成代码...
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========

添加category或左侧快捷按钮及右侧按钮群没有排序功能

不知是不是我没找到对应的接口,我只看到有insert接口,

SARibbonCategory* insertCategoryPage(const QString& title, int index);
void insertCategoryPage(SARibbonCategory* category, int index);

void SARibbonBar::insertCategoryPage(SARibbonCategory* category, int index)
{
    if (nullptr == category) {
        return;
    }
    category->setRibbonPannelLayoutMode(isTwoRowStyle() ? SARibbonPannel::TwoRowMode : SARibbonPannel::ThreeRowMode);
    int i = m_d->_ribbonTabBar->insertTab(index, category->windowTitle());

    _SARibbonTabData tabdata;

    tabdata.category = category;
    tabdata.index    = i;
    m_d->_ribbonTabBar->setTabData(i, QVariant::fromValue(tabdata));
    m_d->_stackedContainerWidget->insertWidget(index, category);

    connect(category, &QWidget::windowTitleChanged, this, &SARibbonBar::onCategoryWindowTitleChanged);
    QApplication::postEvent(this, new QResizeEvent(size(), size()));
}

但是这个接口的方式利用的是tabbar和stack widget的插入功能,单单只通过index索引是无法有效控制插入顺序的,例如,定义category1的索引为20,category2的索引为21,但在无法确定category1和category2的插入谁先进行时,还是无法保证这两个category谁在前,因为如果他们都超过的容器的size那将都添加到最后,这种情况在独立插件或模块中使用时比较明显,介于此我在本地代码中加入了排序功能,我的思路是给category添加了ID属性,用ID的大小来计算索引,

...

    //通过ID判断插入顺序
    int index;
    auto listCategoryPages = CategoryPages();
    if(listCategoryPages.isEmpty())
    {
        index = d->ribbonTabBar->insertTab(0, category->windowTitle());
    }
    else
    {
        bool bFind = false;
        for(auto c : listCategoryPages)
        {
            if(c->CategoryID() > category->CategoryID())
            {
                index = listCategoryPages.indexOf(c);
                bFind = true;
                break;
            }
        }

        //没找到说明最大,插入到最后
        if(!bFind)
        {
            index = d->ribbonTabBar->insertTab(listCategoryPages.size(), category->windowTitle());
        }
        else
        {
            index = d->ribbonTabBar->insertTab(index, category->windowTitle());
        }
    }

    category->SetRibbonPannelLayoutMode(IsTwoRowStyle() ? RibbonPannel::TwoRowMode : RibbonPannel::ThreeRowMode);

...

这样一来ID也不必连续,也方便新添加的category定义ID,通常每个ID之间都会有10或100的间距,给后续的category以空间。
希望可以改善此功能,快捷区那里是一样的道理,

void SARibbonButtonGroupWidget::actionEvent(QActionEvent* e)

这里我就简单在添加时给QAction::setData()了;目的都是添加一个ID

Application button

Hi,

SARibbonBar is a great plugin, i love it :)

How can i show the menu when i click on application button?

thanks

Issue in Context Category

Hi,
I have an issue when i use context categories, i have 4 contexts categories i want to show only one context for a specific action, i use a list of contextCategory and for each element i call this setContextCategoryVisible() function.

The problem is that when for example i show contextA for the first time and show another context it works perfectly but when i come back to contextA this is what happens:
image

and i can't hide it again :'(. Can you please fix it?

构建SARinbbon时报错

错误信息如下:
......\SARibbon-master\src\SARibbonBar\SARibbonCtrlContainer.cpp:65:43: error: 'class QFontMetrics' has no member named 'horizontalAdvance'
int textWidth = fontMetrics().horizontalAdvance(text);

看了一下,对应类,发现确实没有对应的成员函数。

关于ContextCategory隐藏的问题

当启用了不止一个ContextCategory时,如果隐藏非最后一个的ContextCategory (使用ribbonBar()->hideContextCategory()方法),似会造成其后的ContextCategory标签出现问题。例如,以下两张图分别给出隐藏之前和隐藏之后的。
image
image

如果所隐藏的ContextCategory是最后一个,则没有发现问题。

How to merge a SARibbonPannel into another?

Hi, is there any way to merge two SARibbonPannels? just push the elements from one into another. I have been looking through the source code while finding that it is kind of complicated to do so, this may be a useful function to provide in SARibbonPannel class.

Qt6.2无法编译通过

本工程在Qt5.15版本可以正常通过,但是无法在win10上面Qt6.2版本中的QtCreator编译通过,编译输入如下图所示:
图片

是否可以在Release中增加编译过的lib库文件,提供给用户使用?谢谢

Removing margin

Hi,

I want to remove margins of ribbon, could you please show me how?

Windows 10 系统下高清屏幕的支持。

直接编译作者给的示例程序,发现在 4K 屏幕图标、文字非常小,甚至无法辨认。参考网络上的解决方案,我在 main 函数的添加了以下语句:

QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps

然后编译运行,图标和字体均可以清晰显示,但是标题栏的最小/大化键和关闭键异常的大。
具体情况如下图:
image

请问这种情况该如何修复。谢谢。

系统:Windows 10 1909 x64
显示屏:4K 13.3 英寸
Qt 版本:5.14.1 (MingW 7.3 x64)

QDesignerContainerExtension need canAddWidget and canRemoveWidget in Qt6.3

I have built the solution on msvc 2022 + Qt6.3 and I have some notes:

replace qt5_wrap_cpp with qt6_wrap_cpp in cmake ;

All class that use QDesignerContainerExtension have errors (abstract class):
add bool canRemove(int index) const Q_DECL_OVERRIDE; and bool canAddWidget() const Q_DECL_OVERRIDE;

Thanks and sorry to write in english, I don't know chinese.

请问如何设置最小化、最大化和关闭按钮WindowButtonGroup显示大小

首先感谢分享代码。
image
windows button设置如下:
buttonMinimize->setFixedSize(40, 28);//原来设置:buttonMinimize->setFixedSize(30, 28);
buttonMaximize->setFixedSize(40, 28);//原来设置:buttonMaximize->setFixedSize(30, 28);
buttonClose->setFixedSize(40, 28);//原来设置:
WindowButtonGroup大小应该是120宽度,结果实际是100,改了好久没成功,不知道改哪里,能指明下吗?谢谢了!

wps模式下正常窗口,标题栏无法拖动,上边框区域拉伸不太灵

你好:
我想使用wps模式,但wps模式下正常窗口不再是wps模式了,如图:
2020-08-28_22-05-09
修改resizeEvent()后是wps模式了,但标题栏却无法拖动窗口了(红色表示部分),且上边框拉伸不咋灵了(橙色表示部分)。
3
看了事件传递,但不太明白RibbonBar上的标题栏和按钮上面的事件是如何传递给Frameless 标题栏的。
请问还要修改哪里呀?谢谢!

关于ApplicationButton的问题

作者您好,我看了下源代码ApplicationButton是个QPushButton,但是ribbon->applicationButton()返回的是个抽象类QAbstractButton,请问我需要利用qobject_cast<QPushButton*>(ribbon->applicationButton())->setMenu()来设置菜单吗?(使用此方法会导致右侧有个倒三角图标)

Support Qt5 while building with cmake

in CMakeLists.txt
find_package(Qt6 COMPONENTS Core Widgets GUI) if (NOT Qt6_FOUND) find_package(Qt5 5.15 REQUIRED COMPONENTS Core Widgets GUI) set(Qt_VERSION_MAJOR 5) else() set(Qt_VERSION_MAJOR 5) endif()

in src/SARibbonBar/CMakeLists.txt
target_link_libraries(${LIB_NAME} Qt${QT_VERSION_MAJOR}::Widgets)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.