Exemplo n.º 1
0
	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);
	}
Exemplo n.º 2
0
void CQ3DBarsModifier::actionTriggered(QAction* action)
{
  if (action == NULL) return;

  QString option = action->text();
  QMenu *menu = qobject_cast<QMenu*> (action->parent());

  if (menu == NULL)
    {
      if (option == "Change label style")
        {
          changeLabelBackground();
        }
      else if (option == "Smooth bars")
        {
          setSmoothBars(!m_primarySeries->isMeshSmooth());
        }
      else if (option == "Change camera preset")
        {
          changePresetCamera();
        }
      else if (option == "Zoom to selected bar")
        {
          zoomToSelectedBar();
        }
      else if (option == "Show background")
        {
          setBackgroundEnabled(!m_graph->activeTheme()->isBackgroundEnabled());
        }
      else if (option == "Show grid")
        {
          setGridEnabled(!m_graph->activeTheme()->isGridEnabled());
        }
      else if (option == "Show reflections")
        {
          setReflection(!m_graph->isReflection());
        }
      else if (option == "Show Gradients")
        {
          toggleGradient();
        }

      return;
    }

  QString title = menu->title();

  if (title == "Theme")
    {
      changeTheme(menu->actions().indexOf(action));
    }
  else if (title == "Selection Mode")
    {
      if (option == "None")
        {
          m_graph->setSelectionMode(QAbstract3DGraph::SelectionNone);
        }
      else if (option == "Bar")
        {
          m_graph->setSelectionMode(QAbstract3DGraph::SelectionItem);
        }
      else if (option == "Row")
        {
          m_graph->setSelectionMode(QAbstract3DGraph::SelectionRow);
        }
      else if (option == "Bar and Row")
        {
          m_graph->setSelectionMode(QAbstract3DGraph::SelectionItemAndRow);
        }
      else if (option == "Column")
        {
          m_graph->setSelectionMode(QAbstract3DGraph::SelectionColumn);
        }
      else if (option == "Bar and Column")
        {
          m_graph->setSelectionMode(QAbstract3DGraph::SelectionItemAndColumn);
        }
      else if (option == "Row and Column")
        {
          m_graph->setSelectionMode(QAbstract3DGraph::SelectionRowAndColumn);
        }
      else if (option == "Bar, Row and Column")
        {
          m_graph->setSelectionMode(QAbstract3DGraph::SelectionItemRowAndColumn);
        }
      else if (option == "Slice into Row")
        {
          m_graph->setSelectionMode(QAbstract3DGraph::SelectionSlice | QAbstract3DGraph::SelectionRow);
        }
      else if (option == "Slice into Row and Item")
        {
          m_graph->setSelectionMode(QAbstract3DGraph::SelectionSlice | QAbstract3DGraph::SelectionItemAndRow);
        }
      else if (option == "Slice into Column")
        {
          m_graph->setSelectionMode(QAbstract3DGraph::SelectionSlice | QAbstract3DGraph::SelectionColumn);
        }
      else if (option == "Slice into Column and Item")
        {
          m_graph->setSelectionMode(QAbstract3DGraph::SelectionSlice | QAbstract3DGraph::SelectionItemAndColumn);
        }
    }
  else if (title == "Style")
    {
      if (option == "Bar")
        {
          m_primarySeries->setMesh(QAbstract3DSeries::MeshBar);
        }
      else if (option == "Pyramid")
        {
          m_primarySeries->setMesh(QAbstract3DSeries::MeshPyramid);
        }
      else if (option == "Cone")
        {
          m_primarySeries->setMesh(QAbstract3DSeries::MeshCone);
        }
      else if (option == "Cylinder")
        {
          m_primarySeries->setMesh(QAbstract3DSeries::MeshCylinder);
        }
      else if (option == "Bevel bar")
        {
          m_primarySeries->setMesh(QAbstract3DSeries::MeshBevelBar);
        }
      else if (option == "Sphere")
        {
          m_primarySeries->setMesh(QAbstract3DSeries::MeshSphere);
        }

    }
  else if (title == "Shadow")
    {
      if (option == "None")
        {
          m_graph->setShadowQuality(QAbstract3DGraph::ShadowQualityNone);
        }
      else if (option == "Low")
        {
          m_graph->setShadowQuality(QAbstract3DGraph::ShadowQualityLow);
        }
      else if (option == "Medium")
        {
          m_graph->setShadowQuality(QAbstract3DGraph::ShadowQualityMedium);
        }
      else if (option == "High")
        {
          m_graph->setShadowQuality(QAbstract3DGraph::ShadowQualityHigh);
        }
      else if (option == "Low Soft")
        {
          m_graph->setShadowQuality(QAbstract3DGraph::ShadowQualitySoftLow);
        }
      else if (option == "Medium Soft")
        {
          m_graph->setShadowQuality(QAbstract3DGraph::ShadowQualitySoftMedium);
        }
      else if (option == "High Soft")
        {
          m_graph->setShadowQuality(QAbstract3DGraph::ShadowQualitySoftHigh);
        }
    }

}