Back to index

scribus-ng  1.3.4.dfsg+svn20071115
dcolor.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 <qdialog.h>
00008 #include <qlayout.h>
00009 #include <qlabel.h>
00010 #include <qpushbutton.h>
00011 #include <qcombobox.h>
00012 #include <qpixmap.h>
00013 #include <qiconset.h>
00014 
00015 #include "commonstrings.h"
00016 #include "scribusdoc.h"
00017 #include "page.h"
00018 #include "colorcombo.h"
00019 #include "prefsmanager.h"
00020 
00021 #include "dcolor.h"
00022 #include "dcolor.moc"
00023 
00024 
00025 extern QPixmap loadIcon(QString nam);
00026 
00027 DelColor::DelColor( QWidget* parent, ColorList colorList, QString colorName, bool haveDoc)
00028     : QDialog( parent, "dd", true, 0 )
00029 {
00030        setName( "DelColor" );
00031     setCaption( tr( "Delete Color" ) );
00032        setIcon(loadIcon("AppIcon.png"));
00033     dialogLayout = new QVBoxLayout( this, 10, 5 );
00034     delColorLayout = new QGridLayout;
00035     delColorLayout->setSpacing( 6 );
00036     delColorLayout->setMargin( 5 );
00037     deleteLabel = new QLabel( tr( "Delete Color:" ), this, "deleteLabel" );
00038     delColorLayout->addWidget( deleteLabel, 0, 0 );
00039     colorToDelLabel = new QLabel( colorName, this, "colorToDelLabel" );
00040     delColorLayout->addWidget( colorToDelLabel, 0, 1 );
00041 
00042        PrefsManager* prefsManager = PrefsManager::instance();
00043        bool isToolColor = prefsManager->isToolColor(colorName);
00044        if (haveDoc || isToolColor)
00045        {
00046        replaceLabel = new QLabel( tr( "Replace With:" ), this, "replaceLabel" );
00047        delColorLayout->addWidget( replaceLabel, 1, 0 );
00048        replacementColData = new ColorCombo(false, this);
00049               colorList.remove(colorName);
00050               // 10/26/2004 pv - user can replace deleted color with "None"
00051               replacementColData->insertItem(CommonStrings::tr_NoneColor);
00052               replacementColData->insertItems(colorList, ColorCombo::smallPixmaps);
00053        delColorLayout->addWidget( replacementColData, 1, 1 );
00054        replacementColor = replacementColData->text(0);
00055        }
00056     dialogLayout->addLayout( delColorLayout );
00057 
00058     okCancelLayout = new QHBoxLayout;
00059     okCancelLayout->setSpacing( 6 );
00060     okCancelLayout->setMargin( 0 );
00061     QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
00062     okCancelLayout->addItem( spacer );
00063     okButton = new QPushButton( CommonStrings::tr_OK, this, "okButton" );
00064     okCancelLayout->addWidget( okButton );
00065     cancelButton = new QPushButton( CommonStrings::tr_Cancel, this, "PushButton13" );
00066     cancelButton->setDefault( true );
00067     okCancelLayout->addWidget( cancelButton );
00068     dialogLayout->addLayout( okCancelLayout );
00069     setMaximumSize(sizeHint());
00070 
00071     connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
00072     connect( cancelButton, SIGNAL( clicked() ), this, SLOT( reject() ) );
00073        if (haveDoc || isToolColor)
00074        connect( replacementColData, SIGNAL(activated(int)), this, SLOT( ReplaceColor(int) ) );
00075 }
00076 
00077 void DelColor::ReplaceColor(int id)
00078 {
00079     replacementColor = replacementColData->text(id);
00080 }
00081 
00082 const QString DelColor::getReplacementColor()
00083 {
00084        return replacementColor;
00085 }