예제 #1
0
QMenu* WidgetBase::addCopyCompatibleMenu (
    QMenu* menu, const char* nameOp, 
    const boost::shared_ptr<QAction>* actionCopyOp, 
    IsCopyCompatibleType isCopyCompatible) const
{
    size_t viewCount = GetSettings ().GetViewCount ();
    bool actions = false;
    QMenu* menuOp = menu->addMenu (nameOp);
    if (viewCount > 1)
    {
        ViewNumber::Enum currentViewNumber = GetViewNumber ();
	for (size_t i = 0; i < viewCount; ++i)
	{
	    ViewNumber::Enum otherViewNumber = ViewNumber::Enum (i);
	    if (CALL_MEMBER (*this, isCopyCompatible) (
                    currentViewNumber, otherViewNumber))
            {
                menuOp->addAction (actionCopyOp[i].get ());
                actions = true;
            }
	}
    }
    if (! actions)
	menuOp->setDisabled (true);
    return menuOp;
}
예제 #2
0
void WidgetBase::addCopyMenu (
    QMenu* menu, const char* nameOp, 
    const boost::shared_ptr<QAction>* actionCopyOp) const
{
    
    QMenu* menuOp = menu->addMenu (nameOp);
    if (GetViewCount () > 1)
    {
	for (size_t i = 0; i < GetViewCount (); ++i)
	{
	    ViewNumber::Enum viewNumber = ViewNumber::Enum (i);
	    if (viewNumber == GetViewNumber ())
		continue;
	    menuOp->addAction (actionCopyOp[i].get ());
	}
    }
    if (GetViewCount () == 1)
        menuOp->setDisabled (true);
}
예제 #3
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);
    }
}
예제 #4
0
void TupPaintArea::mousePressEvent(QMouseEvent *event)
{
    #ifdef K_DEBUG
           T_FUNCINFO;
    #endif

    // SQA: Temporal solution for cases when there's no current frame defined
    if (!graphicsScene()->currentFrame()) {
        return;
    }

    if (graphicsScene()->currentFrame()->isLocked()) {
        #ifdef K_DEBUG
               tFatal() << "TupPaintArea::mousePressEvent() - Frame is locked!";
        #endif
        return;
    }

    if (k->currentTool.compare(tr("Line Selection")) == 0) {
        // If a node is the target... abort!
        if (event->buttons() == Qt::RightButton) {
            if (qgraphicsitem_cast<TControlNode *>(scene()->itemAt(mapToScene(event->pos()))))
                return;
        }
    }

    if (k->currentTool.compare(tr("Object Selection")) == 0) {

        if (event->buttons() == Qt::RightButton) {

            // If a node is the target... abort!
            if (qgraphicsitem_cast<Node *>(scene()->itemAt(mapToScene(event->pos()))))
                return;

            if (QGraphicsItem *item = scene()->itemAt(mapToScene(event->pos()))) {
                if (item->opacity() == 1) {
                    item->setFlag(QGraphicsItem::ItemIsSelectable, true);
                    item->setSelected(true);
                } else {
                    return;
                }
            }

            QMenu *menu = new QMenu(tr("Drawing area"));
            menu->addAction(kApp->findGlobalAction("undo"));
            menu->addAction(kApp->findGlobalAction("redo"));
            menu->addSeparator();

            QAction *cut = menu->addAction(tr("Cut"), this, SLOT(cutItems()), QKeySequence(tr("Ctrl+X")));
            QAction *copy = menu->addAction(tr("Copy"), this, SLOT(copyItems()), QKeySequence(tr("Ctrl+C")));
            QAction *paste = menu->addAction(tr("Paste"), this, SLOT(pasteItems()), QKeySequence(tr("Ctrl+V")));
            QAction *del = menu->addAction(tr("Delete"), this, SLOT(deleteItems()), QKeySequence(Qt::Key_Delete));

            menu->addSeparator();
            QMenu *order = new QMenu(tr("Order"));

            connect(order, SIGNAL(triggered(QAction*)), this, SLOT(requestMoveSelectedItems(QAction*)));
            order->addAction(tr("Send to back"))->setData(MoveBack);
            order->addAction(tr("Bring to front"))->setData(MoveFront);
            order->addAction(tr("Send backwards"))->setData(MoveBackwards);
            order->addAction(tr("Brind forwards"))->setData(MoveForwards);

            menu->addMenu(order);
            order->setDisabled(true);
            menu->addSeparator();

            // Code commented temporary while SQA is done
            QAction *addItem = menu->addAction(tr("Add to library..."), this, SLOT(addSelectedItemsToLibrary()));
            menu->addSeparator();

            if (scene()->selectedItems().isEmpty()) {
                del->setEnabled(false);
                cut->setEnabled(false);
                copy->setEnabled(false);
                addItem->setEnabled(false);
            } else {
                QList<QGraphicsItem *> selected = scene()->selectedItems();
                foreach (QGraphicsItem *item, selected) {
                         QDomDocument dom;
                         dom.appendChild(dynamic_cast<TupAbstractSerializable *>(item)->toXml(dom));
		         QDomElement root = dom.documentElement();

                         if (root.tagName() == "symbol") {
                             QString key = root.attribute("id").toUpper();
                             if (key.endsWith("JPG") || key.endsWith("PNG") || key.endsWith("GIF") || key.endsWith("XPM")) {
                                 addItem->setEnabled(false);
                                 break;
                             }
                         } else if (root.tagName() == "svg") {
                                    addItem->setEnabled(false);
                                    break;
                         }
                }
            }

            if (k->copiesXml.isEmpty())
                paste->setEnabled(false);

            if (QMenu *toolMenu = graphicsScene()->currentTool()->menu()) {
                menu->addSeparator();
                menu->addMenu(toolMenu);
            }

            k->position = viewPosition();
            k->menuOn = true;
            menu->exec(event->globalPos());
        }
    }