Esempio n. 1
0
Autocorrect::Autocorrect()
{
    /* setup actions for this plugin */
    KAction *configureAction = new KAction(i18n("Configure &Autocorrection..."), this);
    connect(configureAction, SIGNAL(triggered(bool)), this, SLOT(configureAutocorrect()));
    addAction("configure_autocorrection", configureAction);

    m_enabled = new KAction(i18n("Autocorrection"), this);
    m_enabled->setCheckable(true);
    m_enabled->setChecked(true);
    addAction("enable_autocorrection", m_enabled);

    m_singleSpaces = true;
    m_uppercaseFirstCharOfSentence = false;
    m_fixTwoUppercaseChars = false;
    m_autoFormatURLs = false;
    m_trimParagraphs = true;
    m_autoBoldUnderline = false;
    m_autoFractions = true;
    m_autoNumbering = false;
    m_capitalizeWeekDays = false;
    m_autoFormatBulletList = false;
    m_replaceDoubleQuotes = false;
    m_replaceSingleQuotes = false;

    // TODO put this into configuration dialog
    // default double quote open 0x201c
    // default double quote close 0x201d
    // default single quote open 0x2018
    // default single quote close 0x2019
    m_typographicSingleQuotes.begin = QChar(0x2018);
    m_typographicSingleQuotes.end = QChar(0x2019);
    m_typographicDoubleQuotes.begin = QChar(0x201c);
    m_typographicDoubleQuotes.end = QChar(0x201d);

    readConfig();

    KLocale *locale = KGlobal::locale();
    for (int i = 1; i <=7; i++)
        m_cacheNameOfDays.append(locale->calendar()->weekDayName(i).toLower());
}
Esempio n. 2
0
QString DateFormatter::fancy( time_t t ) const
{
  KLocale *locale = KGlobal::locale();

  if ( t <= 0 ) {
    return i18nc( "invalid time specified", "unknown" );
  }

  if ( mTodayOneSecondBeforeMidnight < time( 0 ) ) {
    // determine time_t value of today 23:59:59
    const QDateTime today( QDate::currentDate(), QTime( 23, 59, 59 ) );
    mTodayOneSecondBeforeMidnight = today.toTime_t();
  }

  QDateTime old;
  old.setTime_t( t );

  if ( mTodayOneSecondBeforeMidnight >= t ) {
    const time_t diff = mTodayOneSecondBeforeMidnight - t;
    if ( diff < 7 * 24 * 60 * 60 ) {
      if ( diff < 24 * 60 * 60 ) {
        return i18n( "Today %1",
                     locale->formatTime( old.time(), true ) );
      }
      if ( diff < 2 * 24 * 60 * 60 ) {
        return i18n( "Yesterday %1",
                     locale->formatTime( old.time(), true ) );
      }
      for ( int i = 3; i < 8; i++ ) {
        if ( diff < i * 24 * 60 * 60 ) {
          return i18nc( "1. weekday, 2. time", "%1 %2" ,
                        locale->calendar()->weekDayName( old.date() ) ,
                        locale->formatTime( old.time(), true ) );
        }
      }
    }
  }

  return locale->formatDateTime( old );
}