QIcon QMenuProto::icon() const { QMenu *item = qscriptvalue_cast<QMenu*>(thisObject()); if (item) return item->icon(); return QIcon(); }
void XdgMenuWidgetPrivate::init(const QDomElement& xml) { Q_Q(XdgMenuWidget); mXml = xml; q->clear(); mNeedBuild = true; if (! xml.attribute("title").isEmpty()) q->setTitle(xml.attribute("title")); else q->setTitle(xml.attribute("name")); q->setToolTip(xml.attribute("comment")); QIcon parentIcon; QMenu* parentMenu = qobject_cast<QMenu*>(q->parent()); if (parentMenu) parentIcon = parentMenu->icon(); q->setIcon(XdgIcon::fromTheme(mXml.attribute("icon"), parentIcon)); if (!qobject_cast<XdgMenuWidget*>(q->parent())) buildMenu(); }
inline void CWirelessSettings::createActions() { QAction * enableNetworksAction; QAction * addNetworkAction; QAction * addAdhocAction; QAction * reloadNetworksAction; QAction * importNetworksAction; QAction * exportNetworkAction; QAction * exportMultipleNetworksAction; QAction * reassociateAction; QMenu * advancedFuntionsMenu; QMenu * manageNetworksMenu; m_RescanNetworksAction = new QAction(QIcon(UI_ICON_SEARCH), tr("Scan for ne&tworks"), this); m_ToggleScanResultsAction = new QAction(QIcon(UI_ICON_DETAILED), tr("Show scan results"), this); m_SwitchNetworkAction = new QAction(QIcon(UI_ICON_FORCE), tr("S&witch"), this); m_ConfigureNetworkAction = new QAction(QIcon(UI_ICON_CONFIGURE), tr("&Configure..."), this); m_EnableNetworkAction = new QAction(QIcon(UI_ICON_AP), tr("&Enable"), this); m_DisableNetworkAction = new QAction(QIcon(UI_ICON_AP_DOWN), tr("&Disable"), this); enableNetworksAction = new QAction(/*QIcon(UI_ICON_ENABLE_ALL), */tr("Enable &all"), this); importNetworksAction = new QAction(/*QIcon(UI_ICON_IMPORT), */tr("&Import networks..."), this); exportNetworkAction = new QAction(/*QIcon(UI_ICON_EXPORT), */tr("E&xport selected network..."), this); exportMultipleNetworksAction = new QAction(/*QIcon(UI_ICON_MULTIEXPORT), */tr("Export all &networks..."), this); addNetworkAction = new QAction(QIcon(UI_ICON_ADD), tr("Add &network"), this); addAdhocAction = new QAction(QIcon(UI_ICON_ADD_ADHOC), tr("Add ad-&hoc"), this); m_RemoveNetworkAction = new QAction(QIcon(UI_ICON_REMOVE), tr("&Remove"), this); m_SaveNetworksAction = new QAction(QIcon(UI_ICON_SAVE), tr("&Write managed to global config"), this); reloadNetworksAction = new QAction(/*QIcon(UI_ICON_RELOAD), */tr("Re&load global config"), this); m_AutoSaveNetworksAction = new QAction(/*QIcon(UI_ICON_AUTOSAVE), */tr("&Autowrite global config"), this); m_KeepScanResultsAction = new QAction(/*QIcon(UI_ICON_DETAILED), */tr("&Keep scan results visible"), this); reassociateAction = new QAction(QIcon(UI_ICON_RELOAD), tr("&Reassociate"), this); manageNetworksMenu = new QMenu(tr("More...")); manageNetworksMenu->setIcon(QIcon(UI_ICON_EDIT)); advancedFuntionsMenu = new QMenu(tr("Advanced...")); advancedFuntionsMenu->setIcon(QIcon(UI_ICON_ADVANCED)); m_SetBSSIDMenu = new QMenu(tr("Switch to alternate BSSID")); m_SetBSSIDMenu->setIcon(QIcon(UI_ICON_AP)); updateBSSIDMenu(); m_AutoSaveNetworksAction->setCheckable(true); m_ToggleScanResultsAction->setCheckable(true); m_ToggleScanResultsAction->setChecked(false); ui.availableAPGroupBox->setVisible(false); m_KeepScanResultsAction->setCheckable(true); m_EnableNetworkAction->setEnabled(false); m_DisableNetworkAction->setEnabled(false); m_SwitchNetworkAction->setEnabled(false); m_ConfigureNetworkAction->setEnabled(false); m_RemoveNetworkAction->setEnabled(false); connect(m_RescanNetworksAction, &QAction::triggered, this, &CWirelessSettings::handleRescanRequest); connect(m_ToggleScanResultsAction, &QAction::toggled, ui.availableAPGroupBox, &QGroupBox::setVisible); connect(m_SwitchNetworkAction, &QAction::triggered, this, &CWirelessSettings::switchToSelectedNetwork); connect(m_ConfigureNetworkAction, &QAction::triggered, this, &CWirelessSettings::configureSelectedNetwork); connect(m_EnableNetworkAction, &QAction::triggered, this, &CWirelessSettings::enableSelectedNetwork); connect(m_DisableNetworkAction, &QAction::triggered, this, &CWirelessSettings::disableSelectedNetwork); connect(enableNetworksAction, &QAction::triggered, this, &CWirelessSettings::enableNetworks); connect(importNetworksAction, &QAction::triggered, this, &CWirelessSettings::importNetworks); connect(exportNetworkAction, &QAction::triggered, this, &CWirelessSettings::exportSelectedNetwork); connect(exportMultipleNetworksAction, &QAction::triggered, this, &CWirelessSettings::exportMultipleNetworks); connect(addNetworkAction, &QAction::triggered, this, &CWirelessSettings::addNetwork); connect(addAdhocAction, &QAction::triggered, this, &CWirelessSettings::addAdhoc); connect(m_RemoveNetworkAction, &QAction::triggered, this, &CWirelessSettings::removeSelectedNetwork); connect(m_SaveNetworksAction, &QAction::triggered, m_Device->getWireless()->getWpaSupplicant(), &CWpaSupplicant::save_config); connect(reloadNetworksAction, &QAction::triggered, m_Device->getWireless()->getWpaSupplicant(), &CWpaSupplicant::reconfigure); connect(m_KeepScanResultsAction, &QAction::toggled, this, &CWirelessSettings::keepScanResultsVisible); connect(reassociateAction, &QAction::triggered, m_Device->getWireless()->getWpaSupplicant(), &CWpaSupplicant::reassociate); manageNetworksMenu->addAction(enableNetworksAction); manageNetworksMenu->addSeparator(); manageNetworksMenu->addAction(importNetworksAction); manageNetworksMenu->addAction(exportNetworkAction); manageNetworksMenu->addAction(exportMultipleNetworksAction); advancedFuntionsMenu->addAction(m_SaveNetworksAction); advancedFuntionsMenu->addAction(reloadNetworksAction); advancedFuntionsMenu->addSeparator(); advancedFuntionsMenu->addAction(m_AutoSaveNetworksAction); advancedFuntionsMenu->addAction(m_KeepScanResultsAction); advancedFuntionsMenu->addSeparator(); advancedFuntionsMenu->addMenu(m_SetBSSIDMenu); ui.managedView->addAction(m_EnableNetworkAction); ui.managedView->addAction(m_DisableNetworkAction); ui.managedView->addAction(getSeparator(this)); ui.managedView->addAction(m_SwitchNetworkAction); ui.managedView->addAction(m_ConfigureNetworkAction); ui.managedView->addAction(getSeparator(this)); ui.managedView->addAction(addNetworkAction); ui.managedView->addAction(addAdhocAction); ui.managedView->addAction(m_RemoveNetworkAction); ui.managedView->addAction(getSeparator(this)); ui.managedView->addAction(manageNetworksMenu->menuAction()); ui.managedView->setContextMenuPolicy(Qt::ActionsContextMenu); ui.availableView->addAction(addNetworkAction); ui.availableView->addAction(getSeparator(this)); ui.availableView->addAction(m_RescanNetworksAction); ui.availableView->setContextMenuPolicy(Qt::ActionsContextMenu); ui.enableNetworkButton->setDefaultAction(m_EnableNetworkAction); ui.disableNetworkButton->setDefaultAction(m_DisableNetworkAction); ui.switchNetworkButton->setDefaultAction(m_SwitchNetworkAction); ui.configureNetworkButton->setDefaultAction(m_ConfigureNetworkAction); ui.removeNetworkButton->setDefaultAction(m_RemoveNetworkAction); ui.toggleScanResultsButton->setDefaultAction(m_ToggleScanResultsAction); ui.manageNetworksButton->setMenu(manageNetworksMenu); ui.manageNetworksButton->setText(manageNetworksMenu->title()); ui.manageNetworksButton->setIcon(manageNetworksMenu->icon()); ui.manageNetworksButton->setPopupMode(QToolButton::InstantPopup); ui.addNetworkButton->setDefaultAction(addNetworkAction); ui.addAdhocButton->setDefaultAction(addAdhocAction); ui.rescanNetworksButton->setDefaultAction(m_RescanNetworksAction); ui.advancedFunctionsButton->setMenu(advancedFuntionsMenu); ui.advancedFunctionsButton->setText(advancedFuntionsMenu->title()); ui.advancedFunctionsButton->setIcon(advancedFuntionsMenu->icon()); ui.advancedFunctionsButton->setPopupMode(QToolButton::InstantPopup); ui.reassociateButton->setDefaultAction(reassociateAction); m_SetBSSIDMapper = new QSignalMapper(this); connect(m_SetBSSIDMapper, static_cast<void(QSignalMapper::*)(const QString &)>(&QSignalMapper::mapped), this, &CWirelessSettings::handleBSSIDSwitchRequest); }