Ejemplo n.º 1
0
QMenu* KoSelectShapeAction::createShapeMenu()
{
    // get all available shapes from the registry and fill the menu
    QMenu* menu = new QMenu();
    foreach( const QString & shapeId, KoShapeRegistry::instance()->keys() ) {
        KoShapeFactory* factory = KoShapeRegistry::instance()->value( shapeId );

        // if there are templates create a submenu
        if( !factory->templates().isEmpty() ) {
            QMenu* tmp = menu->addMenu( KIcon( factory->icon() ), factory->name() );
            tmp->setToolTip( factory->toolTip() );
            foreach( const KoShapeTemplate & shapeTemplate, factory->templates() ) {
                QAction* action = tmp->addAction( shapeTemplate.name );
                action->setIcon( KIcon( shapeTemplate.icon ) );
                action->setToolTip( shapeTemplate.toolTip );
                action->setData( shapeTemplate.id );
            }
        }
Ejemplo n.º 2
0
QMenu *BtMenuView::newMenu(QMenu *parentMenu, const QModelIndex &itemIndex) {
    QVariant displayData(m_model->data(itemIndex, Qt::DisplayRole));
    QVariant iconData(m_model->data(itemIndex, Qt::DecorationRole));
    QVariant toolTipData(m_model->data(itemIndex, Qt::ToolTipRole));
    QVariant statusTipData(m_model->data(itemIndex, Qt::StatusTipRole));
    QVariant whatsThisData(m_model->data(itemIndex, Qt::WhatsThisRole));

    QMenu *childMenu = new QMenu(parentMenu);

    // Set text:
    if (displayData.canConvert(QVariant::String)) {
        childMenu->setTitle(displayData.toString());
    }

    // Set icon:
    if (iconData.canConvert(QVariant::Icon)) {
        childMenu->setIcon(iconData.value<QIcon>());
    }

    // Set tooltip:
    if (toolTipData.canConvert(QVariant::String)) {
        childMenu->setToolTip(toolTipData.toString());
    }

    // Set status tip:
    if (statusTipData.canConvert(QVariant::String)) {
        childMenu->setStatusTip(statusTipData.toString());
    }

    // Set whatsthis:
    if (whatsThisData.canConvert(QVariant::String)) {
        childMenu->setWhatsThis(whatsThisData.toString());
    }

    return childMenu;
}
Ejemplo n.º 3
0
void ViewToolTipAndUrlManager::fillContextMenu(QMenu *menu) {
  Graph *graph = _view->graph();

  QAction *action = menu->addAction("Tooltips");
  action->setToolTip(QString("When moving the mouse pointer, a tooltip is displayed with some "
                             "information about the graph element located under the pointer"));
  action->setCheckable(true);
  action->setChecked(_tooltips);
  connect(action, SIGNAL(triggered(bool)), this, SLOT(displayToolTips(bool)));

  // add submenu to manage the url property choice
  QMenu *urlPropMenu;
  if (graph->existProperty(_urlPropName))
    urlPropMenu = menu->addMenu(
        QString("Url property").append(" (").append(tlpStringToQString(_urlPropName)).append(")"));
  else {
    urlPropMenu = menu->addMenu("Url property");
    _urlPropName.clear();
  }
  urlPropMenu->setToolTip(
      QString("Choose the property giving the web page associated with a graph element"));

  QActionGroup *urlPropGroup = new QActionGroup(urlPropMenu);
  urlPropGroup->setExclusive(true);
  connect(urlPropMenu, SIGNAL(triggered(QAction *)), this, SLOT(setUrlProp(QAction *)));
  action = urlPropMenu->addAction(" None ");
  action->setCheckable(true);
  urlPropGroup->addAction(action);
  if (_urlPropName.empty())
    action->setChecked(true);
  action->setToolTip(QString("The graph elements have no associated web page"));
  // get all existing StringProperty
  std::set<std::string> props;
  for (auto inheritedProp : graph->getInheritedObjectProperties()) {
    StringProperty *prop = dynamic_cast<StringProperty *>(inheritedProp);

    if (prop != nullptr)
      props.insert(prop->getName());
  }

  for (auto localProp : graph->getLocalObjectProperties()) {
    StringProperty *prop = dynamic_cast<StringProperty *>(localProp);
    if (prop != nullptr)
      props.insert(prop->getName());
  }

  // insert the StringProperty found
  for (auto propName : props) {
    // among the view... properties only viewLabel is allowed
    if (propName.find("view") != 0 || propName == "viewLabel") {
      action = urlPropMenu->addAction(tlpStringToQString(propName));
      action->setToolTip(
          QString("The url of the web page associated with a graph element is given by the \"")
              .append(tlpStringToQString(propName))
              .append(QString("\" property value")));
      urlPropGroup->addAction(action);
      action->setCheckable(true);
      if (_urlPropName == propName)
        action->setChecked(true);
    }
  }
}
void cListWidget::navigate_to_clicked_folder(QListWidgetItem *current)
{
    //creash protection
    //the clear() triggers a currentitemChanged and we receive
    //a bad null pointer
    if ( this->workLock == true )
        return;

    this->workLock = true;
    //if this is a FILE -> wanna copy?
    if ( this->count() > 0 &&
         this->children().count() > 0 )
    {
        //fi is the COPY-SOURCE
        QFileInfo fi( current->toolTip() );
        if ( fi.isFile() )
        {
            //we're a file -> wanna copy? & return
            QMenu* m = new QMenu();
            m->addAction( QIcon( ":/resources/img/" ), tr( "copy to /maps" ) );
            m->setToolTip( this->projectFolder + "/maps/" );
            QDir d( this->projectFolder + "/res/" );
            QStringList dirs = d.entryList( QDir::NoFilter, QDir::Name );
            for ( int i = 0; i < dirs.count(); i++ )
            {
                if ( dirs.at(i) != "." && dirs.at(i) != ".." )
                {
                    m->addAction( QIcon( ":/resources/img/" ), tr( "copy to /res/" ) + dirs.at(i) );
                    m->actions().last()->setToolTip( this->projectFolder + "/res/" + dirs.at(i) );
                }
            }

            QAction* a = m->exec( this->last_mouse_position );
            if ( a != 0 )
            {
                //check if the target file already exists in the pro folder
                //DESTINATION-FILE:
                QFile f( a->toolTip() + "/" + fi.fileName() );

                //if-> ask for renameing or exit
                if ( f.exists() )
                {
                    QMessageBox msgBox;
                    msgBox.setWindowTitle( tr( "File already exists" ) );
                    msgBox.setText( tr( "The file " ) + fi.fileName() + tr( " does already exist at the path\n" )
                                               + a->toolTip() + "/" + fi.fileName()
                                               + tr( "\nDo you want to replace it?" ) );
                    msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
                    msgBox.setDefaultButton(QMessageBox::No);
                    msgBox.setIcon(QMessageBox::Warning);
                    if ( msgBox.exec() == QMessageBox::Yes )
                    {
                        f.copy( fi.absoluteFilePath(), a->toolTip() + "/" + fi.fileName() );
                        emit this->copy_done( tr( "Successfully copied file " ) + fi.absoluteFilePath()
                                              + tr( " to " )
                                              + a->toolTip() + "/" + fi.fileName() );
                    }
                }
                else
                {
                    //straight copy
                    f.copy( fi.absoluteFilePath(), a->toolTip() + "/" + fi.fileName() );
                    emit this->copy_done( tr( "Successfully copied file " ) + fi.absoluteFilePath()
                                          + tr( " to " )
                                          + a->toolTip() + "/" + fi.fileName() );
                }
            }
            this->clearSelection();
            this->workLock = false;
            return;
        }
    }

    //else this is a folder an we navigate

    //applying new values
    if ( this->count() > 0 &&
         this->children().count() > 0 )
    {
        QDir dpath;
        dpath.cd( current->toolTip() );
        this->absolute_path = dpath.absolutePath() ;
        dpath.cd("/");
    }

    //rebuilding the gui


    //adding new widgets
    //adding folders

    this->navigate_to_our_folder();

    //removing lock
    this->clearSelection();
    this->workLock = false;
}