Scribus Developer Documentation - API
logo-pen

Scribus Developer Documentation - API

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 
00008 #include "alignselect.h"
00009 #include <QEvent>
00010 #include <QPixmap>
00011 #include <QToolTip>
00012 #include "util_icon.h"
00013 
00014 AlignSelect::AlignSelect(QWidget* parent) : QWidget(parent)
00015 {
00016     buttonGroup = new QButtonGroup(this);
00017 
00018     GroupAlignLayout = new QHBoxLayout( this );
00019     GroupAlignLayout->setSpacing( 0 );
00020     GroupAlignLayout->setMargin( 0 );
00021 
00022     TextL = new QToolButton( this );
00023     TextL->setMaximumSize( QSize( 22, 22 ) );
00024     TextL->setIcon(QIcon(loadIcon("16/format-justify-left.png")));
00025     TextL->setCheckable( true );
00026     TextL->setChecked( true );
00027     GroupAlignLayout->addWidget( TextL );
00028     buttonGroup->addButton(TextL, 0);
00029 
00030     TextC = new QToolButton( this );
00031     TextC->setMaximumSize( QSize( 22, 22 ) );
00032     TextC->setIcon(QIcon(loadIcon("16/format-justify-center.png")));
00033     TextC->setCheckable( true );
00034     GroupAlignLayout->addWidget( TextC );
00035     buttonGroup->addButton(TextC, 1);
00036 
00037     TextR = new QToolButton( this );
00038     TextR->setMaximumSize( QSize( 22, 22 ) );
00039     TextR->setIcon(QIcon(loadIcon("16/format-justify-right.png")));
00040     TextR->setCheckable( true );
00041     GroupAlignLayout->addWidget( TextR );
00042     buttonGroup->addButton(TextR, 2);
00043 
00044     TextB = new QToolButton( this );
00045     TextB->setMaximumSize( QSize( 22, 22 ) );
00046     TextB->setIcon(QIcon(loadIcon("16/format-justify-fill-block.png")));
00047     TextB->setCheckable( true );
00048     GroupAlignLayout->addWidget( TextB );
00049     buttonGroup->addButton(TextB, 3);
00050 
00051     TextF = new QToolButton( this );
00052     TextF->setMaximumSize( QSize( 22, 22 ) );
00053     TextF->setIcon(QIcon(loadIcon("16/format-justify-fill.png")));
00054     TextF->setCheckable( true );
00055     GroupAlignLayout->addWidget( TextF );
00056     buttonGroup->addButton(TextF, 4);
00057     resize(minimumSizeHint());
00058     connect(buttonGroup, SIGNAL(buttonClicked(int)), this, SLOT(setTypeStyle(int)));
00059 }
00060 
00061 void AlignSelect::setStyle(int s)
00062 {
00063     if ((s >= 0) && (s < 5))
00064         buttonGroup->button(s)->setChecked(true);
00065 }
00066 
00067 int AlignSelect::getStyle()
00068 {
00069     int ret = 0;
00070     if (TextL->isChecked())
00071         ret = 0;
00072     if (TextR->isChecked())
00073         ret = 2;
00074     if (TextC->isChecked())
00075         ret = 1;
00076     if (TextB->isChecked())
00077         ret = 3;
00078     if (TextF->isChecked())
00079         ret = 4;
00080     return ret;
00081 }
00082 
00083 void AlignSelect::setTypeStyle(int a)
00084 {
00085     selected = a;
00086     emit State(a);
00087 }
00088 
00089 int AlignSelect::selectedId()
00090 {
00091     return selected;
00092 }
00093 
00094 void AlignSelect::changeEvent(QEvent *e)
00095 {
00096     if (e->type() == QEvent::LanguageChange)
00097     {
00098         languageChange();
00099     }
00100 }
00101 
00102 void AlignSelect::languageChange()
00103 {
00104     TextL->setToolTip("");
00105     TextR->setToolTip("");
00106     TextC->setToolTip("");
00107     TextB->setToolTip("");
00108     TextF->setToolTip("");
00109 
00110     TextL->setToolTip( tr("Align Text Left"));
00111     TextR->setToolTip( tr("Align Text Right"));
00112     TextC->setToolTip( tr("Align Text Center"));
00113     TextB->setToolTip( tr("Align Text Justified"));
00114     TextF->setToolTip( tr("Align Text Forced Justified"));
00115 }
Created with personalized Doxygen. This is documentation for GPL software Scribus - Open Source Desktop Publishing.