Back to index

scribus-ng  1.3.4.dfsg+svn20071115
alignselect.cpp
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 #include "alignselect.h"
00008 #include "alignselect.moc"
00009 
00010 extern QPixmap loadIcon(QString nam);
00011 
00012 AlignSelect::AlignSelect(QWidget* parent) : QButtonGroup(parent, "AlignSelect")
00013 {
00014        setFrameShape( QButtonGroup::NoFrame );
00015        setTitle("");
00016        setExclusive( true );
00017        setColumnLayout(0, Qt::Vertical );
00018        layout()->setSpacing( 0 );
00019        layout()->setMargin( 0 );
00020        GroupAlignLayout = new QGridLayout( layout() );
00021        GroupAlignLayout->setAlignment( Qt::AlignTop );
00022 
00023        TextL = new QToolButton( this, "TextL" );
00024        TextL->setMaximumSize( QSize( 22, 22 ) );
00025        TextL->setPixmap(loadIcon("16/format-justify-left.png"));
00026        TextL->setToggleButton( true );
00027        TextL->setOn( true );
00028        GroupAlignLayout->addWidget( TextL, 0, 0 );
00029 
00030        TextC = new QToolButton( this, "TextC" );
00031        TextC->setMaximumSize( QSize( 22, 22 ) );
00032        TextC->setPixmap(loadIcon("16/format-justify-center.png"));
00033        TextC->setToggleButton( true );
00034        GroupAlignLayout->addWidget( TextC, 0, 1 );
00035 
00036        TextR = new QToolButton( this, "TextR" );
00037        TextR->setMaximumSize( QSize( 22, 22 ) );
00038        TextR->setPixmap(loadIcon("16/format-justify-right.png"));
00039        TextR->setToggleButton( true );
00040        GroupAlignLayout->addWidget( TextR, 0, 2 );
00041 
00042        TextB = new QToolButton( this, "TextB" );
00043        TextB->setMaximumSize( QSize( 22, 22 ) );
00044        TextB->setPixmap(loadIcon("16/format-justify-fill-block.png"));
00045        TextB->setToggleButton( true );
00046        GroupAlignLayout->addWidget( TextB, 0, 3 );
00047 
00048        TextF = new QToolButton( this, "TextF" );
00049        TextF->setMaximumSize( QSize( 22, 22 ) );
00050        TextF->setPixmap(loadIcon("16/format-justify-fill.png"));
00051        TextF->setToggleButton( true );
00052        GroupAlignLayout->addWidget( TextF, 0, 4 );
00053        resize(minimumSizeHint());
00054        connect(this, SIGNAL(clicked(int)), this, SLOT(setTypeStyle(int)));
00055 }
00056 
00057 void AlignSelect::setStyle(int s)
00058 {
00059        setButton(s);
00060 }
00061 
00062 int AlignSelect::getStyle()
00063 {
00064        int ret = 0;
00065        if (TextL->isOn())
00066               ret = 0;
00067        if (TextR->isOn())
00068               ret = 2;
00069        if (TextC->isOn())
00070               ret = 1;
00071        if (TextB->isOn())
00072               ret = 3;
00073        if (TextF->isOn())
00074               ret = 4;
00075        return ret;
00076 }
00077 
00078 void AlignSelect::setTypeStyle(int a)
00079 {
00080        emit State(a);
00081 }
00082 
00083 void AlignSelect::languageChange()
00084 {
00085        QToolTip::remove(TextL);
00086        QToolTip::remove(TextR);
00087        QToolTip::remove(TextC);
00088        QToolTip::remove(TextB);
00089        QToolTip::remove(TextF);
00090 
00091        QToolTip::add(TextL, tr("Align Text Left"));
00092        QToolTip::add(TextR, tr("Align Text Right"));
00093        QToolTip::add(TextC, tr("Align Text Center"));
00094        QToolTip::add(TextB, tr("Align Text Justified"));
00095        QToolTip::add(TextF, tr("Align Text Forced Justified"));
00096 }