LRESULT UCPage::onInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { PropPage::translate((HWND)(*this), texts); PropPage::read((HWND)*this, items); CRect rc; ctrlCommands.Attach(GetDlgItem(IDC_MENU_ITEMS)); ctrlCommands.GetClientRect(rc); ctrlCommands.InsertColumn(0, CTSTRING(SETTINGS_NAME), LVCFMT_LEFT, rc.Width()/4, 0); ctrlCommands.InsertColumn(1, CTSTRING(SETTINGS_COMMAND), LVCFMT_LEFT, rc.Width()*2 / 4, 1); ctrlCommands.InsertColumn(2, CTSTRING(HUB), LVCFMT_LEFT, rc.Width() / 4, 2); ctrlCommands.SetExtendedListViewStyle(LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER); // Do specialized reading here UserCommand::List lst = FavoriteManager::getInstance()->getUserCommands(); for(UserCommand::List::iterator i = lst.begin(); i != lst.end(); ++i) { UserCommand& uc = *i; if(!uc.isSet(UserCommand::FLAG_NOSAVE)) { addEntry(uc, ctrlCommands.GetItemCount()); } } return TRUE; }
void UCModel::loadUC(){ UserCommand::List lst = FavoriteManager::getInstance()->getUserCommands(); for (auto i = lst.begin(); i != lst.end(); ++i) { const UserCommand& uc = *i; if(!uc.isSet(UserCommand::FLAG_NOSAVE)) addUC(uc); } }
QMenu *WulforUtil::buildUserCmdMenu(const StringList& hub_list, int ctx, QWidget* parent) { UserCommand::List userCommands = FavoriteManager::getInstance()->getUserCommands(ctx, hub_list); if (userCommands.empty()) return nullptr; QMenu *ucMenu = new QMenu(tr("User commands"), parent); QMenu *menuPtr = ucMenu; for (size_t n = 0; n < userCommands.size(); ++n) { UserCommand *uc = &userCommands[n]; if (uc->getType() == UserCommand::TYPE_SEPARATOR) { // Avoid double separators... if (!menuPtr->actions().isEmpty() && !menuPtr->actions().last()->isSeparator()) { menuPtr->addSeparator(); } } else if (uc->isRaw() || uc->isChat()) { menuPtr = ucMenu; auto _begin = uc->getDisplayName().begin(); auto _end = uc->getDisplayName().end(); for(; _begin != _end; ++_begin) { const QString name = _q(*_begin); if (_begin + 1 == _end) { menuPtr->addAction(name)->setData(uc->getId()); } else { bool found = false; QListIterator<QAction*> iter(menuPtr->actions()); while(iter.hasNext()) { QAction *item = iter.next(); if (item->menu() && item->text() == name) { found = true; menuPtr = item->menu(); break; } } if (!found) menuPtr = menuPtr->addMenu(name); } } } } return ucMenu; }