void Configuration::setServiceMenu() { KMenu *menu = qobject_cast<KMenu*>(sender()); if (menu->actions().count() > 1) { return; } KServiceGroup::Ptr rootGroup = KServiceGroup::group(menu->actions()[0]->data().toString()); if (!rootGroup || !rootGroup->isValid() || rootGroup->noDisplay()) { return; } KServiceGroup::List list = rootGroup->entries(true, true, true, true); QAction *action = menu->addAction(KIcon("list-add"), i18n("Add This Menu")); action->setData(rootGroup->relPath()); menu->addSeparator(); for (int i = 0; i < list.count(); ++i) { if (list.at(i)->isType(KST_KService)) { const KService::Ptr service = KService::Ptr::staticCast(list.at(i)); action = menu->addAction(KIcon(service->icon()), service->name()); action->setEnabled(false); } else if (list.at(i)->isType(KST_KServiceGroup)) { const KServiceGroup::Ptr group = KServiceGroup::Ptr::staticCast(list.at(i)); if (group->noDisplay() || group->childCount() == 0) { continue; } KMenu *subMenu = new KMenu(menu); QAction *action = subMenu->addAction(QString()); action->setData(group->relPath()); action->setVisible(false); action = menu->addAction(KIcon(group->icon()), group->caption()); action->setMenu(subMenu); connect(subMenu, SIGNAL(aboutToShow()), this, SLOT(setServiceMenu())); } else if (list.at(i)->isType(KST_KServiceSeparator)) { menu->addSeparator(); } } }
void tst_QToolBar::task197996_visibility() { QMainWindow mw; QToolBar *toolBar = new QToolBar(&mw); mw.addToolBar(toolBar); toolBar->addAction(new QAction("Foo", &mw)); QAction *pAction = new QAction("Test", &mw); toolBar->addAction(pAction); pAction->setVisible(false); toolBar->setVisible(false); toolBar->setVisible(true); pAction->setVisible(true); mw.show(); QVERIFY(toolBar->widgetForAction(pAction)->isVisible()); toolBar->setVisible(false); pAction->setVisible(false); toolBar->setVisible(true); pAction->setVisible(true); QTest::qWait(100); QVERIFY(toolBar->widgetForAction(pAction)->isVisible()); }
void FLAccessControlMainWindow::processObject(QObject *obj) { QMainWindow *mw = ::qt_cast<QMainWindow *>(obj); if (!mw || !acosPerms_) return; if (!perm_.isEmpty()) { QObjectList *l = mw->queryList("QAction"); QObjectListIt ito(*l); QAction *a; while ((a = ::qt_cast<QAction *>(ito.current())) != 0) { ++ito; if ((*acosPerms_)[a->name()]) continue; if (perm_ == "-w" || perm_ == "--") a->setVisible(false); } delete l; } QDictIterator < QString > it(*acosPerms_); for (; it.current(); ++it) { QAction *a = ::qt_cast<QAction *>(mw->child(it.currentKey(), "QAction")); if (a) { QString perm = *(*it); if (perm == "-w" || perm == "--") a->setVisible(false); } } }
void MainWidget::mainTabContextualMenu(const QPoint &pos) { if (debug) qDebug() << PDEBUG; if (ui->tableWidget_main->currentItem() == nullptr) return; // create menu QMenu menu(this); QAction *refreshTable = menu.addAction(QApplication::translate("MainWidget", "Refresh")); refreshTable->setIcon(QIcon::fromTheme("view-refresh")); menu.addSeparator(); QAction *startProfile = menu.addAction(QApplication::translate("MainWidget", "Start profile")); QAction *restartProfile = menu.addAction(QApplication::translate("MainWidget", "Restart profile")); restartProfile->setIcon(QIcon::fromTheme("view-refresh")); QAction *enableProfile = menu.addAction(QApplication::translate("MainWidget", "Enable profile")); menu.addSeparator(); QAction *editProfile = menu.addAction(QApplication::translate("MainWidget", "Edit profile")); editProfile->setIcon(QIcon::fromTheme("document-edit")); QAction *removeProfile = menu.addAction(QApplication::translate("MainWidget", "Remove profile")); removeProfile->setIcon(QIcon::fromTheme("edit-delete")); // set text if (!ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 2)->text().isEmpty()) { restartProfile->setVisible(true); startProfile->setText(QApplication::translate("MainWidget", "Stop profile")); startProfile->setIcon(QIcon::fromTheme("process-stop")); } else { restartProfile->setVisible(false); startProfile->setText(QApplication::translate("MainWidget", "Start profile")); startProfile->setIcon(QIcon::fromTheme("system-run")); } if (!ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 3)->text().isEmpty()) { enableProfile->setText(QApplication::translate("MainWidget", "Disable profile")); enableProfile->setIcon(QIcon::fromTheme("edit-remove")); } else { enableProfile->setText(QApplication::translate("MainWidget", "Enable profile")); enableProfile->setIcon(QIcon::fromTheme("list-add")); } // actions QAction *action = menu.exec(ui->tableWidget_main->viewport()->mapToGlobal(pos)); if (action == refreshTable) { if (debug) qDebug() << PDEBUG << ":" << "Refresh table"; updateMainTab(); } else if (action == startProfile) { if (debug) qDebug() << PDEBUG << ":" << "Start profile"; mainTabStartProfile(); } else if (action == restartProfile) { if (debug) qDebug() << PDEBUG << ":" << "Restart profile"; mainTabRestartProfile(); } else if (action == enableProfile) { if (debug) qDebug() << PDEBUG << ":" << "Enable profile"; mainTabEnableProfile(); } else if (action == editProfile) { if (debug) qDebug() << PDEBUG << ":" << "Edit profile"; mainTabEditProfile(); } else if (action == removeProfile) { if (debug) qDebug() << PDEBUG << ":" << "Remove profile"; mainTabRemoveProfile(); } }
/* * TODO: * ==== * - display value of a port (nice to have) * - triangle port (nice to have) * - mouse over (over a node or port) (nice to have) * - round shaped nodes (nice to have) */ namespace Magus { //****************************************************************************/ QtNodeEditor::QtNodeEditor(QWidget* parent) : QWidget(parent) { QVBoxLayout* mainLayout = new QVBoxLayout; mView = new QGraphicsView(this); mScene = new QtNodeGraphicsScene(); mScene->installEventFilter(this); mView->setScene(mScene); mView->setRenderHint(QPainter::Antialiasing, true); mView->setInteractive(true); mView->setMouseTracking(true); mainLayout->addWidget(mView); mLastRemovedNode = 0; mRubberBand = 0; mZoom = 1.0f; mFisheyeViewEnabled = false; mFisheyeMaxZoom = 1.0f; mFisheyeSteps = 5; mHeaderTitleIcon = NODE_HEADER_COMPOUND_ICON; mAction1Icon = NODE_HEADER_ACTION1_ICON; mAction2Icon = NODE_HEADER_ACTION2_ICON; mCompoundNodeDropped = 0; mRubberbandSelection = false; mContextMenuEnabled = true; mContextMenu = new QMenu(this); mContextMenu->addAction(new QAction(NODE_ACTION_DELETE, this)); mContextMenu->addAction(new QAction(NODE_ACTION_CENTER, this)); mZoomSubMenu = mContextMenu->addMenu(NODE_ACTION_ZOOM); QAction* action; QActionGroup actionGroupZoom(mZoomSubMenu); actionGroupZoom.setExclusive(true); action = new QAction(NODE_ACTION_ZOOM_10, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_25, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_50, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_75, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_90, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_100, this); action->setCheckable(true); action->setChecked(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_150, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_200, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_250, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_300, this); action->setCheckable(true); actionGroupZoom.addAction(action); mZoomSubMenu->addActions(actionGroupZoom.actions()); mFisheyeViewSubMenu = mContextMenu->addMenu(NODE_ACTION_FISHEY_VIEW); QActionGroup actionGroupFisheye(mFisheyeViewSubMenu); actionGroupFisheye.setExclusive(true); action = new QAction(NODE_ACTION_FISHEYE_DISABLED, this); action->setCheckable(true); action->setChecked(true); actionGroupFisheye.addAction(action); action = new QAction(NODE_ACTION_FISHEYE_NORMAL, this); action->setCheckable(true); actionGroupFisheye.addAction(action); action = new QAction(NODE_ACTION_FISHEYE_NORMAL_SUBTLE, this); action->setCheckable(true); actionGroupFisheye.addAction(action); action = new QAction(NODE_ACTION_FISHEYE_LARGE, this); action->setCheckable(true); actionGroupFisheye.addAction(action); action = new QAction(NODE_ACTION_FISHEYE_LARGE_SUBTLE, this); action->setCheckable(true); actionGroupFisheye.addAction(action); mFisheyeViewSubMenu->addActions(actionGroupFisheye.actions()); mContextMenu->addAction(new QAction(NODE_ACTION_SELECTED_TO_COMPOUND, this)); mContextMenu->addAction(new QAction(NODE_ACTION_COLLAPSE_ALL, this)); mContextMenu->addAction(new QAction(NODE_ACTION_EXPAND_ALL, this)); mContextMenu->addAction(new QAction(NODE_ACTION_EXPAND_COMPOUNDS, this)); mContextMenu->addAction(new QAction(NODE_ACTION_CENTER, this)); setMenuZoomEnabled(true); setMenuSelectionToCompoundEnabled(true); setMenuCollapseExpandEnabled(true); setMenuExpandCompoundsEnabled(true); setMenuFisheyeViewEnabled(true); setContextMenuPolicy(Qt::CustomContextMenu); connect(mContextMenu, SIGNAL(triggered(QAction*)), this, SLOT(contextMenuItemSelected(QAction*))); setLayout(mainLayout); } //****************************************************************************/ QtNodeEditor::~QtNodeEditor(void) { } //****************************************************************************/ void QtNodeEditor::setContextMenuEnabled(bool enabled) { mContextMenuEnabled = enabled; } //****************************************************************************/ void QtNodeEditor::setCompoundHeaderTitleIcon(const QString& fileNameIcon) { mHeaderTitleIcon = fileNameIcon; } //****************************************************************************/ void QtNodeEditor::setCompoundAction1Icon(const QString& fileNameIcon) { mAction1Icon = fileNameIcon; } //****************************************************************************/ void QtNodeEditor::setCompoundAction2Icon(const QString& fileNameIcon) { mAction2Icon = fileNameIcon; } //****************************************************************************/ bool QtNodeEditor::isContextMenuEnabled(void) { return mContextMenuEnabled; } //****************************************************************************/ void QtNodeEditor::setMenuZoomEnabled(bool enabled) { mMenuZoomEnabled = enabled; QAction* action = getActionFromContextMenu(NODE_ACTION_ZOOM); if (action) action->setVisible(enabled); } //****************************************************************************/ bool QtNodeEditor::isMenuZoomEnabled(void) { return mMenuZoomEnabled; } //****************************************************************************/ void QtNodeEditor::setMenuSelectionToCompoundEnabled(bool enabled) { mMenuSelectionToCompoundEnabled = enabled; QAction* action = getActionFromContextMenu(NODE_ACTION_SELECTED_TO_COMPOUND); if (action) action->setVisible(enabled); } //****************************************************************************/ bool QtNodeEditor::isMenuSelectionToCompoundEnabled(void) { return mMenuSelectionToCompoundEnabled; } //****************************************************************************/ void QtNodeEditor::setMenuCollapseExpandEnabled(bool enabled) { mMenuCollapseExpandEnabled = enabled; QAction* action = getActionFromContextMenu(NODE_ACTION_EXPAND_ALL); if (action) action->setVisible(enabled); action = getActionFromContextMenu(NODE_ACTION_COLLAPSE_ALL); if (action) action->setVisible(enabled); }
Editor::Editor(QStandardItemModel *model, QWidget *parent) : QWidget(parent), editables(Settings::fileIcons()) { QSizePolicy left(QSizePolicy::Preferred, QSizePolicy::Preferred); QSizePolicy right(QSizePolicy::Preferred, QSizePolicy::Preferred); left.setHorizontalStretch(2); right.setHorizontalStretch(4); // -- // QVBoxLayout *layout = new QVBoxLayout(this); QToolBar *tool_bar = new QToolBar(this); files = new QComboBox(tool_bar); tabs = new QTabWidget(this); tabs->setTabsClosable(true); this->variants = new QComboBox(tool_bar); files->setModel(model); files->setStyleSheet(STYLESHEET_COMBOBOXES); files->setSizePolicy(left); layout->addWidget(tool_bar); layout->addWidget(tabs); layout->setContentsMargins(0, 1, 0, 2); layout->setSpacing(2); tool_bar->addWidget(files); tool_bar->layout()->setContentsMargins(0, 0, 0, 0); tool_bar->layout()->setSpacing(2); this->variants->setStyleSheet(STYLESHEET_COMBOBOXES); this->variants->setSizePolicy(right); QAction *variants = tool_bar->addWidget(this->variants); variants->setVisible(false); setLayout(layout); setMinimumSize(64, 64); connections.append(connect(tabs, static_cast<void(QTabWidget::*)(int)>(&QTabWidget::tabCloseRequested), [ this ] (int index) { this->files->removeItem(index); this->tabs->removeTab(index); })); connections.append(connect(tabs, static_cast<void(QTabWidget::*)(int)>(&QTabWidget::currentChanged), [ this ] (int index) { if (index < 0) return; this->files->setCurrentIndex(index); })); connections.append(connect(files, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [ variants, this ] (int index) { if (index < 0) return; this->tabs->setCurrentIndex(index); emit selectionChanged(index); QWidget *widget = this->tabs->currentWidget(); if (!widget) return; if (widget->inherits(Viewer::staticMetaObject.className())) variants->setVisible(true); else variants->setVisible(false); widget->setFocus(); })); }
void MainWindow::loadRecentFiles(QSettings *s) { QStringList files; bool modified = false; s->beginGroup("Recent_Files"); for (int c = 1; c <= 4; c++) { QString key = QString("File_%1").arg(c); if (s->contains(key)) { QString file = s->value(key).toString(); if (QFile::exists(file)) { files.append(file); } else { modified = true; } } else { break; } } if (modified) { for (int c = 0; c < 4; c++) { QString key = QString("File_%1").arg(c + 1); if (files.count() > c) { s->setValue(key, files.at(c)); } else { if (s->contains(key)) { s->remove(key); } } } s->sync(); } s->endGroup(); for (int c = 0; c < 4; c++) { QAction *action = this->findChild<QAction *>(QString("actionRecent%1").arg(c + 1)); if (files.count() > c) { QFileInfo fi(files.at(c)); action->setText(fi.fileName()); action->setToolTip(fi.absoluteFilePath()); action->setVisible(true); } else { action->setVisible(false); } } }
PreviewActionGroup::PreviewActionGroup(QDesignerFormEditorInterface *core, QObject *parent) : QActionGroup(parent), m_core(core) { /* Create a list of up to MaxDeviceActions invisible actions to be * populated with device profiles (actiondata: index) followed by the * standard style actions (actiondata: style name). */ connect(this, SIGNAL(triggered(QAction*)), this, SLOT(slotTriggered(QAction*))); setExclusive(true); const QString objNamePostfix = QStringLiteral("_action"); // Create invisible actions for devices. Set index as action data. QString objNamePrefix = QStringLiteral("__qt_designer_device_"); for (int i = 0; i < MaxDeviceActions; i++) { QAction *a = new QAction(this); QString objName = objNamePrefix; objName += QString::number(i); objName += objNamePostfix; a->setObjectName(objName); a->setVisible(false); a->setData(i); addAction(a); } // Create separator at index MaxDeviceActions QAction *sep = new QAction(this); sep->setObjectName(QStringLiteral("__qt_designer_deviceseparator")); sep->setSeparator(true); sep->setVisible(false); addAction(sep); // Populate devices updateDeviceProfiles(); // Add style actions const QStringList styles = QStyleFactory::keys(); const QStringList::const_iterator cend = styles.constEnd(); // Make sure ObjectName is unique in case toolbar solution is used. objNamePrefix = QStringLiteral("__qt_designer_style_"); // Create styles. Set style name string as action data. for (QStringList::const_iterator it = styles.constBegin(); it != cend ;++it) { QAction *a = new QAction(tr("%1 Style").arg(*it), this); QString objName = objNamePrefix; objName += *it; objName += objNamePostfix; a->setObjectName(objName); a->setData(*it); addAction(a); } }
/* * TODO: * ==== * - display value of a port (nice to have) * - triangle port (nice to have) * - mouse over (over a node or port) (nice to have) * - round shaped nodes (nice to have) */ namespace Magus { //****************************************************************************/ QtNodeEditor::QtNodeEditor(QWidget* parent) : QWidget(parent) { QVBoxLayout* mainLayout = new QVBoxLayout; mView = new QGraphicsView(this); mScene = new QtNodeGraphicsScene(); mScene->installEventFilter(this); mView->setScene(mScene); mView->setRenderHint(QPainter::Antialiasing, true); mView->setInteractive(true); mView->setMouseTracking(true); mainLayout->addWidget(mView); mLastRemovedNode = 0; mRubberBand = 0; mZoom = 1.0f; mFisheyeViewEnabled = false; mFisheyeMaxZoom = 1.0f; mFisheyeSteps = 5; mHeaderTitleIcon = NODE_HEADER_COMPOUND_ICON; mAction1Icon = NODE_HEADER_ACTION1_ICON; mAction2Icon = NODE_HEADER_ACTION2_ICON; mCompoundNodeDropped = 0; mRubberbandSelection = false; mContextMenuEnabled = true; mContextMenu = new QMenu(this); mContextMenu->addAction(new QAction(NODE_ACTION_DELETE, this)); mContextMenu->addAction(new QAction(NODE_ACTION_CENTER, this)); mZoomSubMenu = mContextMenu->addMenu(NODE_ACTION_ZOOM); QAction* action; QActionGroup actionGroupZoom(mZoomSubMenu); actionGroupZoom.setExclusive(true); action = new QAction(NODE_ACTION_ZOOM_10, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_25, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_50, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_75, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_90, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_100, this); action->setCheckable(true); action->setChecked(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_150, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_200, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_250, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_300, this); action->setCheckable(true); actionGroupZoom.addAction(action); mZoomSubMenu->addActions(actionGroupZoom.actions()); mFisheyeViewSubMenu = mContextMenu->addMenu(NODE_ACTION_FISHEY_VIEW); QActionGroup actionGroupFisheye(mFisheyeViewSubMenu); actionGroupFisheye.setExclusive(true); action = new QAction(NODE_ACTION_FISHEYE_DISABLED, this); action->setCheckable(true); action->setChecked(true); actionGroupFisheye.addAction(action); action = new QAction(NODE_ACTION_FISHEYE_NORMAL, this); action->setCheckable(true); actionGroupFisheye.addAction(action); action = new QAction(NODE_ACTION_FISHEYE_NORMAL_SUBTLE, this); action->setCheckable(true); actionGroupFisheye.addAction(action); action = new QAction(NODE_ACTION_FISHEYE_LARGE, this); action->setCheckable(true); actionGroupFisheye.addAction(action); action = new QAction(NODE_ACTION_FISHEYE_LARGE_SUBTLE, this); action->setCheckable(true); actionGroupFisheye.addAction(action); mFisheyeViewSubMenu->addActions(actionGroupFisheye.actions()); mContextMenu->addAction(new QAction(NODE_ACTION_SELECTED_TO_COMPOUND, this)); mContextMenu->addAction(new QAction(NODE_ACTION_COLLAPSE_ALL, this)); mContextMenu->addAction(new QAction(NODE_ACTION_EXPAND_ALL, this)); mContextMenu->addAction(new QAction(NODE_ACTION_EXPAND_COMPOUNDS, this)); mContextMenu->addAction(new QAction(NODE_ACTION_CENTER, this)); setMenuZoomEnabled(true); setMenuSelectionToCompoundEnabled(true); setMenuCollapseExpandEnabled(true); setMenuExpandCompoundsEnabled(true); setMenuFisheyeViewEnabled(true); setContextMenuPolicy(Qt::CustomContextMenu); connect(mContextMenu, SIGNAL(triggered(QAction*)), this, SLOT(contextMenuItemSelected(QAction*))); setLayout(mainLayout); } //****************************************************************************/ QtNodeEditor::~QtNodeEditor(void) { } //****************************************************************************/ void QtNodeEditor::setContextMenuEnabled(bool enabled) { mContextMenuEnabled = enabled; } //****************************************************************************/ void QtNodeEditor::setCompoundHeaderTitleIcon(const QString& fileNameIcon) { mHeaderTitleIcon = fileNameIcon; } //****************************************************************************/ void QtNodeEditor::setCompoundAction1Icon(const QString& fileNameIcon) { mAction1Icon = fileNameIcon; } //****************************************************************************/ void QtNodeEditor::setCompoundAction2Icon(const QString& fileNameIcon) { mAction2Icon = fileNameIcon; } //****************************************************************************/ bool QtNodeEditor::isContextMenuEnabled(void) { return mContextMenuEnabled; } //****************************************************************************/ void QtNodeEditor::setMenuZoomEnabled(bool enabled) { mMenuZoomEnabled = enabled; QAction* action = getActionFromContextMenu(NODE_ACTION_ZOOM); if (action) action->setVisible(enabled); } //****************************************************************************/ bool QtNodeEditor::isMenuZoomEnabled(void) { return mMenuZoomEnabled; } //****************************************************************************/ void QtNodeEditor::setMenuSelectionToCompoundEnabled(bool enabled) { mMenuSelectionToCompoundEnabled = enabled; QAction* action = getActionFromContextMenu(NODE_ACTION_SELECTED_TO_COMPOUND); if (action) action->setVisible(enabled); }
/* * TODO: * ==== * - display value of a port (nice to have) * - triangle port (nice to have) * - mouse over (over a node or port) (nice to have) * - round shaped nodes (nice to have) */ namespace Magus { //****************************************************************************/ QtNodeEditor::QtNodeEditor(QWidget* parent) : QWidget(parent) { QVBoxLayout* mainLayout = new QVBoxLayout; mView = new QGraphicsView(this); mScene = new QtNodeGraphicsScene(); mScene->installEventFilter(this); mView->setScene(mScene); mView->setRenderHint(QPainter::Antialiasing, true); mView->setInteractive(true); mView->setMouseTracking(true); mainLayout->addWidget(mView); mLastRemovedNode = 0; mRubberBand = 0; mZoom = 1.0f; mFisheyeViewEnabled = false; mFisheyeMaxZoom = 1.0f; mFisheyeSteps = 5; mHeaderTitleIcon = NODE_HEADER_COMPOUND_ICON; mAction1Icon = NODE_HEADER_ACTION1_ICON; mAction2Icon = NODE_HEADER_ACTION2_ICON; mCompoundNodeDropped = 0; mRubberbandSelection = false; mContextMenuEnabled = true; mContextMenu = new QMenu(this); mContextMenu->addAction(new QAction(NODE_ACTION_DELETE, this)); mContextMenu->addAction(new QAction(NODE_ACTION_CENTER, this)); mZoomSubMenu = mContextMenu->addMenu(NODE_ACTION_ZOOM); QAction* action; QActionGroup actionGroupZoom(mZoomSubMenu); actionGroupZoom.setExclusive(true); action = new QAction(NODE_ACTION_ZOOM_10, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_25, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_50, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_75, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_90, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_100, this); action->setCheckable(true); action->setChecked(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_150, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_200, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_250, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_300, this); action->setCheckable(true); actionGroupZoom.addAction(action); mZoomSubMenu->addActions(actionGroupZoom.actions()); mFisheyeViewSubMenu = mContextMenu->addMenu(NODE_ACTION_FISHEY_VIEW); QActionGroup actionGroupFisheye(mFisheyeViewSubMenu); actionGroupFisheye.setExclusive(true); action = new QAction(NODE_ACTION_FISHEYE_DISABLED, this); action->setCheckable(true); action->setChecked(true); actionGroupFisheye.addAction(action); action = new QAction(NODE_ACTION_FISHEYE_NORMAL, this); action->setCheckable(true); actionGroupFisheye.addAction(action); action = new QAction(NODE_ACTION_FISHEYE_NORMAL_SUBTLE, this); action->setCheckable(true); actionGroupFisheye.addAction(action); action = new QAction(NODE_ACTION_FISHEYE_LARGE, this); action->setCheckable(true); actionGroupFisheye.addAction(action); action = new QAction(NODE_ACTION_FISHEYE_LARGE_SUBTLE, this); action->setCheckable(true); actionGroupFisheye.addAction(action); mFisheyeViewSubMenu->addActions(actionGroupFisheye.actions()); mContextMenu->addAction(new QAction(NODE_ACTION_SELECTED_TO_COMPOUND, this)); mContextMenu->addAction(new QAction(NODE_ACTION_COLLAPSE_ALL, this)); mContextMenu->addAction(new QAction(NODE_ACTION_EXPAND_ALL, this)); mContextMenu->addAction(new QAction(NODE_ACTION_EXPAND_COMPOUNDS, this)); mContextMenu->addAction(new QAction(NODE_ACTION_CENTER, this)); setMenuZoomEnabled(true); setMenuSelectionToCompoundEnabled(true); setMenuCollapseExpandEnabled(true); setMenuExpandCompoundsEnabled(true); setMenuFisheyeViewEnabled(true); setContextMenuPolicy(Qt::CustomContextMenu); connect(mContextMenu, SIGNAL(triggered(QAction*)), this, SLOT(contextMenuItemSelected(QAction*))); setLayout(mainLayout); } //****************************************************************************/ QtNodeEditor::~QtNodeEditor(void) { } //****************************************************************************/ void QtNodeEditor::setContextMenuEnabled(bool enabled) { mContextMenuEnabled = enabled; } //****************************************************************************/ void QtNodeEditor::setCompoundHeaderTitleIcon(const QString& fileNameIcon) { mHeaderTitleIcon = fileNameIcon; } //****************************************************************************/ void QtNodeEditor::setCompoundAction1Icon(const QString& fileNameIcon) { mAction1Icon = fileNameIcon; } //****************************************************************************/ void QtNodeEditor::setCompoundAction2Icon(const QString& fileNameIcon) { mAction2Icon = fileNameIcon; } //****************************************************************************/ bool QtNodeEditor::isContextMenuEnabled(void) { return mContextMenuEnabled; } //****************************************************************************/ void QtNodeEditor::setMenuZoomEnabled(bool enabled) { mMenuZoomEnabled = enabled; QAction* action = getActionFromContextMenu(NODE_ACTION_ZOOM); if (action) action->setVisible(enabled); }
// Search through the list of known stack menu items & find the menu for // this notebook's stack. If one doesn't exist we add it. QMenu* NotebookMenuButton::findStack(Notebook n) { if (!n.__isset.stack || QString::fromStdString(n.stack).trimmed() == "") return &rootMenu; QString stack = QString::fromStdString(n.stack).trimmed(); for (int i=0; i<stackMenus.size(); i++) { if (stackMenus.at(i)->title().toLower() == stack.toLower()) return stackMenus.at(i); } // Create a new stack. We add a dummy action item to the // menu so we know where to add the menu later. This // keeps things in sorted order QMenu *newMenu = new QMenu(this); newMenu->setTitle(stack); QFont f = newMenu->font(); f.setPointSize(10); f.setBold(false); newMenu->setFont(f); stackMenus.append(newMenu); QAction *placeHolder = new QAction(this); placeHolder->setVisible(false); placeHolder->setText(stack); addNotebookMenuItem(&rootMenu, placeHolder); addStackMenuItem(newMenu); return newMenu; }
Context::AppletToolbarAppletItem::AppletToolbarAppletItem( QGraphicsItem* parent, Plasma::Applet* applet ) : AppletToolbarBase( parent ) , m_applet( applet ) , m_label( 0 ) , m_deleteIcon( 0 ) , m_labelPadding( 5 ) , m_configEnabled( false ) { m_label = new QGraphicsTextItem( this ); if( m_applet ) { m_label->setPlainText( m_applet->name() ); setToolTip( m_applet->name() ); } else { m_label->setPlainText( i18n("no applet name") ); } setAcceptHoverEvents( true ); m_label->setAcceptHoverEvents( true ); QAction* delApplet = new QAction( i18n( "Remove Applet" ), this ); delApplet->setIcon( KIcon( "edit-delete" ) ); delApplet->setVisible( true ); delApplet->setEnabled( true ); connect( delApplet, SIGNAL( triggered() ), this, SLOT( deleteApplet() ) ); m_deleteIcon = addAction( delApplet, 18 ); m_deleteIcon->hide(); setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); paletteChanged( palette() ); connect( The::paletteHandler(), SIGNAL(newPalette(QPalette)), SLOT(paletteChanged(QPalette)) ); }
void MainWindow::build_recent_files_menu() { assert(m_recently_opened.empty()); m_recently_opened.reserve(MaxRecentlyOpenedFiles); for (int i = 0; i < MaxRecentlyOpenedFiles; ++i) { QAction* action = new QAction(this); action->setVisible(false); connect(action, SIGNAL(triggered()), SLOT(slot_open_recent())); m_ui->menu_open_recent->addAction(action); m_recently_opened.push_back(action); } QSettings settings(SettingsOrgString, SettingsRecentFilesEntryString); QStringList files = settings.value(SettingsRecentFileListString).toStringList(); update_recent_files_menu(files); m_ui->menu_open_recent->addSeparator(); m_clear_open_recent_menu = new QAction(this); m_clear_open_recent_menu->setText("&Clear Menu"); connect(m_clear_open_recent_menu, SIGNAL(triggered()), SLOT(slot_clear_open_recent_files_menu())); m_ui->menu_open_recent->addAction(m_clear_open_recent_menu); }
DockWidget::DockWidget(QWidget *parent, const char *name, PPPStats *st) : KSystemTrayIcon(parent), stats(st) { setObjectName(name); // load pixmaps dock_none_pixmap = UserIcon("dock_none"); dock_left_pixmap = UserIcon("dock_left"); dock_right_pixmap = UserIcon("dock_right"); dock_both_pixmap = UserIcon("dock_both"); setIcon(dock_none_pixmap); // popup menu for right mouse button popup_m = contextMenu(); popup_m->addAction(i18n("Details"), p_kppp, SLOT(showStats())); popup_m->addSeparator(); popup_m->addAction(i18n("Disconnect"), p_kppp, SLOT(disconnect())); // TODO see if we can rather connect the quit action to the // main window's quit handling, bypassing KSystemTrayIcon::maybeQuit QAction *quit = actionCollection()->action(KStandardAction::name(KStandardAction::Quit)); if (quit != 0) quit->setVisible(false); // connect to stats for little modem animation connect(stats, SIGNAL(statsChanged(int)), SLOT(paintIcon(int))); DockWidget::dock_widget = this; }
void ZLQtApplicationWindow::setToolbarItemState(ZLToolbar::ItemPtr item, bool visible, bool enabled) { QAction *action = myToolbarActions[item]; if (action != 0) { action->setEnabled(enabled); action->setVisible(visible); } }
/* * TODO: * ==== * - display value of a port (nice to have) * - triangle port (nice to have) * - mouse over (over a node or port) (nice to have) * - round shaped nodes (nice to have) */ namespace Magus { //****************************************************************************/ QtNodeEditor::QtNodeEditor(QWidget* parent) : QWidget(parent) { QVBoxLayout* mainLayout = new QVBoxLayout; mView = new QGraphicsView(this); mScene = new QtNodeGraphicsScene(); mScene->installEventFilter(this); mView->setScene(mScene); mView->setRenderHint(QPainter::Antialiasing, true); mView->setInteractive(true); mView->setMouseTracking(true); mainLayout->addWidget(mView); mLastRemovedNode = 0; mRubberBand = 0; mZoom = 1.0f; mFisheyeViewEnabled = false; mFisheyeMaxZoom = 1.0f; mFisheyeSteps = 5; mHeaderTitleIcon = NODE_HEADER_COMPOUND_ICON; mAction1Icon = NODE_HEADER_ACTION1_ICON; mAction2Icon = NODE_HEADER_ACTION2_ICON; mCompoundNodeDropped = 0; mRubberbandSelection = false; mContextMenuEnabled = true; mContextMenu = new QMenu(this); mContextMenu->addAction(new QAction(NODE_ACTION_DELETE, this)); mContextMenu->addAction(new QAction(NODE_ACTION_CENTER, this)); mZoomSubMenu = mContextMenu->addMenu(NODE_ACTION_ZOOM); QAction* action; QActionGroup actionGroupZoom(mZoomSubMenu); actionGroupZoom.setExclusive(true); action = new QAction(NODE_ACTION_ZOOM_10, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_25, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_50, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_75, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_90, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_100, this); action->setCheckable(true); action->setChecked(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_150, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_200, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_250, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_300, this); action->setCheckable(true); actionGroupZoom.addAction(action); mZoomSubMenu->addActions(actionGroupZoom.actions()); mFisheyeViewSubMenu = mContextMenu->addMenu(NODE_ACTION_FISHEY_VIEW); QActionGroup actionGroupFisheye(mFisheyeViewSubMenu); actionGroupFisheye.setExclusive(true); action = new QAction(NODE_ACTION_FISHEYE_DISABLED, this); action->setCheckable(true); action->setChecked(true); actionGroupFisheye.addAction(action); action = new QAction(NODE_ACTION_FISHEYE_NORMAL, this); action->setCheckable(true); actionGroupFisheye.addAction(action); action = new QAction(NODE_ACTION_FISHEYE_NORMAL_SUBTLE, this); action->setCheckable(true); actionGroupFisheye.addAction(action); action = new QAction(NODE_ACTION_FISHEYE_LARGE, this); action->setCheckable(true); actionGroupFisheye.addAction(action); action = new QAction(NODE_ACTION_FISHEYE_LARGE_SUBTLE, this); action->setCheckable(true); actionGroupFisheye.addAction(action); mFisheyeViewSubMenu->addActions(actionGroupFisheye.actions()); mContextMenu->addAction(new QAction(NODE_ACTION_SELECTED_TO_COMPOUND, this)); mContextMenu->addAction(new QAction(NODE_ACTION_COLLAPSE_ALL, this)); mContextMenu->addAction(new QAction(NODE_ACTION_EXPAND_ALL, this)); mContextMenu->addAction(new QAction(NODE_ACTION_EXPAND_COMPOUNDS, this)); mContextMenu->addAction(new QAction(NODE_ACTION_CENTER, this)); setMenuZoomEnabled(true); setMenuSelectionToCompoundEnabled(true); setMenuCollapseExpandEnabled(true); setMenuExpandCompoundsEnabled(true); setMenuFisheyeViewEnabled(true); setContextMenuPolicy(Qt::CustomContextMenu); connect(mContextMenu, SIGNAL(triggered(QAction*)), this, SLOT(contextMenuItemSelected(QAction*))); setLayout(mainLayout); } //****************************************************************************/ QtNodeEditor::~QtNodeEditor(void) { } //****************************************************************************/ void QtNodeEditor::setContextMenuEnabled(bool enabled) { mContextMenuEnabled = enabled; } //****************************************************************************/ void QtNodeEditor::setCompoundHeaderTitleIcon(const QString& fileNameIcon) { mHeaderTitleIcon = fileNameIcon; } //****************************************************************************/ void QtNodeEditor::setCompoundAction1Icon(const QString& fileNameIcon) { mAction1Icon = fileNameIcon; } //****************************************************************************/ void QtNodeEditor::setCompoundAction2Icon(const QString& fileNameIcon) { mAction2Icon = fileNameIcon; } //****************************************************************************/ bool QtNodeEditor::isContextMenuEnabled(void) { return mContextMenuEnabled; } //****************************************************************************/ void QtNodeEditor::setMenuZoomEnabled(bool enabled) { mMenuZoomEnabled = enabled; QAction* action = getActionFromContextMenu(NODE_ACTION_ZOOM); if (action) action->setVisible(enabled); } //****************************************************************************/ bool QtNodeEditor::isMenuZoomEnabled(void) { return mMenuZoomEnabled; } //****************************************************************************/ void QtNodeEditor::setMenuSelectionToCompoundEnabled(bool enabled) { mMenuSelectionToCompoundEnabled = enabled; QAction* action = getActionFromContextMenu(NODE_ACTION_SELECTED_TO_COMPOUND); if (action) action->setVisible(enabled); } //****************************************************************************/ bool QtNodeEditor::isMenuSelectionToCompoundEnabled(void) { return mMenuSelectionToCompoundEnabled; } //****************************************************************************/ void QtNodeEditor::setMenuCollapseExpandEnabled(bool enabled) { mMenuCollapseExpandEnabled = enabled; QAction* action = getActionFromContextMenu(NODE_ACTION_EXPAND_ALL); if (action) action->setVisible(enabled); action = getActionFromContextMenu(NODE_ACTION_COLLAPSE_ALL); if (action) action->setVisible(enabled); } //****************************************************************************/ bool QtNodeEditor::isMenuCollapseExpandEnabled(void) { return mMenuCollapseExpandEnabled; } //****************************************************************************/ void QtNodeEditor::setMenuExpandCompoundsEnabled(bool enabled) { mMenuExpandCompoundsEnabled = enabled; QAction* action = getActionFromContextMenu(NODE_ACTION_EXPAND_COMPOUNDS); if (action) action->setVisible(enabled); } //****************************************************************************/ bool QtNodeEditor::isMenuExpandCompoundsEnabled(void) { return mMenuExpandCompoundsEnabled; } //****************************************************************************/ void QtNodeEditor::setMenuFisheyeViewEnabled(bool enabled) { mMenuFisheyeViewEnabled = enabled; QAction* action = getActionFromContextMenu(NODE_ACTION_FISHEY_VIEW); if (action) action->setVisible(enabled); }
QAction *ToolBarChanger::insertWidget(QWidget *AWidget, int AGroup) { if (!FWidgets.values().contains(AWidget)) { if (AGroup > TBG_ALLIGN_CHANGE) FAllignChange->setVisible(true); QMap<int, QAction *>::const_iterator it = FSeparators.upperBound(AGroup); QAction *before = it!=FSeparators.end() ? it.value() : NULL; QAction *handle = before!=NULL ? FToolBar->insertWidget(before, AWidget) : FToolBar->addWidget(AWidget); if (!FSeparators.contains(AGroup)) { QAction *separator = FToolBar->insertSeparator(handle); separator->setVisible(FSeparatorsVisible); FSeparators.insert(AGroup, separator); updateSeparatorVisible(); } FWidgets.insertMulti(AGroup,AWidget); FHandles.insert(AWidget, handle); connect(AWidget,SIGNAL(destroyed(QObject *)),SLOT(onWidgetDestroyed(QObject *))); emit itemInserted(before,handle,FButtons.key(qobject_cast<QToolButton *>(AWidget)),AWidget,AGroup); updateVisible(); } return FHandles.value(AWidget); }
void ZLQtApplicationWindow::setToolbarItemState(ZLToolbar::ItemPtr item, bool visible, bool enabled) { QAction *action = myActions[&*item]; if (action != 0) { action->setEnabled(enabled); action->setVisible(visible); } switch (item->type()) { default: break; case ZLToolbar::Item::MENU_BUTTON: { ZLToolbar::MenuButtonItem &buttonItem = (ZLToolbar::MenuButtonItem&)*item; shared_ptr<ZLPopupData> data = buttonItem.popupData(); if (!data.isNull() && (data->id() != myPopupIdMap[&buttonItem])) { myPopupIdMap[&buttonItem] = data->id(); QToolButton *button = myMenuButtons[&buttonItem]; QMenu *menu = button->menu(); menu->clear(); const size_t count = data->count(); for (size_t i = 0; i < count; ++i) { menu->addAction(new ZLQtRunPopupAction(menu, data, i)); } } break; } } }
/* * TODO: * ==== * - display value of a port (nice to have) * - triangle port (nice to have) * - mouse over (over a node or port) (nice to have) * - round shaped nodes (nice to have) */ namespace Magus { //****************************************************************************/ QtNodeEditor::QtNodeEditor(QWidget* parent) : QWidget(parent) { QVBoxLayout* mainLayout = new QVBoxLayout; mView = new QGraphicsView(this); mScene = new QtNodeGraphicsScene(); mScene->installEventFilter(this); mView->setScene(mScene); mView->setRenderHint(QPainter::Antialiasing, true); mView->setInteractive(true); mView->setMouseTracking(true); mainLayout->addWidget(mView); mLastRemovedNode = 0; mRubberBand = 0; mZoom = 1.0f; mFisheyeViewEnabled = false; mFisheyeMaxZoom = 1.0f; mFisheyeSteps = 5; mHeaderTitleIcon = NODE_HEADER_COMPOUND_ICON; mAction1Icon = NODE_HEADER_ACTION1_ICON; mAction2Icon = NODE_HEADER_ACTION2_ICON; mCompoundNodeDropped = 0; mRubberbandSelection = false; mContextMenuEnabled = true; mContextMenu = new QMenu(this); mContextMenu->addAction(new QAction(NODE_ACTION_DELETE, this)); mContextMenu->addAction(new QAction(NODE_ACTION_CENTER, this)); mZoomSubMenu = mContextMenu->addMenu(NODE_ACTION_ZOOM); QAction* action; QActionGroup actionGroupZoom(mZoomSubMenu); actionGroupZoom.setExclusive(true); action = new QAction(NODE_ACTION_ZOOM_10, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_25, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_50, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_75, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_90, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_100, this); action->setCheckable(true); action->setChecked(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_150, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_200, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_250, this); action->setCheckable(true); actionGroupZoom.addAction(action); action = new QAction(NODE_ACTION_ZOOM_300, this); action->setCheckable(true); actionGroupZoom.addAction(action); mZoomSubMenu->addActions(actionGroupZoom.actions()); mFisheyeViewSubMenu = mContextMenu->addMenu(NODE_ACTION_FISHEY_VIEW); QActionGroup actionGroupFisheye(mFisheyeViewSubMenu); actionGroupFisheye.setExclusive(true); action = new QAction(NODE_ACTION_FISHEYE_DISABLED, this); action->setCheckable(true); action->setChecked(true); actionGroupFisheye.addAction(action); action = new QAction(NODE_ACTION_FISHEYE_NORMAL, this); action->setCheckable(true); actionGroupFisheye.addAction(action); action = new QAction(NODE_ACTION_FISHEYE_NORMAL_SUBTLE, this); action->setCheckable(true); actionGroupFisheye.addAction(action); action = new QAction(NODE_ACTION_FISHEYE_LARGE, this); action->setCheckable(true); actionGroupFisheye.addAction(action); action = new QAction(NODE_ACTION_FISHEYE_LARGE_SUBTLE, this); action->setCheckable(true); actionGroupFisheye.addAction(action); mFisheyeViewSubMenu->addActions(actionGroupFisheye.actions()); mContextMenu->addAction(new QAction(NODE_ACTION_SELECTED_TO_COMPOUND, this)); mContextMenu->addAction(new QAction(NODE_ACTION_COLLAPSE_ALL, this)); mContextMenu->addAction(new QAction(NODE_ACTION_EXPAND_ALL, this)); mContextMenu->addAction(new QAction(NODE_ACTION_EXPAND_COMPOUNDS, this)); mContextMenu->addAction(new QAction(NODE_ACTION_CENTER, this)); setMenuZoomEnabled(true); setMenuSelectionToCompoundEnabled(true); setMenuCollapseExpandEnabled(true); setMenuExpandCompoundsEnabled(true); setMenuFisheyeViewEnabled(true); setContextMenuPolicy(Qt::CustomContextMenu); connect(mContextMenu, SIGNAL(triggered(QAction*)), this, SLOT(contextMenuItemSelected(QAction*))); setLayout(mainLayout); } //****************************************************************************/ QtNodeEditor::~QtNodeEditor(void) { } //****************************************************************************/ void QtNodeEditor::setContextMenuEnabled(bool enabled) { mContextMenuEnabled = enabled; } //****************************************************************************/ void QtNodeEditor::setCompoundHeaderTitleIcon(const QString& fileNameIcon) { mHeaderTitleIcon = fileNameIcon; } //****************************************************************************/ void QtNodeEditor::setCompoundAction1Icon(const QString& fileNameIcon) { mAction1Icon = fileNameIcon; } //****************************************************************************/ void QtNodeEditor::setCompoundAction2Icon(const QString& fileNameIcon) { mAction2Icon = fileNameIcon; } //****************************************************************************/ bool QtNodeEditor::isContextMenuEnabled(void) { return mContextMenuEnabled; } //****************************************************************************/ void QtNodeEditor::setMenuZoomEnabled(bool enabled) { mMenuZoomEnabled = enabled; QAction* action = getActionFromContextMenu(NODE_ACTION_ZOOM); if (action) action->setVisible(enabled); } //****************************************************************************/ bool QtNodeEditor::isMenuZoomEnabled(void) { return mMenuZoomEnabled; } //****************************************************************************/ void QtNodeEditor::setMenuSelectionToCompoundEnabled(bool enabled) { mMenuSelectionToCompoundEnabled = enabled; QAction* action = getActionFromContextMenu(NODE_ACTION_SELECTED_TO_COMPOUND); if (action) action->setVisible(enabled); } //****************************************************************************/ bool QtNodeEditor::isMenuSelectionToCompoundEnabled(void) { return mMenuSelectionToCompoundEnabled; } //****************************************************************************/ void QtNodeEditor::setMenuCollapseExpandEnabled(bool enabled) { mMenuCollapseExpandEnabled = enabled; QAction* action = getActionFromContextMenu(NODE_ACTION_EXPAND_ALL); if (action) action->setVisible(enabled); action = getActionFromContextMenu(NODE_ACTION_COLLAPSE_ALL); if (action) action->setVisible(enabled); } //****************************************************************************/ bool QtNodeEditor::isMenuCollapseExpandEnabled(void) { return mMenuCollapseExpandEnabled; } //****************************************************************************/ void QtNodeEditor::setMenuExpandCompoundsEnabled(bool enabled) { mMenuExpandCompoundsEnabled = enabled; QAction* action = getActionFromContextMenu(NODE_ACTION_EXPAND_COMPOUNDS); if (action) action->setVisible(enabled); }
Context::AppletToolbarConfigItem::AppletToolbarConfigItem( QGraphicsItem* parent ) : AppletToolbarBase( parent ) , m_iconPadding( 2 ) , m_icon( 0 ) { QAction* listAdd = new QAction( i18n( "Configure Applets..." ), this ); listAdd->setIcon( KIcon( "configure" ) ); listAdd->setVisible( true ); listAdd->setEnabled( true ); connect( listAdd, SIGNAL(triggered()), this, SIGNAL(triggered()) ); m_icon = new Plasma::IconWidget( this ); m_icon->setAction( listAdd ); m_icon->setText( QString() ); m_icon->setToolTip( listAdd->text() ); m_icon->setDrawBackground( false ); m_icon->setOrientation( Qt::Horizontal ); QSizeF iconSize = m_icon->sizeFromIconSize( 22 ); m_icon->setMinimumSize( iconSize ); m_icon->setMaximumSize( iconSize ); m_icon->resize( iconSize ); m_icon->setZValue( zValue() + 1 ); setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred ); }
HelpViewer::HelpViewer(QHelpEngine *engine, CentralWidget *parent) : QWebView(parent) , helpEngine(engine) , parentWidget(parent) , loadFinished(false) { setAcceptDrops(false); setPage(new HelpPage(parent, helpEngine, this)); page()->setNetworkAccessManager(new HelpNetworkAccessManager(engine, this)); QAction* action = pageAction(QWebPage::OpenLinkInNewWindow); action->setText(tr("Open Link in New Tab")); if (!parent) action->setVisible(false); pageAction(QWebPage::DownloadLinkToDisk)->setVisible(false); pageAction(QWebPage::DownloadImageToDisk)->setVisible(false); pageAction(QWebPage::OpenImageInNewWindow)->setVisible(false); connect(pageAction(QWebPage::Copy), SIGNAL(changed()), this, SLOT(actionChanged())); connect(pageAction(QWebPage::Back), SIGNAL(changed()), this, SLOT(actionChanged())); connect(pageAction(QWebPage::Forward), SIGNAL(changed()), this, SLOT(actionChanged())); connect(page(), SIGNAL(linkHovered(QString,QString,QString)), this, SIGNAL(highlighted(QString))); connect(this, SIGNAL(urlChanged(QUrl)), this, SIGNAL(sourceChanged(QUrl))); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(setLoadFinished(bool))); }
QAction* ActionResource::toQAction() const { Log log( Log::LT_TRACE, Log::MOD_MAIN, "QAction* ActionResource::toQAction() const" ); if( !( m_Type == AT_ITEM || m_Type == AT_SEPARATOR ) ) { return NULL; }; log.write( Log::LT_TRACE, "Produce item %s", getText() ); QAction* act = new QAction( getText(), NULL ); act->setAutoRepeat( getAutoRepeat() ); act->setCheckable( getCheckable() ); act->setChecked( getChecked() ); act->setData( getData() ); act->setFont( getFont() ); act->setIcon( getIcon() ); act->setIconVisibleInMenu( getIconVisibleInMenu() ); act->setMenuRole( getMenuRole() ); act->setSeparator( m_Type == AT_SEPARATOR ); act->setShortcut( getShortcut() ); act->setShortcutContext( getShortcutContext() ); act->setStatusTip( getStatusTip() ); act->setToolTip( getTooltip() ); act->setVisible( getVisible() ); act->setWhatsThis( getWhatsThis() ); return act; };
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void StandardSIMPLViewApplication::updateRecentFileList(const QString& file) { SIMPLViewMenuItems* menuItems = SIMPLViewMenuItems::Instance(); for (int i = 0; i < m_SIMPLViewInstances.size(); i++) { SIMPLView_UI* window = m_SIMPLViewInstances[i]; if (NULL != window) { QMenu* recentFilesMenu = menuItems->getMenuRecentFiles(); QAction* clearRecentFilesAction = menuItems->getActionClearRecentFiles(); // Clear the Recent Items Menu recentFilesMenu->clear(); // Get the list from the static object QStringList files = QRecentFileList::instance()->fileList(); foreach(QString file, files) { QAction* action = new QAction(recentFilesMenu); action->setText(QRecentFileList::instance()->parentAndFileName(file)); action->setData(file); action->setVisible(true); recentFilesMenu->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(openRecentFile())); } recentFilesMenu->addSeparator(); recentFilesMenu->addAction(clearRecentFilesAction); }
void K3b::VideoDVDRippingView::slotContextMenuAboutToShow() { QAction *actionCheckTracks = actionCollection()->action("check_tracks"); QAction *actionUncheckTracks = actionCollection()->action("uncheck_tracks"); const QModelIndexList selectedRows = d->view->selectionModel()->selectedRows(); if ( !selectedRows.empty() ) { const Qt::CheckState commonState = mu::commonCheckState( selectedRows ); actionCheckTracks->setVisible( commonState != Qt::Checked ); actionCheckTracks->setText( selectedRows.count() == 1 ? i18n("Check Track") : i18n("Check Tracks") ); actionUncheckTracks->setVisible( commonState != Qt::Unchecked ); actionUncheckTracks->setText( selectedRows.count() == 1 ? i18n("Uncheck Track") : i18n("Uncheck Tracks") ); } else { actionCheckTracks->setVisible( false ); actionUncheckTracks->setVisible( false ); } }
// Set the state of the menu items void selectMenu::enable( imageContextMenu::imageContextMenuOptions option, bool state ) { QAction* action = getAction( option ); if( action ) { action->setVisible( state ); } }
DesktopViewProxy::DesktopViewProxy(MainWindow* mainWindow, KisMainWindow* parent) : QObject(parent) , d(new Private(mainWindow, parent)) { Q_ASSERT(parent); // "There MUST be a KisMainWindow assigned, otherwise everything will blow up"); // Hide this one... as it doesn't work at all well and release happens :P QAction* closeAction = d->desktopWindow->actionCollection()->action("file_close"); closeAction->setVisible(false); // Concept is simple - simply steal all the actions we require to work differently, and reconnect them to local functions QAction* newAction = d->desktopWindow->actionCollection()->action("file_new"); newAction->disconnect(d->desktopWindow); connect(newAction, SIGNAL(triggered(bool)), this, SLOT(fileNew())); QAction* openAction = d->desktopWindow->actionCollection()->action("file_open"); openAction->disconnect(d->desktopWindow); connect(openAction, SIGNAL(triggered(bool)), this, SLOT(fileOpen())); QAction* saveAction = d->desktopWindow->actionCollection()->action("file_save"); saveAction->disconnect(d->desktopWindow); connect(saveAction, SIGNAL(triggered(bool)), this, SLOT(fileSave())); QAction* saveasAction = d->desktopWindow->actionCollection()->action("file_save_as"); saveasAction->disconnect(d->desktopWindow); connect(saveasAction, SIGNAL(triggered(bool)), this, SLOT(fileSaveAs())); QAction* reloadAction = d->desktopWindow->actionCollection()->action("file_reload_file"); reloadAction->disconnect(d->desktopWindow); connect(reloadAction, SIGNAL(triggered(bool)), this, SLOT(reload())); QAction* loadExistingAsNewAction = d->desktopWindow->actionCollection()->action("file_import_file"); //Hide the "Load existing as new" action. It serves little purpose and currently //does the same as open. We cannot just remove it from the action collection though //since that causes a crash in KisMainWindow. loadExistingAsNewAction->setVisible(false); // Recent files need a touch more work, as they aren't simply an action. KRecentFilesAction* recent = qobject_cast<KRecentFilesAction*>(d->desktopWindow->actionCollection()->action("file_open_recent")); recent->disconnect(d->desktopWindow); connect(recent, SIGNAL(urlSelected(QUrl)), this, SLOT(slotFileOpenRecent(QUrl))); recent->clear(); recent->loadEntries(KGlobal::config()->group("RecentFiles")); connect(d->desktopWindow, SIGNAL(documentSaved()), this, SIGNAL(documentSaved())); // XXX: Shortcut editor is untested in Gemini since refactoring. connect(KisActionRegistry::instance(), SIGNAL(shortcutsUpdated()), this, SLOT(updateShortcuts())); }
ExtenderGroup::ExtenderGroup(Extender *parent, uint groupId) : ExtenderItem(parent, groupId), d(new ExtenderGroupPrivate(this)) { connect(extender(), SIGNAL(itemAttached(Plasma::ExtenderItem*)), this, SLOT(addItemToGroup(Plasma::ExtenderItem*))); connect(extender(), SIGNAL(itemDetached(Plasma::ExtenderItem*)), this, SLOT(removeItemFromGroup(Plasma::ExtenderItem*))); //this isn't actually connected to anything, we will just check if it's running or not d->resizeTimer = new QTimer(this); d->resizeTimer->setSingleShot(true); config().writeEntry("isGroup", true); setAcceptDrops(true); QGraphicsLinearLayout *lay = static_cast<QGraphicsLinearLayout *>(layout()); d->childsWidget = new QGraphicsWidget(this); d->childsWidget->installEventFilter(this); d->layout = new QGraphicsLinearLayout(Qt::Vertical, d->childsWidget); d->childsWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); lay->addItem(d->childsWidget); QAction *expand = new QAction(this); expand->setVisible(false); expand->setToolTip(i18n("Show this group.")); connect(expand, SIGNAL(triggered()), this, SLOT(expandGroup())); addAction("expand", expand); QAction *collapse = new QAction(this); collapse->setVisible(true); collapse->setToolTip(i18n("Hide this group.")); connect(collapse, SIGNAL(triggered()), this, SLOT(collapseGroup())); addAction("collapse", collapse); d->themeChanged(); QString groupName; foreach (ExtenderItem *item, extender()->attachedItems()) { groupName = item->config().readEntry("group", ""); if (!groupName.isEmpty() && groupName == name()) { item->setGroup(this); } }
void MenuManager::setup(MenuItem* menuItems) const { if (!menuItems) return; // empty menu bar QMenuBar* menuBar = getMainWindow()->menuBar(); //menuBar->setUpdatesEnabled(false); QList<MenuItem*> items = menuItems->getItems(); QList<QAction*> actions = menuBar->actions(); for (QList<MenuItem*>::ConstIterator it = items.begin(); it != items.end(); ++it) { // search for the menu action QAction* action = findAction(actions, QString::fromAscii((*it)->command().c_str())); if (!action) { // There must be not more than one separator in the menu bar, so // we can safely remove it if available and append it at the end if ((*it)->command() == "Separator") { action = menuBar->addSeparator(); action->setObjectName(QLatin1String("Separator")); } else { // create a new menu std::string menuName = (*it)->command(); QMenu* menu = menuBar->addMenu( QApplication::translate("Workbench", menuName.c_str(), 0, QApplication::UnicodeUTF8)); action = menu->menuAction(); menu->setObjectName(QString::fromAscii(menuName.c_str())); action->setObjectName(QString::fromAscii(menuName.c_str())); } // set the menu user data action->setData(QString::fromAscii((*it)->command().c_str())); } else { // put the menu at the end menuBar->removeAction(action); menuBar->addAction(action); action->setVisible(true); int index = actions.indexOf(action); actions.removeAt(index); } // flll up the menu if (!action->isSeparator()) setup(*it, action->menu()); } // hide all menus which we don't need for the moment for (QList<QAction*>::Iterator it = actions.begin(); it != actions.end(); ++it) { (*it)->setVisible(false); } // enable update again //menuBar->setUpdatesEnabled(true); }
void MainWindow::on_actionCalibrate_triggered() { emit calibrationDemanded(); QLabel * status = findChild<QLabel*>("appStatus"); status->setText("Place the effector on the location " "indicated by the red dot, then press return"); QAction * actionCalibrate = findChild<QAction*>("actionCalibrate"); actionCalibrate->setVisible(false); }
void VegetationWidget::slotShowContextMenu(const QPoint&) { QListView* view = qobject_cast<QListView*>(sender()); QAction* importGrass = getActionByText(_mainMenu, QWidget::tr("导入草资源")); QAction* importTree = getActionByText(_mainMenu, QWidget::tr("导入树资源")); QAction* viewSelected = getActionByText(_mainMenu, QWidget::tr("预览资源")); QAction* deleteSelected = getActionByText(_mainMenu, QWidget::tr("删除")); if (view == _treeListView) { importGrass->setVisible(false); importTree->setVisible(true); QItemSelectionModel* selectionModel = _treeListView->selectionModel(); QModelIndexList modelList = selectionModel->selectedIndexes(); if (modelList.size() < 1) { viewSelected->setEnabled(false); deleteSelected->setEnabled(false); } else { viewSelected->setEnabled(true); deleteSelected->setEnabled(true); } } else { importGrass->setVisible(true); importTree->setVisible(false); QItemSelectionModel* selectionModel = _grassListView->selectionModel(); QModelIndexList modelList = selectionModel->selectedIndexes(); if (modelList.size() < 1) { viewSelected->setEnabled(false); deleteSelected->setEnabled(false); } else { viewSelected->setEnabled(true); deleteSelected->setEnabled(true); } } _mainMenu->exec(QCursor::pos()); }