Example #1
0
void MainWindow::initMenu()
{
	//file
	_fileMenu = menuBar()->addMenu(QWidget::tr("文件(&F)"));
	QAction* actionNewFile = new QAction(QIcon(":/images/new.png"), QWidget::tr("新建(&New)"), this);
	actionNewFile->setShortcut(QWidget::tr("Ctrl+N"));
	actionNewFile->setToolTip(QWidget::tr("新建场景文件"));
	connect(actionNewFile, SIGNAL(triggered()), this, SLOT(slotNewFile()));
	_fileMenu->addAction(actionNewFile);
	QAction* actionOpenFile = new QAction(QIcon(":/images/open.png"), QWidget::tr("打开(&Open)"), this);
	actionOpenFile->setShortcut(QWidget::tr("Ctrl+O"));
	actionOpenFile->setToolTip(QWidget::tr("打开一个场景文件"));
	connect(actionOpenFile, SIGNAL(triggered()), this, SLOT(slotOpenFile()));
	_fileMenu->addAction(actionOpenFile);
	QAction* actionSaveFile = new QAction(QIcon(":/images/save.png"), QWidget::tr("保存(&Save)"), this);
	actionSaveFile->setShortcut(QWidget::tr("Ctrl+S"));
	actionSaveFile->setToolTip(QWidget::tr("保存场景文件"));
	actionSaveFile->setEnabled(false);
	connect(actionSaveFile, SIGNAL(triggered()), this, SLOT(slotSaveFile()));
	_fileMenu->addAction(actionSaveFile);
	QAction* actionSaveAsFile = new QAction(QIcon(":/images/save.png"), QWidget::tr("另存(SaveAs)"), this);
	actionSaveAsFile->setToolTip(QWidget::tr("另存场景文件"));
	actionSaveAsFile->setEnabled(false);
	connect(actionSaveAsFile, SIGNAL(triggered()), this, SLOT(slotSaveAsFile()));
	_fileMenu->addAction(actionSaveAsFile);
	QAction* actionExit = new QAction(QIcon(":/images/close.png"), QWidget::tr("退出(&X)"), this);
	actionExit->setToolTip(QWidget::tr("退出场景编辑器"));
	connect(actionExit, SIGNAL(triggered()), this, SLOT(slotExit()));
	_fileMenu->addAction(actionExit);
	//edit
	_editMenu = menuBar()->addMenu(QWidget::tr("编辑(&E)"));
	QAction* actionUndo = new QAction(QIcon(":/images/undo.png"), QWidget::tr("撤销"), this);
	actionUndo->setShortcut(QWidget::tr("Ctrl+Z"));
	actionUndo->setToolTip(QWidget::tr("撤销Ctrl+Z"));
	actionUndo->setEnabled(false);
	connect(actionUndo, SIGNAL(triggered()), this, SLOT(slotUndo()));
	_editMenu->addAction(actionUndo);
	QAction* actionRedo = new QAction(QIcon(":/images/redo.png"), QWidget::tr("重做"), this);
	actionRedo->setShortcut(QWidget::tr("Ctrl+Y"));
	actionRedo->setToolTip(QWidget::tr("重做Ctrl+Y"));
	actionRedo->setEnabled(false);
	connect(actionRedo, SIGNAL(triggered()), this, SLOT(slotRedo()));
	_editMenu->addAction(actionRedo);
	QAction* actionCopy = new QAction(QIcon(":/images/copy.png"), QWidget::tr("复制"), this);
	actionCopy->setShortcut(QWidget::tr("Ctrl+C"));
	actionCopy->setToolTip(QWidget::tr("复制Ctrl+C"));
	actionCopy->setEnabled(false);
	connect(actionCopy, SIGNAL(triggered()), this, SLOT(slotCopy()));
	_editMenu->addAction(actionCopy);
	QAction* actionRotateFast = new QAction(QIcon(":/images/rotate.png"), QWidget::tr("快速旋转"), this);
	actionRotateFast->setShortcut(QKeySequence(Qt::Key_F3));
	actionRotateFast->setToolTip(QWidget::tr("快速旋转F3"));
	actionRotateFast->setEnabled(false);
	connect(actionRotateFast, SIGNAL(triggered()), this, SLOT(slotRotateFast()));
	_editMenu->addAction(actionRotateFast);
	QAction* actionAlign = new QAction(QIcon(":/images/align.png"), QWidget::tr("对齐"), this);
	actionAlign->setShortcut(QWidget::tr("Ctrl+L"));
	actionAlign->setToolTip(QWidget::tr("对齐Ctrl+L"));
	actionAlign->setEnabled(false);
	connect(actionAlign, SIGNAL(triggered()), this, SLOT(slotAlign()));
	_editMenu->addAction(actionAlign);
	QAction* actionDelete = new QAction(QIcon(":/images/delete.png"), QWidget::tr("删除"), this);
	actionDelete->setShortcut(QKeySequence(QKeySequence::Delete));
	actionDelete->setToolTip(QWidget::tr("删除Delete"));
	actionDelete->setEnabled(false);
	connect(actionDelete, SIGNAL(triggered()), this, SLOT(slotDelete()));
	_editMenu->addAction(actionDelete);
	//windowsMenu
	_windowsMenu = menuBar()->addMenu(QWidget::tr("窗口(&W)"));
	QAction* actionObjectsTreeDockWidget = new QAction(QIcon(":/images/default.png"), QWidget::tr("场景树(&ObjTree)"), this);
	actionObjectsTreeDockWidget->setShortcut(QKeySequence("h"));
	actionObjectsTreeDockWidget->setToolTip(QWidget::tr("打开或隐藏对象树窗口"));
	actionObjectsTreeDockWidget->setEnabled(false);
	connect(actionObjectsTreeDockWidget, SIGNAL(triggered()), this, SLOT(slotObjectTreeWidgetActive()));
	_windowsMenu->addAction(actionObjectsTreeDockWidget);
	QAction* actionPropertyDockWidget = new QAction(QIcon(":/images/default.png"), QWidget::tr("属性窗"), this);
	actionPropertyDockWidget->setToolTip(QWidget::tr("打开或隐藏属性窗口"));
	actionPropertyDockWidget->setEnabled(false);
	connect(actionPropertyDockWidget, SIGNAL(triggered()), this, SLOT(slotPropertyDockWidgetActive()));
	_windowsMenu->addAction(actionPropertyDockWidget);
	QAction* actionBuiltinResourcesDockWidget = new QAction(QIcon(":/images/default.png"), QWidget::tr("内置资源列表"), this);
	actionBuiltinResourcesDockWidget->setToolTip(QWidget::tr("打开或隐藏内置资源列表窗口"));
	actionBuiltinResourcesDockWidget->setEnabled(false);
	connect(actionBuiltinResourcesDockWidget, SIGNAL(triggered()), this, SLOT(slotBuiltinResourcesDockWidgetActive()));
	_windowsMenu->addAction(actionBuiltinResourcesDockWidget);
	QAction* actionvdsResourcesDockWidget = new QAction(QIcon(":/images/default.png"), QWidget::tr("资源列表"), this);
	actionvdsResourcesDockWidget->setToolTip(QWidget::tr("打开或隐藏资源列表窗口"));
	actionvdsResourcesDockWidget->setEnabled(false);
	connect(actionvdsResourcesDockWidget, SIGNAL(triggered()), this, SLOT(slotvdsResourcesDockWidgetActive()));
	_windowsMenu->addAction(actionvdsResourcesDockWidget);
	QAction* actionCSharpAssemblyDockWidget = new QAction(QIcon(":/images/default.png"), QWidget::tr("脚本列表"), this);
	actionCSharpAssemblyDockWidget->setToolTip(QWidget::tr("打开或隐藏脚本列表窗口"));
	actionCSharpAssemblyDockWidget->setEnabled(false);
	connect(actionCSharpAssemblyDockWidget, SIGNAL(triggered()), this, SLOT(slotCSharpAssemblyDockWidgetActive()));
	_windowsMenu->addAction(actionCSharpAssemblyDockWidget);
	//tool
	_toolMenu = menuBar()->addMenu(QWidget::tr("工具(&T)"));
	QAction* actionAnimationMerge = new QAction(QIcon(":/images/default.png"), QWidget::tr("动画合并(&AnimationMerge)"), this);
	actionAnimationMerge->setToolTip(QWidget::tr("完成骨骼动画合并"));
	actionAnimationMerge->setEnabled(false);
	connect(actionAnimationMerge, SIGNAL(triggered()), this, SLOT(slotAnimationMerge()));
	_toolMenu->addAction(actionAnimationMerge);
	QAction* particleEdit = new QAction(QIcon(":/images/default.png"), QWidget::tr("粒子编辑(&Particle)"), this);
	particleEdit->setToolTip(QWidget::tr("编辑粒子效果"));
	particleEdit->setEnabled(false);
	connect(particleEdit, SIGNAL(triggered()), this, SLOT(slotParticleEdit()));
	_toolMenu->addAction(particleEdit);
	QAction* actionPlantBrushDockWidget = new QAction(QIcon(":/images/default.png"), QWidget::tr("植被编辑"), this);
	actionPlantBrushDockWidget->setToolTip(QWidget::tr("打开或隐藏植被编辑窗口"));
	actionPlantBrushDockWidget->setEnabled(false);
	connect(actionPlantBrushDockWidget, SIGNAL(triggered()), this, SLOT(slotPlantBrushDockWidgetActive()));
	_toolMenu->addAction(actionPlantBrushDockWidget);
	QAction* actionViewPointEdit = new QAction(QIcon(":/images/default.png"), QWidget::tr("视点编辑(&ViewPoint)"), this);
	actionViewPointEdit->setToolTip(QWidget::tr("定义视点"));
	actionViewPointEdit->setEnabled(false);
	connect(actionViewPointEdit, SIGNAL(triggered()), this, SLOT(slotViewPointEdit()));
	_toolMenu->addAction(actionViewPointEdit);
	QAction* actionPhysicalEdit = new QAction(QIcon(":/images/default.png"), QWidget::tr("物理编辑"), this);
	actionPhysicalEdit->setToolTip(QWidget::tr("定义碰撞体或碰撞面"));
	actionPhysicalEdit->setEnabled(false);
	connect(actionPhysicalEdit, SIGNAL(triggered()), this, SLOT(slotPhysicalEditDockWidgetActive()));
	_toolMenu->addAction(actionPhysicalEdit);
	QAction* actionRiverEdit = new QAction(QIcon(":/images/default.png"), QWidget::tr("河流编辑"), this);
	actionRiverEdit->setToolTip(QWidget::tr("定义河流效果"));
	actionRiverEdit->setEnabled(false);
	connect(actionRiverEdit, SIGNAL(triggered()), this, SLOT(slotRiverEditDockWidgetActive()));
	_toolMenu->addAction(actionRiverEdit);
	QAction* modelConvert = new QAction(QIcon(":/images/default.png"), QWidget::tr("模型转换(&ConvertModel)"), this);
	modelConvert->setToolTip(QWidget::tr("转换模型到其他平台"));
	modelConvert->setEnabled(true);
	connect(modelConvert, SIGNAL(triggered()), this, SLOT(slotConvertModel()));
	_toolMenu->addAction(modelConvert);
	QAction* compressDir = new QAction(QIcon(":/images/default.png"), QWidget::tr("压缩文件夹"), this);
	compressDir->setToolTip(QWidget::tr("压缩文件夹,可以设定文件名编码"));
	compressDir->setEnabled(true);
	connect(compressDir, SIGNAL(triggered()), this, SLOT(slotCompressDir()));
	_toolMenu->addAction(compressDir);
	//animation
	_animationMenu = menuBar()->addMenu(QWidget::tr("动画(&A)"));
	///////////////////////////////////////////////////////////////////should move to PlotAnimation later
	QAction* actionViewPointAnimationEdit = new QAction(QIcon(":/images/default.png"), QWidget::tr("视点动画编辑"), this);
	actionViewPointAnimationEdit->setToolTip(QWidget::tr("编辑视点动画"));
	actionViewPointAnimationEdit->setEnabled(false);
	connect(actionViewPointAnimationEdit, SIGNAL(triggered()), this, SLOT(slotViewPointAnimationEdit()));
	_animationMenu->addAction(actionViewPointAnimationEdit);
	QAction* actionPlotAnimationEdit = new QAction(QIcon(":/images/default.png"), QWidget::tr("剧情编辑"), this);
	actionPlotAnimationEdit->setToolTip(QWidget::tr("编辑一段剧情"));
	actionPlotAnimationEdit->setEnabled(false);
	connect(actionPlotAnimationEdit, SIGNAL(triggered()), this, SLOT(slotPlotAnimationEdit()));
	_animationMenu->addAction(actionPlotAnimationEdit);
}
Example #2
0
ApplicationWindow::ApplicationWindow()
	: QMainWindow( 0 )
{

clipboard = QApplication::clipboard();

QDateTime dt = QDateTime::currentDateTime();
appPath=qApp->applicationDirPath();
logfilePath=appPath + "\\log_" + qgetenv("USERNAME") + "_" + dt.toString("ddMMyy") + ".txt";

setWindowTitle("Info");

//installPath=QDir(QDir::currentPath() + "\\scripts");
installPath=QDir(appPath  + "\\scripts");
    if (!installPath.exists())
    {
        QMessageBox::critical(this, "Info", "Could not open install path " + installPath.absolutePath() + ".");
        exit (1);
    }

//Tray Icon
iconTray = new QSystemTrayIcon;
    QIcon mwIcon(":/info.png");
        iconTray->setIcon(mwIcon);
    iconTray->setVisible(true);
    iconTray->show();
    connect(iconTray, SIGNAL(activated ( QSystemTrayIcon::ActivationReason )), this, SLOT(systemTrayActivated(QSystemTrayIcon::ActivationReason)));

//main widget
window = new QWidget(this);

        setCentralWidget(window);
        resize(540,480);
        statusBar()->showMessage( "Welcome" );

        QMenu* fileMenu = menuBar()->addMenu(tr("&File"));

        QAction* updateAction   = new QAction(tr("&Update"), window);
        updateAction->setShortcut(Qt::CTRL + Qt::Key_U);
       //     connect(updateAction, SIGNAL(triggered(bool)), this, SLOT(writeServiceSlot()));
        fileMenu->addAction(updateAction);
        updateAction->setEnabled(false);

        QAction* findAction   = new QAction(tr("&Find"), window);
        findAction->setShortcut(Qt::CTRL + Qt::Key_F);
       //     connect(findAction, SIGNAL(triggered(bool)), this, SLOT(findItem()));
        fileMenu->addAction(findAction);
        findAction->setEnabled(false);

        QAction* refreshAction   = new QAction(tr("&Refresh"), window);
        refreshAction->setShortcut(Qt::CTRL + Qt::Key_R);
            connect(refreshAction, SIGNAL(triggered(bool)), this, SLOT(refreshGUI()));
        fileMenu->addAction(refreshAction);

        fileMenu->addSeparator ();

        QAction* exitAction   = new QAction(tr("&Exit"), window);
            exitAction->setShortcut(Qt::CTRL + Qt::Key_X);
            connect(exitAction, SIGNAL(triggered()), this, SLOT(realExit()));
            fileMenu->addAction(exitAction);


       QMenu* editMenu = menuBar()->addMenu(tr("&Edit"));

       QAction* clipAction   = new QAction(tr("&Copy to Clipboard"), window);
           clipAction->setShortcut(Qt::CTRL + Qt::Key_C);
           connect(clipAction, SIGNAL(triggered()), this, SLOT(copyToClipboard()));
           editMenu->addAction(clipAction);

       QAction* logfileAction   = new QAction(tr("&Open Logfile"), window);
           logfileAction->setShortcut(Qt::CTRL + Qt::Key_O);
           connect(logfileAction, SIGNAL(triggered()), this, SLOT(openLogfile()));
           editMenu->addAction(logfileAction);


       QMenu* helpMenu = menuBar()->addMenu(tr("&?"));

       QAction* aboutAction   = new QAction(tr("&about"), window);
           connect(aboutAction, SIGNAL(triggered()), this, SLOT(about()));
           helpMenu->addAction(aboutAction);

// End of Menu
/*
|----------------|
| Maingrid       |
| |----------|   |
| |Topgrid   |   |
| |          |   |
| |----------|   |
|                |
| |-------------||
| |Body |-----| ||
| |     |Info | ||
| |     |     | ||
| |     |-----| ||
| |-------------||
|----------------|

*/



        QGridLayout *mainGrid = new QGridLayout (window);
        QGridLayout *topGrid = new QGridLayout (window);
            mainGrid->addLayout(topGrid,0,0);

        QGridLayout *bodyGrid = new QGridLayout (window);
                mainGrid->addLayout(bodyGrid,1,0,1,2);

        QGridLayout *infoGrid = new QGridLayout (window);
                bodyGrid->addLayout(infoGrid,0,1);

        //Hostname
        topGrid->addWidget(new QLabel("Computername:", window),0,0);
        QLineEdit *hostLine = new QLineEdit(window);
            hostLine->setText(qgetenv("COMPUTERNAME"));
            hostLine->setReadOnly(true);
            topGrid->addWidget(hostLine,0,1);
        //End Hostname

        //Domain
        topGrid->addWidget(new QLabel("Domain:", window),1,0);
        QLineEdit *userdomainLine = new QLineEdit(window);
            userdomainLine->setText(qgetenv("USERDOMAIN"));
            userdomainLine->setReadOnly(true);
            topGrid->addWidget(userdomainLine,1,1);
        //End Domain


        //Username
        topGrid->addWidget(new QLabel("Username:"******"USERNAME"));
            userLine->setReadOnly(true);
            topGrid->addWidget(userLine,2,1);
        //End Username

        //Interface
        topGrid->addWidget(new QLabel("Interface:", window),5,0);

        interfaceBox = new QComboBox(window);
            connect(interfaceBox, SIGNAL(currentIndexChanged ( int )), this, SLOT(interfaceBoxIndexChanged ( int )));
        topGrid->addWidget(interfaceBox,5,1);
        //End Interface


        //MAC
        topGrid->addWidget(new QLabel("MAC:", window),6,0);
        macLine = new QLineEdit(window);
        macLine->setReadOnly(true);
            topGrid->addWidget(macLine,6,1);
        //End MAC

        //IP
        topGrid->addWidget(new QLabel("IP:", window),7,0);
        ipLine = new QLineEdit(window);
        ipLine->setReadOnly(true);
            topGrid->addWidget(ipLine,7,1);
        //End IP

        //Mask
        topGrid->addWidget(new QLabel("Netmask:", window),8,0);
        maskLine = new QLineEdit(window);
        maskLine->setReadOnly(true);
            topGrid->addWidget(maskLine,8,1);
        //End Mask

        topGrid->addItem(new QSpacerItem ( 10, 10, QSizePolicy::Maximum, QSizePolicy::Maximum ),0,1);
        //Index
            /*
        topGrid->addWidget(new QLabel("Index:", window),9,0);
        indexLine = new QLineEdit(window);
        indexLine->setReadOnly(true);
            topGrid->addWidget(indexLine,9,1);
            */
        //End Mask

        //The Tree
        treeWidget = new QTreeWidget(window);
            treeWidget->setColumnCount(6);
            treeWidget->setSortingEnabled(false);
            treeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
            treeWidget->setFont(QFont(font().family(), 12));

            QStringList treeHeaderLabels;
            treeHeaderLabels << "Tool" << "Author" << "Version" << "Path" << "Tree" << "arguments" << "interpreter";
                treeWidget->setHeaderLabels(treeHeaderLabels);
                treeWidget->setColumnHidden(1, true);
                treeWidget->setColumnHidden(2, true);
                treeWidget->setColumnHidden(3, true);
                treeWidget->setColumnHidden(4, true);
                treeWidget->setColumnHidden(5, true);
                treeWidget->setColumnHidden(6, true);

          connect(treeWidget, SIGNAL(itemPressed(QTreeWidgetItem*,int)), this, SLOT(treeItemPressed(QTreeWidgetItem*,int)));
        bodyGrid->addWidget(treeWidget,0,0);


        //Infos on the right
        infoScript = new QLabel(window);
            infoGrid->addWidget(infoScript,0,0);

        infoPath = new QLabel(window);
            infoGrid->addWidget(infoPath,1,0);

        infoAuthor = new QLabel(window);
            infoGrid->addWidget(infoAuthor,2,0);

        infoVersion = new QLabel(window);
            infoGrid->addWidget(infoVersion,3,0);

        infoInterpreter = new QLabel(window);
             infoGrid->addWidget(infoInterpreter,4,0);

        infoGrid->addItem(new QSpacerItem ( 10, 10, QSizePolicy::Maximum, QSizePolicy::Maximum ),5,0);

        QHBoxLayout *argumentsLayout = new QHBoxLayout(window);
        infoArgumentsTitle = new QLabel(window);
            argumentsLayout->addWidget(infoArgumentsTitle);

        infoArgumentsValue = new QLineEdit(window);
            infoArgumentsValue->setVisible(false);
             argumentsLayout->addWidget(infoArgumentsValue);

        infoGrid->addLayout(argumentsLayout,6,0);
        infoGrid->addItem(new QSpacerItem ( 10, 10, QSizePolicy::Maximum, QSizePolicy::Maximum ),7,0);

        QHBoxLayout *buttonLayout = new QHBoxLayout(window);
        runButton = new QPushButton("  Start  ",window);
            runButton->setEnabled(false);
            connect(runButton, SIGNAL(clicked()), this, SLOT(runButtonClicked()));

        //Push Button to the right
        buttonLayout->addWidget(runButton);
        buttonLayout->addItem(new QSpacerItem ( 10, 10, QSizePolicy::Expanding, QSizePolicy::Maximum ));
        infoGrid->addLayout(buttonLayout,8,0);


        //QSpacerItem ( int w, int h, QSizePolicy::Policy hPolicy = QSizePolicy::Minimum, QSizePolicy::Policy vPolicy = QSizePolicy::Minimum )
        //top Grid nach links
        mainGrid->addItem(new QSpacerItem ( 300, 10, QSizePolicy::Expanding, QSizePolicy::Maximum ),0,1);

        //make tree big
        bodyGrid->addItem(new QSpacerItem ( 0, 10, QSizePolicy::Maximum, QSizePolicy::Expanding ),0,2);

        //button up
        infoGrid->addItem(new QSpacerItem ( 10, 10, QSizePolicy::Maximum, QSizePolicy::Expanding ),8,0);



        //Initial IP filling
        //refreshGUI();
        writeLogBool=false;
        interfaceBoxIndexChanged(0);
        getInterfaces();
        QString text=interfaceBox->currentText() + ": " + ipLine->text() +  "\nComputer: " + qgetenv("COMPUTERNAME") + "\nUser: "******"USERNAME") + "\n";
        iconTray->setToolTip(text);
        writeLogBool=true;


}
void ItemPhysEnv::contextMenu(QGraphicsSceneMouseEvent *mouseEvent)
{
    m_scene->m_contextMenuIsOpened = true; //bug protector

    //Remove selection from non-bgo items
    if(!this->isSelected())
    {
        m_scene->clearSelection();
        this->setSelected(true);
    }

    this->setSelected(true);
    QMenu ItemMenu;

    /*************Layers*******************/
    QMenu *LayerName = ItemMenu.addMenu(tr("Layer: ") + QString("[%1]").arg(m_data.layer).replace("&", "&&&"));
    QAction *setLayer;
    QList<QAction *> layerItems;
    QAction *newLayer = LayerName->addAction(tr("Add to new layer..."));
    LayerName->addSeparator();

    for(LevelLayer &layer : m_scene->m_data->layers)
    {
        //Skip system layers
        if((layer.name == "Destroyed Blocks") || (layer.name == "Spawned NPCs")) continue;

        setLayer = LayerName->addAction(layer.name.replace("&", "&&&") + ((layer.hidden) ? "" + tr("[hidden]") : ""));
        setLayer->setData(layer.name);
        setLayer->setCheckable(true);
        setLayer->setEnabled(true);
        setLayer->setChecked(layer.name == m_data.layer);
        layerItems.push_back(setLayer);
    }
    ItemMenu.addSeparator();
    /*************Layers*end***************/

    QMenu *WaterType =     ItemMenu.addMenu(tr("Environment type"));
    WaterType->deleteLater();

#define CONTEXT_MENU_ITEM_CHK(name, enable, visible, label, checked_condition)\
    name = WaterType->addAction(label);\
    name->setCheckable(true);\
    name->setEnabled(enable);\
    name->setVisible(visible);\
    name->setChecked(checked_condition); typeID++;

    QAction *envTypes[16];
    int typeID = 0;
    bool enable_new_types = !m_scene->m_data->meta.smbx64strict
            && (m_scene->m_configs->editor.supported_features.level_phys_ez_new_types == EditorSetup::FeaturesSupport::F_ENABLED);
    bool show_new_types = (m_scene->m_configs->editor.supported_features.level_phys_ez_new_types != EditorSetup::FeaturesSupport::F_HIDDEN);

    CONTEXT_MENU_ITEM_CHK(envTypes[typeID], true, true,                       tr("Water"),        m_data.env_type == LevelPhysEnv::ENV_WATER);
    CONTEXT_MENU_ITEM_CHK(envTypes[typeID], true, true,                       tr("Quicksand"),    m_data.env_type == LevelPhysEnv::ENV_QUICKSAND);
    CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("Custom liquid"), m_data.env_type == LevelPhysEnv::ENV_CUSTOM_LIQUID);
    CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("Gravity Field"), m_data.env_type == LevelPhysEnv::ENV_GRAVITATIONAL_FIELD);
    CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("Touch Event (Once)"), m_data.env_type == LevelPhysEnv::ENV_TOUCH_EVENT_ONCE_PLAYER);
    CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("Touch Event (Every frame)"), m_data.env_type == LevelPhysEnv::ENV_TOUCH_EVENT_PLAYER);
    CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("NPC/Player Touch Event (Once)"), m_data.env_type == LevelPhysEnv::ENV_TOUCH_EVENT_ONCE_NPC);
    CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("NPC/Player Touch Event (Every frame)"), m_data.env_type == LevelPhysEnv::ENV_TOUCH_EVENT_NPC);
    CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("Mouse click Event"), m_data.env_type == LevelPhysEnv::ENV_CLICK_EVENT);
    CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("Collision script"), m_data.env_type == LevelPhysEnv::ENV_COLLISION_SCRIPT);
    CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("Mouse click Script"), m_data.env_type == LevelPhysEnv::ENV_CLICK_SCRIPT);
    CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("Collision Event"), m_data.env_type == LevelPhysEnv::ENV_COLLISION_EVENT);
    CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("Air chamber"), m_data.env_type == LevelPhysEnv::ENV_AIR);
    CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("NPC Touch Event (Once)"), m_data.env_type == LevelPhysEnv::ENV_TOUCH_EVENT_ONCE_NPC1);
    CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("NPC Touch Event (Every frame)"), m_data.env_type == LevelPhysEnv::ENV_TOUCH_EVENT_NPC1);
    CONTEXT_MENU_ITEM_CHK(envTypes[typeID], enable_new_types, show_new_types, tr("NPC Hurting Field"), m_data.env_type == LevelPhysEnv::ENV_NPC_HURTING_FIELD);

#undef CONTEXT_MENU_ITEM_CHK

    ItemMenu.addSeparator();

    QMenu *copyPreferences =    ItemMenu.addMenu(tr("Copy preferences"));
    QAction *copyPosXYWH =      copyPreferences->addAction(tr("Position: X, Y, Width, Height"));
    QAction *copyPosLTRB =      copyPreferences->addAction(tr("Position: Left, Top, Right, Bottom"));
    ItemMenu.addSeparator();

    QAction *resize =           ItemMenu.addAction(tr("Resize"));
    resize->deleteLater();

    ItemMenu.addSeparator();
    QAction *copyWater =        ItemMenu.addAction(tr("Copy"));
    QAction *cutWater =         ItemMenu.addAction(tr("Cut"));
    ItemMenu.addSeparator();
    QAction *remove =           ItemMenu.addAction(tr("Remove"));

    /*****************Waiting for answer************************/
    QAction *selected = ItemMenu.exec(mouseEvent->screenPos());
    /***********************************************************/

    if(!selected)
        return;


    if(selected == cutWater)
        m_scene->m_mw->on_actionCut_triggered();
    else if(selected == copyWater)
        m_scene->m_mw->on_actionCopy_triggered();
    else if(selected == copyPosXYWH)
    {
        QApplication::clipboard()->setText(
            QString("X=%1; Y=%2; W=%3; H=%4;")
            .arg(m_data.x)
            .arg(m_data.y)
            .arg(m_data.w)
            .arg(m_data.h)
        );
        m_scene->m_mw->showStatusMsg(tr("Preferences have been copied: %1").arg(QApplication::clipboard()->text()));
    }
    else if(selected == copyPosLTRB)
    {
        QApplication::clipboard()->setText(
            QString("Left=%1; Top=%2; Right=%3; Bottom=%4;")
            .arg(m_data.x)
            .arg(m_data.y)
            .arg(m_data.x + m_data.w)
            .arg(m_data.y + m_data.h)
        );
        m_scene->m_mw->showStatusMsg(tr("Preferences have been copied: %1").arg(QApplication::clipboard()->text()));
    }
    else if(selected == resize)
        m_scene->setPhysEnvResizer(this, true);
    else if(selected == remove)
        m_scene->removeSelectedLvlItems();
    else if(selected == newLayer)
        m_scene->setLayerToSelected();
    else
    {
        bool found = false;
        //Fetch layers menu
        foreach(QAction *lItem, layerItems)
        {
            if(selected == lItem)
            {
                //FOUND!!!
                m_scene->setLayerToSelected(lItem->data().toString());
                found = true;
                break;
            }//Find selected layer's item
        }

        if(!found)
        {
            for(int i = 0; i < typeID; i++)
            {
                if(selected == envTypes[i])
                {
                    LevelData modData;
                    for(QGraphicsItem *selItem : m_scene->selectedItems())
                    {
                        if(selItem->data(ITEM_TYPE).toString() == "Water")
                        {
                            ItemPhysEnv *pe = dynamic_cast<ItemPhysEnv*>(selItem);
                            modData.physez.push_back(pe->m_data);
                            pe->setType(i);
                            m_scene->invalidate(pe->boundingRect());
                        }
                    }
                    m_scene->m_history->addChangeSettings(modData, HistorySettings::SETTING_WATERTYPE, QVariant(true));
                    if(!m_scene->m_opts.animationEnabled)
                        m_scene->update();
                    found = true;
                    break;
                }
            }
        }
    }
}
Example #4
0
void lemon::enableLogin()
{
  QAction *action = actionCollection()->action("login");
  action->setEnabled(true);
}
Example #5
0
// Setup the GUI
void Mainwindow::initGUI()
{
    QAction *action;

    // Start a new game
    action = KStandardGameAction::gameNew(this, SLOT(menuNewLSkatGame()), actionCollection());
    if (global_demo_mode) action->setEnabled(false);

    // Clear all time statistics
    action = KStandardGameAction::clearStatistics(this, SLOT(menuClearStatistics()), actionCollection());
    action->setWhatsThis(i18n("Clears the all time statistics which is kept in all sessions."));
    if (global_demo_mode) action->setEnabled(false);

    // End a game
    action = KStandardGameAction::end(this, SLOT(menuEndGame()), actionCollection());
    action->setWhatsThis(i18n("Ends a currently played game. No winner will be declared."));
    action->setEnabled(false);

    // Quit the program
    action = KStandardGameAction::quit(this, SLOT(close()), actionCollection());
    action->setWhatsThis(i18n("Quits the program."));

    // Determine start player
    KSelectAction *startPlayerAct = new KSelectAction(i18n("Starting Player"), this);
    actionCollection()->addAction(QLatin1String("startplayer"), startPlayerAct);
    connect(startPlayerAct, SIGNAL(triggered(int)), this, SLOT(menuStartplayer()));
    startPlayerAct->setToolTip(i18n("Changing starting player..."));
    startPlayerAct->setWhatsThis(i18n("Chooses which player begins the next game."));
    QStringList list;
    list.clear();
    list.append(i18n("Player &1"));
    list.append(i18n("Player &2"));
    startPlayerAct->setItems(list);
    if (global_demo_mode) startPlayerAct->setEnabled(false);

    // Determine who player player 1
    KSelectAction *player1Act = new KSelectAction(i18n("Player &1 Played By"), this);
    actionCollection()->addAction(QLatin1String("player1"), player1Act);
    connect(player1Act, SIGNAL(triggered(int)), this, SLOT(menuPlayer1By()));
    player1Act->setToolTip(i18n("Changing who plays player 1..."));
    player1Act->setWhatsThis(i18n("Changing who plays player 1."));
    list.clear();
    list.append(i18n("&Mouse"));
    list.append(i18n("&Computer"));
    player1Act->setItems(list);
    if (global_demo_mode) player1Act->setEnabled(false);

    // Determine who player player 2
    KSelectAction *player2Act = new KSelectAction(i18n("Player &2 Played By"), this);
    actionCollection()->addAction(QLatin1String("player2"), player2Act);
    connect(player2Act, SIGNAL(triggered(int)), this, SLOT(menuPlayer2By()));
    player2Act->setToolTip(i18n("Changing who plays player 2..."));
    player2Act->setWhatsThis(i18n("Changing who plays player 2."));
    player2Act->setItems(list);
    if (global_demo_mode) player2Act->setEnabled(false);

    // Add all theme files to the menu
    QStringList themes(mThemeFiles.keys());
    themes.sort();

    KSelectAction *themeAct = new KSelectAction(i18n("&Theme"), this);
    actionCollection()->addAction(QLatin1String("theme"), themeAct);
    themeAct->setItems(themes);
    connect(themeAct, SIGNAL(triggered(int)), SLOT(changeTheme(int)));
    if (global_debug > 0) kDebug() << "Setting current theme item to" << mThemeIndexNo;
    themeAct->setCurrentItem(mThemeIndexNo);
    themeAct->setToolTip(i18n("Changing theme..."));
    themeAct->setWhatsThis(i18n("Changing theme."));

    // Choose card deck
    KAction *action1 = actionCollection()->addAction(QLatin1String("select_carddeck"));
    action1->setText(i18n("Select &Card Deck..."));
    action1->setShortcuts(KShortcut(Qt::Key_F10));
    connect(action1, SIGNAL(triggered(bool)), this, SLOT(menuCardDeck()));
    action1->setToolTip(i18n("Configure card decks..."));
    action1->setWhatsThis(i18n("Choose how the cards should look."));

    // Change player names
    action = actionCollection()->addAction(QLatin1String("change_names"));
    action->setText(i18n("&Change Player Names..."));
    connect(action, SIGNAL(triggered(bool)), this, SLOT(menuPlayerNames()));
    if (global_demo_mode) action->setEnabled(false);
}
Example #6
0
TazDlg::TazDlg(QWidget* pParent)
	: QMainWindow(pParent), m_settings("tobis_stuff", "takin"),
		m_pSettingsDlg(new SettingsDlg(this, &m_settings)),
		m_pStatusMsg(new QLabel(this)),
		m_pCoordQStatusMsg(new QLabel(this)),
		m_pCoordCursorStatusMsg(new QLabel(this)),
		m_sceneRecip(this),
		m_dlgRecipParam(this, &m_settings),
		m_dlgRealParam(this, &m_settings),
		m_pGotoDlg(new GotoDlg(this, &m_settings))
{
	//log_debug("In ", __func__, ".");

	const bool bSmallqVisible = 0;
	const bool bBZVisible = 1;
	const bool bWSVisible = 1;

	this->setupUi(this);
	this->setWindowTitle(s_strTitle.c_str());
	this->setFont(g_fontGen);
	this->setWindowIcon(load_icon("res/icons/takin.svg"));

	btnAtoms->setEnabled(g_bHasScatlens);

	if(m_settings.contains("main/geo"))
	{
		QByteArray geo = m_settings.value("main/geo").toByteArray();
		restoreGeometry(geo);
	}
	/*if(m_settings.contains("main/width") && m_settings.contains("main/height"))
	{
		int iW = m_settings.value("main/width").toInt();
		int iH = m_settings.value("main/height").toInt();
		resize(iW, iH);
	}*/

	m_pStatusMsg->setFrameStyle(QFrame::Panel | QFrame::Sunken);
	m_pCoordQStatusMsg->setFrameStyle(QFrame::Panel | QFrame::Sunken);
	m_pCoordCursorStatusMsg->setFrameStyle(QFrame::Panel | QFrame::Sunken);
	for(QLabel* pLabel : {m_pStatusMsg/*, m_pCoordQStatusMsg, m_pCoordCursorStatusMsg*/})
		pLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Preferred);

	QStatusBar *pStatusBar = new QStatusBar(this);
	pStatusBar->addWidget(m_pStatusMsg, 1);
	pStatusBar->addPermanentWidget(m_pCoordQStatusMsg, 0);
	pStatusBar->addPermanentWidget(m_pCoordCursorStatusMsg, 0);
	m_pCoordQStatusMsg->setMinimumWidth(350);
	m_pCoordQStatusMsg->setAlignment(Qt::AlignCenter);
	m_pCoordCursorStatusMsg->setMinimumWidth(325);
	m_pCoordCursorStatusMsg->setAlignment(Qt::AlignCenter);
	this->setStatusBar(pStatusBar);

	// --------------------------------------------------------------------------------

	m_vecEdits_real =
	{
		editA, editB, editC,
		editAlpha, editBeta, editGamma
	};
	m_vecEdits_recip =
	{
		editARecip, editBRecip, editCRecip,
		editAlphaRecip, editBetaRecip, editGammaRecip
	};

	m_vecEdits_plane =
	{
		editScatX0, editScatX1, editScatX2,
		editScatY0, editScatY1, editScatY2,

		editRealX0, editRealX1, editRealX2,
		editRealY0, editRealY1, editRealY2,
	};
	m_vecEdits_monoana =
	{
		editMonoD, editAnaD
	};

	//m_vecSpinBoxesSample = { spinRotPhi, spinRotTheta, spinRotPsi };
	m_vecCheckBoxesSenses = { checkSenseM, checkSenseS, checkSenseA };


	m_vecEditNames_real =
	{
		"sample/a", "sample/b", "sample/c",
		"sample/alpha", "sample/beta", "sample/gamma"
	};
	m_vecEditNames_recip =
	{
		"sample/a_recip", "sample/b_recip", "sample/c_recip",
		"sample/alpha_recip", "sample/beta_recip", "sample/gamma_recip"
	};
	m_vecEditNames_plane =
	{
		"plane/x0", "plane/x1", "plane/x2",
		"plane/y0", "plane/y1", "plane/y2",

		"plane/real_x0", "plane/real_x1", "plane/real_x2",
		"plane/real_y0", "plane/real_y1", "plane/real_y2",
	};
	m_vecEditNames_monoana =
	{
		"tas/mono_d", "tas/ana_d"
	};

	m_vecSpinBoxNamesSample = {"sample/phi", "sample/theta", "sample/psi"};
	m_vecCheckBoxNamesSenses = {"tas/sense_m", "tas/sense_s", "tas/sense_a"};


	// recip
	m_pviewRecip = new ScatteringTriangleView(groupRecip);
	groupRecip->addTab(m_pviewRecip, "Reciprocal Lattice");

	m_pviewProjRecip = new ProjLatticeView(groupRecip);
	groupRecip->addTab(m_pviewProjRecip, "Projection");

	m_pviewRecip->setScene(&m_sceneRecip);
	m_pviewProjRecip->setScene(&m_sceneProjRecip);

	if(m_settings.contains("main/recip_tab"))
		groupRecip->setCurrentIndex(m_settings.value("main/recip_tab").value<int>());


	// real
	m_pviewRealLattice = new LatticeView(groupReal);
	groupReal->addTab(m_pviewRealLattice, "Real Lattice");

	m_pviewReal = new TasLayoutView(groupReal);
	groupReal->addTab(m_pviewReal, "TAS Instrument");

	m_pviewTof = new TofLayoutView(groupReal);
	groupReal->addTab(m_pviewTof, "TOF Instrument");

	m_pviewRealLattice->setScene(&m_sceneRealLattice);
	m_pviewReal->setScene(&m_sceneReal);
	m_pviewTof->setScene(&m_sceneTof);

	if(m_settings.contains("main/real_tab"))
		groupReal->setCurrentIndex(m_settings.value("main/real_tab").value<int>());



	QObject::connect(m_pSettingsDlg, SIGNAL(SettingsChanged()), this, SLOT(SettingsChanged()));

	QObject::connect(&m_sceneReal, SIGNAL(nodeEvent(bool)), this, SLOT(RealNodeEvent(bool)));
	QObject::connect(&m_sceneRecip, SIGNAL(nodeEvent(bool)), this, SLOT(RecipNodeEvent(bool)));
	QObject::connect(&m_sceneTof, SIGNAL(nodeEvent(bool)), this, SLOT(TofNodeEvent(bool)));

	// TAS
	QObject::connect(&m_sceneRecip, SIGNAL(triangleChanged(const TriangleOptions&)),
		&m_sceneReal, SLOT(triangleChanged(const TriangleOptions&)));
	QObject::connect(&m_sceneReal, SIGNAL(tasChanged(const TriangleOptions&)),
		&m_sceneRecip, SLOT(tasChanged(const TriangleOptions&)));
	QObject::connect(&m_sceneRecip, SIGNAL(paramsChanged(const RecipParams&)),
		&m_sceneReal, SLOT(recipParamsChanged(const RecipParams&)));

	// TOF
	QObject::connect(&m_sceneRecip, SIGNAL(triangleChanged(const TriangleOptions&)),
		&m_sceneTof, SLOT(triangleChanged(const TriangleOptions&)));
	QObject::connect(&m_sceneTof, SIGNAL(tasChanged(const TriangleOptions&)),
		&m_sceneRecip, SLOT(tasChanged(const TriangleOptions&)));
	QObject::connect(&m_sceneRecip, SIGNAL(paramsChanged(const RecipParams&)),
		&m_sceneTof, SLOT(recipParamsChanged(const RecipParams&)));

	// connections between instruments
	QObject::connect(&m_sceneTof, SIGNAL(tasChanged(const TriangleOptions&)),
		&m_sceneReal, SLOT(triangleChanged(const TriangleOptions&)));
	QObject::connect(&m_sceneReal, SIGNAL(tasChanged(const TriangleOptions&)),
		&m_sceneTof, SLOT(triangleChanged(const TriangleOptions&)));

	// scale factor
	if(m_pviewRecip)
		QObject::connect(m_pviewRecip, SIGNAL(scaleChanged(t_real_glob)),
			&m_sceneRecip, SLOT(scaleChanged(t_real_glob)));
	if(m_pviewProjRecip)
		QObject::connect(m_pviewProjRecip, SIGNAL(scaleChanged(t_real_glob)),
			&m_sceneProjRecip, SLOT(scaleChanged(t_real_glob)));
	if(m_pviewRealLattice)
		QObject::connect(m_pviewRealLattice, SIGNAL(scaleChanged(t_real_glob)),
			&m_sceneRealLattice, SLOT(scaleChanged(t_real_glob)));
	if(m_pviewReal)
		QObject::connect(m_pviewReal, SIGNAL(scaleChanged(t_real_glob)),
			&m_sceneReal, SLOT(scaleChanged(t_real_glob)));
	if(m_pviewTof)
		QObject::connect(m_pviewTof, SIGNAL(scaleChanged(t_real_glob)),
			&m_sceneTof, SLOT(scaleChanged(t_real_glob)));

	// parameter dialogs
	QObject::connect(&m_sceneRecip, SIGNAL(paramsChanged(const RecipParams&)),
		&m_dlgRecipParam, SLOT(paramsChanged(const RecipParams&)));
	QObject::connect(&m_sceneReal, SIGNAL(paramsChanged(const RealParams&)),
		&m_dlgRealParam, SLOT(paramsChanged(const RealParams&)));

	// cursor position
	QObject::connect(&m_sceneRecip, SIGNAL(coordsChanged(t_real_glob, t_real_glob, t_real_glob, bool, t_real_glob, t_real_glob, t_real_glob)),
		this, SLOT(RecipCoordsChanged(t_real_glob, t_real_glob, t_real_glob, bool, t_real_glob, t_real_glob, t_real_glob)));
	QObject::connect(&m_sceneProjRecip, SIGNAL(coordsChanged(t_real_glob, t_real_glob, t_real_glob, bool, t_real_glob, t_real_glob, t_real_glob)),
		this, SLOT(RecipCoordsChanged(t_real_glob, t_real_glob, t_real_glob, bool, t_real_glob, t_real_glob, t_real_glob)));
	QObject::connect(&m_sceneRealLattice, SIGNAL(coordsChanged(t_real_glob, t_real_glob, t_real_glob, bool, t_real_glob, t_real_glob, t_real_glob)),
		this, SLOT(RealCoordsChanged(t_real_glob, t_real_glob, t_real_glob, bool, t_real_glob, t_real_glob, t_real_glob)));

	QObject::connect(&m_sceneRecip, SIGNAL(spurionInfo(const tl::ElasticSpurion&, const std::vector<tl::InelasticSpurion<t_real_glob>>&, const std::vector<tl::InelasticSpurion<t_real_glob>>&)),
		this, SLOT(spurionInfo(const tl::ElasticSpurion&, const std::vector<tl::InelasticSpurion<t_real_glob>>&, const std::vector<tl::InelasticSpurion<t_real_glob>>&)));

	QObject::connect(m_pGotoDlg, SIGNAL(vars_changed(const CrystalOptions&, const TriangleOptions&)),
		this, SLOT(VarsChanged(const CrystalOptions&, const TriangleOptions&)));
	QObject::connect(&m_sceneRecip, SIGNAL(paramsChanged(const RecipParams&)),
		m_pGotoDlg, SLOT(RecipParamsChanged(const RecipParams&)));

	QObject::connect(&m_sceneRecip, SIGNAL(paramsChanged(const RecipParams&)),
		this, SLOT(recipParamsChanged(const RecipParams&)));


	for(QLineEdit* pEdit : m_vecEdits_monoana)
		QObject::connect(pEdit, SIGNAL(textEdited(const QString&)), this, SLOT(UpdateDs()));

	for(QLineEdit* pEdit : m_vecEdits_real)
	{
		QObject::connect(pEdit, SIGNAL(textEdited(const QString&)), this, SLOT(CheckCrystalType()));
		QObject::connect(pEdit, SIGNAL(textEdited(const QString&)), this, SLOT(CalcPeaks()));
	}

	for(QLineEdit* pEdit : m_vecEdits_plane)
	{
		QObject::connect(pEdit, SIGNAL(textEdited(const QString&)), this, SLOT(CalcPeaks()));
	}

	//for(QDoubleSpinBox* pSpin : m_vecSpinBoxesSample)
	//	QObject::connect(pSpin, SIGNAL(valueChanged(t_real)), this, SLOT(CalcPeaks()));

	for(QLineEdit* pEdit : m_vecEdits_recip)
	{
		QObject::connect(pEdit, SIGNAL(textEdited(const QString&)), this, SLOT(CheckCrystalType()));
		QObject::connect(pEdit, SIGNAL(textEdited(const QString&)), this, SLOT(CalcPeaksRecip()));
	}

	QObject::connect(checkSenseM, SIGNAL(stateChanged(int)), this, SLOT(UpdateMonoSense()));
	QObject::connect(checkSenseS, SIGNAL(stateChanged(int)), this, SLOT(UpdateSampleSense()));
	QObject::connect(checkSenseA, SIGNAL(stateChanged(int)), this, SLOT(UpdateAnaSense()));

	QObject::connect(editSpaceGroupsFilter, SIGNAL(textEdited(const QString&)), this, SLOT(RepopulateSpaceGroups()));
	QObject::connect(comboSpaceGroups, SIGNAL(currentIndexChanged(int)), this, SLOT(SetCrystalType()));
	QObject::connect(comboSpaceGroups, SIGNAL(currentIndexChanged(int)), this, SLOT(CalcPeaks()));
	QObject::connect(checkPowder, SIGNAL(stateChanged(int)), this, SLOT(CalcPeaks()));

	QObject::connect(btnAtoms, SIGNAL(clicked(bool)), this, SLOT(ShowAtomsDlg()));



	// --------------------------------------------------------------------------------
	// file menu
	QMenu *pMenuFile = new QMenu("File", this);

	QAction *pNew = new QAction("New", this);
	pNew->setIcon(load_icon("res/icons/document-new.svg"));
	pMenuFile->addAction(pNew);

	pMenuFile->addSeparator();

	QAction *pLoad = new QAction("Load...", this);
	pLoad->setIcon(load_icon("res/icons/document-open.svg"));
	pMenuFile->addAction(pLoad);

	m_pMenuRecent = new QMenu("Recently Loaded", this);
	tl::RecentFiles recent(&m_settings, "main/recent");
	m_pMapperRecent = new QSignalMapper(m_pMenuRecent);
	QObject::connect(m_pMapperRecent, SIGNAL(mapped(const QString&)),
		this, SLOT(LoadFile(const QString&)));
	recent.FillMenu(m_pMenuRecent, m_pMapperRecent);
	pMenuFile->addMenu(m_pMenuRecent);

	QAction *pSave = new QAction("Save", this);
	pSave->setIcon(load_icon("res/icons/document-save.svg"));
	pMenuFile->addAction(pSave);

	QAction *pSaveAs = new QAction("Save as...", this);
	pSaveAs->setIcon(load_icon("res/icons/document-save-as.svg"));
	pMenuFile->addAction(pSaveAs);

	pMenuFile->addSeparator();

	QAction *pImport = new QAction("Import...", this);
	pImport->setIcon(load_icon("res/icons/drive-harddisk.svg"));
	pMenuFile->addAction(pImport);

	m_pMenuRecentImport = new QMenu("Recently Imported", this);
	tl::RecentFiles recentimport(&m_settings, "main/recent_import");
	m_pMapperRecentImport = new QSignalMapper(m_pMenuRecentImport);
	QObject::connect(m_pMapperRecentImport, SIGNAL(mapped(const QString&)),
		this, SLOT(ImportFile(const QString&)));
	recentimport.FillMenu(m_pMenuRecentImport, m_pMapperRecentImport);
	pMenuFile->addMenu(m_pMenuRecentImport);

	pMenuFile->addSeparator();

	QAction *pSettings = new QAction("Settings...", this);
	pSettings->setIcon(load_icon("res/icons/preferences-system.svg"));
	pMenuFile->addAction(pSettings);

	pMenuFile->addSeparator();

	QAction *pExit = new QAction("Exit", this);
	pExit->setIcon(load_icon("res/icons/system-log-out.svg"));
	pMenuFile->addAction(pExit);


	// --------------------------------------------------------------------------------
	// recip menu
	m_pMenuViewRecip = new QMenu("Reciprocal Space", this);

	m_pGoto = new QAction("Go to Position...", this);
	m_pGoto->setIcon(load_icon("res/icons/goto.svg"));
	m_pMenuViewRecip->addAction(m_pGoto);

	QAction *pRecipParams = new QAction("Information...", this);
	m_pMenuViewRecip->addAction(pRecipParams);
	m_pMenuViewRecip->addSeparator();

	m_pSmallq = new QAction("Show Reduced Scattering Vector q", this);
	m_pSmallq->setIcon(load_icon("res/icons/q.svg"));
	m_pSmallq->setCheckable(1);
	m_pSmallq->setChecked(bSmallqVisible);
	m_pMenuViewRecip->addAction(m_pSmallq);

	m_pSnapSmallq = new QAction("Snap G to Bragg Peak", this);
	m_pSnapSmallq->setCheckable(1);
	m_pSnapSmallq->setChecked(m_sceneRecip.getSnapq());
	m_pMenuViewRecip->addAction(m_pSnapSmallq);

	QAction *pKeepAbsKiKf = new QAction("Keep |ki| and |kf| Fixed", this);
	pKeepAbsKiKf->setCheckable(1);
	pKeepAbsKiKf->setChecked(m_sceneRecip.getKeepAbsKiKf());
	m_pMenuViewRecip->addAction(pKeepAbsKiKf);

	m_pBZ = new QAction("Show First Brillouin Zone", this);
	m_pBZ->setIcon(load_icon("res/icons/brillouin.svg"));
	m_pBZ->setCheckable(1);
	m_pBZ->setChecked(bBZVisible);
	m_pMenuViewRecip->addAction(m_pBZ);


	QMenu *pMenuEwald = new QMenu("Ewald Sphere", this);
	QActionGroup *pGroupEwald = new QActionGroup(this);
	m_pEwaldSphereNone = new QAction("Disabled", this);
	m_pEwaldSphereKi = new QAction("Around ki", this);
	m_pEwaldSphereKf = new QAction("Around kf", this);
	for(QAction* pAct : {m_pEwaldSphereNone, m_pEwaldSphereKi, m_pEwaldSphereKf})
	{
		pAct->setCheckable(1);
		pGroupEwald->addAction(pAct);
	}

	m_pEwaldSphereKf->setChecked(1);
	pMenuEwald->addActions(pGroupEwald->actions());
	m_pMenuViewRecip->addMenu(pMenuEwald);


	m_pMenuViewRecip->addSeparator();

	QMenu *pMenuProj = new QMenu("Projection", this);
	pMenuProj->setTearOffEnabled(1);
	QActionGroup *pGroupProj = new QActionGroup(this);

	m_pProjGnom = new QAction("Gnomonic", this);
	m_pProjStereo = new QAction("Stereographic", this);
	m_pProjPara = new QAction("Parallel", this);
	m_pProjPersp = new QAction("Perspectivic", this);

	for(QAction *pAct : {m_pProjGnom, m_pProjStereo, m_pProjPara, m_pProjPersp})
	{
		pAct->setCheckable(1);
		pGroupProj->addAction(pAct);
	}

	m_pProjStereo->setChecked(1);
	pMenuProj->addActions(pGroupProj->actions());

	m_pMenuViewRecip->addMenu(pMenuProj);

#if !defined NO_3D
	QAction *pView3D = new QAction("3D View...", this);
	//pView3D->setIcon(QIcon::fromTheme("applications-graphics"));
	m_pMenuViewRecip->addAction(pView3D);
#endif

	m_pMenuViewRecip->addSeparator();

	QAction *pRecipExport = new QAction("Export Lattice Graphics...", this);
	pRecipExport->setIcon(load_icon("res/icons/image-x-generic.svg"));
	m_pMenuViewRecip->addAction(pRecipExport);

	QAction *pProjExport = new QAction("Export Projection Graphics...", this);
	pProjExport->setIcon(load_icon("res/icons/image-x-generic.svg"));
	m_pMenuViewRecip->addAction(pProjExport);

#ifdef USE_GIL
	QAction *pBZExport = new QAction("Export Brillouin Zone Image...", this);
	pBZExport->setIcon(load_icon("res/icons/image-x-generic.svg"));
	m_pMenuViewRecip->addAction(pBZExport);
#endif


	// --------------------------------------------------------------------------------
	// real menu
	m_pMenuViewReal = new QMenu("Real Space", this);
	m_pMenuViewReal->addAction(m_pGoto);

	QAction *pRealParams = new QAction("Information...", this);
	m_pMenuViewReal->addAction(pRealParams);

	m_pMenuViewReal->addSeparator();

	m_pShowRealQDir = new QAction("Show Q Direction", this);
	m_pShowRealQDir->setCheckable(1);
	m_pShowRealQDir->setChecked(m_sceneReal.GetTasLayout()->GetRealQVisible());
	m_pMenuViewReal->addAction(m_pShowRealQDir);

	m_pWS = new QAction("Show Wigner-Seitz Cell", this);
	m_pWS->setIcon(load_icon("res/icons/brillouin.svg"));
	m_pWS->setCheckable(1);
	m_pWS->setChecked(bWSVisible);
	m_pMenuViewReal->addAction(m_pWS);

	m_pMenuViewReal->addSeparator();

#if !defined NO_3D
	QAction *pView3DReal = new QAction("3D View...", this);
	//pView3DReal->setIcon(QIcon::fromTheme("applications-graphics"));
	m_pMenuViewReal->addAction(pView3DReal);
	m_pMenuViewReal->addSeparator();
#endif

	QAction *pRealLatticeExport = new QAction("Export Lattice Graphics...", this);
	pRealLatticeExport->setIcon(load_icon("res/icons/image-x-generic.svg"));
	m_pMenuViewReal->addAction(pRealLatticeExport);

	QAction *pRealExport = new QAction("Export TAS Layout...", this);
	pRealExport->setIcon(load_icon("res/icons/image-x-generic.svg"));
	m_pMenuViewReal->addAction(pRealExport);

	QAction *pTofExport = new QAction("Export TOF Layout...", this);
	pTofExport->setIcon(load_icon("res/icons/image-x-generic.svg"));
	m_pMenuViewReal->addAction(pTofExport);

#ifdef USE_GIL
	QAction *pWSExport = new QAction("Export Wigner-Seitz Cell Image...", this);
	pWSExport->setIcon(load_icon("res/icons/image-x-generic.svg"));
	m_pMenuViewReal->addAction(pWSExport);
#endif

	QAction *pExportUC = new QAction("Export Unit Cell Model...", this);
	pExportUC->setIcon(load_icon("res/icons/image-x-generic.svg"));
	m_pMenuViewReal->addAction(pExportUC);


	// --------------------------------------------------------------------------------
	// resolution menu
	QMenu *pMenuReso = new QMenu("Resolution", this);

	QAction *pResoParams = new QAction("Parameters...", this);
	pResoParams->setIcon(load_icon("res/icons/accessories-calculator.svg"));
	pMenuReso->addAction(pResoParams);

	pMenuReso->addSeparator();

	QAction *pResoEllipses = new QAction("Ellipses...", this);
	pResoEllipses->setIcon(load_icon("res/icons/ellipses.svg"));
	pMenuReso->addAction(pResoEllipses);

#if !defined NO_3D
	QAction *pResoEllipses3D = new QAction("3D Ellipsoids...", this);
	pMenuReso->addAction(pResoEllipses3D);
#endif

	pMenuReso->addSeparator();

	QAction *pResoConv = new QAction("Convolution...", this);
	pMenuReso->addAction(pResoConv);


	// --------------------------------------------------------------------------------
	// calc menu
	QMenu *pMenuCalc = new QMenu("Calculation", this);

	QAction *pNeutronProps = new QAction("Neutron Properties...", this);
	pNeutronProps->setIcon(load_icon("res/icons/x-office-spreadsheet-template.svg"));
	pMenuCalc->addAction(pNeutronProps);

	pMenuCalc->addSeparator();

	QAction *pPowder = new QAction("Powder Lines...", this);
	pPowder->setIcon(load_icon("res/icons/weather-snow.svg"));
	pMenuCalc->addAction(pPowder);

	QAction *pDW = new QAction("Scattering Factors...", this);
	pMenuCalc->addAction(pDW);

	QAction *pFormfactor = nullptr;
	if(g_bHasFormfacts && g_bHasScatlens)
	{
		pFormfactor = new QAction("Form Factors...", this);
		pMenuCalc->addAction(pFormfactor);
	}

	QAction *pSgList = new QAction("Space Group Types...", this);
	pMenuCalc->addAction(pSgList);

	QAction *pDisp = new QAction("Dispersions...", this);
	//pDisp->setIcon(load_icon("disp.svg"));
	pMenuCalc->addAction(pDisp);

	pMenuCalc->addSeparator();

	QAction *pDynPlane = new QAction("Kinematic Plane...", this);
	pMenuCalc->addAction(pDynPlane);

	QAction *pSpuri = new QAction("Spurious Scattering...", this);
	pMenuCalc->addAction(pSpuri);


#if !defined NO_NET
	// --------------------------------------------------------------------------------
	// network menu
	QMenu *pMenuNet = new QMenu("Network", this);

	QAction *pConn = new QAction("Connect to Instrument...", this);
	pConn->setIcon(load_icon("res/icons/network-transmit-receive.svg"));
	pMenuNet->addAction(pConn);

	QAction *pDisconn = new QAction("Disconnect", this);
	pDisconn->setIcon(load_icon("res/icons/network-offline.svg"));
	pMenuNet->addAction(pDisconn);

	pMenuNet->addSeparator();

	QAction *pNetScanMon = new QAction("Scan Monitor...", this);
	pMenuNet->addAction(pNetScanMon);

	QAction *pNetCache = new QAction("Network Cache...", this);
	pMenuNet->addAction(pNetCache);

	QAction *pNetRefresh = new QAction("Refresh", this);
	pNetRefresh->setIcon(load_icon("res/icons/view-refresh.svg"));
	pMenuNet->addSeparator();
	pMenuNet->addAction(pNetRefresh);
#endif


	// --------------------------------------------------------------------------------
	// tools menu
	QMenu *pMenuTools = new QMenu("Tools", this);

	QAction *pScanViewer = new QAction("Scan Viewer...", this);
	pMenuTools->addAction(pScanViewer);



	// --------------------------------------------------------------------------------
	// help menu
	QMenu *pMenuHelp = new QMenu("Help", this);

	QAction *pHelp = new QAction("Show Help...", this);
	pHelp->setIcon(load_icon("res/icons/help-browser.svg"));
	pMenuHelp->addAction(pHelp);

	QAction *pDevelDoc = new QAction("Show Developer Help...", this);
	if(find_resource("doc/devel/html/index.html", 0) == "")
		pDevelDoc->setEnabled(0);
	pDevelDoc->setIcon(load_icon("res/icons/help-browser.svg"));
	pMenuHelp->addAction(pDevelDoc);

	pMenuHelp->addSeparator();

	QAction *pAboutQt = new QAction("About Qt...", this);
	//pAboutQt->setIcon(QIcon::fromTheme("help-about"));
	pMenuHelp->addAction(pAboutQt);

	//pMenuHelp->addSeparator();
	QAction *pAbout = new QAction("About Takin...", this);
	pAbout->setIcon(load_icon("res/icons/dialog-information.svg"));
	pMenuHelp->addAction(pAbout);



	// --------------------------------------------------------------------------------
	QMenuBar *pMenuBar = new QMenuBar(this);
	pMenuBar->addMenu(pMenuFile);
	pMenuBar->addMenu(m_pMenuViewRecip);
	pMenuBar->addMenu(m_pMenuViewReal);
	pMenuBar->addMenu(pMenuReso);
	pMenuBar->addMenu(pMenuCalc);
	pMenuBar->addMenu(pMenuTools);
#if !defined NO_NET
	pMenuBar->addMenu(pMenuNet);
#endif
	pMenuBar->addMenu(pMenuHelp);


	QObject::connect(pNew, SIGNAL(triggered()), this, SLOT(New()));
	QObject::connect(pLoad, SIGNAL(triggered()), this, SLOT(Load()));
	QObject::connect(pSave, SIGNAL(triggered()), this, SLOT(Save()));
	QObject::connect(pSaveAs, SIGNAL(triggered()), this, SLOT(SaveAs()));
	QObject::connect(pImport, SIGNAL(triggered()), this, SLOT(Import()));
	QObject::connect(pScanViewer, SIGNAL(triggered()), this, SLOT(ShowScanViewer()));
	QObject::connect(pSettings, SIGNAL(triggered()), this, SLOT(ShowSettingsDlg()));
	QObject::connect(pExit, SIGNAL(triggered()), this, SLOT(close()));

	QObject::connect(m_pSmallq, SIGNAL(toggled(bool)), this, SLOT(EnableSmallq(bool)));
	QObject::connect(m_pBZ, SIGNAL(toggled(bool)), this, SLOT(EnableBZ(bool)));
	QObject::connect(m_pWS, SIGNAL(toggled(bool)), this, SLOT(EnableWS(bool)));

	for(QAction* pAct : {m_pEwaldSphereNone, m_pEwaldSphereKi, m_pEwaldSphereKf})
		QObject::connect(pAct, SIGNAL(triggered()), this, SLOT(ShowEwaldSphere()));

	QObject::connect(m_pShowRealQDir, SIGNAL(toggled(bool)), this, SLOT(EnableRealQDir(bool)));

	QObject::connect(m_pSnapSmallq, SIGNAL(toggled(bool)), &m_sceneRecip, SLOT(setSnapq(bool)));
	QObject::connect(pKeepAbsKiKf, SIGNAL(toggled(bool)), &m_sceneRecip, SLOT(setKeepAbsKiKf(bool)));

	QObject::connect(pRecipParams, SIGNAL(triggered()), this, SLOT(ShowRecipParams()));
	QObject::connect(pRealParams, SIGNAL(triggered()), this, SLOT(ShowRealParams()));

	for(QAction *pProj : {m_pProjGnom, m_pProjStereo, m_pProjPara, m_pProjPersp})
		QObject::connect(pProj, SIGNAL(triggered()), this, SLOT(RecipProjChanged()));

#if !defined NO_3D
	QObject::connect(pView3D, SIGNAL(triggered()), this, SLOT(Show3D()));
	QObject::connect(pView3DReal, SIGNAL(triggered()), this, SLOT(Show3DReal()));
	QObject::connect(pResoEllipses3D, SIGNAL(triggered()), this, SLOT(ShowResoEllipses3D()));
#endif

	QObject::connect(pRecipExport, SIGNAL(triggered()), this, SLOT(ExportRecip()));
	QObject::connect(pProjExport, SIGNAL(triggered()), this, SLOT(ExportProj()));
	QObject::connect(pRealExport, SIGNAL(triggered()), this, SLOT(ExportReal()));
	QObject::connect(pTofExport, SIGNAL(triggered()), this, SLOT(ExportTof()));
	QObject::connect(pRealLatticeExport, SIGNAL(triggered()), this, SLOT(ExportRealLattice()));

	QObject::connect(pExportUC, SIGNAL(triggered()), this, SLOT(ExportUCModel()));

#ifdef USE_GIL
	QObject::connect(pBZExport, SIGNAL(triggered()), this, SLOT(ExportBZImage()));
	QObject::connect(pWSExport, SIGNAL(triggered()), this, SLOT(ExportWSImage()));
#endif

	QObject::connect(pResoParams, SIGNAL(triggered()), this, SLOT(ShowResoParams()));
	QObject::connect(pResoEllipses, SIGNAL(triggered()), this, SLOT(ShowResoEllipses()));
	QObject::connect(pResoConv, SIGNAL(triggered()), this, SLOT(ShowResoConv()));

	QObject::connect(pNeutronProps, SIGNAL(triggered()), this, SLOT(ShowNeutronDlg()));
	QObject::connect(m_pGoto, SIGNAL(triggered()), this, SLOT(ShowGotoDlg()));
	QObject::connect(pPowder, SIGNAL(triggered()), this, SLOT(ShowPowderDlg()));
	QObject::connect(pDisp, SIGNAL(triggered()), this, SLOT(ShowDispDlg()));
	QObject::connect(pSpuri, SIGNAL(triggered()), this, SLOT(ShowSpurions()));
	QObject::connect(pDW, SIGNAL(triggered()), this, SLOT(ShowDWDlg()));
	QObject::connect(pDynPlane, SIGNAL(triggered()), this, SLOT(ShowDynPlaneDlg()));

#if !defined NO_NET
	QObject::connect(pConn, SIGNAL(triggered()), this, SLOT(ShowConnectDlg()));
	QObject::connect(pDisconn, SIGNAL(triggered()), this, SLOT(Disconnect()));
	QObject::connect(pNetRefresh, SIGNAL(triggered()), this, SLOT(NetRefresh()));
	QObject::connect(pNetCache, SIGNAL(triggered()), this, SLOT(ShowNetCache()));
	QObject::connect(pNetScanMon, SIGNAL(triggered()), this, SLOT(ShowNetScanMonitor()));
#endif

	QObject::connect(pSgList, SIGNAL(triggered()), this, SLOT(ShowSgListDlg()));

	if(pFormfactor)
		QObject::connect(pFormfactor, SIGNAL(triggered()), this, SLOT(ShowFormfactorDlg()));

	QObject::connect(pHelp, SIGNAL(triggered()), this, SLOT(ShowHelp()));
	QObject::connect(pDevelDoc, SIGNAL(triggered()), this, SLOT(ShowDevelDoc()));
	QObject::connect(pAbout, SIGNAL(triggered()), this, SLOT(ShowAbout()));
	QObject::connect(pAboutQt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));


	setMenuBar(pMenuBar);
	// --------------------------------------------------------------------------------


	// --------------------------------------------------------------------------------
	// context menus
	if(m_pviewRecip) m_pviewRecip->setContextMenuPolicy(Qt::CustomContextMenu);
	if(m_pviewProjRecip) m_pviewProjRecip->setContextMenuPolicy(Qt::CustomContextMenu);
	if(m_pviewRealLattice) m_pviewRealLattice->setContextMenuPolicy(Qt::CustomContextMenu);
	if(m_pviewReal) m_pviewReal->setContextMenuPolicy(Qt::CustomContextMenu);
	if(m_pviewTof) m_pviewTof->setContextMenuPolicy(Qt::CustomContextMenu);

	if(m_pviewRecip)
		QObject::connect(m_pviewRecip, SIGNAL(customContextMenuRequested(const QPoint&)),
			this, SLOT(RecipContextMenu(const QPoint&)));
	if(m_pviewProjRecip)
		QObject::connect(m_pviewProjRecip, SIGNAL(customContextMenuRequested(const QPoint&)),
			this, SLOT(RecipContextMenu(const QPoint&)));
	if(m_pviewRealLattice)
		QObject::connect(m_pviewRealLattice, SIGNAL(customContextMenuRequested(const QPoint&)),
			this, SLOT(RealContextMenu(const QPoint&)));
	if(m_pviewReal)
		QObject::connect(m_pviewReal, SIGNAL(customContextMenuRequested(const QPoint&)),
			this, SLOT(RealContextMenu(const QPoint&)));
	if(m_pviewTof)
		QObject::connect(m_pviewTof, SIGNAL(customContextMenuRequested(const QPoint&)),
			this, SLOT(RealContextMenu(const QPoint&)));


	// --------------------------------------------------------------------------------
	// tool bars
	QToolBar *pFileTools = new QToolBar(this);
	pFileTools->setWindowTitle("File");
	pFileTools->addAction(pNew);
	pFileTools->addAction(pLoad);
	pFileTools->addAction(pImport);
	pFileTools->addAction(pSave);
	pFileTools->addAction(pSaveAs);
	addToolBar(pFileTools);

	QToolBar *pRecipTools = new QToolBar(this);
	pRecipTools->setWindowTitle("Reciprocal Space");
	pRecipTools->addAction(m_pGoto);
	pRecipTools->addAction(m_pSmallq);
	pRecipTools->addAction(m_pBZ);
	//pRecipTools->addAction(m_pEwaldSphere);
	addToolBar(pRecipTools);

	QToolBar *pResoTools = new QToolBar(this);
	pResoTools->setWindowTitle("Resolution");
	pResoTools->addAction(pResoParams);
	pResoTools->addAction(pResoEllipses);
	addToolBar(pResoTools);

	QToolBar *pCalcTools = new QToolBar(this);
	pCalcTools->setWindowTitle("Calculation");
	pCalcTools->addAction(pNeutronProps);
	pCalcTools->addAction(pPowder);
	addToolBar(pCalcTools);

#if !defined NO_NET
	QToolBar *pNetTools = new QToolBar(this);
	pNetTools->setWindowTitle("Network");
	pNetTools->addAction(pConn);
	pNetTools->addAction(pDisconn);
	pNetTools->addAction(pNetRefresh);
	addToolBar(pNetTools);
#endif

	// --------------------------------------------------------------------------------


	RepopulateSpaceGroups();

	unsigned int iMaxPeaks = m_settings.value("main/max_peaks", 10).toUInt();

	m_sceneRecip.GetTriangle()->SetMaxPeaks(iMaxPeaks);
	m_sceneRecip.GetTriangle()->SetPlaneDistTolerance(s_dPlaneDistTolerance);

	m_sceneProjRecip.GetLattice()->SetMaxPeaks(iMaxPeaks/2);

	m_sceneRealLattice.GetLattice()->SetMaxPeaks(iMaxPeaks);
	m_sceneRealLattice.GetLattice()->SetPlaneDistTolerance(s_dPlaneDistTolerance);

#if !defined NO_3D
	if(m_pRecip3d)
	{
		m_pRecip3d->SetMaxPeaks((t_real)iMaxPeaks);
		m_pRecip3d->SetPlaneDistTolerance(s_dPlaneDistTolerance);
	}
#endif

	m_bReady = 1;
	UpdateDs();
	CalcPeaks();


	m_sceneRecip.GetTriangle()->SetqVisible(bSmallqVisible);
	m_sceneRecip.GetTriangle()->SetBZVisible(bBZVisible);
	m_sceneRecip.GetTriangle()->SetEwaldSphereVisible(EWALD_KF);
	m_sceneRealLattice.GetLattice()->SetWSVisible(bWSVisible);
	m_sceneRecip.emitUpdate();
	//m_sceneRecip.emitAllParams();

	setAcceptDrops(1);
}
Example #7
0
void ManualAlignment::probePickedCallback(void * ud, SoEventCallback * n)
{
    Gui::View3DInventorViewer* view  = reinterpret_cast<Gui::View3DInventorViewer*>(n->getUserData());
    const SoEvent* ev = n->getEvent();
    if (ev->getTypeId() == SoMouseButtonEvent::getClassTypeId()) {
        // set as handled
        n->getAction()->setHandled();
        n->setHandled();

        const SoMouseButtonEvent * mbe = static_cast<const SoMouseButtonEvent *>(ev);
        if (mbe->getButton() == SoMouseButtonEvent::BUTTON1 && mbe->getState() == SoButtonEvent::DOWN) {
            // if we are in 'align' mode then handle the click event
            ManualAlignment* self = ManualAlignment::instance();
            // Get the closest point to the camera of the whole scene. 
            // This point doesn't need to be part of this view provider.
            Gui::WaitCursor wc;
            const SoPickedPoint * point = view->getPickedPoint(n);
            if (point) {
                Gui::ViewProvider* vp = static_cast<Gui::ViewProvider*>(view->getViewProviderByPath(point->getPath()));
                if (vp && vp->getTypeId().isDerivedFrom(Gui::ViewProviderDocumentObject::getClassTypeId())) {
                    Gui::ViewProviderDocumentObject* that = static_cast<Gui::ViewProviderDocumentObject*>(vp);
                    if (self->applyPickedProbe(that, point)) {
                        const SbVec3f& vec = point->getPoint();
                        Gui::getMainWindow()->showMessage(
                            tr("Point picked at (%1,%2,%3)")
                            .arg(vec[0]).arg(vec[1]).arg(vec[2]));
                    }
                    else {
                        Gui::getMainWindow()->showMessage(
                            tr("No point was found on model"));
                    }
                }
            }
            else {
                Gui::getMainWindow()->showMessage(
                    tr("No point was picked"));
            }
        }
        else if (mbe->getButton() == SoMouseButtonEvent::BUTTON2 && mbe->getState() == SoButtonEvent::UP) {
            ManualAlignment* self = ManualAlignment::instance();
            if (self->myAlignModel.isEmpty() || self->myFixedGroup.isEmpty())
                return;
            self->showInstructions();
            int nPoints;
            if (view == self->myViewer->getViewer(0))
                nPoints = self->myAlignModel.activeGroup().countPoints();
            else
                nPoints = self->myFixedGroup.countPoints();
            QMenu menu;
            QAction* fi = menu.addAction(QLatin1String("&Align"));
            QAction* rem = menu.addAction(QLatin1String("&Remove last point"));
            //QAction* cl = menu.addAction("C&lear");
            QAction* ca = menu.addAction(QLatin1String("&Cancel"));
            fi->setEnabled(self->canAlign());
            rem->setEnabled(nPoints > 0);
            menu.addSeparator();
            QAction* sync = menu.addAction(QLatin1String("&Synchronize views"));
            sync->setCheckable(true);
            if (self->d->sensorCam1->getAttachedNode())
                sync->setChecked(true);
            QAction* id = menu.exec(QCursor::pos());
            if (id == fi) {
                // call align->align();
                QTimer::singleShot(300, self, SLOT(onAlign()));
            }
            else if ((id == rem) && (view == self->myViewer->getViewer(0))) {
                QTimer::singleShot(300, self, SLOT(onRemoveLastPointMoveable()));
            }
            else if ((id == rem) && (view == self->myViewer->getViewer(1))) {
                QTimer::singleShot(300, self, SLOT(onRemoveLastPointFixed()));
            }
            //else if (id == cl) {
            //    // call align->clear();
            //    QTimer::singleShot(300, self, SLOT(onClear()));
            //}
            else if (id == ca) {
                // call align->cancel();
                QTimer::singleShot(300, self, SLOT(onCancel()));
            }
            else if (id == sync) {
                // setup sensor connection
                if (sync->isChecked()) {
                    SoCamera* cam1 = self->myViewer->getViewer(0)->getSoRenderManager()->getCamera();
                    SoCamera* cam2 = self->myViewer->getViewer(1)->getSoRenderManager()->getCamera();
                    if (cam1 && cam2) {
                        self->d->sensorCam1->attach(cam1);
                        self->d->rot_cam1 = cam1->orientation.getValue();
                        self->d->pos_cam1 = cam1->position.getValue();
                        self->d->sensorCam2->attach(cam2);
                        self->d->rot_cam2 = cam2->orientation.getValue();
                        self->d->pos_cam2 = cam2->position.getValue();
                    }
                }
                else {
                    self->d->sensorCam1->detach();
                    self->d->sensorCam2->detach();
                }
            }
        }
    }
}
Example #8
0
void dspWoScheduleByWorkOrder::sPopulateMenu(QMenu *pMenu, QTreeWidgetItem *selected, int)
{
  QString  status(selected->text(1));
  QAction *menuItem;

  menuItem = pMenu->addAction(tr("Edit W/O"), this, SLOT(sEdit()));
  if (!_privileges->check("MaintainWorkOrders"))
    menuItem->setEnabled(false);
  menuItem = pMenu->addAction(tr("View W/O"), this, SLOT(sView()));

  pMenu->addSeparator();

  if (status == "E")
  {
    menuItem = pMenu->addAction(tr("Release W/O"), this, SLOT(sReleaseWO()));
    if (!_privileges->check("ReleaseWorkOrders"))
      menuItem->setEnabled(false);
  }
  else if (status == "R")
  {
    menuItem = pMenu->addAction(tr("Recall W/O"), this, SLOT(sRecallWO()));
    if (!_privileges->check("RecallWorkOrders"))
      menuItem->setEnabled(false);
  }

  if ((status == "E") || (status == "R") || (status == "I"))
  {
    menuItem = pMenu->addAction(tr("Post Production..."), this, SLOT(sPostProduction()));
    if (!_privileges->check("PostProduction"))
      menuItem->setEnabled(false);

    if (status != "E")
    {
      menuItem = pMenu->addAction(tr("Correct Production Posting..."), this, SLOT(sCorrectProductionPosting()));
      if (!_privileges->check("PostProduction"))
        menuItem->setEnabled(false);
    }

    pMenu->addSeparator();
  }

  if (status == "O")
  {
    menuItem = pMenu->addAction(tr("Explode W/O..."), this, SLOT(sExplodeWO()));
    if (!_privileges->check("ExplodeWorkOrders"))
      menuItem->setEnabled(false);
  }
  else if (status == "E")
  {
    menuItem = pMenu->addAction(tr("Implode W/O..."), this, SLOT(sImplodeWO()));
    if (!_privileges->check("ImplodeWorkOrders"))
      menuItem->setEnabled(false);
  }

  if ((status == "O") || (status == "E"))
  {
    menuItem = pMenu->addAction(tr("Delete W/O..."), this, SLOT(sDeleteWO()));
    if (!_privileges->check("DeleteWorkOrders"))
      menuItem->setEnabled(false);
  }
  else
  {
    menuItem = pMenu->addAction(tr("Close W/O..."), this, SLOT(sCloseWO()));
    if (!_privileges->check("CloseWorkOrders"))
      menuItem->setEnabled(false);
  }

  pMenu->addSeparator();

  if ((status == "E") || (status == "R") || (status == "I"))
  {
    menuItem = pMenu->addAction(tr("View W/O Material Requirements..."), this, SLOT(sViewWomatl()));
    if (!_privileges->check("ViewWoMaterials"))
      menuItem->setEnabled(false);

    menuItem = pMenu->addAction(tr("Inventory Availability by Work Order..."), this, SLOT(sInventoryAvailabilityByWorkOrder()));
    if (!_privileges->check("ViewInventoryAvailability"))
      menuItem->setEnabled(false);

    pMenu->addSeparator();

    menuItem = pMenu->addAction(tr("Print Traveler..."), this, SLOT(sPrintTraveler()));
    if (!_privileges->check("PrintWorkOrderPaperWork"))
      menuItem->setEnabled(false);

    pMenu->addSeparator();

    menuItem = pMenu->addAction(tr("Issue Material Item..."), this, SLOT(sIssueWoMaterialItem()));
    menuItem->setEnabled(_privileges->check("IssueWoMaterials"));
  }

  if ((status == "O") || (status == "E"))
  {
    pMenu->addSeparator();

    menuItem = pMenu->addAction(tr("Reprioritize W/O..."), this, SLOT(sReprioritizeWo()));
    if (!_privileges->check("ReprioritizeWorkOrders"))
      menuItem->setEnabled(false);

    menuItem = pMenu->addAction(tr("Reschedule W/O..."), this, SLOT(sRescheduleWO()));
    if (!_privileges->check("RescheduleWorkOrders"))
      menuItem->setEnabled(false);

    menuItem = pMenu->addAction(tr("Change W/O Quantity..."), this, SLOT(sChangeWOQty()));
    if (!_privileges->check("ChangeWorkOrderQty"))
      menuItem->setEnabled(false);
  }

  pMenu->addSeparator();
  
  menuItem = pMenu->addAction(tr("View Bill of Materials..."), this, SLOT(sViewBOM()));
  menuItem->setEnabled(_privileges->check("ViewBOMs"));

  pMenu->addSeparator();

  menuItem = pMenu->addAction(tr("Running Availability..."), this, SLOT(sDspRunningAvailability()));
}
Example #9
0
Menu::Menu() {
    MenuWrapper * fileMenu = addMenu("File");
#ifdef Q_OS_MAC
    addActionToQMenuAndActionHash(fileMenu, MenuOption::AboutApp, 0, qApp, SLOT(aboutApp()), QAction::AboutRole);
#endif
    auto dialogsManager = DependencyManager::get<DialogsManager>();
    AccountManager& accountManager = AccountManager::getInstance();

    {
        addActionToQMenuAndActionHash(fileMenu, MenuOption::Login);

        // connect to the appropriate signal of the AccountManager so that we can change the Login/Logout menu item
        connect(&accountManager, &AccountManager::profileChanged,
                dialogsManager.data(), &DialogsManager::toggleLoginDialog);
        connect(&accountManager, &AccountManager::logoutComplete,
                dialogsManager.data(), &DialogsManager::toggleLoginDialog);
    }

    addDisabledActionAndSeparator(fileMenu, "Scripts");
    addActionToQMenuAndActionHash(fileMenu, MenuOption::LoadScript, Qt::CTRL | Qt::Key_O,
                                  qApp, SLOT(loadDialog()));
    addActionToQMenuAndActionHash(fileMenu, MenuOption::LoadScriptURL,
                                    Qt::CTRL | Qt::SHIFT | Qt::Key_O, qApp, SLOT(loadScriptURLDialog()));
    addActionToQMenuAndActionHash(fileMenu, MenuOption::StopAllScripts, 0, qApp, SLOT(stopAllScripts()));
    addActionToQMenuAndActionHash(fileMenu, MenuOption::ReloadAllScripts, Qt::CTRL | Qt::Key_R,
                                  qApp, SLOT(reloadAllScripts()));
    addActionToQMenuAndActionHash(fileMenu, MenuOption::RunningScripts, Qt::CTRL | Qt::Key_J,
                                  qApp, SLOT(toggleRunningScriptsWidget()));

    auto addressManager = DependencyManager::get<AddressManager>();

    addDisabledActionAndSeparator(fileMenu, "History");

    QAction* backAction = addActionToQMenuAndActionHash(fileMenu,
                                                        MenuOption::Back,
                                                        0,
                                                        addressManager.data(),
                                                        SLOT(goBack()));

    QAction* forwardAction = addActionToQMenuAndActionHash(fileMenu,
                                                           MenuOption::Forward,
                                                           0,
                                                           addressManager.data(),
                                                           SLOT(goForward()));

    // connect to the AddressManager signal to enable and disable the back and forward menu items
    connect(addressManager.data(), &AddressManager::goBackPossible, backAction, &QAction::setEnabled);
    connect(addressManager.data(), &AddressManager::goForwardPossible, forwardAction, &QAction::setEnabled);

    // set the two actions to start disabled since the stacks are clear on startup
    backAction->setDisabled(true);
    forwardAction->setDisabled(true);

    addDisabledActionAndSeparator(fileMenu, "Location");
    qApp->getBookmarks()->setupMenus(this, fileMenu);

    addActionToQMenuAndActionHash(fileMenu,
                                  MenuOption::AddressBar,
                                  Qt::CTRL | Qt::Key_L,
                                  dialogsManager.data(),
                                  SLOT(toggleAddressBar()));
    addActionToQMenuAndActionHash(fileMenu, MenuOption::CopyAddress, 0,
                                  addressManager.data(), SLOT(copyAddress()));
    addActionToQMenuAndActionHash(fileMenu, MenuOption::CopyPath, 0,
                                  addressManager.data(), SLOT(copyPath()));

    addActionToQMenuAndActionHash(fileMenu,
                                  MenuOption::Quit,
                                  Qt::CTRL | Qt::Key_Q,
                                  qApp,
                                  SLOT(quit()),
                                  QAction::QuitRole);


    MenuWrapper* editMenu = addMenu("Edit");

    QUndoStack* undoStack = qApp->getUndoStack();
    QAction* undoAction = undoStack->createUndoAction(editMenu);
    undoAction->setShortcut(Qt::CTRL | Qt::Key_Z);
    addActionToQMenuAndActionHash(editMenu, undoAction);

    QAction* redoAction = undoStack->createRedoAction(editMenu);
    redoAction->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_Z);
    addActionToQMenuAndActionHash(editMenu, redoAction);

    addActionToQMenuAndActionHash(editMenu,
                                  MenuOption::Preferences,
                                  Qt::CTRL | Qt::Key_Comma,
                                  dialogsManager.data(),
                                  SLOT(editPreferences()),
                                  QAction::PreferencesRole);

    addActionToQMenuAndActionHash(editMenu, MenuOption::Attachments, 0,
                                  dialogsManager.data(), SLOT(editAttachments()));
    addActionToQMenuAndActionHash(editMenu, MenuOption::Animations, 0,
                                  dialogsManager.data(), SLOT(editAnimations()));

    MenuWrapper* toolsMenu = addMenu("Tools");
    addActionToQMenuAndActionHash(toolsMenu, MenuOption::ScriptEditor,  Qt::ALT | Qt::Key_S,
                                  dialogsManager.data(), SLOT(showScriptEditor()));

#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
    auto speechRecognizer = DependencyManager::get<SpeechRecognizer>();
    QAction* speechRecognizerAction = addCheckableActionToQMenuAndActionHash(toolsMenu, MenuOption::ControlWithSpeech,
                                                                             Qt::CTRL | Qt::SHIFT | Qt::Key_C,
                                                                             speechRecognizer->getEnabled(),
                                                                             speechRecognizer.data(),
                                                                             SLOT(setEnabled(bool)));
    connect(speechRecognizer.data(), SIGNAL(enabledUpdated(bool)), speechRecognizerAction, SLOT(setChecked(bool)));
#endif

    addActionToQMenuAndActionHash(toolsMenu, MenuOption::Chat,
                                  0, // QML Qt::Key_Backslash,
                                  dialogsManager.data(), SLOT(showIRCLink()));
    addActionToQMenuAndActionHash(toolsMenu, MenuOption::AddRemoveFriends, 0,
                                  qApp, SLOT(showFriendsWindow()));

    MenuWrapper* visibilityMenu = toolsMenu->addMenu("I Am Visible To");
    {
        QActionGroup* visibilityGroup = new QActionGroup(toolsMenu);
        auto discoverabilityManager = DependencyManager::get<DiscoverabilityManager>();

        QAction* visibleToEveryone = addCheckableActionToQMenuAndActionHash(visibilityMenu, MenuOption::VisibleToEveryone,
            0, discoverabilityManager->getDiscoverabilityMode() == Discoverability::All,
            discoverabilityManager.data(), SLOT(setVisibility()));
        visibilityGroup->addAction(visibleToEveryone);

        QAction* visibleToFriends = addCheckableActionToQMenuAndActionHash(visibilityMenu, MenuOption::VisibleToFriends,
            0, discoverabilityManager->getDiscoverabilityMode() == Discoverability::Friends,
            discoverabilityManager.data(), SLOT(setVisibility()));
        visibilityGroup->addAction(visibleToFriends);

        QAction* visibleToNoOne = addCheckableActionToQMenuAndActionHash(visibilityMenu, MenuOption::VisibleToNoOne,
            0, discoverabilityManager->getDiscoverabilityMode() == Discoverability::None,
            discoverabilityManager.data(), SLOT(setVisibility()));
        visibilityGroup->addAction(visibleToNoOne);

        connect(discoverabilityManager.data(), &DiscoverabilityManager::discoverabilityModeChanged,
            discoverabilityManager.data(), &DiscoverabilityManager::visibilityChanged);
    }

    addActionToQMenuAndActionHash(toolsMenu,
                                  MenuOption::ToolWindow,
                                  Qt::CTRL | Qt::ALT | Qt::Key_T,
                                  dialogsManager.data(),
                                  SLOT(toggleToolWindow()));

    addActionToQMenuAndActionHash(toolsMenu,
                                  MenuOption::Console,
                                  Qt::CTRL | Qt::ALT | Qt::Key_J,
                                  DependencyManager::get<StandAloneJSConsole>().data(),
                                  SLOT(toggleConsole()));

    addActionToQMenuAndActionHash(toolsMenu,
                                  MenuOption::ResetSensors,
                                  0, // QML Qt::Key_Apostrophe,
                                  qApp,
                                  SLOT(resetSensors()));

    addActionToQMenuAndActionHash(toolsMenu, MenuOption::PackageModel, 0,
                                  qApp, SLOT(packageModel()));

    addMenu(DisplayPlugin::MENU_PATH());
    {
        MenuWrapper* displayModeMenu = addMenu(MenuOption::OutputMenu);
        QActionGroup* displayModeGroup = new QActionGroup(displayModeMenu);
        displayModeGroup->setExclusive(true);
    }

    MenuWrapper* avatarMenu = addMenu("Avatar");
    QObject* avatar = DependencyManager::get<AvatarManager>()->getMyAvatar();

    MenuWrapper* inputModeMenu = addMenu(MenuOption::InputMenu);
    QActionGroup* inputModeGroup = new QActionGroup(inputModeMenu);
    inputModeGroup->setExclusive(false);
    
    MenuWrapper* avatarSizeMenu = avatarMenu->addMenu("Size");
    addActionToQMenuAndActionHash(avatarSizeMenu,
                                  MenuOption::IncreaseAvatarSize,
                                  0, // QML Qt::Key_Plus,
                                  avatar,
                                  SLOT(increaseSize()));
    addActionToQMenuAndActionHash(avatarSizeMenu,
                                  MenuOption::DecreaseAvatarSize,
                                  0, // QML Qt::Key_Minus,
                                  avatar,
                                  SLOT(decreaseSize()));
    addActionToQMenuAndActionHash(avatarSizeMenu,
                                  MenuOption::ResetAvatarSize,
                                  0, // QML Qt::Key_Equal,
                                  avatar,
                                  SLOT(resetSize()));

    addCheckableActionToQMenuAndActionHash(avatarMenu, MenuOption::KeyboardMotorControl,
            Qt::CTRL | Qt::SHIFT | Qt::Key_K, true, avatar, SLOT(updateMotionBehaviorFromMenu()));
    addCheckableActionToQMenuAndActionHash(avatarMenu, MenuOption::ScriptedMotorControl, 0, true,
            avatar, SLOT(updateMotionBehaviorFromMenu()));
    addCheckableActionToQMenuAndActionHash(avatarMenu, MenuOption::NamesAboveHeads, 0, true);
    addCheckableActionToQMenuAndActionHash(avatarMenu, MenuOption::BlueSpeechSphere, 0, true);
    addCheckableActionToQMenuAndActionHash(avatarMenu, MenuOption::EnableCharacterController, 0, true,
            avatar, SLOT(updateMotionBehaviorFromMenu()));

    MenuWrapper* viewMenu = addMenu("View");
    addActionToQMenuAndActionHash(viewMenu, MenuOption::ReloadContent, 0, qApp, SLOT(reloadResourceCaches()));

    MenuWrapper* cameraModeMenu = viewMenu->addMenu("Camera Mode");
    QActionGroup* cameraModeGroup = new QActionGroup(cameraModeMenu);
    cameraModeGroup->setExclusive(true);
    cameraModeGroup->addAction(addCheckableActionToQMenuAndActionHash(cameraModeMenu,
                                                                      MenuOption::FirstPerson, 0, // QML Qt:: Key_P
                                                                      false, qApp, SLOT(cameraMenuChanged())));
    cameraModeGroup->addAction(addCheckableActionToQMenuAndActionHash(cameraModeMenu,
                                                                      MenuOption::ThirdPerson, 0,
                                                                      true, qApp, SLOT(cameraMenuChanged())));
    cameraModeGroup->addAction(addCheckableActionToQMenuAndActionHash(cameraModeMenu,
                                                                      MenuOption::IndependentMode, 0,
                                                                      false, qApp, SLOT(cameraMenuChanged())));
    cameraModeGroup->addAction(addCheckableActionToQMenuAndActionHash(cameraModeMenu,
                                                                      MenuOption::CameraEntityMode, 0,
                                                                      false, qApp, SLOT(cameraMenuChanged())));
    cameraModeGroup->addAction(addCheckableActionToQMenuAndActionHash(cameraModeMenu,
                                                                      MenuOption::FullscreenMirror, 0, // QML Qt::Key_H,
                                                                      false, qApp, SLOT(cameraMenuChanged())));

    addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::Mirror,
        0, //QML Qt::SHIFT | Qt::Key_H,
        true);
    addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::FullscreenMirror,
        0, // QML Qt::Key_H,
        false, qApp, SLOT(cameraMenuChanged()));
    
    addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::CenterPlayerInView,
                                           0, false, qApp, SLOT(rotationModeChanged()));

    addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::TurnWithHead, 0, false);

    addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::WorldAxes);

    addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::Stats);
    addActionToQMenuAndActionHash(viewMenu, MenuOption::Log,
        Qt::CTRL | Qt::SHIFT | Qt::Key_L,
        qApp, SLOT(toggleLogDialog()));
    addActionToQMenuAndActionHash(viewMenu, MenuOption::AudioNetworkStats, 0,
                                  dialogsManager.data(), SLOT(audioStatsDetails()));
    addActionToQMenuAndActionHash(viewMenu, MenuOption::BandwidthDetails, 0,
                                  dialogsManager.data(), SLOT(bandwidthDetails()));
    addActionToQMenuAndActionHash(viewMenu, MenuOption::OctreeStats, 0,
                                  dialogsManager.data(), SLOT(octreeStatsDetails()));


    MenuWrapper* developerMenu = addMenu("Developer");

    MenuWrapper* renderOptionsMenu = developerMenu->addMenu("Render");
    addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Atmosphere,
        0, // QML Qt::SHIFT | Qt::Key_A,
        true);
    addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::DebugAmbientOcclusion);
    addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Antialiasing);

    MenuWrapper* ambientLightMenu = renderOptionsMenu->addMenu(MenuOption::RenderAmbientLight);
    QActionGroup* ambientLightGroup = new QActionGroup(ambientLightMenu);
    ambientLightGroup->setExclusive(true);
    ambientLightGroup->addAction(addCheckableActionToQMenuAndActionHash(ambientLightMenu, MenuOption::RenderAmbientLightGlobal, 0, true));
    ambientLightGroup->addAction(addCheckableActionToQMenuAndActionHash(ambientLightMenu, MenuOption::RenderAmbientLight0, 0, false));
    ambientLightGroup->addAction(addCheckableActionToQMenuAndActionHash(ambientLightMenu, MenuOption::RenderAmbientLight1, 0, false));
    ambientLightGroup->addAction(addCheckableActionToQMenuAndActionHash(ambientLightMenu, MenuOption::RenderAmbientLight2, 0, false));
    ambientLightGroup->addAction(addCheckableActionToQMenuAndActionHash(ambientLightMenu, MenuOption::RenderAmbientLight3, 0, false));
    ambientLightGroup->addAction(addCheckableActionToQMenuAndActionHash(ambientLightMenu, MenuOption::RenderAmbientLight4, 0, false));
    ambientLightGroup->addAction(addCheckableActionToQMenuAndActionHash(ambientLightMenu, MenuOption::RenderAmbientLight5, 0, false));
    ambientLightGroup->addAction(addCheckableActionToQMenuAndActionHash(ambientLightMenu, MenuOption::RenderAmbientLight6, 0, false));
    ambientLightGroup->addAction(addCheckableActionToQMenuAndActionHash(ambientLightMenu, MenuOption::RenderAmbientLight7, 0, false));
    ambientLightGroup->addAction(addCheckableActionToQMenuAndActionHash(ambientLightMenu, MenuOption::RenderAmbientLight8, 0, false));
    ambientLightGroup->addAction(addCheckableActionToQMenuAndActionHash(ambientLightMenu, MenuOption::RenderAmbientLight9, 0, false));

    addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::ThrottleFPSIfNotFocus, 0, true);

    MenuWrapper* resolutionMenu = renderOptionsMenu->addMenu(MenuOption::RenderResolution);
    QActionGroup* resolutionGroup = new QActionGroup(resolutionMenu);
    resolutionGroup->setExclusive(true);
    resolutionGroup->addAction(addCheckableActionToQMenuAndActionHash(resolutionMenu, MenuOption::RenderResolutionOne, 0, true));
    resolutionGroup->addAction(addCheckableActionToQMenuAndActionHash(resolutionMenu, MenuOption::RenderResolutionTwoThird, 0, false));
    resolutionGroup->addAction(addCheckableActionToQMenuAndActionHash(resolutionMenu, MenuOption::RenderResolutionHalf, 0, false));
    resolutionGroup->addAction(addCheckableActionToQMenuAndActionHash(resolutionMenu, MenuOption::RenderResolutionThird, 0, false));
    resolutionGroup->addAction(addCheckableActionToQMenuAndActionHash(resolutionMenu, MenuOption::RenderResolutionQuarter, 0, false));

    addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Stars,
        0, // QML Qt::Key_Asterisk,
        true);

    addActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::LodTools,
        0, // QML Qt::SHIFT | Qt::Key_L,
        dialogsManager.data(), SLOT(lodTools()));
    
    MenuWrapper* assetDeveloperMenu = developerMenu->addMenu("Assets");
    
    auto& assetDialogFactory = AssetUploadDialogFactory::getInstance();
    assetDialogFactory.setDialogParent(this);
    
    QAction* assetUpload = addActionToQMenuAndActionHash(assetDeveloperMenu,
                                                         MenuOption::UploadAsset,
                                                         0,
                                                         &assetDialogFactory,
                                                         SLOT(showDialog()));
    
    // disable the asset upload action by default - it gets enabled only if asset server becomes present
    assetUpload->setEnabled(false);
    
    auto& atpMigrator = ATPAssetMigrator::getInstance();
    atpMigrator.setDialogParent(this);
    
    addActionToQMenuAndActionHash(assetDeveloperMenu, MenuOption::AssetMigration,
                                                            0, &atpMigrator,
                                                            SLOT(loadEntityServerFile()));
    
    MenuWrapper* avatarDebugMenu = developerMenu->addMenu("Avatar");

    MenuWrapper* faceTrackingMenu = avatarDebugMenu->addMenu("Face Tracking");
    {
        QActionGroup* faceTrackerGroup = new QActionGroup(avatarDebugMenu);

        bool defaultNoFaceTracking = true;
#ifdef HAVE_DDE
        defaultNoFaceTracking = false;
#endif
        QAction* noFaceTracker = addCheckableActionToQMenuAndActionHash(faceTrackingMenu, MenuOption::NoFaceTracking,
            0, defaultNoFaceTracking,
            qApp, SLOT(setActiveFaceTracker()));
        faceTrackerGroup->addAction(noFaceTracker);

#ifdef HAVE_FACESHIFT
        QAction* faceshiftFaceTracker = addCheckableActionToQMenuAndActionHash(faceTrackingMenu, MenuOption::Faceshift,
            0, false,
            qApp, SLOT(setActiveFaceTracker()));
        faceTrackerGroup->addAction(faceshiftFaceTracker);
#endif
#ifdef HAVE_DDE
        QAction* ddeFaceTracker = addCheckableActionToQMenuAndActionHash(faceTrackingMenu, MenuOption::UseCamera,
            0, true,
            qApp, SLOT(setActiveFaceTracker()));
        faceTrackerGroup->addAction(ddeFaceTracker);
#endif
    }
#ifdef HAVE_DDE
    faceTrackingMenu->addSeparator();
    QAction* binaryEyelidControl = addCheckableActionToQMenuAndActionHash(faceTrackingMenu, MenuOption::BinaryEyelidControl, 0, true);
    binaryEyelidControl->setVisible(true);  // DDE face tracking is on by default
    QAction* coupleEyelids = addCheckableActionToQMenuAndActionHash(faceTrackingMenu, MenuOption::CoupleEyelids, 0, true);
    coupleEyelids->setVisible(true);  // DDE face tracking is on by default
    QAction* useAudioForMouth = addCheckableActionToQMenuAndActionHash(faceTrackingMenu, MenuOption::UseAudioForMouth, 0, true);
    useAudioForMouth->setVisible(true);  // DDE face tracking is on by default
    QAction* ddeFiltering = addCheckableActionToQMenuAndActionHash(faceTrackingMenu, MenuOption::VelocityFilter, 0, true);
    ddeFiltering->setVisible(true);  // DDE face tracking is on by default
    QAction* ddeCalibrate = addActionToQMenuAndActionHash(faceTrackingMenu, MenuOption::CalibrateCamera, 0,
        DependencyManager::get<DdeFaceTracker>().data(), SLOT(calibrate()));
    ddeCalibrate->setVisible(true);  // DDE face tracking is on by default
#endif
#if defined(HAVE_FACESHIFT) || defined(HAVE_DDE)
    faceTrackingMenu->addSeparator();
    addCheckableActionToQMenuAndActionHash(faceTrackingMenu, MenuOption::MuteFaceTracking,
        Qt::CTRL | Qt::SHIFT | Qt::Key_F, true);  // DDE face tracking is on by default
    addCheckableActionToQMenuAndActionHash(faceTrackingMenu, MenuOption::AutoMuteAudio, 0, false);
#endif

#ifdef HAVE_IVIEWHMD
    MenuWrapper* eyeTrackingMenu = avatarDebugMenu->addMenu("Eye Tracking");
    addCheckableActionToQMenuAndActionHash(eyeTrackingMenu, MenuOption::SMIEyeTracking, 0, false,
        qApp, SLOT(setActiveEyeTracker()));
    {
        MenuWrapper* calibrateEyeTrackingMenu = eyeTrackingMenu->addMenu("Calibrate");
        addActionToQMenuAndActionHash(calibrateEyeTrackingMenu, MenuOption::OnePointCalibration, 0,
            qApp, SLOT(calibrateEyeTracker1Point()));
        addActionToQMenuAndActionHash(calibrateEyeTrackingMenu, MenuOption::ThreePointCalibration, 0,
            qApp, SLOT(calibrateEyeTracker3Points()));
        addActionToQMenuAndActionHash(calibrateEyeTrackingMenu, MenuOption::FivePointCalibration, 0,
            qApp, SLOT(calibrateEyeTracker5Points()));
    }
    addCheckableActionToQMenuAndActionHash(eyeTrackingMenu, MenuOption::SimulateEyeTracking, 0, false,
        qApp, SLOT(setActiveEyeTracker()));
#endif

    auto avatarManager = DependencyManager::get<AvatarManager>();
    addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::AvatarReceiveStats, 0, false,
                                           avatarManager.data(), SLOT(setShouldShowReceiveStats(bool)));

    addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::RenderSkeletonCollisionShapes);
    addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::RenderHeadCollisionShapes);
    addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::RenderBoundingCollisionShapes);
    addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::RenderLookAtVectors, 0, false);
    addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::RenderLookAtTargets, 0, false);
    addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::RenderFocusIndicator, 0, false);
    addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::ShowWhosLookingAtMe, 0, false);
    addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::FixGaze, 0, false);
    addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::EnableAvatarUpdateThreading, 0, false,
                                           qApp, SLOT(setAvatarUpdateThreading(bool)));
    addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::EnableRigAnimations, 0, false,
                                           avatar, SLOT(setEnableRigAnimations(bool)));
    addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::EnableAnimGraph, 0, true,
                                           avatar, SLOT(setEnableAnimGraph(bool)));
    addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::AnimDebugDrawBindPose, 0, false,
                                           avatar, SLOT(setEnableDebugDrawBindPose(bool)));
    addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::AnimDebugDrawAnimPose, 0, false,
                                           avatar, SLOT(setEnableDebugDrawAnimPose(bool)));
    addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::MeshVisible, 0, true,
                                           avatar, SLOT(setEnableMeshVisible(bool)));
    addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::DisableEyelidAdjustment, 0, false);

    addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::ComfortMode, 0, true);

    MenuWrapper* handOptionsMenu = developerMenu->addMenu("Hands");
    addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::DisplayHandTargets, 0, false);
    addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::EnableHandMouseInput, 0, false);
    addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::LowVelocityFilter, 0, true,
                                           qApp, SLOT(setLowVelocityFilter(bool)));
    addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::ShowIKConstraints, 0, false);

    MenuWrapper* leapOptionsMenu = handOptionsMenu->addMenu("Leap Motion");
    addCheckableActionToQMenuAndActionHash(leapOptionsMenu, MenuOption::LeapMotionOnHMD, 0, false);

#ifdef HAVE_RSSDK
    MenuWrapper* realSenseOptionsMenu = handOptionsMenu->addMenu("RealSense");
    addActionToQMenuAndActionHash(realSenseOptionsMenu, MenuOption::LoadRSSDKFile, 0,
                                  RealSense::getInstance(), SLOT(loadRSSDKFile()));
#endif

    MenuWrapper* networkMenu = developerMenu->addMenu("Network");
    addActionToQMenuAndActionHash(networkMenu, MenuOption::ReloadContent, 0, qApp, SLOT(reloadResourceCaches()));
    addCheckableActionToQMenuAndActionHash(networkMenu, MenuOption::DisableNackPackets, 0, false,
                                           qApp->getEntityEditPacketSender(),
                                           SLOT(toggleNackPackets()));
    addCheckableActionToQMenuAndActionHash(networkMenu,
                                           MenuOption::DisableActivityLogger,
                                           0,
                                           false,
                                           &UserActivityLogger::getInstance(),
                                           SLOT(disable(bool)));
    addActionToQMenuAndActionHash(networkMenu, MenuOption::CachesSize, 0,
                                  dialogsManager.data(), SLOT(cachesSizeDialog()));
    addActionToQMenuAndActionHash(networkMenu, MenuOption::DiskCacheEditor, 0,
                                  dialogsManager.data(), SLOT(toggleDiskCacheEditor()));

    addActionToQMenuAndActionHash(networkMenu, MenuOption::ShowDSConnectTable, 0,
                                  dialogsManager.data(), SLOT(showDomainConnectionDialog()));

    MenuWrapper* timingMenu = developerMenu->addMenu("Timing and Stats");

    MenuWrapper* perfTimerMenu = timingMenu->addMenu("Performance Timer");
    addCheckableActionToQMenuAndActionHash(perfTimerMenu, MenuOption::DisplayDebugTimingDetails, 0, false);
    addCheckableActionToQMenuAndActionHash(perfTimerMenu, MenuOption::OnlyDisplayTopTen, 0, true);
    addCheckableActionToQMenuAndActionHash(perfTimerMenu, MenuOption::ExpandUpdateTiming, 0, false);
    addCheckableActionToQMenuAndActionHash(perfTimerMenu, MenuOption::ExpandMyAvatarTiming, 0, false);
    addCheckableActionToQMenuAndActionHash(perfTimerMenu, MenuOption::ExpandMyAvatarSimulateTiming, 0, false);
    addCheckableActionToQMenuAndActionHash(perfTimerMenu, MenuOption::ExpandOtherAvatarTiming, 0, false);
    addCheckableActionToQMenuAndActionHash(perfTimerMenu, MenuOption::ExpandPaintGLTiming, 0, false);

    addCheckableActionToQMenuAndActionHash(timingMenu, MenuOption::FrameTimer);
    addActionToQMenuAndActionHash(timingMenu, MenuOption::RunTimingTests, 0, qApp, SLOT(runTests()));
    addCheckableActionToQMenuAndActionHash(timingMenu, MenuOption::PipelineWarnings);
    addCheckableActionToQMenuAndActionHash(timingMenu, MenuOption::LogExtraTimings);
    addCheckableActionToQMenuAndActionHash(timingMenu, MenuOption::SuppressShortTimings);
    addCheckableActionToQMenuAndActionHash(timingMenu, MenuOption::ShowRealtimeEntityStats);

    auto audioIO = DependencyManager::get<AudioClient>();
    MenuWrapper* audioDebugMenu = developerMenu->addMenu("Audio");
    addCheckableActionToQMenuAndActionHash(audioDebugMenu, MenuOption::AudioNoiseReduction,
                                           0,
                                           true,
                                           audioIO.data(),
                                           SLOT(toggleAudioNoiseReduction()));

    addCheckableActionToQMenuAndActionHash(audioDebugMenu, MenuOption::EchoServerAudio, 0, false,
                                           audioIO.data(), SLOT(toggleServerEcho()));
    addCheckableActionToQMenuAndActionHash(audioDebugMenu, MenuOption::EchoLocalAudio, 0, false,
                                           audioIO.data(), SLOT(toggleLocalEcho()));
    addCheckableActionToQMenuAndActionHash(audioDebugMenu, MenuOption::MuteAudio,
                                           Qt::CTRL | Qt::Key_M,
                                           false,
                                           audioIO.data(),
                                           SLOT(toggleMute()));
    addActionToQMenuAndActionHash(audioDebugMenu,
                                  MenuOption::MuteEnvironment,
                                  0,
                                  audioIO.data(),
                                  SLOT(sendMuteEnvironmentPacket()));

    auto scope = DependencyManager::get<AudioScope>();

    MenuWrapper* audioScopeMenu = audioDebugMenu->addMenu("Audio Scope");
    addCheckableActionToQMenuAndActionHash(audioScopeMenu, MenuOption::AudioScope,
                                           Qt::CTRL | Qt::Key_P, false,
                                           scope.data(),
                                           SLOT(toggle()));
    addCheckableActionToQMenuAndActionHash(audioScopeMenu, MenuOption::AudioScopePause,
                                           Qt::CTRL | Qt::SHIFT | Qt::Key_P ,
                                           false,
                                           scope.data(),
                                           SLOT(togglePause()));
    addDisabledActionAndSeparator(audioScopeMenu, "Display Frames");
    {
        QAction *fiveFrames = addCheckableActionToQMenuAndActionHash(audioScopeMenu, MenuOption::AudioScopeFiveFrames,
                                               0,
                                               true,
                                               scope.data(),
                                               SLOT(selectAudioScopeFiveFrames()));

        QAction *twentyFrames = addCheckableActionToQMenuAndActionHash(audioScopeMenu, MenuOption::AudioScopeTwentyFrames,
                                               0,
                                               false,
                                               scope.data(),
                                               SLOT(selectAudioScopeTwentyFrames()));

        QAction *fiftyFrames = addCheckableActionToQMenuAndActionHash(audioScopeMenu, MenuOption::AudioScopeFiftyFrames,
                                               0,
                                               false,
                                               scope.data(),
                                               SLOT(selectAudioScopeFiftyFrames()));

        QActionGroup* audioScopeFramesGroup = new QActionGroup(audioScopeMenu);
        audioScopeFramesGroup->addAction(fiveFrames);
        audioScopeFramesGroup->addAction(twentyFrames);
        audioScopeFramesGroup->addAction(fiftyFrames);
    }

    MenuWrapper* physicsOptionsMenu = developerMenu->addMenu("Physics");
    addCheckableActionToQMenuAndActionHash(physicsOptionsMenu, MenuOption::PhysicsShowOwned);
    addCheckableActionToQMenuAndActionHash(physicsOptionsMenu, MenuOption::PhysicsShowHulls);

    addCheckableActionToQMenuAndActionHash(developerMenu, MenuOption::DisplayCrashOptions, 0, true);
    addActionToQMenuAndActionHash(developerMenu, MenuOption::CrashInterface, 0, qApp, SLOT(crashApplication()));

    MenuWrapper* helpMenu = addMenu("Help");
    addActionToQMenuAndActionHash(helpMenu, MenuOption::EditEntitiesHelp, 0, qApp, SLOT(showEditEntitiesHelp()));

#ifndef Q_OS_MAC
    QAction* aboutAction = helpMenu->addAction(MenuOption::AboutApp);
    connect(aboutAction, SIGNAL(triggered()), qApp, SLOT(aboutApp()));
#endif
}
Example #10
0
// ---------------------------------------------------------------------------
void 
TextEdit::setupFileActions()
{
    QToolBar *tb = new QToolBar(this);
    tb->setWindowTitle(tr("File Actions"));
    addToolBar(tb);

    QMenu *menu = new QMenu(tr("&File"), this);
    menuBar()->addMenu(menu);

    QAction *a;

    a = new QAction(QIcon(rsrcPath + "/filenew.png"), tr("&New"), this);
    a->setShortcut(QKeySequence::New);
    connect(a, SIGNAL(triggered()), this, SLOT(fileNew()));
    tb->addAction(a);
    menu->addAction(a);

    a = new QAction(QIcon(rsrcPath + "/fileopen.png"), tr("&Open..."), this);
    a->setShortcut(QKeySequence::Open);
    connect(a, SIGNAL(triggered()), this, SLOT(fileOpen()));
    tb->addAction(a);
    menu->addAction(a);

    menu->addSeparator();

    actionSave = a = new QAction(QIcon(rsrcPath + "/filesave.png"), tr("&Save"), this);
    a->setShortcut(QKeySequence::Save);
    connect(a, SIGNAL(triggered()), this, SLOT(fileSave()));
    a->setEnabled(false);
    tb->addAction(a);
    menu->addAction(a);

    a = new QAction(tr("Save &As..."), this);
    connect(a, SIGNAL(triggered()), this, SLOT(fileSaveAs()));
    menu->addAction(a);
    menu->addSeparator();

#ifndef QT_NO_PRINTER
    a = new QAction(QIcon(rsrcPath + "/fileprint.png"), tr("&Print..."), this);
    a->setShortcut(QKeySequence::Print);
    connect(a, SIGNAL(triggered()), this, SLOT(filePrint()));
    tb->addAction(a);
    menu->addAction(a);

    a = new QAction(QIcon(rsrcPath + "/fileprint.png"), tr("Print Preview..."), this);
    connect(a, SIGNAL(triggered()), this, SLOT(filePrintPreview()));
    menu->addAction(a);

    a = new QAction(QIcon(rsrcPath + "/exportpdf.png"), tr("&Export PDF..."), this);
    a->setShortcut(Qt::CTRL + Qt::Key_D);
    connect(a, SIGNAL(triggered()), this, SLOT(filePrintPdf()));
    tb->addAction(a);
    menu->addAction(a);

    menu->addSeparator();
#endif

    a = new QAction(tr("&Quit"), this);
    a->setShortcut(Qt::CTRL + Qt::Key_Q);
    connect(a, SIGNAL(triggered()), this, SLOT(close()));
    menu->addAction(a);
}
Example #11
0
void TabBarWidget::contextMenuEvent(QContextMenuEvent *event)
{
	m_clickedTab = tabAt(event->pos());

	if (m_previewWidget && m_previewWidget->isVisible())
	{
		m_previewWidget->hide();
	}

	if (m_previewTimer > 0)
	{
		killTimer(m_previewTimer);

		m_previewTimer = 0;
	}

	QMenu menu(this);
	menu.addAction(ActionsManager::getAction(QLatin1String("NewTab")));
	menu.addAction(ActionsManager::getAction(QLatin1String("NewTabPrivate")));

	if (m_clickedTab >= 0)
	{
		const bool isPinned = getTabProperty(m_clickedTab, QLatin1String("isPinned"), false).toBool();
		int amount = 0;

		for (int i = 0; i < count(); ++i)
		{
			if (getTabProperty(i, QLatin1String("isPinned"), false).toBool() || i == m_clickedTab)
			{
				continue;
			}

			++amount;
		}

		menu.addAction(tr("Clone Tab"), this, SLOT(cloneTab()))->setEnabled(getTabProperty(m_clickedTab, QLatin1String("canClone"), false).toBool());
		menu.addAction((isPinned ? tr("Unpin Tab") : tr("Pin Tab")), this, SLOT(pinTab()));
		menu.addSeparator();
		menu.addAction(tr("Detach Tab"), this, SLOT(detachTab()))->setEnabled(count() > 1);
		menu.addSeparator();

		if (isPinned)
		{
			QAction *closeAction = menu.addAction(QString());

			ActionsManager::setupLocalAction(closeAction, QLatin1String("CloseTab"), true);

			closeAction->setEnabled(false);
		}
		else
		{
			menu.addAction(ActionsManager::getAction(QLatin1String("CloseTab")));
		}

		menu.addAction(QIcon(":/icons/tab-close-other.png"), tr("Close Other Tabs"), this, SLOT(closeOther()))->setEnabled(amount > 0);
	}

	menu.exec(event->globalPos());

	m_clickedTab = -1;

	if (underMouse())
	{
		m_previewTimer = startTimer(250);
	}
}
Example #12
0
void
SourceTreeView::setupMenus()
{
    m_playlistMenu.clear();
    m_roPlaylistMenu.clear();
    m_latchMenu.clear();
    m_privacyMenu.clear();

    bool readonly = true;
    SourcesModel::RowType type = ( SourcesModel::RowType )model()->data( m_contextMenuIndex, SourcesModel::SourceTreeItemTypeRole ).toInt();
    if ( type == SourcesModel::StaticPlaylist || type == SourcesModel::AutomaticPlaylist || type == SourcesModel::Station )
    {

        PlaylistItem* item = itemFromIndex< PlaylistItem >( m_contextMenuIndex );
        playlist_ptr playlist = item->playlist();
        if ( !playlist.isNull() )
        {
            readonly = !playlist->author()->isLocal();
        }
    }

    QAction* latchOnAction = ActionCollection::instance()->getAction( "latchOn" );
    m_latchMenu.addAction( latchOnAction );

    m_privacyMenu.addAction( ActionCollection::instance()->getAction( "togglePrivacy" ) );

    if ( type == SourcesModel::Collection )
    {
        SourceItem* item = itemFromIndex< SourceItem >( m_contextMenuIndex );
        source_ptr source = item->source();
        if ( !source.isNull() )
        {
            if ( m_latchManager->isLatched( source ) )
            {
                QAction *latchOffAction = ActionCollection::instance()->getAction( "latchOff" );
                m_latchMenu.addAction( latchOffAction );
                connect( latchOffAction, SIGNAL( triggered() ), SLOT( latchOff() ) );
                m_latchMenu.addSeparator();
                QAction *latchRealtimeAction = ActionCollection::instance()->getAction( "realtimeFollowingAlong" );
                latchRealtimeAction->setChecked( source->playlistInterface()->latchMode() == Tomahawk::PlaylistInterface::RealTime );
                m_latchMenu.addAction( latchRealtimeAction );
                connect( latchRealtimeAction, SIGNAL( toggled( bool ) ), SLOT( latchModeToggled( bool ) ) );
            }
        }
    }

    QAction *loadPlaylistAction = ActionCollection::instance()->getAction( "loadPlaylist" );
    m_playlistMenu.addAction( loadPlaylistAction );
    QAction *renamePlaylistAction = ActionCollection::instance()->getAction( "renamePlaylist" );
    m_playlistMenu.addAction( renamePlaylistAction );
    m_playlistMenu.addSeparator();

    QAction *copyPlaylistAction = m_playlistMenu.addAction( tr( "&Copy Link" ) );
    QAction *deletePlaylistAction = m_playlistMenu.addAction( tr( "&Delete %1" ).arg( SourcesModel::rowTypeToString( type ) ) );

    QString addToText = QString( "Add to my %1" );
    if ( type == SourcesModel::StaticPlaylist )
        addToText = addToText.arg( "Playlists" );
    if ( type == SourcesModel::AutomaticPlaylist )
        addToText = addToText.arg( "Automatic Playlists" );
    else if ( type == SourcesModel::Station )
        addToText = addToText.arg( "Stations" );

    QAction *addToLocalAction = m_roPlaylistMenu.addAction( tr( addToText.toUtf8(), "Adds the given playlist, dynamic playlist, or station to the users's own list" ) );

    m_roPlaylistMenu.addAction( copyPlaylistAction );
    deletePlaylistAction->setEnabled( !readonly );
    renamePlaylistAction->setEnabled( !readonly );
    addToLocalAction->setEnabled( readonly );

    if ( type == SourcesModel::StaticPlaylist )
        copyPlaylistAction->setText( tr( "&Export Playlist" ) );

    connect( loadPlaylistAction,   SIGNAL( triggered() ), SLOT( loadPlaylist() ) );
    connect( renamePlaylistAction, SIGNAL( triggered() ), SLOT( renamePlaylist() ) );
    connect( deletePlaylistAction, SIGNAL( triggered() ), SLOT( deletePlaylist() ) );
    connect( copyPlaylistAction,   SIGNAL( triggered() ), SLOT( copyPlaylistLink() ) );
    connect( addToLocalAction,     SIGNAL( triggered() ), SLOT( addToLocal() ) );
    connect( latchOnAction,        SIGNAL( triggered() ), SLOT( latchOnOrCatchUp() ), Qt::QueuedConnection );
}
ExternalHelpWindow::ExternalHelpWindow(QWidget *parent)
    : QMainWindow(parent)
{
    QSettings *settings = Core::ICore::settings();
    settings->beginGroup(QLatin1String(Help::Constants::ID_MODE_HELP));

    const QVariant geometry = settings->value(QLatin1String("geometry"));
    if (geometry.isValid())
        restoreGeometry(geometry.toByteArray());
    else
        resize(640, 480);

    settings->endGroup();

    QAction *action = new QAction(this);
    action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_I));
    connect(action, SIGNAL(triggered()), this, SIGNAL(activateIndex()));
    addAction(action);

    action = new QAction(this);
    action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_C));
    connect(action, SIGNAL(triggered()), this, SIGNAL(activateContents()));
    addAction(action);

    action = new QAction(this);
    action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Slash));
    connect(action, SIGNAL(triggered()), this, SIGNAL(activateSearch()));
    addAction(action);

    action = new QAction(this);
    action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_B));
    connect(action, SIGNAL(triggered()), this, SIGNAL(activateBookmarks()));
    addAction(action);

    action = new QAction(this);
    action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_O));
    connect(action, SIGNAL(triggered()), this, SIGNAL(activateOpenPages()));
    addAction(action);

    CentralWidget *centralWidget = CentralWidget::instance();

    action = new QAction(this);
    action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Plus));
    connect(action, SIGNAL(triggered()), centralWidget, SLOT(zoomIn()));
    addAction(action);

    action = new QAction(this);
    action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Minus));
    connect(action, SIGNAL(triggered()), centralWidget, SLOT(zoomOut()));
    addAction(action);

    action = new QAction(this);
    action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M));
    connect(action, SIGNAL(triggered()), this, SIGNAL(addBookmark()));
    addAction(action);

    action = new QAction(this);
    action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_C));
    connect(action, SIGNAL(triggered()), centralWidget, SLOT(copy()));
    addAction(action);

    action = new QAction(this);
    action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_P));
    connect(action, SIGNAL(triggered()), centralWidget, SLOT(print()));
    addAction(action);

    action = new QAction(this);
    action->setShortcut(QKeySequence::Back);
    action->setEnabled(centralWidget->isBackwardAvailable());
    connect(action, SIGNAL(triggered()), centralWidget, SLOT(backward()));
    connect(centralWidget, SIGNAL(backwardAvailable(bool)), action,
        SLOT(setEnabled(bool)));

    action = new QAction(this);
    action->setShortcut(QKeySequence::Forward);
    action->setEnabled(centralWidget->isForwardAvailable());
    connect(action, SIGNAL(triggered()), centralWidget, SLOT(forward()));
    connect(centralWidget, SIGNAL(forwardAvailable(bool)), action,
        SLOT(setEnabled(bool)));

    QAction *reset = new QAction(this);
    connect(reset, SIGNAL(triggered()), centralWidget, SLOT(resetZoom()));
    addAction(reset);

    QAction *ctrlTab = new QAction(this);
    connect(ctrlTab, SIGNAL(triggered()), &OpenPagesManager::instance(),
        SLOT(gotoPreviousPage()));
    addAction(ctrlTab);

    QAction *ctrlShiftTab = new QAction(this);
    connect(ctrlShiftTab, SIGNAL(triggered()), &OpenPagesManager::instance(),
        SLOT(gotoNextPage()));
    addAction(ctrlShiftTab);

    action = new QAction(QIcon(QLatin1String(Core::Constants::ICON_TOGGLE_SIDEBAR)),
        tr("Show Sidebar"), this);
    connect(action, SIGNAL(triggered()), this, SIGNAL(showHideSidebar()));

    if (Utils::HostOsInfo::isMacHost()) {
        reset->setShortcut(QKeySequence(Qt::ALT + Qt::Key_0));
        action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_0));
        ctrlTab->setShortcut(QKeySequence(Qt::ALT + Qt::Key_Tab));
        ctrlShiftTab->setShortcut(QKeySequence(Qt::ALT + Qt::SHIFT + Qt::Key_Tab));
    } else {
        reset->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_0));
        action->setShortcut(QKeySequence(Qt::ALT + Qt::Key_0));
        ctrlTab->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Tab));
        ctrlShiftTab->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Tab));
    }

    QToolButton *button = new QToolButton;
    button->setDefaultAction(action);

    QStatusBar *statusbar = statusBar();
    statusbar->show();
    statusbar->setProperty("p_styled", true);
    statusbar->addPermanentWidget(button);

    QWidget *w = new QWidget;
    QHBoxLayout *layout = new QHBoxLayout(w);
    layout->addStretch(1);
    statusbar->insertWidget(1, w, 1);

    installEventFilter(this);
    setWindowTitle(tr("Qt Creator Offline Help"));
}
Example #14
0
void AppActions::updateExtensionsActionsAndMenus()
{
  ExtensionsRegistry* ExtReg = ExtensionsRegistry::instance();

  ExtensionsRegistry::ExtensionsByName_t* Extensions = ExtReg->registeredFeatureExtensions();

  ExtensionsRegistry::ExtensionsByName_t::iterator it;
  ExtensionsRegistry::ExtensionsByName_t::iterator itb = Extensions->begin();
  ExtensionsRegistry::ExtensionsByName_t::iterator ite = Extensions->end();

  mp_SpatialExtensionsMenu->clear();
  mp_ModelExtensionsMenu->clear();
  mp_ResultsExtensionsMenu->clear();
  mp_OtherExtensionsMenu->clear();

  for (it = itb; it!= ite; ++it)
  {

    QString MenuText = WaresTranslationsRegistry::instance()
      ->tryTranslate(QString::fromStdString((*it).second->FileFullPath),
                     "signature",(*it).second->Signature->MenuText);

    // Replace empty menu text by extension ID
    MenuText = QString::fromStdString(openfluid::tools::replaceEmptyString(MenuText.toStdString(),(*it).first));

    m_ExtensionsActions[(*it).first] = new QAction(MenuText,this);

    // associate extension ID with QAction for use when action is triggered and launch the correct extension
    m_ExtensionsActions[(*it).first]->setData(QString((*it).first.c_str()));

    // set extension in the correct menu, taking into account the extension category
    if ((*it).second->Signature->Category == openfluid::builderext::CAT_SPATIAL)
    {
      mp_SpatialExtensionsMenu->addAction(m_ExtensionsActions[(*it).first]);
    }
    else if ((*it).second->Signature->Category == openfluid::builderext::CAT_MODEL)
    {
      mp_ModelExtensionsMenu->addAction(m_ExtensionsActions[(*it).first]);
    }
    else if ((*it).second->Signature->Category == openfluid::builderext::CAT_RESULTS)
    {
      mp_ResultsExtensionsMenu->addAction(m_ExtensionsActions[(*it).first]);
    }
    else
    {
      mp_OtherExtensionsMenu->addAction(m_ExtensionsActions[(*it).first]);
    }
  }


  // fill empty menus with a "none" action

  QAction *NoneAction;

  if (mp_SpatialExtensionsMenu->isEmpty())
  {
    NoneAction = new QAction(tr("(none)"),this);
    NoneAction->setEnabled(false);
    mp_SpatialExtensionsMenu->addAction(NoneAction);
  }

  if (mp_ModelExtensionsMenu->isEmpty())
  {
    NoneAction = new QAction(tr("(none)"),this);
    NoneAction->setEnabled(false);
    mp_ModelExtensionsMenu->addAction(NoneAction);
  }

  if (mp_ResultsExtensionsMenu->isEmpty())
  {
    NoneAction = new QAction(tr("(none)"),this);
    NoneAction->setEnabled(false);
    mp_ResultsExtensionsMenu->addAction(NoneAction);
  }

  if (mp_OtherExtensionsMenu->isEmpty())
  {
    NoneAction = new QAction(tr("(none)"),this);
    NoneAction->setEnabled(false);
    mp_OtherExtensionsMenu->addAction(NoneAction);
  }

}
Example #15
0
QAction* QtWebKitWebWidget::getAction(WindowAction action)
{
	const QWebPage::WebAction webAction = mapAction(action);

	if (webAction != QWebPage::NoWebAction)
	{
		return m_webView->page()->action(webAction);
	}

	if (action == NoAction)
	{
		return NULL;
	}

	if (m_actions.contains(action))
	{
		return m_actions[action];
	}

	QAction *actionObject = new QAction(this);
	actionObject->setData(action);

	connect(actionObject, SIGNAL(triggered()), this, SLOT(triggerAction()));

	switch (action)
	{
		case OpenLinkInNewTabAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("OpenLinkInNewTab"), true);

			break;
		case OpenLinkInNewTabBackgroundAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("OpenLinkInNewTabBackground"), true);

			break;
		case OpenLinkInNewWindowAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("OpenLinkInNewWindow"), true);

			break;
		case OpenLinkInNewWindowBackgroundAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("OpenLinkInNewWindowBackground"), true);

			break;
		case OpenFrameInThisTabAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("OpenFrameInThisTab"), true);

			break;
		case OpenFrameInNewTabBackgroundAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("OpenFrameInNewTabBackground"), true);

			break;
		case CopyFrameLinkToClipboardAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("CopyFrameLinkToClipboard"), true);

			break;
		case ViewSourceFrameAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("ViewSourceFrame"), true);

			actionObject->setEnabled(false);

			break;
		case ReloadFrameAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("ReloadFrame"), true);

			break;
		case SaveLinkToDownloadsAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("SaveLinkToDownloads"));

			break;
		case RewindBackAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("RewindBack"), true);

			actionObject->setEnabled(getAction(GoBackAction)->isEnabled());

			break;
		case RewindForwardAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("RewindForward"), true);

			actionObject->setEnabled(getAction(GoForwardAction)->isEnabled());

			break;
		case ReloadTimeAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("ReloadTime"), true);

			actionObject->setMenu(new QMenu(this));
			actionObject->setEnabled(false);

			break;
		case PrintAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("Print"), true);

			break;
		case BookmarkAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("AddBookmark"), true);

			break;
		case BookmarkLinkAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("BookmarkLink"), true);

			break;
		case CopyAddressAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("CopyAddress"), true);

			break;
		case ViewSourceAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("ViewSource"), true);

			actionObject->setEnabled(false);

			break;
		case ValidateAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("Validate"), true);

			actionObject->setMenu(new QMenu(this));
			actionObject->setEnabled(false);

			break;
		case ContentBlockingAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("ContentBlocking"), true);

			actionObject->setEnabled(false);

			break;
		case WebsitePreferencesAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("WebsitePreferences"), true);

			actionObject->setEnabled(false);

			break;
		case FullScreenAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("FullScreen"), true);

			actionObject->setEnabled(false);

			break;
		case ZoomInAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("ZoomIn"));

			break;
		case ZoomOutAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("ZoomOut"), true);

			break;
		case ZoomOriginalAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("ZoomOriginal"), true);

			break;
		case SearchAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("Search"), true);

			break;
		case SearchMenuAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("SearchMenu"), true);

			actionObject->setMenu(new QMenu(this));

			connect(actionObject->menu(), SIGNAL(aboutToShow()), this, SLOT(searchMenuAboutToShow()));
			connect(actionObject->menu(), SIGNAL(triggered(QAction*)), this, SLOT(search(QAction*)));

			break;
		case OpenSelectionAsLinkAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("OpenSelectionAsLink"), true);

			break;
		case ClearAllAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("ClearAll"), true);

			break;
		case SpellCheckAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("SpellCheck"), true);

			actionObject->setEnabled(false);

			break;
		case ImagePropertiesAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("ImageProperties"), true);

			break;
		case CreateSearchAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("CreateSearch"), true);

			break;
		case ReloadOrStopAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("Reload"));

			actionObject->setEnabled(true);
			actionObject->setShortcut(QKeySequence());

			break;
		case InspectPageAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("InspectPage"));

			actionObject->setEnabled(true);
			actionObject->setShortcut(QKeySequence());

			break;
		case FindAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("Find"), true);

			actionObject->setEnabled(true);

			break;
		case FindNextAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("FindNext"), true);

			actionObject->setEnabled(true);

			break;
		case FindPreviousAction:
			ActionsManager::setupLocalAction(actionObject, QLatin1String("FindPrevious"), true);

			actionObject->setEnabled(true);

			break;
		default:
			actionObject->deleteLater();
			actionObject = NULL;

			break;
	}

	if (actionObject)
	{
		m_actions[action] = actionObject;
	}

	return actionObject;
}
Example #16
0
void QgsLegendLayer::addToPopupMenu( QMenu& theMenu )
{
  QgsMapLayer *lyr = layer();
  QAction *toggleEditingAction = QgisApp::instance()->actionToggleEditing();
  QAction *saveLayerEditsAction = QgisApp::instance()->actionSaveActiveLayerEdits();
  QAction *allEditsAction = QgisApp::instance()->actionAllEdits();

  // zoom to layer extent
  theMenu.addAction( QgsApplication::getThemeIcon( "/mActionZoomToLayer.svg" ),
                     tr( "&Zoom to Layer Extent" ), legend(), SLOT( legendLayerZoom() ) );
  if ( lyr->type() == QgsMapLayer::RasterLayer )
  {
    theMenu.addAction( tr( "&Zoom to Best Scale (100%)" ), legend(), SLOT( legendLayerZoomNative() ) );

    QgsRasterLayer *rasterLayer =  qobject_cast<QgsRasterLayer *>( lyr );
    if ( rasterLayer && rasterLayer->rasterType() != QgsRasterLayer::Palette )
    {
      theMenu.addAction( tr( "&Stretch Using Current Extent" ), legend(), SLOT( legendLayerStretchUsingCurrentExtent() ) );
    }
  }

  // show in overview
  QAction* showInOverviewAction = theMenu.addAction( tr( "&Show in Overview" ), this, SLOT( showInOverview() ) );
  showInOverviewAction->setCheckable( true );
  showInOverviewAction->blockSignals( true );
  showInOverviewAction->setChecked( mLyr.isInOverview() );
  showInOverviewAction->blockSignals( false );

  // remove from canvas
  theMenu.addAction( QgsApplication::getThemeIcon( "/mActionRemoveLayer.svg" ), tr( "&Remove" ), QgisApp::instance(), SLOT( removeLayer() ) );

  // duplicate layer
  QAction* duplicateLayersAction = theMenu.addAction( QgsApplication::getThemeIcon( "/mActionDuplicateLayer.svg" ), tr( "&Duplicate" ), QgisApp::instance(), SLOT( duplicateLayers() ) );

  // set layer crs
  theMenu.addAction( QgsApplication::getThemeIcon( "/mActionSetCRS.png" ), tr( "&Set Layer CRS" ), QgisApp::instance(), SLOT( setLayerCRS() ) );

  // assign layer crs to project
  theMenu.addAction( QgsApplication::getThemeIcon( "/mActionSetProjectCRS.png" ), tr( "Set &Project CRS from Layer" ), QgisApp::instance(), SLOT( setProjectCRSFromLayer() ) );

  theMenu.addSeparator();

  if ( lyr->type() == QgsMapLayer::VectorLayer )
  {
    QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer *>( lyr );

    // attribute table
    theMenu.addAction( QgsApplication::getThemeIcon( "/mActionOpenTable.png" ), tr( "&Open Attribute Table" ),
                       QgisApp::instance(), SLOT( attributeTable() ) );

    // allow editing
    int cap = vlayer->dataProvider()->capabilities();
    if ( cap & QgsVectorDataProvider::EditingCapabilities )
    {
      if ( toggleEditingAction )
      {
        theMenu.addAction( toggleEditingAction );
        toggleEditingAction->setChecked( vlayer->isEditable() );
      }
      if ( saveLayerEditsAction && vlayer->isModified() )
      {
        theMenu.addAction( saveLayerEditsAction );
      }
    }

    if ( allEditsAction->isEnabled() )
    {
      theMenu.addAction( allEditsAction );
    }

    // disable duplication of memory layers
    if ( vlayer->storageType() == "Memory storage" && legend()->selectedLayers().count() == 1 )
    {
      duplicateLayersAction->setEnabled( false );
    }

    // save as vector file
    theMenu.addAction( tr( "Save As..." ), QgisApp::instance(), SLOT( saveAsFile() ) );

    // save selection as vector file
    QAction* saveSelectionAsAction = theMenu.addAction( tr( "Save Selection As..." ), QgisApp::instance(), SLOT( saveSelectionAsVectorFile() ) );
    if ( vlayer->selectedFeatureCount() == 0 )
    {
      saveSelectionAsAction->setEnabled( false );
    }

    if ( !vlayer->isEditable() && vlayer->dataProvider()->supportsSubsetString() && vlayer->vectorJoins().isEmpty() )
      theMenu.addAction( tr( "&Filter..." ), QgisApp::instance(), SLOT( layerSubsetString() ) );

    //show number of features in legend if requested
    QAction* showNFeaturesAction = new QAction( tr( "Show Feature Count" ), &theMenu );
    showNFeaturesAction->setCheckable( true );
    showNFeaturesAction->setChecked( mShowFeatureCount );
    QObject::connect( showNFeaturesAction, SIGNAL( toggled( bool ) ), this, SLOT( setShowFeatureCount( bool ) ) );
    theMenu.addAction( showNFeaturesAction );
    theMenu.addSeparator();
  }
Example #17
0
/**
 * Allow changing tile properties through a context menu.
 */
void TilesetView::contextMenuEvent(QContextMenuEvent *event)
{
    const QModelIndex index = indexAt(event->pos());
    const TilesetModel *model = tilesetModel();
    if (!model)
        return;

    Tile *tile = model->tileAt(index);

    QMenu menu;

    QIcon propIcon(QLatin1String(":images/16x16/document-properties.png"));

    if (tile) {
        if (mEditTerrain) {
            // Select this tile to make sure it is clear that only a single
            // tile is being used.
            selectionModel()->setCurrentIndex(index,
                                              QItemSelectionModel::SelectCurrent |
                                              QItemSelectionModel::Clear);

            QAction *addTerrain = menu.addAction(tr("Add Terrain Type"));
            connect(addTerrain, &QAction::triggered, this, &TilesetView::addTerrainType);

            if (mTerrain) {
                QAction *setImage = menu.addAction(tr("Set Terrain Image"));
                connect(setImage, &QAction::triggered, this, &TilesetView::selectTerrainImage);
            }
        } else if (mEditWangSet) {
            selectionModel()->setCurrentIndex(index,
                                              QItemSelectionModel::SelectCurrent |
                                              QItemSelectionModel::Clear);

            if (mWangSet) {
                QAction *setImage = menu.addAction(tr("Set Wang Set Image"));
                connect(setImage, &QAction::triggered, this, &TilesetView::selectWangSetImage);
            }
            if (mWangBehavior != WholeId && mWangColorIndex) {
                QAction *setImage = menu.addAction(tr("Set Wang Color Image"));
                connect(setImage, &QAction::triggered, this, &TilesetView::selectWangColorImage);
            }
        } else if (mTilesetDocument) {
            QAction *tileProperties = menu.addAction(propIcon,
                                                     tr("Tile &Properties..."));
            Utils::setThemeIcon(tileProperties, "document-properties");
            connect(tileProperties, &QAction::triggered, this, &TilesetView::editTileProperties);
        } else {
            // Assuming we're used in the MapEditor

            // Enable "swap" if there are exactly 2 tiles selected
            bool exactlyTwoTilesSelected =
                    (selectionModel()->selectedIndexes().size() == 2);

            QAction *swapTilesAction = menu.addAction(tr("&Swap Tiles"));
            swapTilesAction->setEnabled(exactlyTwoTilesSelected);
            connect(swapTilesAction, &QAction::triggered, this, &TilesetView::swapTiles);
        }

        menu.addSeparator();
    }

    QAction *toggleGrid = menu.addAction(tr("Show &Grid"));
    toggleGrid->setCheckable(true);
    toggleGrid->setChecked(mDrawGrid);

    Preferences *prefs = Preferences::instance();
    connect(toggleGrid, &QAction::toggled,
            prefs, &Preferences::setShowTilesetGrid);

    menu.exec(event->globalPos());
}
Example #18
0
void ConsoleChannel::initMenu()
{
    Fixture* fxi = m_doc->fixture(fixture());
    Q_ASSERT(fxi != NULL);

    const QLCChannel* ch = fxi->channel(m_channel);
    Q_ASSERT(ch != NULL);

    // Get rid of a possible previous menu
    if (m_menu != NULL)
    {
        delete m_menu;
        m_menu = NULL;
    }

    // Create a popup menu and set the channel name as its title
    m_menu = new QMenu(this);
    m_presetButton->setMenu(m_menu);
    m_presetButton->setPopupMode(QToolButton::InstantPopup);

    QString btnIconStr = ch->getIconNameFromGroup(ch->group());
    if (btnIconStr.startsWith(":"))
        m_presetButton->setStyleSheet("QToolButton { border-image: url(" + btnIconStr + ") 0 0 0 0 stretch stretch; }");
    else
    {
        m_presetButton->setStyleSheet("QToolButton { background: " + btnIconStr + "; }");
        setIntensityButton(ch);
    }

    switch(ch->group())
    {
    case QLCChannel::Colour:
        m_cngWidget = new ClickAndGoWidget();
        m_cngWidget->setType(ClickAndGoWidget::Preset, ch);
        break;
    case QLCChannel::Effect:
        m_cngWidget = new ClickAndGoWidget();
        m_cngWidget->setType(ClickAndGoWidget::Preset, ch);
        break;
    case QLCChannel::Gobo:
        m_cngWidget = new ClickAndGoWidget();
        m_cngWidget->setType(ClickAndGoWidget::Preset, ch);
        break;
    default:
        break;
    }

    if (m_cngWidget != NULL)
    {
        QWidgetAction* action = new QWidgetAction(this);
        action->setDefaultWidget(m_cngWidget);
        m_menu->addAction(action);
        connect(m_cngWidget, SIGNAL(levelChanged(uchar)),
                this, SLOT(slotClickAndGoLevelChanged(uchar)));
        connect(m_cngWidget, SIGNAL(levelAndPresetChanged(uchar,QImage)),
                this, SLOT(slotClickAndGoLevelAndPresetChanged(uchar, QImage)));
    }
    else
    {
        QAction* action = m_menu->addAction(m_presetButton->icon(), ch->name());
        m_menu->setTitle(ch->name());
        action->setEnabled(false);
        m_menu->addSeparator();

        // Initialize the preset menu only for intelligent fixtures
        if (fxi->isDimmer() == false)
            initCapabilityMenu(ch);
    }
}
Example #19
0
void IdDialog::IdListCustomPopupMenu( QPoint )
{
    QMenu contextMnu( this );


    std::list<RsGxsId> own_identities ;
    rsIdentity->getOwnIds(own_identities) ;

    QTreeWidgetItem *item = ui->treeWidget_IdList->currentItem();
    if (item) {
        uint32_t item_flags = item->data(RSID_COL_KEYID,Qt::UserRole).toUInt() ;

        if(!(item_flags & RSID_FILTER_OWNED_BY_YOU))
        {
            if(own_identities.size() <= 1)
            {
                QAction *action = contextMnu.addAction(QIcon(":/images/chat_24.png"), tr("Chat with this person"), this, SLOT(chatIdentity()));

                if(own_identities.empty())
                    action->setEnabled(false) ;
                else
                    action->setData(QString::fromStdString((own_identities.front()).toStdString())) ;
            }
            else
            {
                QMenu *mnu = contextMnu.addMenu(QIcon(":/images/chat_24.png"),tr("Chat with this person as...")) ;

                for(std::list<RsGxsId>::const_iterator it=own_identities.begin(); it!=own_identities.end(); ++it)
                {
                    RsIdentityDetails idd ;
                    rsIdentity->getIdDetails(*it,idd) ;

                    QPixmap pixmap ;

                    if(idd.mAvatar.mSize == 0 || !pixmap.loadFromData(idd.mAvatar.mData, idd.mAvatar.mSize, "PNG"))
                        pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(*it)) ;

                    QAction *action = mnu->addAction(QIcon(pixmap), QString("%1 (%2)").arg(QString::fromUtf8(idd.mNickname.c_str()), QString::fromStdString((*it).toStdString())), this, SLOT(chatIdentity()));
                    action->setData(QString::fromStdString((*it).toStdString())) ;
                }
            }

            contextMnu.addAction(QIcon(":/images/mail_new.png"), tr("Send message to this person"), this, SLOT(sendMsg()));
        }
    }

    contextMnu.addSeparator();

    contextMnu.addAction(ui->editIdentity);
    contextMnu.addAction(ui->removeIdentity);

    contextMnu.addSeparator();

    hideIdAct->setChecked(!ui->treeWidget_IdList->isColumnHidden(RSID_COL_KEYID));
    hideTypeAct->setChecked(!ui->treeWidget_IdList->isColumnHidden(RSID_COL_IDTYPE));

    QMenu *menu = contextMnu.addMenu(tr("Columns"));
    menu->addAction(hideIdAct);
    menu->addAction(hideTypeAct);

    contextMnu.exec(QCursor::pos());
}
Example #20
0
bool WebView::popupSpellMenu(QContextMenuEvent *event)
{
    // return false if not handled
    if (!ReKonfig::automaticSpellChecking())
        return false;

    QWebElement element(m_contextMenuHitResult.element());
    if (element.isNull())
        return false;

    int selStart = element.evaluateJavaScript("this.selectionStart").toInt();
    int selEnd = element.evaluateJavaScript("this.selectionEnd").toInt();
    if (selEnd != selStart)
        return false; // selection, handle normally

    // No selection - Spell Checking only
    // Get word
    QString text = element.evaluateJavaScript("this.value").toString();
    QRegExp ws("\\b");
    int s1 = text.lastIndexOf(ws, selStart);
    int s2 = text.indexOf(ws, selStart);
    QString word = text.mid(s1, s2 - s1).trimmed();

    // sanity check
    if (word.isEmpty())
        return false;

    kDebug() << s1 << ":" << s2 << ":" << word << ":";
    Sonnet::Speller spellor;
    if (spellor.isCorrect(word))
        return false; // no need to popup spell menu

    // find alternates
    QStringList words = spellor.suggest(word);

    // Construct popup menu
    QMenu mnu(this);

    // Add alternates
    if (words.isEmpty())
    {
        QAction *a = mnu.addAction(i18n("No suggestions for %1", word));
        a->setEnabled(false);
    }
    else
    {
        QStringListIterator it(words);
        while (it.hasNext())
        {
            QString w = it.next();
            QAction *aWord = mnu.addAction(w);
            aWord->setData(w);
        }
    }

    // Add dictionary options
    mnu.addSeparator();
    QAction *aIgnore = mnu.addAction(i18n("Ignore"));
    QAction *aAddToDict = mnu.addAction(i18n("Add to Dictionary"));

    QAction *aSpellChoice = mnu.exec(event->globalPos());
    if (aSpellChoice)
    {
        if (aSpellChoice == aAddToDict)
            spellor.addToPersonal(word);
        else if (aSpellChoice == aIgnore)
        {
            // Ignore :)
        }
        else
        {
            // Choose a replacement word
            QString w = aSpellChoice->data().toString();
            if (!w.isEmpty())
            {
                // replace word
                QString script(QL1S("this.value=this.value.substring(0,"));
                script += QString::number(s1);
                script += QL1S(") + \'");
                script +=  w.replace('\'', "\\\'"); // Escape any Quote marks in replacement word
                script += QL1C('\'') + QL1S("+this.value.substring(");
                script += QString::number(s2);
                script += QL1C(')');
                
                element.evaluateJavaScript(script);
                // reposition cursor
                element.evaluateJavaScript("this.selectionEnd=this.selectionStart=" + QString::number(selStart) + QL1C(';'));
            }
        }
    }

    return true;
}
Example #21
0
void CtrlRenders::contextMenuEvent(QContextMenuEvent *event)
{
	QMenu menu(this);
	ActionId * action_id;
	QAction * action;

	action = new QAction("Hide:", this);
	action->setEnabled( false);
	menu.addAction( action);
	menu.addSeparator();

	action_id = new ActionId( ListNodes::e_HideInvert, "Invert", this);
	action_id->setCheckable( true);
	action_id->setChecked( m_list->getFlagsHideShow() & ListNodes::e_HideInvert);
	connect( action_id, SIGNAL( triggeredId( int ) ), m_list, SLOT( actHideShow( int) ));
	menu.addAction( action_id);
	menu.addSeparator();

	action_id = new ActionId( ListNodes::e_HideHidden, "Hidden", this);
	action_id->setCheckable( true);
	action_id->setChecked( m_list->getFlagsHideShow() & ListNodes::e_HideHidden);
	connect( action_id, SIGNAL( triggeredId( int ) ), m_list, SLOT( actHideShow( int) ));
	menu.addAction( action_id);

	action_id = new ActionId( ListNodes::e_HideOffline, "Offline", this);
	action_id->setCheckable( true);
	action_id->setChecked( m_list->getFlagsHideShow() & ListNodes::e_HideOffline);
	connect( action_id, SIGNAL( triggeredId( int ) ), m_list, SLOT( actHideShow( int) ));
	menu.addAction( action_id);

	menu.addSeparator();

	action = new QAction("Size:", this);
	action->setEnabled( false);
	menu.addAction( action);
	menu.addSeparator();

	action_id = new ActionId( int(ListRenders::EVariableSize), "Variable", this);
	action_id->setCheckable( true);
	action_id->setChecked( ListRenders::getDisplaySize() == ListRenders::EVariableSize);
	connect( action_id, SIGNAL( triggeredId( int ) ), m_list, SLOT( actChangeSize( int) ));
	menu.addAction( action_id);

	action_id = new ActionId( int(ListRenders::EBigSize), "Big", this);
	action_id->setCheckable( true);
	action_id->setChecked( ListRenders::getDisplaySize() == ListRenders::EBigSize);
	connect( action_id, SIGNAL( triggeredId( int ) ), m_list, SLOT( actChangeSize( int) ));
	menu.addAction( action_id);

	action_id = new ActionId( int(ListRenders::ENormalSize), "Normal", this);
	action_id->setCheckable( true);
	action_id->setChecked( ListRenders::getDisplaySize() == ListRenders::ENormalSize);
	connect( action_id, SIGNAL( triggeredId( int ) ), m_list, SLOT( actChangeSize( int) ));
	menu.addAction( action_id);

	action_id = new ActionId( int(ListRenders::ESMallSize), "Small", this);
	action_id->setCheckable( true);
	action_id->setChecked( ListRenders::getDisplaySize() == ListRenders::ESMallSize);
	connect( action_id, SIGNAL( triggeredId( int ) ), m_list, SLOT( actChangeSize( int) ));
	menu.addAction( action_id);

	menu.exec( event->globalPos());
}
Example #22
0
MainMenu::MainMenu(bool autoclose, const QStringList &runList, const QStringList &busyList, QWidget *parent) :
    QMenu(parent),
    SingletonWidget(this)
{
    move(QCursor::pos());
    QAction *act = addAction(style()->standardIcon(QStyle::SP_DriveCDIcon), tr("Install Application"));
    act->setData(Install);
    act->setEnabled(busyList.isEmpty());
    addSeparator();
    QFileInfoList pList = FS::data().entryInfoList(QDir::AllDirs | QDir::NoDotAndDotDot);
    if (pList.isEmpty())
        addEmpty(this);
    else
    {
        sortList(pList);
        for (const QFileInfo &pInfo : pList)
        {
            QString hash = pInfo.fileName();
            QFileInfoList sList = FS::shortcuts(hash).entryInfoList(QDir::Files);
            sortList(sList, false);
            QSettings s(FS::prefix(hash).absoluteFilePath(".settings"), QSettings::IniFormat);
            s.setIniCodec("UTF-8");
            QString name = s.value("Name").toString();
            QMenu *pMenu = addMenu(getPrefixIcon(hash), QString(name).replace('&', "&&"));
            bool run = runList.contains(hash);
            bool busyOrRun = busyList.contains(hash) || run;
            if (sList.isEmpty())
                addEmpty(pMenu);
            else
            {
                QDir iDir = FS::icons(hash);
                for (const QFileInfo &shortcut : sList)
                {
                    QString base = shortcut.fileName();
                    QIcon icon = iDir.exists(base) ? QIcon(iDir.absoluteFilePath(base)) :
                                                     style()->standardIcon(QStyle::SP_FileLinkIcon);
                    QSettings s(shortcut.absoluteFilePath(), QSettings::IniFormat);
                    s.setIniCodec("UTF-8");
                    QString name = s.value("Name").toString();
                    act = pMenu->addAction(icon, QString(name).replace('&', "&&"));
                    act->setProperty("PrefixHash", hash);
                    act->setProperty("Exe", FS::toUnixPath(hash, s.value("Exe").toString()));
                    act->setProperty("WorkDir", FS::toUnixPath(hash, s.value("WorkDir").toString()));
                    act->setProperty("Args", s.value("Args").toString());
                    if (s.value("Debug", true).toBool())
                    {
                        act->setData(Debug);
                        act->setProperty("Shortcut", shortcut.absoluteFilePath());
                    }
                    else
                        act->setData(Run);
                }
            }
            pMenu->addSeparator();
            QMenu *ccMenu = pMenu->addMenu(style()->standardIcon(QStyle::SP_ComputerIcon), tr("Control Center"));
            act = ccMenu->addAction(style()->standardIcon(QStyle::SP_MediaPlay), tr("Run File"));
            act->setProperty("PrefixHash", hash);
            act->setData(RunFile);
            act = ccMenu->addAction(style()->standardIcon(QStyle::SP_DirOpenIcon), tr("Browse"));
            act->setProperty("PrefixHash", hash);
            ccMenu->addSeparator();
            QMenu *uMenu = ccMenu->addMenu(style()->standardIcon(QStyle::SP_DialogResetButton), tr("Utilities"));
            uMenu->setDisabled(busyOrRun);
            act = uMenu->addAction(QIcon(":/winecfg"), tr("Winecfg"));
            act->setProperty("PrefixHash", hash);
            act->setProperty("Exe", FS::toUnixPath(hash, "C:\\windows\\system32\\winecfg.exe"));
            act->setData(Run);
            act = uMenu->addAction(QIcon(":/regedit"), tr("Regedit"));
            act->setProperty("PrefixHash", hash);
            act->setProperty("Exe", FS::toUnixPath(hash, "C:\\windows\\regedit.exe"));
            act->setData(Run);
            act = ccMenu->addAction(style()->standardIcon(QStyle::SP_FileDialogDetailedView), tr("Edit"));
            act->setProperty("PrefixHash", hash);
            act->setData(Edit);
            act->setDisabled(busyOrRun);
            ccMenu->addSeparator();
            act = ccMenu->addAction(style()->standardIcon(QStyle::SP_TrashIcon), tr("Delete"));
            act->setProperty("PrefixName", name);
            act->setProperty("PrefixHash", hash);
            act->setData(Delete);
            act->setDisabled(busyOrRun);
            pMenu->addSeparator();
            act = pMenu->addAction(style()->standardIcon(QStyle::SP_DialogCancelButton), tr("Terminate"));
            act->setProperty("PrefixName", name);
            act->setProperty("PrefixHash", hash);
            act->setData(Terminate);
            act->setEnabled(run);
        }
    }
    addSeparator();
    act = addAction(style()->standardIcon(QStyle::SP_FileDialogDetailedView), tr("Settings"));
    act->setData(Settings);
    act->setEnabled(busyList.isEmpty() && runList.isEmpty());
    addSeparator();
    act = addAction(QIcon::fromTheme("winewizard"), tr("About"));
    act->setData(About);
    act = addAction(style()->standardIcon(QStyle::SP_DialogHelpButton), tr("Help"));
    act->setData(Help);
    if (!autoclose)
    {
        addSeparator();
        act = addAction(style()->standardIcon(QStyle::SP_DialogCloseButton), tr("Quit"));
        act->setData(Quit);
    }
}
Example #23
0
void lemon::enableUi()
{
  m_view->setEnabled(true);
  m_view->frame->setEnabled(true);
  m_view->frameLeft->setEnabled(true);
  QAction *action = actionCollection()->action("enterCode");
  action->setEnabled(true);
  action = actionCollection()->action("startOperation");
  action->setDisabled(true);
  action = actionCollection()->action("searchItem");
  action->setEnabled(true);
  action = actionCollection()->action("deleteSelectedItem");
  action->setEnabled(true);
  action = actionCollection()->action("finishTransaction");
  action->setEnabled(true);
  action = actionCollection()->action("cancelTransaction");
  action->setEnabled(true);
  action = actionCollection()->action("balance");
  action->setEnabled(true);
  action = actionCollection()->action("payFocus");
  action->setEnabled(true);
  action = actionCollection()->action("cancelTicket");
  action->setEnabled(true);
  action = actionCollection()->action("showProductsGrid");
  action->setEnabled(true);
  action = actionCollection()->action("cashIn");
  action->setEnabled(true);
  action = actionCollection()->action("cashOut");
  action->setEnabled(true);
  action = actionCollection()->action("cashAvailable");
  action->setEnabled(true);
  action = actionCollection()->action("reprintTicket");
  action->setEnabled(true);
  action = actionCollection()->action("showPriceChecker");
  action->setEnabled(true);
  action = actionCollection()->action("endOfDay");
  action->setEnabled(true);
  action = actionCollection()->action("specialOrder");
  action->setEnabled(true);
  action = actionCollection()->action("specialOrderComplete");
  action->setEnabled(true);
  action = actionCollection()->action("occasionalDiscount");
  action->setEnabled(true);

  action = actionCollection()->action("suspendSale");
  action->setEnabled(true);
  action = actionCollection()->action("resumeSale");
  action->setEnabled(true);

  action = actionCollection()->action("resumeReservation");
  action->setEnabled(true);

  action = actionCollection()->action("makeReservation");
  action->setEnabled(true);

  action = actionCollection()->action("showCredits");
  action->setEnabled(true);
  
  if (m_view->canStartSelling()) {
//     action = actionCollection()->action("suspendSale");
//     action->setEnabled(true);
  }
}
Example #24
0
// Note: the QDesktopViewWidget Class will become it's own widget
// so others can easly create there own desktopsor file managers with
// only a few lines of code
QDesktopViewWidget::QDesktopViewWidget(QWidget *parent) :
    QListWidget(parent)
{
    // This sets the QDesktopViewWidget(QListWidget) to transparent so that the
    // desktop wallpaper below it can be seen. Note: the color: white propertiy
    // needs to be moved to the desktop config file
    setStyleSheet("QListView {background-color: transparent; color: white;}");

    // Note: Need to check if config files exist, if it doesnt we need to
    // create it.

    // In the future the below QDesktopViewWidget settings will be wrapped
    // in this block of code so every aspect of how the desktop looks and feels
    // can be configured.

    // Note: Needs to be moved to a class function of it's own
    //desktopSettings = new QSettings("chipara", "desktop");
    //desktopSettings->beginGroup("desktop");
    //desktopSettings->endGroup();

    // Variouse settings for the QDesktopViewWidget(QListWidget) class
    setSelectionMode(QAbstractItemView::ExtendedSelection);
    setViewMode(QListView::IconMode);
    setSpacing(20);
    setFlow(QListView::TopToBottom);
    setMovement(QListView::Snap);
    setLayoutMode(QListView::Batched);
    setBatchSize(100);
    setMovement(QListView::Snap);
    setIconSize(QSize(48, 48));
    setUniformItemSizes(true);
    setWrapping(true);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setSortingEnabled(true);
    setLayoutDirection(Qt::LeftToRight);
    setSelectionRectVisible(true);
    setTextElideMode(Qt::ElideMiddle);
    setDragEnabled(true);
    setFrameStyle(0);
    setFrameShape(QFrame::NoFrame);
    setAutoScroll(true);
    setResizeMode(QListView::Adjust);

    // Right Click Desktop Menu
    menu = new QMenu(this);

    // Create submenu for Create Document
    QMenu *viewMenu = menu->addMenu(tr("&View"));
    QActionGroup *viewGroup = new QActionGroup(this);

    // Large Icons
    extraLargeIcons = new QAction(QIcon::fromTheme("folder"), "X-Large Icons", this);
    extraLargeIcons->setCheckable(true);
    viewGroup->addAction(extraLargeIcons);
    viewMenu->addAction(extraLargeIcons);
    connect(extraLargeIcons, SIGNAL(triggered()), this, SLOT(resizeIcons()));

    // Large Icons
    largeIcons = new QAction(QIcon::fromTheme("folder"), "Large Icons", this);
    largeIcons->setCheckable(true);
    viewGroup->addAction(largeIcons);
    viewMenu->addAction(largeIcons);
    connect(largeIcons, SIGNAL(triggered()), this, SLOT(resizeIcons()));

    // Medium Icons
    mediumIcons = new QAction(QIcon::fromTheme("folder"), "Medium Icons", this);
    mediumIcons->setCheckable(true);
    mediumIcons->setChecked(true);
    viewGroup->addAction(mediumIcons);
    viewMenu->addAction(mediumIcons);
    connect(mediumIcons, SIGNAL(triggered()), this, SLOT(resizeIcons()));

    // Medium Icons
    smallIcons = new QAction(QIcon::fromTheme("folder"), "Small Icons", this);
    smallIcons->setCheckable(true);
    viewGroup->addAction(smallIcons);
    viewMenu->addAction(smallIcons);
    connect(smallIcons, SIGNAL(triggered()), this, SLOT(resizeIcons()));

    // Add a separator to the menu
    viewMenu->addSeparator();

    QActionGroup *layoutGroup = new QActionGroup(this);
    // Medium Icons
    leftToRight = new QAction(QIcon::fromTheme("folder"), "Left To Right", this);
    leftToRight->setCheckable(true);
    layoutGroup->addAction(leftToRight);
    viewMenu->addAction(leftToRight);
    connect(leftToRight, SIGNAL(triggered()), this, SLOT(layoutDirection()));

    // Medium Icons
    rightToLeft = new QAction(QIcon::fromTheme("folder"), "Right To Left", this);
    rightToLeft->setCheckable(true);
    layoutGroup->addAction(rightToLeft);
    viewMenu->addAction(rightToLeft);
    connect(rightToLeft, SIGNAL(triggered()), this, SLOT(layoutDirection()));

    // Add a separator to the menu
    viewMenu->addSeparator();

    // Sort By Size
    showIcons = new QAction(QIcon::fromTheme("folder"), "Show Desktop Icons", this);
    showIcons->setCheckable(true);
    showIcons->setChecked(true);
    viewMenu->addAction(showIcons);
    connect(showIcons, SIGNAL(triggered()), this, SLOT(showDesktopIcons()));

    // Create submenu for Create Document
    QMenu *sortMenu = menu->addMenu(tr("&Sort By"));
    QActionGroup *sortGroup = new QActionGroup(this);

    // Sort By Name
    QAction *nameSort = new QAction(QIcon::fromTheme("folder"), "Name", this);
    nameSort->setCheckable(true);
    nameSort->setChecked(true);
    sortGroup->addAction(nameSort);
    sortMenu->addAction(nameSort);

    // Sort By Size
    QAction *sizeSort = new QAction(QIcon::fromTheme("folder"), "Size", this);
    sizeSort->setCheckable(true);
    sizeSort->setDisabled(true);
    sortGroup->addAction(sizeSort);
    sortMenu->addAction(sizeSort);

    // Sort By Size
    QAction *typeSort = new QAction(QIcon::fromTheme("folder"), "Item Type", this);
    typeSort->setCheckable(true);
    typeSort->setDisabled(true);
    sortGroup->addAction(typeSort);
    sortMenu->addAction(typeSort);

    // Sort By Size
    QAction *dateSort = new QAction(QIcon::fromTheme("folder"), "Date Modified", this);
    dateSort->setCheckable(true);
    dateSort->setDisabled(true);
    sortGroup->addAction(dateSort);
    sortMenu->addAction(dateSort);

    // Refresh
    QAction *refresh = new QAction(QIcon::fromTheme("folder"), "Refresh", this);
    menu->addAction(refresh);

    // Add a separator to the menu
    menu->addSeparator();

    // Paste
    QAction *paste = new QAction(QIcon::fromTheme("folder"), "Paste", this);
    paste->setEnabled(false);
    menu->addAction(paste);

    // Paste Shortcut
    QAction *pasteShortCut = new QAction(QIcon::fromTheme("folder"), "Paste Shortcut", this);
    pasteShortCut->setEnabled(false);
    menu->addAction(pasteShortCut);

    // Add a separator to the menu
    menu->addSeparator();

    // New Menu
    QMenu *create = menu->addMenu(tr("&New"));

    // Create Folder
    QAction *createFolder = new QAction(QIcon::fromTheme("folder"), tr("&Folder"), this);
    create->addAction(createFolder);
    createFolder->setIconVisibleInMenu(true);
    connect(createFolder, SIGNAL(triggered()), this, SLOT(createFolder()));

    // Create Launcher
    QAction *createLauncher = new QAction(QIcon::fromTheme("application-x-desktop"), tr("&Launcher"), this);
    create->addAction(createLauncher);
    createLauncher->setIconVisibleInMenu(true);
    connect(createLauncher, SIGNAL(triggered()), this, SLOT(createLauncher()));

    // Create Empty File
    QAction *createEmptyFile = new QAction(QIcon::fromTheme("text-plain"), tr("&Empty File"), this);
    create->addAction(createEmptyFile);
    createEmptyFile->setIconVisibleInMenu(true);
    connect(createEmptyFile, SIGNAL(triggered()), this, SLOT(createEmptyFile()));

    // Add a separator to the menu
    menu->addSeparator();

    // Paste
    QAction *desktopSettings = new QAction(QIcon::fromTheme("preferences-desktop"), "Desktop Settings", this);
    desktopSettings->setIconVisibleInMenu(true);
    menu->addAction(desktopSettings);
    connect(desktopSettings, SIGNAL(triggered()), this, SLOT(execDesktopSettings()));

    // Right Click Desktop Icon Menu
    iconMenu = new QIconMenu(this);

    //
    desktopDir = new QFileSystemWatcher;
    desktopDir->addPath(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation));

    //
    dSettings = new QSettings("chipara", "desktop");
    dSettings->beginGroup("window");

    if (dSettings->value("showIcons") == 1) {
        showIcons->setChecked(true);
    } else {
        showIcons->setChecked(false);
    }

    //
    if (dSettings->value("layoutDirection") == 1) {
        setLayoutDirection(Qt::LeftToRight);
        leftToRight->setChecked(true);
    } else {
        setLayoutDirection(Qt::RightToLeft);
        rightToLeft->setChecked(true);
    }

    //
    if (dSettings->value("iconSize") == 1) {
        this->setIconSize(QSize(128, 128));
        extraLargeIcons->setChecked(true);
    } else if (dSettings->value("iconSize") == 2) {
        this->setIconSize(QSize(64, 64));
        largeIcons->setChecked(true);
    } else if (dSettings->value("iconSize") == 3) {
        this->setIconSize(QSize(48, 48));
        mediumIcons->setChecked(true);
    } else if (dSettings->value("iconSize") == 4) {
        this->setIconSize(QSize(36, 36));
        smallIcons->setChecked(true);
    }


    populatedDesktop();

    dSettings->endGroup();

    // Desktop Icon Double Click EventexecDesktopSettings
    connect(this, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(iconClicked(QListWidgetItem*)));
    connect(desktopDir, SIGNAL(directoryChanged(QString)), this, SLOT(populatedDesktop()));
}
Example #25
0
void MainWindow::repopulateAccountsMenu()
{
	accountMenu->clear();

	std::shared_ptr<MojangAccountList> accounts = MMC->accounts();
	MojangAccountPtr active_account = accounts->activeAccount();

	QString active_username = "";
	if (active_account != nullptr)
	{
		active_username = accounts->activeAccount()->username();
	}

	if (accounts->count() <= 0)
	{
		QAction *action = new QAction(tr("No accounts added!"), this);
		action->setEnabled(false);
		accountMenu->addAction(action);

		accountMenu->addSeparator();
	}
	else
	{
		// TODO: Nicer way to iterate?
		for (int i = 0; i < accounts->count(); i++)
		{
			MojangAccountPtr account = accounts->at(i);

			// Styling hack
			QAction *section = new QAction(account->username(), this);
			section->setEnabled(false);
			accountMenu->addAction(section);

			for (auto profile : account->profiles())
			{
				QAction *action = new QAction(profile.name, this);
				action->setData(account->username());
				action->setCheckable(true);
				if (active_username == account->username())
				{
					action->setChecked(true);
				}

				action->setIcon(SkinUtils::getFaceFromCache(profile.name));
				accountMenu->addAction(action);
				connect(action, SIGNAL(triggered(bool)), SLOT(changeActiveAccount()));
			}

			accountMenu->addSeparator();
		}
	}

	QAction *action = new QAction(tr("No Default Account"), this);
	action->setCheckable(true);
	action->setIcon(QIcon::fromTheme("noaccount"));
	action->setData("");
	if (active_username.isEmpty())
	{
		action->setChecked(true);
	}

	accountMenu->addAction(action);
	connect(action, SIGNAL(triggered(bool)), SLOT(changeActiveAccount()));

	accountMenu->addSeparator();
	accountMenu->addAction(manageAccountsAction);
}
Example #26
0
void QgsDualView::viewWillShowContextMenu( QMenu *menu, const QModelIndex &atIndex )
{
  if ( !menu )
  {
    return;
  }

  QModelIndex sourceIndex = mFilterModel->mapToSource( atIndex );

  QAction *copyContentAction = new QAction( tr( "Copy Cell Content" ), this );
  copyContentAction->setData( QVariant::fromValue<QModelIndex>( sourceIndex ) );
  menu->addAction( copyContentAction );
  connect( copyContentAction, &QAction::triggered, this, &QgsDualView::copyCellContent );

  QgsVectorLayer *vl = mFilterModel->layer();
  QgsMapCanvas *canvas = mFilterModel->mapCanvas();
  if ( canvas && vl && vl->geometryType() != QgsWkbTypes::NullGeometry )
  {
    menu->addAction( tr( "Zoom to Feature" ), this, SLOT( zoomToCurrentFeature() ) );
    menu->addAction( tr( "Pan to Feature" ), this, SLOT( panToCurrentFeature() ) );
    menu->addAction( tr( "Flash Feature" ), this, SLOT( flashCurrentFeature() ) );
  }

  //add user-defined actions to context menu
  QList<QgsAction> actions = mLayer->actions()->actions( QStringLiteral( "Field" ) );
  if ( !actions.isEmpty() )
  {
    QAction *a = menu->addAction( tr( "Run Layer Action" ) );
    a->setEnabled( false );

    const auto constActions = actions;
    for ( const QgsAction &action : constActions )
    {
      if ( !action.runable() )
        continue;

      if ( vl && !vl->isEditable() && action.isEnabledOnlyWhenEditable() )
        continue;

      QgsAttributeTableAction *a = new QgsAttributeTableAction( action.name(), this, action.id(), sourceIndex );
      menu->addAction( action.name(), a, &QgsAttributeTableAction::execute );
    }
  }

  //add actions from QgsMapLayerActionRegistry to context menu
  QList<QgsMapLayerAction *> registeredActions = QgsGui::mapLayerActionRegistry()->mapLayerActions( mLayer );
  if ( !registeredActions.isEmpty() )
  {
    //add a separator between user defined and standard actions
    menu->addSeparator();

    const auto constRegisteredActions = registeredActions;
    for ( QgsMapLayerAction *action : constRegisteredActions )
    {
      QgsAttributeTableMapLayerAction *a = new QgsAttributeTableMapLayerAction( action->text(), this, action, sourceIndex );
      menu->addAction( action->text(), a, &QgsAttributeTableMapLayerAction::execute );
    }
  }

  menu->addSeparator();
  QgsAttributeTableAction *a = new QgsAttributeTableAction( tr( "Open Form" ), this, QString(), sourceIndex );
  menu->addAction( tr( "Open Form" ), a, &QgsAttributeTableAction::featureForm );
}
void FolderNavigationWidget::contextMenuEvent(QContextMenuEvent *ev)
{
    QMenu menu;
    // Open current item
    const QModelIndex current = currentItem();
    const bool hasCurrentItem = current.isValid();
    QAction *actionOpen = menu.addAction(actionOpenText(m_fileSystemModel, current));
    actionOpen->setEnabled(hasCurrentItem);

    // JULIA STUDIO -------
    QAction* actionJuliaRun = menu.addAction(tr("Run this file"));
    actionJuliaRun->setEnabled( hasCurrentItem && !m_fileSystemModel->isDir(current) );
    // -------

    // Explorer & teminal
    QAction *actionExplorer = menu.addAction(Core::FileUtils::msgGraphicalShellAction());
    actionExplorer->setEnabled(hasCurrentItem);
    QAction *actionTerminal = menu.addAction(Core::FileUtils::msgTerminalAction());
    actionTerminal->setEnabled(hasCurrentItem);

    QAction *actionFind = menu.addAction(msgFindOnFileSystem());
    actionFind->setEnabled(hasCurrentItem);
    // open with...
    if (!m_fileSystemModel->isDir(current)) {
        QMenu *openWith = menu.addMenu(tr("Open with"));
        Core::DocumentManager::populateOpenWithMenu(openWith,
                                                m_fileSystemModel->filePath(current));
    }

    // Open file dialog to choose a path starting from current
    QAction *actionChooseFolder = menu.addAction(tr("Choose Folder..."));

    QAction *action = menu.exec(ev->globalPos());
    if (!action)
        return;

    ev->accept();
    if (action == actionOpen) { // Handle open file.
        openItem(current);
        return;
    }
    if (action == actionChooseFolder) { // Open file dialog
        const QString newPath = QFileDialog::getExistingDirectory(this, tr("Choose Folder"), currentDirectory());
        if (!newPath.isEmpty())
            setCurrentDirectory(newPath);
        return;
    }
    if (action == actionTerminal) {
        Core::FileUtils::openTerminal(m_fileSystemModel->filePath(current));
        return;
    }
    if (action == actionExplorer) {
        Core::FileUtils::showInGraphicalShell(this, m_fileSystemModel->filePath(current));
        return;
    }
    if (action == actionFind) {
        QFileInfo info = m_fileSystemModel->fileInfo(current);
        if (m_fileSystemModel->isDir(current))
            findOnFileSystem(info.absoluteFilePath());
        else
            findOnFileSystem(info.absolutePath());
        return;
    }
    // JULIA STUDIO -------
    if (action == actionJuliaRun) {
      QFileInfo file_info = m_fileSystemModel->fileInfo(current);
      IEvaluator* evaluator = findEvaluatorFor( file_info.suffix() );

      evaluator->eval( &file_info );

      return;
    }
    // -------

    Core::DocumentManager::executeOpenWithMenuAction(action);
}
void RazorTaskButton::contextMenuEvent(QContextMenuEvent* event)
{
    if (event->modifiers().testFlag(Qt::ControlModifier))
    {
        event->ignore();
        return;
    }


    XfitMan xf = xfitMan();

    WindowAllowedActions allow = xf.getAllowedActions(mWindow);
    WindowState state = xf.getWindowState(mWindow);

//    qDebug() << "Context menu " << xfitMan().getName(mWindow);
//    qDebug() << "  Allowed Actions:";
//    qDebug() << "    * Move          " << allow.Move;
//    qDebug() << "    * Resize        " << allow.Resize;
//    qDebug() << "    * Minimize      " << allow.Minimize;
//    qDebug() << "    * Shade         " << allow.Shade;
//    qDebug() << "    * Stick         " << allow.Stick;
//    qDebug() << "    * MaximizeHoriz " << allow.MaximizeHoriz;
//    qDebug() << "    * MaximizeVert  " << allow.MaximizeVert;
//    qDebug() << "    * FullScreen    " << allow.FullScreen;
//    qDebug() << "    * ChangeDesktop " << allow.ChangeDesktop;
//    qDebug() << "    * Close         " << allow.Close;
//    qDebug() << "    * AboveLayer    " << allow.AboveLayer;
//    qDebug() << "    * BelowLayer    " << allow.BelowLayer;
//    qDebug();
//    qDebug() << "  Window State:";
//    qDebug() << "    * Modal         " << state.Modal;
//    qDebug() << "    * Sticky        " << state.Sticky;
//    qDebug() << "    * MaximizedVert " << state.MaximizedVert;
//    qDebug() << "    * MaximizedHoriz" << state.MaximizedHoriz;
//    qDebug() << "    * Shaded        " << state.Shaded;
//    qDebug() << "    * SkipTaskBar   " << state.SkipTaskBar;
//    qDebug() << "    * SkipPager     " << state.SkipPager;
//    qDebug() << "    * Hidden        " << state.Hidden;
//    qDebug() << "    * FullScreen    " << state.FullScreen;
//    qDebug() << "    * AboveLayer    " << state.AboveLayer;
//    qDebug() << "    * BelowLayer    " << state.BelowLayer;
//    qDebug() << "    * Attention     " << state.Attention;

    QMenu menu(tr("Application"));
    QAction* a;

    /* KDE menu *******

      + To &Desktop >
      +     &All Desktops
      +     ---
      +     &1 Desktop 1
      +     &2 Desktop 2
      + &To Current Desktop
        &Move
        Re&size
      + Mi&nimize
      + Ma&ximize
      + &Shade
        Ad&vanced >
            Keep &Above Others
            Keep &Below Others
            Fill screen
        &Layer >
            Always on &top
            &Normal
            Always on &bottom
      ---
      + &Close
    */

    // ** Desktop menu **************************
    int deskNum = xf.getNumDesktop();
    if (deskNum > 1)
    {
        int winDesk = xf.getWindowDesktop(mWindow);
        QMenu* deskMenu = menu.addMenu(tr("To &Desktop"));

        a = deskMenu->addAction(tr("&All Desktops"));
        a->setData(-1);
        a->setEnabled(winDesk != -1);
        connect(a, SIGNAL(triggered(bool)), this, SLOT(moveApplicationToDesktop()));
        deskMenu->addSeparator();

        for (int i=0; i<deskNum; ++i)
        {
            a = deskMenu->addAction(tr("Desktop &%1").arg(i+1));
            a->setData(i);
            a->setEnabled( i != winDesk );
            connect(a, SIGNAL(triggered(bool)), this, SLOT(moveApplicationToDesktop()));
        }

        int curDesk = xf.getActiveDesktop();
        a = menu.addAction(tr("&To Current Desktop"));
        a->setData(curDesk);
        a->setEnabled( curDesk != winDesk );
        connect(a, SIGNAL(triggered(bool)), this, SLOT(moveApplicationToDesktop()));
    }
Example #29
0
void crmaccount::sPopulate()
{
  q.prepare( "SELECT * "
             "FROM crmacct "
             "WHERE (crmacct_id=:crmacct_id);" );
  q.bindValue(":crmacct_id", _crmacctId);
  q.exec();
  if (q.first())
  {
    _number->setText(q.value("crmacct_number").toString());
    _name->setText(q.value("crmacct_name").toString());
    _active->setChecked(q.value("crmacct_active").toBool());

    QString acctType = q.value("crmacct_type").toString();
    if (acctType == "O")
      _organization->setChecked(true);
    else if (acctType == "I")
      _individual->setChecked(true);
    else
      qWarning("crmaccount::sPopulate() - acctType '%s' incorrect", acctType.toLatin1().data());

    _custId	= q.value("crmacct_cust_id").toInt();
    _competitorId = q.value("crmacct_competitor_id").toInt();
    _partnerId	= q.value("crmacct_partner_id").toInt();
    _prospectId	= q.value("crmacct_prospect_id").toInt();
    _vendId	= q.value("crmacct_vend_id").toInt();
    _taxauthId	= q.value("crmacct_taxauth_id").toInt();
    _primary->setId(q.value("crmacct_cntct_id_1").toInt());
    _secondary->setId(q.value("crmacct_cntct_id_2").toInt());
    _notes->setText(q.value("crmacct_notes").toString());
    _parentCrmacct->setId(q.value("crmacct_parent_id").toInt());
    _comments->setId(_crmacctId);
    _documents->setId(_crmacctId);
    _primary->setSearchAcct(_crmacctId);
    _secondary->setSearchAcct(_crmacctId);
    _owner->setUsername(q.value("crmacct_owner_username").toString());

    _customer->setDisabled(_customer->isChecked());
    _prospect->setChecked(_prospectId > 0);
    _prospect->setDisabled(_customer->isChecked());
    _taxauth->setChecked(_taxauthId > 0);
    
    if (_custId > 0)
    {
      _customer->setChecked(true);
      if (_privileges->check("MaintainCustomerMasters") || 
          _privileges->check("ViewCustomerMasters") )
        _customerButton->setEnabled(true);
    }
    if (_vendId > 0)
    {
      _vendor->setChecked(true);
      _vendorButton->setText("Vendor");
      disconnect(_vendorButton, SIGNAL(clicked()), this, SLOT(sEditVendor()));
      
      QMenu * vendorMenu = new QMenu;
      QAction *menuItem;
      menuItem=vendorMenu->addAction(tr("Edit..."), this, SLOT(sEditVendor()));
      menuItem->setEnabled(_privileges->check("MaintainVendors") &&
                           (_mode == cEdit));
      menuItem=vendorMenu->addAction(tr("View..."), this, SLOT(sViewVendor()));
      menuItem->setEnabled(_privileges->check("ViewVendors") ||
                           _privileges->check("MaintainVendors"));
      menuItem=vendorMenu->addAction(tr("Workbench..."), this, SLOT(sVendorInfo()));
      menuItem->setEnabled(_privileges->check("MaintainVendors"));
      _vendorButton->setMenu(vendorMenu);  
      
    }
    _partner->setChecked(_partnerId > 0);
    _competitor->setChecked(_competitorId > 0);
  }
  else if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }

  sGetCharacteristics();
  sPopulateRegistrations();
  _contacts->sFillList();
  _todoList->sFillList();
  _oplist->sFillList();
}
  void MultiGradientSelector::contextMenuEvent(QContextMenuEvent * e)
  {
    QMenu main_menu(this);
    //Default gradient
    QMenu * defaults = main_menu.addMenu("Default gradients");
    defaults->addAction("grey - yellow - red - purple - blue - black");
    defaults->addAction("grey - black");
    defaults->addAction("yellow - red - purple - blue - black");
    defaults->addAction("orange - red - purple - blue - black");
    defaults->addAction("yellow - orange - red");
    defaults->addSeparator();
    defaults->addAction("black");
    defaults->addAction("white");
    defaults->addAction("red");
    defaults->addAction("green");
    defaults->addAction("blue");
    defaults->addAction("magenta");
    defaults->addAction("turquoise");
    defaults->addAction("yellow");

    //Interploate/Stairs
    QMenu * inter = main_menu.addMenu("Interpolation");
    QAction * current = inter->addAction("None");
    if (gradient_.getInterpolationMode() == MultiGradient::IM_STAIRS)
      current->setEnabled(false);
    current = inter->addAction("Linear");
    if (gradient_.getInterpolationMode() == MultiGradient::IM_LINEAR)
      current->setEnabled(false);

    //Execute
    QAction * result;
    if ((result = main_menu.exec(e->globalPos())))
    {
      if (result->text() == "grey - yellow - red - purple - blue - black")
      {
        gradient_ = MultiGradient::getDefaultGradientLinearIntensityMode();
      }
      if (result->text() == "grey - black")
      {
        gradient_ = MultiGradient::getDefaultGradientLogarithmicIntensityMode();
      }
      else if (result->text() == "yellow - red - purple - blue - black")
      {
        gradient_.fromString("Linear|0,#ffea00;6,#ff0000;14,#aa00ff;23,#5500ff;100,#000000");
      }
      else if (result->text() == "orange - red - purple - blue - black")
      {
        gradient_.fromString("Linear|0,#ffaa00;6,#ff0000;14,#aa00ff;23,#5500ff;100,#000000");
      }
      else if (result->text() == "yellow - orange - red")
      {
        gradient_.fromString("Linear|0,#ffea00;6,#ffaa00;100,#ff0000");
      }
      else if (result->text() == "black")
      {
        gradient_.fromString("Linear|0,#000000;100,#000000");
      }
      else if (result->text() == "white")
      {
        gradient_.fromString("Linear|0,#FFFFFF;100,#FFFFFF");
      }
      else if (result->text() == "red")
      {
        gradient_.fromString("Linear|0,#ff0000;100,#ff0000");
      }
      else if (result->text() == "green")
      {
        gradient_.fromString("Linear|0,#00ff00;100,#00ff00");
      }
      else if (result->text() == "blue")
      {
        gradient_.fromString("Linear|0,#0000ff;100,#0000ff");
      }
      else if (result->text() == "magenta")
      {
        gradient_.fromString("Linear|0,#ff00ff;100,#ff00ff");
      }
      else if (result->text() == "turquoise")
      {
        gradient_.fromString("Linear|0,#00ffff;100,#00ffff");
      }
      else if (result->text() == "yellow")
      {
        gradient_.fromString("Linear|0,#ffff00;100,#ffff00");
      }
      else if (result->text() == "None")
      {
        setInterpolationMode(MultiGradient::IM_STAIRS);
      }
      else if (result->text() == "Linear")
      {
        setInterpolationMode(MultiGradient::IM_LINEAR);
      }
    }
  }