Logo Search packages:      
Sourcecode: kmess version File versions  Download package

void AddEmoticonDialog::interfaceChanged (  ) [private, slot]

Controls the OK button by checking the dialog's widgets

It's called everytime that a change is made to one of the dialog's widgets, and checks if their contents are valid. Then enables or disables the OK button accordingly.

Definition at line 145 of file addemoticondialog.cpp.

Referenced by AddEmoticonDialog().

{
  bool enable = true;
  const QString currentShortcut    ( shortcutEdit_->text() );
  const QString currentEmoticonPath( pictureEdit_ ->text() );

  // Check if the current emoticon path is empty.
  if( currentEmoticonPath.isEmpty() )
  {
    // If the path is empty reset the view
    movie_->stop();
    movie_->setFileName( QString() );
  }
  else if( currentEmoticonPath != movie_->fileName() )
  {
    // User updated the current emoticon path
    movie_->stop();
    movie_->setFileName( pictureEdit_->text() );
  }

  // Start the movie only if it's valid
  if( movie_->isValid() )
  {
    // The chosen file is valid, update the preview.

#ifdef KMESSDEBUG_EMOTICONS_ADDING
    kmDebug() << "Updated preview.";
#endif

    emoticonPreview_->setMovie( movie_ );
    movie_->start();
  }
  else
  {
    // The chosen file is not valid, reset the preview to the KMess logo.

#ifdef KMESSDEBUG_EMOTICONS_ADDING
    kmDebug() << "Resetting preview.";
#endif

    enable = false;
    emoticonPreview_->setPixmap( KIconLoader::global()->loadIcon( "kmess", KIconLoader::Desktop, KIconLoader::SizeHuge ) );

    // Also show why the changes can't be confirmed
    label_->setText( i18n( "Please, select a valid picture file" ) );
  }

  if( currentShortcut.isEmpty() || ! Emoticon::isValidShortcut( currentShortcut ) )
  {
    enable = false;

    // Also show why the changes can't be confirmed
    if( currentShortcut.isEmpty() )
    {
      label_->setText( i18n( "Please, enter a text to associate with this emoticon" ) );
    }
    else
    {
      label_->setText( i18n( "Shortcuts must not:<ul>"
                             "<li>be longer than 7 characters,</li>"
                             "<li>start with \"/\" (they would interfere "
                               "with irc-like commands),</li>"
                             "<li>contain square brackets with text "
                               "within (like [b] or [color], which can be text formatting options)</li>"
                             "</ul>" ) );
    }
  }

  if( enable )
  {
    label_->setText( QString() );
  }
  // Adapt the dialog size to label text changes
  label_->adjustSize();
  adjustSize();
  resize( sizeHint() );

  // Enable the OK button only if both fields have valid contents
  enableButtonOk( enable );
}

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index