Back to index

scribus-ng  1.3.4.dfsg+svn20071115
Public Slots | Public Member Functions | Public Attributes | Protected Slots | Protected Member Functions | Protected Attributes
SWPrefsGui Class Reference

This is the Scribus Short Words plugin configuration widget. More...

#include <swprefsgui.h>

List of all members.

Public Slots

void apply ()
 Apply changes to prefs. Auto connected.
virtual void okButton_pressed ()
 Save the content into user file.
virtual void resetButton_pressed ()
 Re-reads system wide config file.
virtual void cfgEdit_changed ()
 Text editor changed.

Public Member Functions

 SWPrefsGui (QWidget *parent)
 ~SWPrefsGui ()

Public Attributes

QLabel * titleLabel
QTextEdit * cfgEdit
QPushButton * okButton
QPushButton * resetButton

Protected Slots

virtual void languageChange ()

Protected Member Functions

bool loadCfgFile (QString filename)
 Load cfg file.

Protected Attributes

QGridLayout * SWPrefsGuiLayout
QVBoxLayout * editLayout
QHBoxLayout * buttonLayout
QSpacerItem * buttonSpacer

Detailed Description

This is the Scribus Short Words plugin configuration widget.

Used in Preferences dialog.

Author:
Petr Vanek petr@.nosp@m.yarp.nosp@m.en.cz

Definition at line 30 of file swprefsgui.h.


Constructor & Destructor Documentation

SWPrefsGui::SWPrefsGui ( QWidget *  parent)

Definition at line 24 of file swprefsgui.cpp.

       : PrefsPanel(parent, "SWPrefsGui")
{
       SWPrefsGuiLayout = new QGridLayout(this, 1, 1, 11, 6, "SWPrefsGuiLayout");

       editLayout = new QVBoxLayout(0, 0, 6, "editLayout");

       titleLabel = new QLabel(this, "titleLabel");
       editLayout->addWidget(titleLabel);
       cfgEdit = new QTextEdit(this, "cfgEdit");
       editLayout->addWidget(cfgEdit);

       buttonLayout = new QHBoxLayout(0, 0, 6, "buttonLayout");
       buttonSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
       buttonLayout->addItem(buttonSpacer);

       okButton = new QPushButton(this, "okButton");
       buttonLayout->addWidget(okButton);

       resetButton = new QPushButton(this, "resetButton");
       buttonLayout->addWidget(resetButton);
       editLayout->addLayout(buttonLayout);

       SWPrefsGuiLayout->addLayout(editLayout, 0, 0);
       languageChange();
       resize(QSize(362, 359).expandedTo(minimumSizeHint()));
       clearWState(WState_Polished);

       // defaults
       if (QFile::exists(RC_PATH_USR))
       {
              titleLabel->setText( tr("User settings"));
              loadCfgFile(RC_PATH_USR);
       }
       else
       {
              titleLabel->setText( tr("System wide configuration"));
              resetButton->setEnabled(false);
              loadCfgFile(RC_PATH);
       }
       okButton->setEnabled(false);
       SWSyntaxHighlighter *sxHigh = new SWSyntaxHighlighter(cfgEdit);
       //remove that unused warning!
       sxHigh->currentParagraph();

       // signals
       connect(okButton, SIGNAL(clicked()), this, SLOT(okButton_pressed()));
       connect(resetButton, SIGNAL(clicked()), this, SLOT(resetButton_pressed()));
       connect(cfgEdit, SIGNAL(textChanged()), this, SLOT(cfgEdit_changed()));
}

Here is the call graph for this function:

Definition at line 75 of file swprefsgui.cpp.

{
       //delete the highlighter
       delete cfgEdit->syntaxHighlighter();
}

Member Function Documentation

void SWPrefsGui::apply ( ) [slot]

Apply changes to prefs. Auto connected.

Definition at line 95 of file swprefsgui.cpp.

{
       if (okButton->isEnabled())
              okButton_pressed();
}

Here is the call graph for this function:

void SWPrefsGui::cfgEdit_changed ( ) [virtual, slot]

Text editor changed.

Definition at line 138 of file swprefsgui.cpp.

{
       resetButton->setEnabled(true);
       okButton->setEnabled(true);
}

Here is the caller graph for this function:

void SWPrefsGui::languageChange ( ) [protected, virtual, slot]

Definition at line 85 of file swprefsgui.cpp.

{
       okButton->setText( tr("&Save"));
       resetButton->setText( tr("&Reset"));
       // tooltips
       QToolTip::add(okButton, tr("Save user configuration"));
       QToolTip::add(resetButton, "<qt>" + tr("Reload system wide configuration and remove user defined one") + "</qt>");
       QToolTip::add(cfgEdit, "<qt>" + tr("Edit custom configuration. If you save it, it will be used over system wide configuration") + "</qt>");
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool SWPrefsGui::loadCfgFile ( QString  filename) [protected]

Load cfg file.

Parameters:
filenamestring with full path and name.

Definition at line 144 of file swprefsgui.cpp.

{
       QFile f(filename);
       if (!f.open(IO_ReadOnly))
       {
              titleLabel->setText( tr("Cannot open file %1").arg(f.name()));
              return false;
       }
       cfgEdit->clear();
       QTextStream stream(&f);
       stream.setCodec(QTextCodec::codecForName("utf8"));
       while (!stream.atEnd())
              cfgEdit->append(stream.readLine());
       f.close();
       return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void SWPrefsGui::okButton_pressed ( ) [virtual, slot]

Save the content into user file.

Definition at line 101 of file swprefsgui.cpp.

{
       if (QFile::exists(RC_PATH_USR))
       {
              if ((ScMessageBox::warning(this, tr("Short Words"),
                            "<qt>" + tr("User configuration exists elready. "
                                          "Do you really want to overwrite it?") + "</qt>",
                            CommonStrings::trYes,
                            CommonStrings::trNo, 0, 0, 1)
                     ) == 1)
                     return;
       }
       QFile f(RC_PATH_USR);
       if (!f.open(IO_WriteOnly))
       {
              QMessageBox::warning(this, tr("Short Words"),
                      "<qt>" + tr("Cannot write file %1.").arg(RC_PATH_USR) + "</qt>",
                      CommonStrings::tr_OK);
       }
       QTextStream stream(&f);
       stream.setCodec(QTextCodec::codecForName("utf8"));
       stream << cfgEdit->text();
       f.close();
       titleLabel->setText( tr("User settings saved"));
       okButton->setEnabled(false);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void SWPrefsGui::resetButton_pressed ( ) [virtual, slot]

Re-reads system wide config file.

Definition at line 128 of file swprefsgui.cpp.

{
       loadCfgFile(RC_PATH);
       QDir d;
       d.remove(RC_PATH_USR);
       okButton->setEnabled(false);
       resetButton->setEnabled(false);
       titleLabel->setText( tr("System wide configuration reloaded"));
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

QHBoxLayout* SWPrefsGui::buttonLayout [protected]

Definition at line 60 of file swprefsgui.h.

QSpacerItem* SWPrefsGui::buttonSpacer [protected]

Definition at line 61 of file swprefsgui.h.

QTextEdit* SWPrefsGui::cfgEdit

Definition at line 39 of file swprefsgui.h.

QVBoxLayout* SWPrefsGui::editLayout [protected]

Definition at line 59 of file swprefsgui.h.

QPushButton* SWPrefsGui::okButton

Definition at line 40 of file swprefsgui.h.

Definition at line 41 of file swprefsgui.h.

QGridLayout* SWPrefsGui::SWPrefsGuiLayout [protected]

Definition at line 58 of file swprefsgui.h.

Definition at line 38 of file swprefsgui.h.


The documentation for this class was generated from the following files: