Back to index

scribus-ng  1.3.4.dfsg+svn20071115
vlnadialog.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 /* This is the Scribus Short Words GUI class implementation.
00008 
00009 This code is based on the Scribus-Vlna plug in rewritten for
00010 international use.
00011 
00012 2004 Petr Vanek <petr@yarpen.cz>
00013 
00014 This program is free software - see LICENSE file in the distribution
00015 or documentation
00016 */
00017 
00018 #include "version.h"
00019 #include "vlnadialog.h"
00020 #include "vlnadialog.moc"
00021 #include "scribus.h"
00022 #include "scpaths.h"
00023 #include "configuration.h"
00024 #include "helpbrowser.h"
00025 
00026 #include <qvariant.h>
00027 #include <qpushbutton.h>
00028 #include <qbuttongroup.h>
00029 #include <qradiobutton.h>
00030 #include <qlabel.h>
00031 #include <qlayout.h>
00032 #include <qtooltip.h>
00033 #include <qwhatsthis.h>
00034 #include <qmessagebox.h>
00035 #include <qdir.h>
00036 #include <qstringlist.h>
00037 #include <qlayout.h>
00038 #include <qcheckbox.h>
00039 #include <qinputdialog.h>
00040 #include <qprocess.h>
00041 
00042 #include "commonstrings.h"
00043 
00044 SWDialog::SWDialog(QWidget* parent, const char* name, bool modal, WFlags fl)
00045        : QDialog(parent, name, modal, fl)
00046 {
00047        if (!name)
00048               setName("SWDialog");
00049        cfg = new SWConfig();
00050 
00051        SWDialogLayout = new QGridLayout(this, 1, 1, 11, 6, "SWDialogLayout");
00052 
00053        layout4 = new QVBoxLayout(0, 0, 6, "layout4");
00054 
00055        layout3 = new QHBoxLayout(0, 0, 6, "layout3");
00056 
00057        buttonGroup = new QButtonGroup(this, "buttonGroup");
00058 
00059        QGridLayout *gridLayout = new QGridLayout(buttonGroup);
00060        gridLayout->setSpacing(6);
00061        gridLayout->setMargin(9);
00062        
00063        QVBoxLayout *vboxLayout = new QVBoxLayout();
00064        vboxLayout->setSpacing(6);
00065        vboxLayout->setMargin(0);
00066 
00067        frameRadio = new QRadioButton(buttonGroup, "frameRadio");
00068        vboxLayout->addWidget(frameRadio);
00069 
00070        pageRadio = new QRadioButton(buttonGroup, "pageRadio");
00071        vboxLayout->addWidget(pageRadio);
00072 
00073        allRadio = new QRadioButton(buttonGroup, "allRadio");
00074        vboxLayout->addWidget(allRadio);
00075 
00076        gridLayout->addLayout(vboxLayout, 0, 0);
00077        buttonGroup->setMinimumWidth(250); // these Germans withe their long words...
00078        buttonGroup->adjustSize();
00079 
00080        layout3->addWidget(buttonGroup);
00081 
00082        layout2 = new QVBoxLayout(0, 0, 6, "layout2");
00083        QSpacerItem* spacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
00084        layout2->addItem(spacer);
00085 
00086        layout1 = new QVBoxLayout(0, 0, 6, "layout1");
00087 
00088        okButton = new QPushButton(this, "okButton");
00089        okButton->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, 0, 0, okButton->sizePolicy().hasHeightForWidth()));
00090        layout1->addWidget(okButton);
00091 
00092        cancelButton = new QPushButton(this, "cancelButton");
00093        cancelButton->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, 0, 0, cancelButton->sizePolicy().hasHeightForWidth()));
00094        layout1->addWidget(cancelButton);
00095 
00096        layout2->addLayout(layout1);
00097        layout3->addLayout(layout2);
00098        layout4->addLayout(layout3);
00099 
00100        SWDialogLayout->addLayout(layout4, 0, 0);
00101 
00102        languageChange();
00103        resize(QSize(306, 193).expandedTo(minimumSizeHint()));
00104        clearWState(WState_Polished);
00105 
00106        selectAction(cfg->action);
00107 
00108        // signals and slots connections
00109        connect(okButton, SIGNAL(clicked()), this, SLOT(okButton_pressed()));
00110        connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancelButton_pressed()));
00111        connect(buttonGroup, SIGNAL(clicked(int)), this, SLOT(buttonGroup_clicked(int)));
00112 }
00113 
00114 /*
00115  *  Destroys the object and frees any allocated resources
00116  */
00117 SWDialog::~SWDialog()
00118 {
00119        cfg->action = actionSelected;
00120        cfg->saveConfig();
00121 }
00122 
00123 /*
00124  *  Sets the strings of the subwidgets using the current
00125  *  language.
00126  */
00127 void SWDialog::languageChange()
00128 {
00129        setCaption( tr("Short Words", "short words plugin"));
00130        buttonGroup->setTitle( tr("Apply unbreakable space on:", "short words plugin"));
00131        frameRadio->setText( tr("&Selected frames", "short words plugin"));
00132        pageRadio->setText( tr("Active &page", "short words plugin"));
00133        allRadio->setText( tr("&All items", "short words plugin"));
00134        okButton->setText(CommonStrings::tr_OK);
00135        cancelButton->setText(CommonStrings::tr_Cancel);
00136        QToolTip::add(frameRadio, tr("Only selected frames processed.", "short words plugin"));
00137        QToolTip::add(pageRadio, tr("Only actual page processed.", "short words plugin"));
00138        QToolTip::add(allRadio, tr("All items in document processed.", "short words plugin"));
00139 }
00140 
00141 void SWDialog::okButton_pressed()
00142 {
00143        actionSelected = buttonGroup->id(buttonGroup->selected());
00144        accept();
00145 }
00146 
00147 void SWDialog::cancelButton_pressed()
00148 {
00149        reject();
00150 }
00151 
00152 void SWDialog::selectAction(int aAction)
00153 {
00154        if (aAction!=0 && aAction!=1 && aAction!=2) {
00155                      aAction = 0;
00156        }
00157        buttonGroup->setButton(aAction);
00158 }
00159 
00160 void SWDialog::buttonGroup_clicked(int key)
00161 {
00162        buttonGroup->find(key)->setFocus();
00163 }