Scribus Developer Documentation - API
logo-pen

Scribus Developer Documentation - API

smalignselect.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 <QToolTip>
00008 #include "smalignselect.h"
00009 
00010 
00011 SMAlignSelect::SMAlignSelect(QWidget *parent)
00012 : AlignSelect(parent),
00013   hasParent_(false),
00014   useParentStyle_(false),
00015   pStyle_(0)
00016 {
00017     parentButton = new QToolButton(this);
00018     parentButton->setMaximumSize( QSize( 22, 22 ) );
00019     parentButton->setCheckable( true );
00020     parentButton->setText( tr("P", "P as in Parent"));
00021     parentButton->setToolTip( tr("Use parent style's alignment instead of overriding it"));
00022     GroupAlignLayout->addWidget( parentButton );
00023     resize(minimumSizeHint());
00024     parentButton->hide();
00025 }
00026 
00027 void SMAlignSelect::setStyle(int i)
00028 {
00029     disconnect(this, SIGNAL(State(int)), this, SLOT(styleChanged()));
00030     disconnect(parentButton, SIGNAL(pressed()), this, SLOT(pbPressed()));
00031     setFont(false);
00032     hasParent_ = false;
00033     pStyle_ = 0;
00034     parentButton->hide();
00035     AlignSelect::setStyle(i);
00036 }
00037 
00038 void SMAlignSelect::setStyle(int i, bool isParentValue)
00039 {
00040     disconnect(this, SIGNAL(State(int)), this, SLOT(styleChanged()));
00041     disconnect(parentButton, SIGNAL(pressed()), this, SLOT(pbPressed()));
00042     hasParent_ = true;
00043     pStyle_ = i;
00044     setFont(!isParentValue);
00045     if (isParentValue)
00046         parentButton->hide();
00047     else
00048         parentButton->show();
00049 
00050     AlignSelect::setStyle(i);
00051     connect(this, SIGNAL(State(int)), this, SLOT(styleChanged()));
00052     connect(parentButton, SIGNAL(pressed()), this, SLOT(pbPressed()));
00053 }
00054 
00055 void SMAlignSelect::setParentItem(int i)
00056 {
00057     hasParent_ = true;
00058     pStyle_ = i;
00059 }
00060 
00061 bool SMAlignSelect::useParentValue()
00062 {
00063     bool ret = useParentStyle_;
00064     useParentStyle_ = false;
00065     if (ret)
00066         setStyle(pStyle_, true);
00067 
00068     return ret;
00069 }
00070 
00071 void SMAlignSelect::setFont(bool wantBold)
00072 {
00073     QFont f(font());
00074     f.setBold(wantBold);
00075     parentButton->setFont(f);
00076 }
00077 
00078 void SMAlignSelect::styleChanged()
00079 {
00080     if (hasParent_)
00081     {
00082         setFont(true);
00083         parentButton->show();
00084     }
00085 }
00086 
00087 void SMAlignSelect::pbPressed()
00088 {
00089     useParentStyle_ = true;
00090 }
Created with personalized Doxygen. This is documentation for GPL software Scribus - Open Source Desktop Publishing.