Back to index

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

#include <stylemanager.h>

List of all members.

Public Slots

void setKeyText ()
void setNoKey ()

Signals

void newKey (const QString &)
 emitted when a shrotcut is changed.

Public Member Functions

 ShortcutWidget (QWidget *parent=0, const char *name=0)
 ~ShortcutWidget ()
bool event (QEvent *ev)
void keyPressEvent (QKeyEvent *k)
void keyReleaseEvent (QKeyEvent *k)
void setKeyMap (const QMap< QString, Keys > &keymap)
void setShortcut (const QString &shortcut)
void languageChange ()

Static Public Member Functions

static QString getKeyText (int KeyC)

Protected Attributes

QVBoxLayout * keyManagerLayout
QGridLayout * keyGroupLayout
QHBoxLayout * okCancelLayout
QButtonGroup * keyGroup
QRadioButton * noKey
QRadioButton * userDef
QLabel * keyDisplay
QPushButton * setKeyButton
int keyCode
QString Part0
QString Part1
QString Part2
QString Part3
QString Part4

Detailed Description

Definition at line 185 of file stylemanager.h.


Constructor & Destructor Documentation

ShortcutWidget::ShortcutWidget ( QWidget *  parent = 0,
const char *  name = 0 
)

Definition at line 1492 of file stylemanager.cpp.

                                                                : QWidget(parent, name)
{
       Part0 = "";
       Part1 = "";
       Part2 = "";
       Part3 = "";
       keyCode = 0;
       keyManagerLayout = new QVBoxLayout( this, 0, 6); 
       keyManagerLayout->setAlignment( Qt::AlignHCenter );

       keyGroup = new QButtonGroup( this, "keyGroup" );
       keyGroup->setFrameStyle(0);
       keyGroup->setColumnLayout(0, Qt::Vertical );
       keyGroup->layout()->setSpacing( 0 );
       keyGroup->layout()->setMargin( 0 );
       keyGroupLayout = new QGridLayout( keyGroup->layout() );
       keyGroupLayout->setAlignment( Qt::AlignTop );
       keyGroupLayout->setSpacing( 6 );
       keyGroupLayout->setMargin( 11 );

       noKey = new QRadioButton( tr( "&No Key" ), keyGroup, "noKey" );
       keyGroupLayout->addMultiCellWidget( noKey, 0, 1, 0, 1 );
       userDef = new QRadioButton( tr( "&User Defined Key" ), keyGroup, "userDef" );
       keyGroupLayout->addWidget( userDef, 2, 0 );

       keyDisplay = new QLabel( tr( "ALT+SHIFT+T" ), keyGroup, "keyDisplay" );
       keyDisplay->setFrameShape( QLabel::Panel );
       keyDisplay->setFrameShadow( QLabel::Sunken );
       keyDisplay->setAlignment( static_cast<int>( QLabel::AlignCenter ) );
       keyDisplay->setMinimumHeight(40);

       keyGroupLayout->addMultiCellWidget( keyDisplay, 3, 4, 0, 2 );

       setKeyButton = new QPushButton( tr( "Set &Key" ), keyGroup, "setKeyButton" );
       setKeyButton->setToggleButton(true);

       languageChange();

       keyGroupLayout->addMultiCellWidget( setKeyButton, 0, 2, 1, 1, Qt::AlignCenter );
       keyManagerLayout->addWidget( keyGroup );

       connect(noKey, SIGNAL(clicked()), this, SLOT(setNoKey()));
       connect(setKeyButton, SIGNAL(clicked()), this, SLOT(setKeyText()));
}

Here is the call graph for this function:

Definition at line 1735 of file stylemanager.cpp.

{

}

Member Function Documentation

bool ShortcutWidget::event ( QEvent *  ev)

Definition at line 1556 of file stylemanager.cpp.

{
       bool ret = QWidget::event( ev );
       if ( ev->type() == QEvent::KeyPress )
              keyPressEvent((QKeyEvent*)ev);
       if ( ev->type() == QEvent::KeyRelease )
              keyReleaseEvent((QKeyEvent*)ev);
       return ret;
}

Here is the call graph for this function:

QString ShortcutWidget::getKeyText ( int  KeyC) [static]

Definition at line 1671 of file stylemanager.cpp.

{
       if ((KeyC & ~(Qt::META | Qt::CTRL | Qt::ALT | Qt::SHIFT)) == 0)
              return "";
       // on OSX Qt translates modifiers to forsaken symbols, arrows and the like
       // we prefer plain English
       QString res;
       if ((KeyC & Qt::META) != 0)
              res += "Meta+";
       if ((KeyC & Qt::CTRL) != 0)
              res += "Ctrl+";
       if ((KeyC & Qt::ALT) != 0)
              res += "Alt+";
       if ((KeyC & Qt::SHIFT) != 0)
              res += "Shift+";
       return res + QString(QKeySequence(KeyC & ~(Qt::META | Qt::CTRL | Qt::ALT | Qt::SHIFT)));
}

Here is the caller graph for this function:

void ShortcutWidget::keyPressEvent ( QKeyEvent *  k)

Definition at line 1566 of file stylemanager.cpp.

{
       if (setKeyButton->isOn())
       {
              QStringList tl;
              if (!keyDisplay->text().isEmpty())
              {
                     tl = tl.split("+", keyDisplay->text());
                     Part4 = tl[tl.count()-1];
                     if (Part4 == tr("Alt") || Part4 == tr("Ctrl") || Part4 == tr("Shift") || Part4 == tr("Meta"))
                            Part4 = "";
              }
              else
                     Part4 = "";
              switch (k->key())
              {
                     case Key_Meta:
                            Part0 = tr("Meta+");
                            keyCode |= META;
                            break;
                     case Key_Shift:
                            Part3 = tr("Shift+");
                            keyCode |= SHIFT;
                            break;
                     case Key_Alt:
                            Part2 = tr("Alt+");
                            keyCode |= ALT;
                            break;
                     case Key_Control:
                            Part1 = tr("Ctrl+");
                            keyCode |= CTRL;
                            break;
                     default:
                            keyCode |= k->key();
                            keyDisplay->setText(getKeyText(keyCode));
//                          if (checkKey(keyCode))
//                          {
//                                 QMessageBox::information(this,
//                                                                           CommonStrings::trWarning,
//                                                                           tr("This key sequence is already in use"),
//                                                                           CommonStrings::tr_OK);
//                                 keyTable->setText(currRow, 1, "");
//                                 keyDisplay->setText("");
//                                 if (currentKeyMapRow!=NULL)
//                                        currentKeyMapRow.data().keySequence=QKeySequence();
//                                 noKey->setChecked(true);
//                          }
//                          else
//                          {
//                                 QKeySequence newKeySequence(keyCode);
//                                 keyTable->setText(currRow, 1, QString(newKeySequence));
//                                 if (currentKeyMapRow!=NULL)
//                                        currentKeyMapRow.data().keySequence=newKeySequence;
//                                 userDef->setChecked(true);
//                          }
                            setKeyButton->setOn(false);
                            userDef->setChecked(true);
                            releaseKeyboard();
                            emit newKey(keyDisplay->text());
              }
       }
       if (setKeyButton->isOn())
       {
              keyDisplay->setText(Part0+Part1+Part2+Part3+Part4);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ShortcutWidget::keyReleaseEvent ( QKeyEvent *  k)

Definition at line 1633 of file stylemanager.cpp.

{
       if (setKeyButton->isOn())
       {
              if (!keyDisplay->text().isEmpty())
              {
                     QStringList tl;
                     tl = tl.split("+", keyDisplay->text());
                     Part4 = tl[tl.count()-1];
                     if (Part4 == tr("Alt") || Part4 == tr("Ctrl") || Part4 == tr("Shift") || Part4 == tr("Meta"))
                            Part4 = "";
              }
              else
                     Part4 = "";
              if (k->key() == Key_Meta)
              {
                     Part0 = "";
                     keyCode &= ~META;
              }
              if (k->key() == Key_Shift)
              {
                     Part3 = "";
                     keyCode &= ~SHIFT;
              }
              if (k->key() == Key_Alt)
              {
                     Part2 = "";
                     keyCode &= ~ALT;
              }
              if (k->key() == Key_Control)
              {
                     Part1 = "";
                     keyCode &= ~CTRL;
              }
              keyDisplay->setText(Part0+Part1+Part2+Part3+Part4);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1537 of file stylemanager.cpp.

{
/***********************************/
/*      Begin Tooltips             */
/***********************************/

       QToolTip::add(noKey,        tr("No shortcut for the style")); // set no shortcut for this style
       QToolTip::add(userDef,      tr("Style has user defined shortcut")); // not sure what this thing does
       QToolTip::add(setKeyButton, tr("Assign a shortcut for the style")); // activate shorcut assigning

/***********************************/
/*      End Tooltips               */
/***********************************/

       noKey->setText( tr("&No Key"));
       userDef->setText( tr("&User Defined Key"));
       setKeyButton->setText( tr("Set &Key"));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ShortcutWidget::newKey ( const QString &  ) [signal]

emitted when a shrotcut is changed.

Parameter will be QString::null when No key is used

Here is the caller graph for this function:

void ShortcutWidget::setKeyMap ( const QMap< QString, Keys > &  keymap)
void ShortcutWidget::setKeyText ( ) [slot]

Definition at line 1689 of file stylemanager.cpp.

{
       if (setKeyButton->isOn())
       {
              keyCode = 0;
              Part0 = "";
              Part1 = "";
              Part2 = "";
              Part3 = "";
              Part4 = "";
              grabKeyboard();
       }
       else
              releaseKeyboard();
}

Here is the caller graph for this function:

void ShortcutWidget::setNoKey ( ) [slot]

Definition at line 1726 of file stylemanager.cpp.

{
       if (noKey->isChecked())
       {
              keyDisplay->setText("");
              emit newKey(QString::null);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ShortcutWidget::setShortcut ( const QString &  shortcut)

Definition at line 1705 of file stylemanager.cpp.

{
       disconnect(noKey, SIGNAL(clicked()), this, SLOT(setNoKey()));
       disconnect(setKeyButton, SIGNAL(clicked()), this, SLOT(setKeyText()));

       setKeyButton->setOn(false);
       if (shortcut.length() > 0)
       {
              userDef->setChecked(true);
              keyDisplay->setText(shortcut);
       }
       else
       {
              noKey->setChecked(true);
              keyDisplay->setText("");
       }

       connect(noKey, SIGNAL(clicked()), this, SLOT(setNoKey()));
       connect(setKeyButton, SIGNAL(clicked()), this, SLOT(setKeyText()));
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 226 of file stylemanager.h.

QLabel* ShortcutWidget::keyDisplay [protected]

Definition at line 223 of file stylemanager.h.

QButtonGroup* ShortcutWidget::keyGroup [protected]

Definition at line 220 of file stylemanager.h.

QGridLayout* ShortcutWidget::keyGroupLayout [protected]

Definition at line 217 of file stylemanager.h.

QVBoxLayout* ShortcutWidget::keyManagerLayout [protected]

Definition at line 216 of file stylemanager.h.

QRadioButton* ShortcutWidget::noKey [protected]

Definition at line 221 of file stylemanager.h.

QHBoxLayout* ShortcutWidget::okCancelLayout [protected]

Definition at line 218 of file stylemanager.h.

QString ShortcutWidget::Part0 [protected]

Definition at line 227 of file stylemanager.h.

QString ShortcutWidget::Part1 [protected]

Definition at line 228 of file stylemanager.h.

QString ShortcutWidget::Part2 [protected]

Definition at line 229 of file stylemanager.h.

QString ShortcutWidget::Part3 [protected]

Definition at line 230 of file stylemanager.h.

QString ShortcutWidget::Part4 [protected]

Definition at line 231 of file stylemanager.h.

QPushButton* ShortcutWidget::setKeyButton [protected]

Definition at line 224 of file stylemanager.h.

QRadioButton* ShortcutWidget::userDef [protected]

Definition at line 222 of file stylemanager.h.


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