void GCUserView::qlv_contextMenuRequested(Q3ListViewItem *i, const QPoint &pos, int) { if(!i || !i->parent() || !gcDlg_) return; QPointer<GCUserViewItem> lvi = (GCUserViewItem *)i; bool self = gcDlg_->nick() == i->text(0); GCUserViewItem* c = (GCUserViewItem*) findEntry(gcDlg_->nick()); if (!c) { qWarning(QString("groupchatdlg.cpp: Self ('%1') not found in contactlist").arg(gcDlg_->nick())); return; } Q3PopupMenu *pm = new Q3PopupMenu; pm->insertItem(IconsetFactory::icon("psi/sendMessage").icon(), tr("Send &message"), 0); pm->insertItem(IconsetFactory::icon("psi/start-chat").icon(), tr("Open &chat window"), 1); pm->insertSeparator(); pm->insertItem(tr("&Kick"),10); pm->setItemEnabled(10, MUCManager::canKick(c->s.mucItem(),lvi->s.mucItem())); pm->insertItem(tr("&Ban"),11); pm->setItemEnabled(11, MUCManager::canBan(c->s.mucItem(),lvi->s.mucItem())); Q3PopupMenu* rm = new Q3PopupMenu(pm); rm->insertItem(tr("Visitor"),12); rm->setItemChecked(12, lvi->s.mucItem().role() == MUCItem::Visitor); rm->setItemEnabled(12, (!self || lvi->s.mucItem().role() == MUCItem::Visitor) && MUCManager::canSetRole(c->s.mucItem(),lvi->s.mucItem(),MUCItem::Visitor)); rm->insertItem(tr("Participant"),13); rm->setItemChecked(13, lvi->s.mucItem().role() == MUCItem::Participant); rm->setItemEnabled(13, (!self || lvi->s.mucItem().role() == MUCItem::Participant) && MUCManager::canSetRole(c->s.mucItem(),lvi->s.mucItem(),MUCItem::Participant)); rm->insertItem(tr("Moderator"),14); rm->setItemChecked(14, lvi->s.mucItem().role() == MUCItem::Moderator); rm->setItemEnabled(14, (!self || lvi->s.mucItem().role() == MUCItem::Moderator) && MUCManager::canSetRole(c->s.mucItem(),lvi->s.mucItem(),MUCItem::Moderator)); pm->insertItem(tr("Change role"),rm); /*Q3PopupMenu* am = new Q3PopupMenu(pm); am->insertItem(tr("Unaffiliated"),15); am->setItemChecked(15, lvi->s.mucItem().affiliation() == MUCItem::NoAffiliation); am->setItemEnabled(15, (!self || lvi->s.mucItem().affiliation() == MUCItem::NoAffiliation) && MUCManager::canSetAffiliation(c->s.mucItem(),lvi->s.mucItem(),MUCItem::NoAffiliation)); am->insertItem(tr("Member"),16); am->setItemChecked(16, lvi->s.mucItem().affiliation() == MUCItem::Member); am->setItemEnabled(16, (!self || lvi->s.mucItem().affiliation() == MUCItem::Member) && MUCManager::canSetAffiliation(c->s.mucItem(),lvi->s.mucItem(),MUCItem::Member)); am->insertItem(tr("Administrator"),17); am->setItemChecked(17, lvi->s.mucItem().affiliation() == MUCItem::Admin); am->setItemEnabled(17, (!self || lvi->s.mucItem().affiliation() == MUCItem::Admin) && MUCManager::canSetAffiliation(c->s.mucItem(),lvi->s.mucItem(),MUCItem::Admin)); am->insertItem(tr("Owner"),18); am->setItemChecked(18, lvi->s.mucItem().affiliation() == MUCItem::Owner); am->setItemEnabled(18, (!self || lvi->s.mucItem().affiliation() == MUCItem::Owner) && MUCManager::canSetAffiliation(c->s.mucItem(),lvi->s.mucItem(),MUCItem::Owner)); pm->insertItem(tr("Change affiliation"),am);*/ pm->insertSeparator(); //pm->insertItem(tr("Send &file"), 4); //pm->insertSeparator(); pm->insertItem(tr("Check &Status"), 2); pm->insertItem(IconsetFactory::icon("psi/vCard").icon(), tr("User &Info"), 3); int x = pm->exec(pos); bool enabled = pm->isItemEnabled(x) || rm->isItemEnabled(x); delete pm; if(x == -1 || !enabled || lvi.isNull()) return; action(lvi->text(0), lvi->s, x); }
Main::Main(QGraphicsScene& c, QWidget* parent, const char* name, Qt::WindowFlags f) : Q3MainWindow(parent,name,f), canvas(c) { editor = new FigureEditor(canvas,this); QMenuBar* menu = menuBar(); Q3PopupMenu* file = new Q3PopupMenu( menu ); file->insertItem("&Fill canvas", this, SLOT(init()), Qt::CTRL+Qt::Key_F); file->insertItem("&Erase canvas", this, SLOT(clear()), Qt::CTRL+Qt::Key_E); file->insertItem("&New view", this, SLOT(newView()), Qt::CTRL+Qt::Key_N); file->insertSeparator(); file->insertItem("&Print...", this, SLOT(print()), Qt::CTRL+Qt::Key_P); file->insertSeparator(); file->insertItem("E&xit", qApp, SLOT(quit()), Qt::CTRL+Qt::Key_Q); menu->insertItem("&File", file); Q3PopupMenu* edit = new Q3PopupMenu( menu ); edit->insertItem("Add &Circle", this, SLOT(addCircle()), Qt::ALT+Qt::Key_C); edit->insertItem("Add &Hexagon", this, SLOT(addHexagon()), Qt::ALT+Qt::Key_H); edit->insertItem("Add &Polygon", this, SLOT(addPolygon()), Qt::ALT+Qt::Key_P); edit->insertItem("Add Spl&ine", this, SLOT(addSpline()), Qt::ALT+Qt::Key_I); edit->insertItem("Add &Text", this, SLOT(addText()), Qt::ALT+Qt::Key_T); edit->insertItem("Add &Line", this, SLOT(addLine()), Qt::ALT+Qt::Key_L); edit->insertItem("Add &Rectangle", this, SLOT(addRectangle()), Qt::ALT+Qt::Key_R); edit->insertItem("Add &Sprite", this, SLOT(addSprite()), Qt::ALT+Qt::Key_S); edit->insertItem("Create &Mesh", this, SLOT(addMesh()), Qt::ALT+Qt::Key_M ); edit->insertItem("Add &Alpha-blended image", this, SLOT(addButterfly()), Qt::ALT+Qt::Key_A); menu->insertItem("&Edit", edit); Q3PopupMenu* view = new Q3PopupMenu( menu ); view->insertItem("&Enlarge", this, SLOT(enlarge()), Qt::SHIFT+Qt::CTRL+Qt::Key_Plus); view->insertItem("Shr&ink", this, SLOT(shrink()), Qt::SHIFT+Qt::CTRL+Qt::Key_Minus); view->insertSeparator(); view->insertItem("&Rotate clockwise", this, SLOT(rotateClockwise()), Qt::CTRL+Qt::Key_PageDown); view->insertItem("Rotate &counterclockwise", this, SLOT(rotateCounterClockwise()), Qt::CTRL+Qt::Key_PageUp); view->insertItem("&Zoom in", this, SLOT(zoomIn()), Qt::CTRL+Qt::Key_Plus); view->insertItem("Zoom &out", this, SLOT(zoomOut()), Qt::CTRL+Qt::Key_Minus); view->insertItem("Translate left", this, SLOT(moveL()), Qt::CTRL+Qt::Key_Left); view->insertItem("Translate right", this, SLOT(moveR()), Qt::CTRL+Qt::Key_Right); view->insertItem("Translate up", this, SLOT(moveU()), Qt::CTRL+Qt::Key_Up); view->insertItem("Translate down", this, SLOT(moveD()), Qt::CTRL+Qt::Key_Down); view->insertItem("&Mirror", this, SLOT(mirror()), Qt::CTRL+Qt::Key_Home); menu->insertItem("&View", view); menu->insertSeparator(); Q3PopupMenu* help = new Q3PopupMenu( menu ); help->insertItem("&About", this, SLOT(help()), Qt::Key_F1); help->setItemChecked(dbf_id, TRUE); menu->insertItem("&Help",help); statusBar(); setCentralWidget(editor); printer = 0; init(); }
void GCUserView::qlv_contextMenuRequested(Q3ListViewItem *i, const QPoint &pos, int) { if(!i || !i->parent() || !gcDlg_) return; QPointer<GCUserViewItem> lvi = (GCUserViewItem *)i; bool self = gcDlg_->nick() == i->text(0); GCUserViewItem* c = (GCUserViewItem*) findEntry(gcDlg_->nick()); if (!c) { qWarning() << QString("groupchatdlg.cpp: Self ('%1') not found in contactlist").arg(gcDlg_->nick()); return; } Q3PopupMenu *pm = new Q3PopupMenu; pm->insertItem(IconsetFactory::icon("psi/sendMessage").icon(), tr("Send &Message"), 0); pm->insertItem(IconsetFactory::icon("psi/start-chat").icon(), tr("Open &Chat Window"), 1); pm->insertSeparator(); // Kick and Ban submenus QStringList reasons = PsiOptions::instance()->getOption("options.muc.reasons").toStringList(); int cntReasons=reasons.count(); if (cntReasons>99) cntReasons=99; // Only first 99 reasons Q3PopupMenu *kickMenu = new Q3PopupMenu(pm); kickMenu->insertItem(tr("No reason"),10); kickMenu->insertItem(tr("Custom reason"),100); kickMenu->insertSeparator(); bool canKick=MUCManager::canKick(c->s.mucItem(),lvi->s.mucItem()); for (int i=0; i<cntReasons; ++i) kickMenu->insertItem(reasons[i], 101+i); kickMenu->setEnabled(canKick); Q3PopupMenu *banMenu = new Q3PopupMenu(pm); banMenu->insertItem(tr("No reason"),11); banMenu->insertItem(tr("Custom reason"),200); banMenu->insertSeparator(); bool canBan=MUCManager::canBan(c->s.mucItem(),lvi->s.mucItem()); for (int i=0; i<cntReasons; ++i) banMenu->insertItem(reasons[i], 201+i); banMenu->setEnabled(canBan); pm->insertItem(tr("&Kick"), kickMenu); pm->setItemEnabled(10, canKick); pm->insertItem(tr("&Ban"), banMenu); pm->setItemEnabled(11, canBan); Q3PopupMenu* rm = new Q3PopupMenu(pm); rm->insertItem(tr("Visitor"),12); rm->setItemChecked(12, lvi->s.mucItem().role() == MUCItem::Visitor); rm->setItemEnabled(12, (!self || lvi->s.mucItem().role() == MUCItem::Visitor) && MUCManager::canSetRole(c->s.mucItem(),lvi->s.mucItem(),MUCItem::Visitor)); rm->insertItem(tr("Participant"),13); rm->setItemChecked(13, lvi->s.mucItem().role() == MUCItem::Participant); rm->setItemEnabled(13, (!self || lvi->s.mucItem().role() == MUCItem::Participant) && MUCManager::canSetRole(c->s.mucItem(),lvi->s.mucItem(),MUCItem::Participant)); rm->insertItem(tr("Moderator"),14); rm->setItemChecked(14, lvi->s.mucItem().role() == MUCItem::Moderator); rm->setItemEnabled(14, (!self || lvi->s.mucItem().role() == MUCItem::Moderator) && MUCManager::canSetRole(c->s.mucItem(),lvi->s.mucItem(),MUCItem::Moderator)); pm->insertItem(tr("Change Role"),rm); /*Q3PopupMenu* am = new Q3PopupMenu(pm); am->insertItem(tr("Unaffiliated"),15); am->setItemChecked(15, lvi->s.mucItem().affiliation() == MUCItem::NoAffiliation); am->setItemEnabled(15, (!self || lvi->s.mucItem().affiliation() == MUCItem::NoAffiliation) && MUCManager::canSetAffiliation(c->s.mucItem(),lvi->s.mucItem(),MUCItem::NoAffiliation)); am->insertItem(tr("Member"),16); am->setItemChecked(16, lvi->s.mucItem().affiliation() == MUCItem::Member); am->setItemEnabled(16, (!self || lvi->s.mucItem().affiliation() == MUCItem::Member) && MUCManager::canSetAffiliation(c->s.mucItem(),lvi->s.mucItem(),MUCItem::Member)); am->insertItem(tr("Administrator"),17); am->setItemChecked(17, lvi->s.mucItem().affiliation() == MUCItem::Admin); am->setItemEnabled(17, (!self || lvi->s.mucItem().affiliation() == MUCItem::Admin) && MUCManager::canSetAffiliation(c->s.mucItem(),lvi->s.mucItem(),MUCItem::Admin)); am->insertItem(tr("Owner"),18); am->setItemChecked(18, lvi->s.mucItem().affiliation() == MUCItem::Owner); am->setItemEnabled(18, (!self || lvi->s.mucItem().affiliation() == MUCItem::Owner) && MUCManager::canSetAffiliation(c->s.mucItem(),lvi->s.mucItem(),MUCItem::Owner)); pm->insertItem(tr("Change Affiliation"),am);*/ pm->insertSeparator(); //pm->insertItem(tr("Send &File"), 4); //pm->insertSeparator(); pm->insertItem(tr("Check &Status"), 2); pm->insertItem(IconsetFactory::icon("psi/vCard").icon(), tr("User &Info"), 3); int x = pm->exec(pos); bool enabled = pm->isItemEnabled(x) || rm->isItemEnabled(x) || kickMenu->isItemEnabled(x) || banMenu->isItemEnabled(x); delete pm; if(x == -1 || !enabled || lvi.isNull()) return; action(lvi->text(0), lvi->s, x); }