Example #1
0
static void saveShortcuts(QTextStream &fout)
{
	QPtrList<QAction> *actions;
	QAction *action;
	
	fout << "# all shortcuts \n";
	
	actions = Shortcuts::actions();
	for( action = actions->first(); action; action = actions->next() )
		if(strlen(action->name()))
			fout << "map(\"" << action->name() << "\", \"" << (QString)action->accel() << "\")\n";
}
Example #2
0
void QDesignerToolBar::buttonContextMenuEvent( QContextMenuEvent *e, QObject *o )
{
    e->accept();
    QPopupMenu menu( 0 );
    const int ID_DELETE = 1;
    const int ID_SEP = 2;
    const int ID_DELTOOLBAR = 3;
    QMap<QWidget*, QAction*>::Iterator it = actionMap.find( (QWidget*)o );
    if ( it != actionMap.end() && ::qt_cast<QSeparatorAction*>(*it) )
	menu.insertItem( tr( "Delete Separator" ), ID_DELETE );
    else
	menu.insertItem( tr( "Delete Item" ), ID_DELETE );
    menu.insertItem( tr( "Insert Separator" ), ID_SEP );
    menu.insertSeparator();
    menu.insertItem( tr( "Delete Toolbar" ), ID_DELTOOLBAR );
    int res = menu.exec( e->globalPos() );
    if ( res == ID_DELETE ) {
	QMap<QWidget*, QAction*>::Iterator it = actionMap.find( (QWidget*)o );
	if ( it == actionMap.end() )
	    return;
	QAction *a = *it;
	int index = actionList.find( a );
	RemoveActionFromToolBarCommand *cmd = new RemoveActionFromToolBarCommand(
	    tr( "Delete Action '%1' from Toolbar '%2'" ).
	    arg( a->name() ).arg( caption() ),
	    formWindow, a, this, index );
	formWindow->commandHistory()->addCommand( cmd );
	cmd->execute();
    } else if ( res == ID_SEP ) {
	calcIndicatorPos( mapFromGlobal( e->globalPos() ) );
	QAction *a = new QSeparatorAction( 0 );
	int index = actionList.findRef( *actionMap.find( insertAnchor ) );
	if ( index != -1 && afterAnchor )
	    ++index;
	if ( !insertAnchor )
	    index = 0;

	AddActionToToolBarCommand *cmd = new AddActionToToolBarCommand(
	    tr( "Add Separator to Toolbar '%1'" ).
	    arg( a->name() ),
	    formWindow, a, this, index );
	formWindow->commandHistory()->addCommand( cmd );
	cmd->execute();
    } else if ( res == ID_DELTOOLBAR ) {
	RemoveToolBarCommand *cmd = new RemoveToolBarCommand( tr( "Delete Toolbar '%1'" ).arg( name() ),
							      formWindow, 0, this );
	formWindow->commandHistory()->addCommand( cmd );
	cmd->execute();
    }
}
Example #3
0
void QDesignerToolBar::dropEvent( QDropEvent *e )
{
    if ( e->provides( "application/x-designer-actions" ) ||
	 e->provides( "application/x-designer-actiongroup" ) ||
	 e->provides( "application/x-designer-separator" ) )
	e->accept();
    else
	return;
    QString s;
    if ( e->provides( "application/x-designer-actiongroup" ) )
	s = QString( e->encodedData( "application/x-designer-actiongroup" ) );
    else if ( e->provides( "application/x-designer-separator" ) )
	s = QString( e->encodedData( "application/x-designer-separator" ) );
    else
	s = QString( e->encodedData( "application/x-designer-actions" ) );

    indicator->hide();
    QAction *a = 0;
    int index = actionList.findRef( *actionMap.find( insertAnchor ) );
    if ( index != -1 && afterAnchor )
	++index;
    if ( !insertAnchor )
	index = 0;
    if ( e->provides( "application/x-designer-actions" ) ||
	 e->provides( "application/x-designer-separator" ) ) {
	if ( e->provides( "application/x-designer-actions" ) )
	    a = (QDesignerAction*)s.toLong();
	else
	    a = (QSeparatorAction*)s.toLong();
    } else {
	a = (QDesignerActionGroup*)s.toLong();
    }

    if ( actionList.findRef( a ) != -1 ) {
	QMessageBox::warning( MainWindow::self, tr( "Insert/Move Action" ),
			      tr( "Action '%1' has already been added to this toolbar.\n"
				  "An Action may only occur once in a given toolbar." ).
			      arg( a->name() ) );
	return;
    }

    AddActionToToolBarCommand *cmd = new AddActionToToolBarCommand( tr( "Add Action '%1' to Toolbar '%2'" ).
								    arg( a->name() ).arg( caption() ),
								    formWindow, a, this, index );
    formWindow->commandHistory()->addCommand( cmd );
    cmd->execute();

    lastIndicatorPos = QPoint( -1, -1 );
}
void FLAccessControlMainWindow::processObject(QObject *obj)
{
  QMainWindow *mw = ::qt_cast<QMainWindow *>(obj);
  if (!mw || !acosPerms_)
    return;

  if (!perm_.isEmpty()) {
    QObjectList *l = mw->queryList("QAction");
    QObjectListIt ito(*l);
    QAction *a;
    while ((a = ::qt_cast<QAction *>(ito.current())) != 0) {
      ++ito;
      if ((*acosPerms_)[a->name()])
        continue;
      if (perm_ == "-w" || perm_ == "--")
        a->setVisible(false);
    }
    delete l;
  }

  QDictIterator < QString > it(*acosPerms_);
  for (; it.current(); ++it) {
    QAction *a = ::qt_cast<QAction *>(mw->child(it.currentKey(), "QAction"));
    if (a) {
      QString perm = *(*it);
      if (perm == "-w" || perm == "--")
        a->setVisible(false);
    }
  }
}
void ActionEditor::setFormWindow( FormWindow *fw )
{
    listActions->clear();
    formWindow = fw;
    if ( !formWindow ||
	 !::qt_cast<QMainWindow*>(formWindow->mainContainer()) ) {
	setEnabled( FALSE );
    } else {
	setEnabled( TRUE );
	for ( QAction *a = formWindow->actionList().first(); a; a = formWindow->actionList().next() ) {
	    ActionItem *i = 0;
	    if ( ::qt_cast<QAction*>(a->parent()) )
		continue;
	    i = new ActionItem( listActions, a );
	    i->setText( 0, a->name() );
	    i->setPixmap( 0, a->iconSet().pixmap() );
	    // make sure we don't duplicate the connection
 	    QObject::disconnect( a, SIGNAL( destroyed( QObject * ) ),
 				 this, SLOT( removeConnections( QObject * ) ) );
	    QObject::connect( a, SIGNAL( destroyed( QObject * ) ),
			      this, SLOT( removeConnections( QObject* ) ) );
	    if ( ::qt_cast<QActionGroup*>(a) ) {
		insertChildActions( i );
	    }
	}
	if ( listActions->firstChild() ) {
	    listActions->setCurrentItem( listActions->firstChild() );
	    listActions->setSelected( listActions->firstChild(), TRUE );
	}
    }
}
Example #6
0
void QDesignerToolBar::buttonMouseMoveEvent( QMouseEvent *e, QObject *o )
{
    if ( widgetInserting || ( e->state() & LeftButton ) == 0 )
	return;
    if ( QABS( QPoint( dragStartPos - e->pos() ).manhattanLength() ) < QApplication::startDragDistance() )
	return;
    QMap<QWidget*, QAction*>::Iterator it = actionMap.find( (QWidget*)o );
    if ( it == actionMap.end() )
	return;
    QAction *a = *it;
    if ( !a )
	return;
    int index = actionList.find( a );
    RemoveActionFromToolBarCommand *cmd =
	new RemoveActionFromToolBarCommand( tr( "Delete Action '%1' from Toolbar '%2'" ).
					    arg( a->name() ).arg( caption() ),
					    formWindow, a, this, index );
    formWindow->commandHistory()->addCommand( cmd );
    cmd->execute();
    QApplication::sendPostedEvents();
    adjustSize();

    QString type = ::qt_cast<QActionGroup*>(a) ? QString( "application/x-designer-actiongroup" ) :
	::qt_cast<QSeparatorAction*>(a) ? QString( "application/x-designer-separator" ) : QString( "application/x-designer-actions" );
    QStoredDrag *drag = new QStoredDrag( type, this );
    QString s = QString::number( (long)a ); // #### huha, that is evil
    drag->setEncodedData( QCString( s.latin1() ) );
    drag->setPixmap( a->iconSet().pixmap() );
    if ( ::qt_cast<QDesignerAction*>(a) ) {
	if ( formWindow->widgets()->find( ( (QDesignerAction*)a )->widget() ) )
	    formWindow->selectWidget( ( (QDesignerAction*)a )->widget(), FALSE );
    }
    if ( !drag->drag() ) {
	AddActionToToolBarCommand *cmd = new AddActionToToolBarCommand( tr( "Add Action '%1' to Toolbar '%2'" ).
									arg( a->name() ).arg( caption() ),
									formWindow, a, this, index );
	formWindow->commandHistory()->addCommand( cmd );
	cmd->execute();
    }
    lastIndicatorPos = QPoint( -1, -1 );
    indicator->hide();
}
Example #7
0
void MainWindow::showDayView() {
    QObjectListIt itact( *(m_viewsGroup->children()) );
    QAction *a;
    while ( (a=(QAction *)itact.current()) ) {
        ++itact;
        if ( a->name() == QString("DayView") /* no tr */ ) {
            a->setOn(true);
            slotChangeView();
            break;
        }
    }
}
Example #8
0
void QDesignerToolBar::removeWidget( QWidget *w )
{
    QMap<QWidget*, QAction*>::Iterator it = actionMap.find( w );
    if ( it == actionMap.end() )
	return;
    QAction *a = *it;
    int index = actionList.find( a );
    RemoveActionFromToolBarCommand *cmd =
	new RemoveActionFromToolBarCommand( tr( "Delete Action '%1' from Toolbar '%2'" ).
					    arg( a->name() ).arg( caption() ),
					    formWindow, a, this, index );
    formWindow->commandHistory()->addCommand( cmd );
    cmd->execute();
    QApplication::sendPostedEvents();
    adjustSize();
}
Example #9
0
/** maps an action to a shortcut */
PyObject *map(PyObject *, PyObject *args)
{
	char *action, *shortcut;
	QPtrList<QAction> *actions = Shortcuts::actions();
	QAction *a;

	if(!PyArg_ParseTuple(args, "ss", &action, &shortcut)){
		PyErr_SetString(PyExc_TypeError, "two strings required");
		return NULL;
	}
	for(a = actions->first(); a; a = actions->next())
		if(a->name() == QString(action)){
			a->setAccel(QKeySequence(shortcut));
			break;
		}
	if(!a)
		qWarning("no command %s found", action);
	
	Py_INCREF(Py_None);
	return Py_None;
}
void ActionEditor::insertChildActions( ActionItem *i )
{
    if ( !i->actionGroup() || !i->actionGroup()->children() )
	return;
    QObjectListIt it( *i->actionGroup()->children() );
    while ( it.current() ) {
	QObject *o = it.current();
	++it;
	if ( !::qt_cast<QAction*>(o) )
	    continue;
	QAction *a = (QAction*)o;
	ActionItem *i2 = new ActionItem( (QListViewItem*)i, a );
	i->setOpen( TRUE );
	i2->setText( 0, a->name() );
	i2->setPixmap( 0, a->iconSet().pixmap() );
	// make sure we don't duplicate the connection
 	QObject::disconnect( o, SIGNAL( destroyed( QObject * ) ),
 			     this, SLOT( removeConnections( QObject * ) ) );
 	QObject::connect( o, SIGNAL( destroyed( QObject * ) ),
 			  this, SLOT( removeConnections( QObject * ) ) );
	if ( ::qt_cast<QActionGroup*>(a) )
	    insertChildActions( i2 );
    }
}