| 205 | } |
| 206 | |
| 207 | void MainWindow::initRibbon() |
| 208 | { |
| 209 | setAppBarHeight(30); |
| 210 | setRibbonHeight(75); |
| 211 | // QWidget* ribbonTabWidget = new QWidget(this); |
| 212 | // auto ribbonTabLayout = new QVBoxLayout(ribbonTabWidget); |
| 213 | // ribbonTabLayout->setContentsMargins(10, 10, 0, 0); |
| 214 | // _ribbonTabBar = new ElaTabBar(this); |
| 215 | // _ribbonTabBar->setTabSize(QSize(200, 35)); |
| 216 | // ribbonTabLayout->addWidget(_ribbonTabBar); |
| 217 | // setCustomWidget(ElaAppBarType::CustomArea::LeftArea, ribbonTabWidget, this, "processHitTest"); |
| 218 | |
| 219 | _ribbonBar = new ElaRibbonBar(this); |
| 220 | // _ribbonBar->setRibbonTabBar(_ribbonTabBar); |
| 221 | _ribbonBar->move(0, getAppBarHeight()); |
| 222 | auto adminAction = _ribbonBar->addRibbonAction("通用操作", "多用户管理", ElaIconType::User); |
| 223 | ElaMenu* menu = new ElaMenu(this); |
| 224 | menu->addAction("用户资料"); |
| 225 | menu->addAction("角色管理"); |
| 226 | menu->addAction("访问权限"); |
| 227 | adminAction->setMenu(menu); |
| 228 | |
| 229 | _ribbonBar->addRibbonAction("通用操作", "文件管理", "新建", ElaIconType::FilePlus); |
| 230 | _ribbonBar->addRibbonAction("通用操作", "文件管理", "打开", ElaIconType::FolderOpen); |
| 231 | _ribbonBar->addRibbonAction("通用操作", "文件管理", "关闭", ElaIconType::FolderClosed); |
| 232 | _ribbonBar->addRibbonAction("通用操作", "文件管理", "保存", ElaIconType::FileArrowDown); |
| 233 | _ribbonBar->addRibbonAction("通用操作", "文件管理", "另存为", ElaIconType::Files); |
| 234 | |
| 235 | // 命令操作 |
| 236 | auto undoAction = _ribbonBar->addRibbonAction("通用操作", "命令操作", "撤销", ElaIconType::RotateLeft); |
| 237 | connect(undoAction, &QAction::triggered, this, [=]() { |
| 238 | ElaActionCommander::getInstance()->undoCommand("ElaWidgetToolsAction"); |
| 239 | }); |
| 240 | auto redoAction = _ribbonBar->addRibbonAction("通用操作", "命令操作", "重做", ElaIconType::RotateRight); |
| 241 | connect(redoAction, &QAction::triggered, this, [=]() { |
| 242 | ElaActionCommander::getInstance()->redoCommand("ElaWidgetToolsAction"); |
| 243 | }); |
| 244 | undoAction->setEnabled(false); |
| 245 | redoAction->setEnabled(false); |
| 246 | connect(ElaActionCommander::getInstance(), &ElaActionCommander::commanderStateChanged, this, [=](const QString& domainName, ElaActionCommanderType::CommanderState state) { |
| 247 | if (domainName != "ElaWidgetToolsAction") |
| 248 | { |
| 249 | return; |
| 250 | } |
| 251 | switch (state) |
| 252 | { |
| 253 | case ElaActionCommanderType::UndoValid: |
| 254 | { |
| 255 | undoAction->setEnabled(true); |
| 256 | break; |
| 257 | } |
| 258 | case ElaActionCommanderType::UndoInvalid: |
| 259 | { |
| 260 | undoAction->setEnabled(false); |
| 261 | break; |
| 262 | } |
| 263 | case ElaActionCommanderType::RedoValid: |
| 264 | { |
nothing calls this directly
no test coverage detected