Beispiel #1
0
 void updateSuffix(int value)
 {
     if (!pluralSuffix.isEmpty()) {
         KLocalizedString s = pluralSuffix;
         q->setSuffix(s.subs(value).toString());
     }
 }
// private slot virtual [base QDialog]
void kpTransformSkewDialog::accept ()
{
    KLocalizedString message;
    QString caption, continueButtonText;

    if (document ()->selection ())
    {
        if (!document ()->textSelection ())
        {
            message =
                ki18n ("<qt><p>Skewing the selection to %1x%2"
                      " may take a substantial amount of memory."
                      " This can reduce system"
                      " responsiveness and cause other application resource"
                      " problems.</p>"

                      "<p>Are you sure want to skew the selection?</p></qt>");

            caption = i18nc ("@title:window", "Skew Selection?");
            continueButtonText = i18n ("Sk&ew Selection");
        }
    }
    else
    {
        message =
            ki18n ("<qt><p>Skewing the image to %1x%2"
                  " may take a substantial amount of memory."
                  " This can reduce system"
                  " responsiveness and cause other application resource"
                  " problems.</p>"

                  "<p>Are you sure want to skew the image?</p></qt>");

        caption = i18nc ("@title:window", "Skew Image?");
        continueButtonText = i18n ("Sk&ew Image");
    }


    const int newWidth = newDimensions ().width ();
    const int newHeight = newDimensions ().height ();

    if (kpTool::warnIfBigImageSize (m_oldWidth,
            m_oldHeight,
            newWidth, newHeight,
            message.subs (newWidth).subs (newHeight).toString (),
            caption,
            continueButtonText,
            this))
    {
        QDialog::accept ();
    }
}
KUrl
Playlists::newPlaylistFilePath( const QString &fileExtension )
{
    int trailingNumber = 1;
    KLocalizedString fileName = ki18n("Playlist_%1");
    KUrl url( Amarok::saveLocation( "playlists" ) );
    url.addPath( fileName.subs( trailingNumber ).toString() );

    while( QFileInfo( url.path() ).exists() )
        url.setFileName( fileName.subs( ++trailingNumber ).toString() );

    return KUrl( QString( "%1.%2" ).arg( url.path() ).arg( fileExtension ) );
}
Beispiel #4
0
QString AdaptSignatureAction::toolTip() const
{
    DUChainReadLocker lock;
    auto declaration = m_otherSideId.getDeclaration(m_otherSideTopContext.data());
    if (!declaration) {
        return {};
    }
    KLocalizedString msg = m_editingDefinition
                         ? ki18n("Update declaration signature\nfrom: %1\nto: %2")
                         : ki18n("Update definition signature\nfrom: %1\nto: %2");
    msg = msg.subs(CodegenHelper::makeSignatureString(declaration, m_oldSignature, m_editingDefinition));
    msg = msg.subs(CodegenHelper::makeSignatureString(declaration, m_newSignature, !m_editingDefinition));
    return msg.toString();
}
Beispiel #5
0
QString
ConstraintTypes::PlaylistDuration::getName() const
{
    KLocalizedString v;
    if ( m_comparison == CompareNumEquals ) {
        v = ki18nc( "%1 is a length of time (e.g. 5:00 for 5 minutes)", "Playlist duration: equals %1");
    } else if ( m_comparison == CompareNumGreaterThan ) {
        v = ki18nc( "%1 is a length of time (e.g. 5:00 for 5 minutes)", "Playlist duration: more than %1");
    } else if ( m_comparison == CompareNumLessThan ) {
        v = ki18nc( "%1 is a length of time (e.g. 5:00 for 5 minutes)", "Playlist duration: less than %1");
    } else {
        v = ki18n( "Playlist duration: unknown");
    }
    v = v.subs( QTime().addMSecs( m_duration ).toString( "H:mm:ss" ) );
    return v.toString();
}
Beispiel #6
0
QString
ConstraintTypes::PlaylistFileSize::getName() const
{
    KLocalizedString v;
    if ( m_comparison == CompareNumEquals ) {
        v = ki18nc( "%1 is a file size (e.g. 50 MB)", "Total file size of playlist: equals %1");
    } else if ( m_comparison == CompareNumGreaterThan ) {
        v = ki18nc( "%1 is a file size (e.g. 50 MB)", "Total file size of playlist: more than %1");
    } else if ( m_comparison == CompareNumLessThan ) {
        v = ki18nc( "%1 is a file size (e.g. 50 MB)", "Total file size of playlist: less than %1");
    } else {
        v = ki18n( "Total file size of playlist: unknown");
    }
    v = v.subs( KGlobal::locale()->formatByteSize( (double)getWantedSize(), 1, KLocale::MetricBinaryDialect ) );
    return v.toString();
}
Beispiel #7
0
void KIntSpinBox::setSuffix(const KLocalizedString& suffix)
{
    d->pluralSuffix = suffix;
    if (suffix.isEmpty())
        setSuffix(QString());
    else
        d->updateSuffix(value());
}
QString
ConstraintTypes::PlaylistLength::getName() const
{

    KLocalizedString v;
    if ( m_comparison == CompareNumEquals ) {
        v = ki18nc( "%1 is a number", "Playlist length: %1 tracks");
    } else if ( m_comparison == CompareNumGreaterThan ) {
        v = ki18nc( "%1 is a number", "Playlist length: more than %1 tracks");
    } else if ( m_comparison == CompareNumLessThan ) {
        v = ki18nc( "%1 is a number", "Playlist length: less than %1 tracks");
    } else {
        v = ki18n( "Playlist length: unknown");
    }
    v = v.subs( m_length );
    return v.toString();
}
KPAboutData::KPAboutData(const KLocalizedString& pluginName,
                         const QByteArray& /*pluginVersion*/,
                         enum  KAboutLicense::LicenseKey licenseType,
                         const KLocalizedString& pluginDescription,
                         const KLocalizedString& copyrightStatement)
    : QObject(),
      KAboutData(QStringLiteral("kipiplugins"),  // Name without minus separator for KDE bug report.
                 pluginName.toString(),
                 kipipluginsVersion(),
                 pluginDescription.toString(),
                 licenseType,
                 copyrightStatement.toString(),
                 QStringLiteral(),
                 QStringLiteral("http://www.digikam.org"))
{
    QString directory = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
                                               QStringLiteral("kf5/kipi/pics/kipi-plugins_logo.png"));

    // set the kipiplugins logo inside the about dialog
    setProgramLogo(QImage(directory));

    // set the plugin description into long text description
    setOtherText(pluginDescription.toString());

    // put the plugin name and version with kipi-plugins and kipi-plugins version
    KLocalizedString shortDesc = additionalInformation();

    qCDebug(KIPIPLUGINS_LOG) << shortDesc.toString().constData() ;

    // and set the string into the short description
    setShortDescription(shortDesc.toString());
}
Beispiel #10
0
void VirtualDesktopManager::addAction(const QString &name, const KLocalizedString &label, uint value, const QKeySequence &key, void (VirtualDesktopManager::*slot)())
{
    QAction *a = new QAction(this);
    a->setObjectName(name.arg(value));
    a->setText(label.subs(value).toString());
    a->setData(value);
    KGlobalAccel::setGlobalShortcut(a, key);
    input()->registerShortcut(key, a, this, slot);
}
Beispiel #11
0
void AbstractCommand::emitErrorSeeHelp( const KLocalizedString &msg )
{
  QString s;
  if (CommandShell::isActive())
  {
    s = ki18nc("@info:shell %1 is subcommand name, %2 is error message",
               "%2. See 'help %1'")
      .subs( this->name() )
      .subs( msg.toString() ).toString();
  }
  else
  {
    s = ki18nc("@info:shell %1 is application name, %2 is subcommand name, %3 is error message",
               "%3. See '<application>%1</application> help %2'")
      .subs( KCmdLineArgs::appName() )
      .subs( this->name() )
      .subs( msg.toString() ).toString();
  }

  emit error(s);
}
KPAboutData::KPAboutData(const KLocalizedString& pluginName,
                         const QByteArray& /*pluginVersion*/,
                         enum  LicenseKey licenseType,
                         const KLocalizedString& pluginDescription,
                         const KLocalizedString& copyrightStatement)
           : KAboutData (QByteArray("kipiplugins"),  // Name without minus separator for KDE bug report.
                         QByteArray(),
                         pluginName,
                         kipipluginsVersion().toAscii(),
                         KLocalizedString(),
                         licenseType,
                         copyrightStatement,
                         pluginDescription,
                         QByteArray("http://www.digikam.org"))
{
    if (KGlobal::hasMainComponent())
    {
        // setProgramLogo is defined from kde 3.4.0 on
        QString directory = KStandardDirs::locate("data", "kipi/data/kipi-plugins_logo.png");

        // set the kipiplugins logo inside the about dialog
        setProgramLogo(QImage(directory));
    }

    // set the plugin description into long text description
    setOtherText(pluginDescription);

    // put the plugin name and version with kipi-plugins and kipi-plugins version
    KLocalizedString shortDesc = additionalInformation();

    if (KGlobal::hasMainComponent())
    {
        kDebug(AREA_CODE_LOADING) << shortDesc.toString().constData() ;
    }

    // and set the string into the short description
    setShortDescription(shortDesc);
}
Beispiel #13
0
/* called by the player when someone has changed the volume. Update
 * all our widgets, but do NOT change player volume from this method.
 * The Player is already set to new volume value when this is called.
 * @param newVolume has range 0.0 - 1.0.
 */
void VolumePopupButton::slotVolumeChanged( float newVolume )
{
    //kDebug() << "newVolume is " << newVolume;

    bool isMuted = player->muted() || newVolume < 0.01;

    // update icon for our toolbar button
    if ( isMuted )
        setIcon( KIcon( "audio-volume-muted" ) );
    else if ( newVolume < 0.34 )
        setIcon( KIcon( "audio-volume-low" ) );
    else if ( newVolume < 0.67 )
        setIcon( KIcon( "audio-volume-medium" ) );
    else
        setIcon( KIcon( "audio-volume-high" ) );

    m_volumeLabel->setText( i18n( "%1%" , int( newVolume * 100 ) ) );

    // only update if user not dragging it's slider
    if (!m_volumeSlider->isSliderDown()) {
        // emits valueChanged() but not volumeChanged()
        m_volumeSlider->setValue( newVolume * 100 );
    }

    // mimic MPlayer's auto-unmute behavior
    if ( player->muted() && newVolume >= 0.01 ) {
        player->setMuted(false);
    }

    // tooltip for toolbar button
    const KLocalizedString tip = ki18n( "Volume: %1%" );
    this->setToolTip( tip.subs( int( 100 * newVolume ) ).toString() );

    m_prevVolume = m_curVolume;
    m_curVolume  = newVolume;
}
Beispiel #14
0
void CalibrateFlossDlg::updateName(bool modified)
{
    KLocalizedString str = modified ? ki18nc("%1 is floss name, %2 is floss description", "%1-%2 (Modified)") : ki18nc("%1 is floss name, %2 is floss description", "%1-%2");
    ui.SelectedColorName->setText(str.subs(m_item->data(Qt::UserRole).toString()).subs(m_item->data(Qt::UserRole + 1).toString()).toString());
}
Beispiel #15
0
QString Goal::message(int displayType) const
{
  kDebug();
  KLocalizedString res;

//   std::set<unsigned int>::const_iterator it, it_end, it_next;
  
  if(type()==NoGoal)
  {
    QString mes = (QString)"You must conquer the World !";
    return mes;
  }
  else
  {
    if (displayType & GoalDesc)
    {
      res = ki18n(m_description.toUtf8().data());
/*      if (m_player == 0)
      {
        res = res.subs("");
      }
      else
      {
        res = res.subs(m_player->name());
      }*/
      kDebug() << "Goal type='" << m_type << "' mes = '" << res.toString() << "'" << endl;
    
      QList<unsigned int>::const_iterator it, it_end;
      switch (m_type)
      {
      case Goal::GoalPlayer :
        if (!m_players.empty())
        {
          kDebug() << "  player name='" << *m_players.begin() << endl;
          res = res.subs(m_nbCountries);
        }
        else
        {
          res = res.subs(i18n("Error: no player to destroy"));
        }
        break;
      case Goal::Countries:
        kDebug() << "  arg1 = '" << m_nbCountries << "'" << endl;
        res=res.subs(m_nbCountries);
        if (m_nbArmiesByCountry > 0)
        {
          kDebug() << "  arg2 = '" << m_nbArmiesByCountry << "'" << endl;
          res=res.subs(m_nbArmiesByCountry);
        }
        break;
      case Goal::Continents:
//         it = m_continents.begin(); it_end = m_continents.end();
//         for (; it != it_end; it++)
//         {
//           if (*it != 0)
//           {
/*            kDebug() << "  arg = '" << m_automaton->game()->theWorld()->continentWithId(*it)->name() << "'" << endl;
            res=res.subs(i18n(m_automaton->game()->theWorld()->continentWithId(*it)->name().toUtf8().data()));*/
//           }
//         }
        break;
      default:;
      }
    }
  }

  QString mes = res.toString();
  if (displayType & GoalAdvance)
  {
//     int diff = 0;
    switch (m_type)
    {
    case Goal::GoalPlayer :
/*      if (m_automaton->playerNamed(*m_players.begin()) != 0)
      {
        mes += i18n("<br>%1 is still alive...",*m_players.begin());
      }
      else
      {
        mes += i18n("<br>You now have to conquer %1",m_nbCountries);
      }*/
    break;
    case Goal::Countries:
//       diff  = m_nbCountries-m_player->countries().size();
//       if (diff > 0)
//       {
//         mes += i18n("<br>%1, you have still %2 countries to conquer...",m_player->name(),diff);
//       }
//       else
//       {
//         int nbOk = 0;
//         for (unsigned int i = 0; i < m_player->countries().size();i++)
//         {
//           if (m_player->countries().at(i)->nbArmies() >= m_nbArmiesByCountry)
//           {
//             nbOk++;
//           }
//         }
//         mes += i18n("<br>%1, you have enough countries but you still have to put more than %2 armies on %3 of them...",m_player->name(),m_nbArmiesByCountry,m_nbCountries-nbOk);
//         
//       }
      break;
    case Goal::Continents:
/*      mes += i18n("<br>%1, you still have to conquer ",m_player->name());
      it = m_continents.begin(); it_end = m_continents.end();
      if (*it != 0)
      {
        Continent* continent = const_cast<Continent*>(m_automaton->game()->theWorld()->continentWithId(*it));
        int nb = continent->getMembers().size() - continent->countriesOwnedBy(m_player).size();
        mes += i18n("%1 countries in %2",nb,continent->name());
      }
      it++;
      while (it != it_end)
      {
        it_next = it;
        it_next++;
        QString joint;
        if (it_next==it_end)
        {
          joint = i18n(" and ");
        }
        else
        {
          joint = i18n(", ");
        }
        if (*it != 0)
        {
          Continent* continent = const_cast<Continent*>(m_automaton->game()->theWorld()->continentWithId(*it));
          int nb = continent->getMembers().size() - continent->countriesOwnedBy(m_player).size();
          mes += joint + i18nc("@info An element of the enumeration of the number of countries in the given continent", "%1 in %2",nb,continent->name());
        }
        it++;
      }
      mes += '.';*/
      break;
    default:
      break;
;
    }
  }

  return mes;
}
Beispiel #16
0
void KLocalizedStringTest::miscMethods ()
{
    KLocalizedString k;
    QVERIFY(k.isEmpty());
}
Beispiel #17
0
bool KNewLoanWizard::validateCurrentPage()
{
  bool dontLeavePage = false;
  KLocalizedString ks = ki18n(
                          "The loan wizard is unable to calculate two different values for your loan "
                          "at the same time. "
                          "Please enter a value for the %1 on this page or backup to the page where the "
                          "current value to be calculated is defined and fill in a value.");

  if (currentPage() == m_lendBorrowPage) {
    // load the appropriate categories into the list
    loadAccountList();

  } else if (currentPage() == m_interestTypePage) {
    if (field("fixedInterestButton").toBool()) {
      m_pages.setBit(Page_PreviousPayments);
      if (field("previousPaymentButton").toBool())
        m_pages.setBit(Page_RecordPayment);
      else
        m_pages.clearBit(Page_RecordPayment);
      m_pages.clearBit(Page_VariableInterestDate);

    } else {
      m_pages.clearBit(Page_PreviousPayments);
      m_pages.clearBit(Page_RecordPayment);
      m_pages.setBit(Page_VariableInterestDate);
    }

  } else if (currentPage() == m_previousPaymentsPage) {
    if (field("previousPaymentButton").toBool()) {
      m_pages.setBit(Page_RecordPayment);
    } else if (field("noPreviousPaymentButton").toBool()) {
      m_pages.clearBit(Page_RecordPayment);
    }
  } else if (currentPage() == m_loanAmountPage) {
    if (field("thisYearPaymentButton").toBool()
        && !field("loanAmountEditValid").toBool()) {
      dontLeavePage = true;
      KMessageBox::error(0, i18n("You selected, that payments have already been made towards this loan. "
                                 "This requires you to enter the loan amount exactly as found on your "
                                 "last statement."), i18n("Calculation error"));
    } else
      updateLoanAmount();

  } else if (currentPage() == m_interestPage) {

    if (!field("loanAmountEditValid").toBool()
        && !field("interestRateEditValid").toBool()) {
      dontLeavePage = true;
      KMessageBox::error(0, ks.subs(i18n("interest rate")).toString(), i18n("Calculation error"));
    } else
      updateInterestRate();

  } else if (currentPage() == m_durationPage) {
    if ((!field("loanAmountEditValid").toBool()
         || !field("interestRateEditValid").toBool())
        && field("durationValueEdit").toInt() == 0) {
      dontLeavePage = true;
      KMessageBox::error(0, ks.subs(i18n("term")).toString(), i18n("Calculation error"));
    } else
      updateDuration();

  } else if (currentPage() == m_paymentPage) {
    if ((!field("loanAmountEditValid").toBool()
         || !field("interestRateEditValid").toBool()
         || field("durationValueEdit").toInt() == 0)
        && !field("paymentEditValid").toBool()) {
      dontLeavePage = true;
      KMessageBox::error(0, ks.subs(i18n("principal and interest")).toString(), i18n("Calculation error"));
    } else
      updatePayment();

  } else if (currentPage() == m_finalPaymentPage) {
    if ((!field("loanAmountEditValid").toBool()
         || !field("interestRateEditValid").toBool()
         || field("durationValueEdit").toInt() == 0
         || !field("paymentEditValid").toBool())
        && !field("finalPaymentEditValid").toBool()) {
      // if two fields are empty and one of them is the final payment
      // we assume the final payment to be 0 instead of presenting a dialog
      setField("finalPaymentEdit", QVariant::fromValue<MyMoneyMoney>((MyMoneyMoney())));
    }
    updateFinalPayment();
    if (!calculateLoan()) {
      dontLeavePage = true;
    } else
      updateLoanInfo();
  } else if (currentPage() == m_schedulePage) {
    if (field("allPaymentsButton").toBool() || field("noPreviousPaymentButton").toBool()) {
      if (m_assetAccountPage)
        m_pages.setBit(Page_AssetAccount);
    } else {
      if (m_assetAccountPage)
        m_pages.clearBit(Page_AssetAccount);
      m_assetAccountPage->m_assetAccountEdit->slotDeselectAllAccounts();
    }
  }

  if (!dontLeavePage)
    return KNewLoanWizardDecl::validateCurrentPage();
  else
    return false;
}