Subversion Repositories Scribus

Rev

Rev 715 | Rev 735 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
693 fschmid 1
#include "prefsdialogbase.h"
2
#include "prefsdialogbase.moc"
3
#include <qvariant.h>
4
#include <qpushbutton.h>
5
#include <qlayout.h>
6
#include <qtooltip.h>
7
#include <qwhatsthis.h>
8
extern QPixmap loadIcon(QString nam);
9
 
10
PrefsDialogBase::PrefsDialogBase( QWidget* parent ) : QDialog( parent, "PrefsDialogBase", true, 0 )
11
{
715 fschmid 12
        counter = 0;
693 fschmid 13
        setName( "PrefsDialogBase" );
14
        setIcon(loadIcon("AppIcon.png"));
15
        setSizeGripEnabled( TRUE );
16
        prefsLayout = new QVBoxLayout( this, 11, 6, "prefsLayout");
17
        layout3 = new QHBoxLayout( 0, 0, 6, "layout3");
715 fschmid 18
        prefsSelection = new QIconView( this, "prefsSelection" );
19
        prefsSelection->setHScrollBarMode( QIconView::AlwaysOff );
20
        prefsSelection->setVScrollBarMode( QIconView::Auto );
734 fschmid 21
        prefsSelection->setArrangement(QIconView::LeftToRight);
715 fschmid 22
        prefsSelection->setItemsMovable(false);
23
        prefsSelection->setAutoArrange( true );
24
        prefsSelection->setSorting( false );
693 fschmid 25
        prefsSelection->setFocusPolicy(QWidget::NoFocus);
26
        prefsSelection->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)7, 0, 0, prefsSelection->sizePolicy().hasHeightForWidth() ) );
27
        layout3->addWidget( prefsSelection );
28
        prefsWidgets = new QWidgetStack( this, "prefsWidgets" );
29
        layout3->addWidget( prefsWidgets );
30
        prefsLayout->addLayout( layout3 );
31
        layout4 = new QHBoxLayout( 0, 0, 6, "layout4");
32
        QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
33
        layout4->addItem( spacer );
34
        buttonOk = new QPushButton( this, "buttonOk" );
734 fschmid 35
        buttonOk->setAutoDefault( true );
36
        buttonOk->setDefault( true );
693 fschmid 37
        layout4->addWidget( buttonOk );
38
        buttonCancel = new QPushButton( this, "buttonCancel" );
734 fschmid 39
        buttonCancel->setAutoDefault( true );
693 fschmid 40
        layout4->addWidget( buttonCancel );
41
        prefsLayout->addLayout( layout4 );
42
        languageChange();
715 fschmid 43
        connect(prefsSelection, SIGNAL(clicked(QIconViewItem *)), this, SLOT(itemSelected(QIconViewItem* )));
693 fschmid 44
}
45
 
715 fschmid 46
void PrefsDialogBase::addItem(QString name, QPixmap icon, QWidget *tab)
47
{
48
        QIconViewItem* ic = new QIconViewItem(prefsSelection, name, icon);
49
        prefsWidgets->addWidget(tab, counter);
50
        itemMap.insert(ic, counter);
51
        counter++;
734 fschmid 52
//      prefsSelection->arrangeItemsInGrid();
715 fschmid 53
}
54
 
55
void PrefsDialogBase::itemSelected(QIconViewItem* ic)
56
{
57
        if (ic == 0)
58
                return;
59
        if (itemMap.contains(ic))
60
                prefsWidgets->raiseWidget(itemMap[ic]);
61
}
693 fschmid 62
/*
63
 *  Sets the strings of the subwidgets using the current
64
 *  language.
65
 */
66
void PrefsDialogBase::languageChange()
67
{
68
    buttonOk->setText( tr( "&OK" ) );
69
    buttonCancel->setText( tr( "&Cancel" ) );
70
}
71