Exemplo n.º 1
0
EditACLEntryDialog::EditACLEntryDialog( KACLListView *listView, KACLListViewItem *item,
                                        const QStringList &users,
                                        const QStringList &groups,
                                        const QStringList &defaultUsers,
                                        const QStringList &defaultGroups,
                                        int allowedTypes, int allowedDefaultTypes,
                                        bool allowDefaults )
    : KDialog( listView ),
      m_listView( listView ), m_item( item ), m_users( users ), m_groups( groups ),
      m_defaultUsers( defaultUsers ), m_defaultGroups( defaultGroups ),
      m_allowedTypes( allowedTypes ), m_allowedDefaultTypes( allowedDefaultTypes ),
      m_defaultCB( 0 )
{
    setObjectName( "edit_entry_dialog" );
    setModal( true );
    setCaption( i18n( "Edit ACL Entry" ) );
    setButtons( KDialog::Ok | KDialog::Cancel );
    setDefaultButton( KDialog::Ok );

    QWidget *page = new QWidget(  this );
    setMainWidget( page );
    QVBoxLayout *mainLayout = new QVBoxLayout( page );
    mainLayout->setMargin( 0 );
    QGroupBox *gb = new QGroupBox( i18n("Entry Type"), page );
    QVBoxLayout *gbLayout = new QVBoxLayout( gb );

    m_buttonGroup = new QButtonGroup( page );

    if ( allowDefaults ) {
        m_defaultCB = new QCheckBox( i18n("Default for new files in this folder"), page );
        m_defaultCB->setObjectName( QLatin1String( "defaultCB" ) );
        mainLayout->addWidget( m_defaultCB );
        connect( m_defaultCB, SIGNAL( toggled( bool ) ),
                 this, SLOT( slotUpdateAllowedUsersAndGroups() ) );
        connect( m_defaultCB, SIGNAL( toggled( bool ) ),
                 this, SLOT( slotUpdateAllowedTypes() ) );
    }

    QRadioButton *ownerType = new QRadioButton( i18n("Owner"), gb );
    ownerType->setObjectName( QLatin1String( "ownerType" ) );
    gbLayout->addWidget( ownerType );
    m_buttonGroup->addButton( ownerType );
    m_buttonIds.insert( ownerType, KACLListView::User );
    QRadioButton *owningGroupType = new QRadioButton( i18n("Owning Group"), gb );
    owningGroupType->setObjectName( QLatin1String( "owningGroupType" ) );
    gbLayout->addWidget( owningGroupType );
    m_buttonGroup->addButton( owningGroupType );
    m_buttonIds.insert( owningGroupType, KACLListView::Group );
    QRadioButton *othersType = new QRadioButton( i18n("Others"), gb );
    othersType->setObjectName( QLatin1String( "othersType" ) );
    gbLayout->addWidget( othersType );
    m_buttonGroup->addButton( othersType );
    m_buttonIds.insert( othersType, KACLListView::Others );
    QRadioButton *maskType = new QRadioButton( i18n("Mask"), gb );
    maskType->setObjectName( QLatin1String( "maskType" ) );
    gbLayout->addWidget( maskType );
    m_buttonGroup->addButton( maskType );
    m_buttonIds.insert( maskType, KACLListView::Mask );
    QRadioButton *namedUserType = new QRadioButton( i18n("Named user"), gb );
    namedUserType->setObjectName( QLatin1String( "namesUserType" ) );
    gbLayout->addWidget( namedUserType );
    m_buttonGroup->addButton( namedUserType );
    m_buttonIds.insert( namedUserType, KACLListView::NamedUser );
    QRadioButton *namedGroupType = new QRadioButton( i18n("Named group"), gb );
    namedGroupType->setObjectName( QLatin1String( "namedGroupType" ) );
    gbLayout->addWidget( namedGroupType );
    m_buttonGroup->addButton( namedGroupType );
    m_buttonIds.insert( namedGroupType, KACLListView::NamedGroup );

    mainLayout->addWidget( gb );

    connect( m_buttonGroup, SIGNAL( buttonClicked( QAbstractButton* ) ),
             this, SLOT( slotSelectionChanged( QAbstractButton * ) ) );

    m_widgetStack = new QStackedWidget( page );
    mainLayout->addWidget( m_widgetStack );

    KHBox *usersBox = new KHBox( m_widgetStack );
    m_widgetStack->addWidget( usersBox );

    KHBox *groupsBox = new KHBox( m_widgetStack );
    m_widgetStack->addWidget( groupsBox );

    QLabel *usersLabel = new QLabel( i18n( "User: "******"users" ) );
    usersLabel->setBuddy( m_usersCombo );

    QLabel *groupsLabel = new QLabel( i18n( "Group: " ), groupsBox );
    m_groupsCombo = new KComboBox( groupsBox );
    m_groupsCombo->setEditable( false );
    m_groupsCombo->setObjectName( QLatin1String( "groups" ) );
    groupsLabel->setBuddy( m_groupsCombo );

    if ( m_item ) {
        m_buttonIds.key( m_item->type )->setChecked( true );
        if ( m_defaultCB )
            m_defaultCB->setChecked( m_item->isDefault );
        slotUpdateAllowedTypes();
        slotSelectionChanged( m_buttonIds.key( m_item->type ) );
        slotUpdateAllowedUsersAndGroups();
        if ( m_item->type == KACLListView::NamedUser ) {
            m_usersCombo->setItemText( m_usersCombo->currentIndex(), m_item->qualifier );
        } else if ( m_item->type == KACLListView::NamedGroup ) {
            m_groupsCombo->setItemText( m_groupsCombo->currentIndex(), m_item->qualifier );
        }
    } else {
        // new entry, preselect "named user", arguably the most common one
        m_buttonIds.key( KACLListView::NamedUser )->setChecked( true );
        slotUpdateAllowedTypes();
        slotSelectionChanged( m_buttonIds.key( KACLListView::NamedUser ) );
        slotUpdateAllowedUsersAndGroups();
    }
    incrementInitialSize(  QSize( 100, 0 ) );
    connect(this,SIGNAL(okClicked()), this, SLOT(slotOk()));
}
Exemplo n.º 2
0
EditACLEntryDialog::EditACLEntryDialog( KACLListView *listView, KACLListViewItem *item,
                                        const TQStringList &users,
                                        const TQStringList &groups,
                                        const TQStringList &defaultUsers,
                                        const TQStringList &defaultGroups,
                                        int allowedTypes, int allowedDefaultTypes,
                                        bool allowDefaults )
      : KDialogBase( listView, "edit_entry_dialog", true,
              i18n( "Edit ACL Entry" ), KDialogBase::Ok|KDialogBase::Cancel,
              KDialogBase::Ok, false ), 
        m_listView( listView ), m_item( item ), m_users( users ), m_groups( groups ),
        m_defaultUsers( defaultUsers ), m_defaultGroups( defaultGroups ),
        m_allowedTypes( allowedTypes ), m_allowedDefaultTypes( allowedDefaultTypes ),
        m_defaultCB( 0 )
{
    TQWidget *page = new TQWidget(  this );
    setMainWidget( page );
    TQVBoxLayout *mainLayout = new TQVBoxLayout( page, 0, spacingHint(), "mainLayout" );
    m_buttonGroup = new TQVButtonGroup( i18n("Entry Type"), page, "bg" );

    if ( allowDefaults ) {
        m_defaultCB = new TQCheckBox( i18n("Default for new files in this folder"), page, "defaultCB" );
        mainLayout->addWidget( m_defaultCB );
        connect( m_defaultCB, TQT_SIGNAL( toggled( bool ) ),
                 this, TQT_SLOT( slotUpdateAllowedUsersAndGroups() ) );
        connect( m_defaultCB, TQT_SIGNAL( toggled( bool ) ),
                 this, TQT_SLOT( slotUpdateAllowedTypes() ) );

    }

    mainLayout->addWidget( m_buttonGroup );

    TQRadioButton *ownerType = new TQRadioButton( i18n("Owner"), m_buttonGroup, "ownerType" );
    m_buttonGroup->insert( ownerType, KACLListView::User );
    TQRadioButton *owningGroupType = new TQRadioButton( i18n("Owning Group"), m_buttonGroup, "owningGroupType" );
    m_buttonGroup->insert( owningGroupType, KACLListView::Group );
    TQRadioButton *othersType = new TQRadioButton( i18n("Others"), m_buttonGroup, "othersType" );
    m_buttonGroup->insert( othersType, KACLListView::Others );
    TQRadioButton *maskType = new TQRadioButton( i18n("Mask"), m_buttonGroup, "maskType" );
    m_buttonGroup->insert( maskType, KACLListView::Mask );
    TQRadioButton *namedUserType = new TQRadioButton( i18n("Named User"), m_buttonGroup, "namesUserType" );
    m_buttonGroup->insert( namedUserType, KACLListView::NamedUser );
    TQRadioButton *namedGroupType = new TQRadioButton( i18n("Named Group"), m_buttonGroup, "namedGroupType" );
    m_buttonGroup->insert( namedGroupType, KACLListView::NamedGroup );

    connect( m_buttonGroup, TQT_SIGNAL( clicked( int ) ),
             this, TQT_SLOT( slotSelectionChanged( int ) ) );

    m_widgetStack = new TQWidgetStack( page );
    mainLayout->addWidget( m_widgetStack );

    TQHBox *usersBox = new TQHBox( m_widgetStack );
    m_widgetStack->addWidget( usersBox, KACLListView::NamedUser );

    TQHBox *groupsBox = new TQHBox( m_widgetStack );
    m_widgetStack->addWidget( groupsBox, KACLListView::NamedGroup );

    TQLabel *usersLabel = new TQLabel( i18n( "User: "******"users" );
    usersLabel->setBuddy( m_usersCombo );

    TQLabel *groupsLabel = new TQLabel( i18n( "Group: " ), groupsBox );
    m_groupsCombo = new TQComboBox( false, groupsBox, "groups" );
    groupsLabel->setBuddy( m_groupsCombo );

    if ( m_item ) {
        m_buttonGroup->setButton( m_item->type );
        if ( m_defaultCB )
            m_defaultCB->setChecked( m_item->isDefault );
        slotUpdateAllowedTypes();
        slotSelectionChanged( m_item->type );
        slotUpdateAllowedUsersAndGroups();
        if ( m_item->type == KACLListView::NamedUser ) {
            m_usersCombo->setCurrentText( m_item->qualifier );
        } else if ( m_item->type == KACLListView::NamedGroup ) {
            m_groupsCombo->setCurrentText( m_item->qualifier );
        }
    } else {
        // new entry, preselect "named user", arguably the most common one
        m_buttonGroup->setButton( KACLListView::NamedUser );
        slotUpdateAllowedTypes();
        slotSelectionChanged( KACLListView::NamedUser );
        slotUpdateAllowedUsersAndGroups();
    }
    incInitialSize(  TQSize( 100, 0 ) );
}