Subversion Repositories Scribus

Rev

Rev 1828 | Rev 1877 | 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>
1834 fschmid 8
#include <qlabel.h>
9
#include <qfont.h>
693 fschmid 10
extern QPixmap loadIcon(QString nam);
11
 
12
PrefsDialogBase::PrefsDialogBase( QWidget* parent ) : QDialog( parent, "PrefsDialogBase", true, 0 )
13
{
715 fschmid 14
        counter = 0;
693 fschmid 15
        setName( "PrefsDialogBase" );
16
        setIcon(loadIcon("AppIcon.png"));
17
        setSizeGripEnabled( TRUE );
18
        prefsLayout = new QVBoxLayout( this, 11, 6, "prefsLayout");
19
        layout3 = new QHBoxLayout( 0, 0, 6, "layout3");
715 fschmid 20
        prefsSelection = new QIconView( this, "prefsSelection" );
21
        prefsSelection->setHScrollBarMode( QIconView::AlwaysOff );
22
        prefsSelection->setVScrollBarMode( QIconView::Auto );
734 fschmid 23
        prefsSelection->setArrangement(QIconView::LeftToRight);
715 fschmid 24
        prefsSelection->setItemsMovable(false);
735 fschmid 25
        prefsSelection->setAutoArrange( false );
715 fschmid 26
        prefsSelection->setSorting( false );
693 fschmid 27
        prefsSelection->setFocusPolicy(QWidget::NoFocus);
28
        prefsSelection->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)7, 0, 0, prefsSelection->sizePolicy().hasHeightForWidth() ) );
29
        layout3->addWidget( prefsSelection );
1834 fschmid 30
        layout5 = new QVBoxLayout( 0, 0, 6, "layout5");
31
        textLabel1 = new QLabel( this, "textLabel1" );
32
        QFont f(textLabel1->font());
33
        f.setPointSize(f.pointSize()+4);
34
        f.setBold(true);
35
        textLabel1->setFont(f);
36
        textLabel1->setText("");
37
        layout5->addWidget( textLabel1 );
693 fschmid 38
        prefsWidgets = new QWidgetStack( this, "prefsWidgets" );
1834 fschmid 39
        layout5->addWidget( prefsWidgets );
40
        layout3->addLayout(layout5);
693 fschmid 41
        prefsLayout->addLayout( layout3 );
42
        layout4 = new QHBoxLayout( 0, 0, 6, "layout4");
43
        QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
44
        layout4->addItem( spacer );
1828 fschmid 45
        backToDefaults = new QPushButton( this, "backToDefaults" );
46
        backToDefaults->setAutoDefault( false );
47
        backToDefaults->setDefault( false );
48
        layout4->addWidget( backToDefaults );
693 fschmid 49
        buttonOk = new QPushButton( this, "buttonOk" );
1284 fschmid 50
        buttonOk->setAutoDefault( false );
51
        buttonOk->setDefault( false );
693 fschmid 52
        layout4->addWidget( buttonOk );
53
        buttonCancel = new QPushButton( this, "buttonCancel" );
1284 fschmid 54
        buttonCancel->setAutoDefault( false );
55
        buttonCancel->setDefault( false );
693 fschmid 56
        layout4->addWidget( buttonCancel );
57
        prefsLayout->addLayout( layout4 );
58
        languageChange();
715 fschmid 59
        connect(prefsSelection, SIGNAL(clicked(QIconViewItem *)), this, SLOT(itemSelected(QIconViewItem* )));
776 fschmid 60
        connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
61
        connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
693 fschmid 62
}
63
 
800 fschmid 64
int PrefsDialogBase::addItem(QString name, QPixmap icon, QWidget *tab)
715 fschmid 65
{
735 fschmid 66
        QIconViewItem* icx = new QIconViewItem(prefsSelection, name, icon);
715 fschmid 67
        prefsWidgets->addWidget(tab, counter);
1639 cbradney 68
        icx->setDragEnabled(false);
735 fschmid 69
        itemMap.insert(icx, counter);
715 fschmid 70
        counter++;
800 fschmid 71
        return counter-1;
715 fschmid 72
}
73
 
735 fschmid 74
void PrefsDialogBase::arrangeIcons()
75
{
76
        int maxWidth = 0;
77
        QIconViewItem* ic = prefsSelection->firstItem();
78
        int startY = 5;
79
        for (uint cc = 0; cc < prefsSelection->count(); ++cc)
80
        {
81
                int w = ic->width();
82
                maxWidth = QMAX(w, maxWidth);
83
                ic = ic->nextItem();
84
        }
85
        ic = prefsSelection->firstItem();
86
        prefsSelection->setAutoArrange( false );
87
        prefsSelection->setResizeMode(QIconView::Fixed);
88
        for (uint cc = 0; cc < prefsSelection->count(); ++cc)
89
        {
90
                int w = ic->width();
91
                int moveW = (maxWidth - w) / 2;
92
                ic->move(moveW, startY);
795 fschmid 93
                startY += ic->height()+5;
735 fschmid 94
                ic = ic->nextItem();
95
        }
96
}
97
 
715 fschmid 98
void PrefsDialogBase::itemSelected(QIconViewItem* ic)
99
{
100
        if (ic == 0)
101
                return;
102
        if (itemMap.contains(ic))
1834 fschmid 103
        {
715 fschmid 104
                prefsWidgets->raiseWidget(itemMap[ic]);
1834 fschmid 105
                textLabel1->setText(ic->text());
106
        }
715 fschmid 107
}
693 fschmid 108
/*
109
 *  Sets the strings of the subwidgets using the current
110
 *  language.
111
 */
112
void PrefsDialogBase::languageChange()
113
{
114
    buttonOk->setText( tr( "&OK" ) );
115
    buttonCancel->setText( tr( "&Cancel" ) );
1828 fschmid 116
    backToDefaults->setText( tr( "&Defaults" ) );
693 fschmid 117
}
118