Ejemplo n.º 1
0
  void Config::loadEmailSettings()
  {
    KEMailSettings kes;
    kes.setProfile( kes.defaultProfileName() );

    static_cast<KConfigSkeleton::ItemString *>(findItem(QLatin1String( "emailAddress" )))
      ->setDefaultValue(kes.getSetting( KEMailSettings::EmailAddress ));
    static_cast<KConfigSkeleton::ItemString *>(findItem(QLatin1String( "replyTo" )))
      ->setDefaultValue(kes.getSetting( KEMailSettings::ReplyToAddress ));
    static_cast<KConfigSkeleton::ItemString *>(findItem(QLatin1String( "smtpHostname" )))
      ->setDefaultValue(kes.getSetting( KEMailSettings::OutServer ));
  }
Ejemplo n.º 2
0
void kthememanager::slotCreateTheme()
{
    KNewThemeDlg dlg( this );

    KEMailSettings es;
    es.setProfile( es.defaultProfileName() );

    dlg.setName( i18n( "My Theme" ) );
    dlg.setAuthor( es.getSetting( KEMailSettings::RealName ) ) ;
    dlg.setEmail( es.getSetting( KEMailSettings::EmailAddress ) );
    dlg.setVersion( "0.1" );

    if ( dlg.exec() == QDialog::Accepted )
    {

        QString themeName = dlg.getName();
        if ( themeExist(themeName) )
        {
            KMessageBox::information( this, i18n( "Theme %1 already exists." ).arg( themeName ) );
        }
        else
        {
            if ( getThemeVersion( themeName ) != -1 ) // remove the installed theme first
            {
                KTheme::remove( themeName );
            }
            m_theme = new KTheme( this, true );
            m_theme->setName( dlg.getName() );
            m_theme->setAuthor( dlg.getAuthor() );
            m_theme->setEmail( dlg.getEmail() );
            m_theme->setHomepage( dlg.getHomepage() );
            m_theme->setComment( dlg.getComment().replace( "\n", "" ) );
            m_theme->setVersion( dlg.getVersion() );

            QString result = m_theme->createYourself( true );
	    m_theme->addPreview();

            if ( !result.isEmpty() )
                KMessageBox::information( this, i18n( "Your theme has been successfully created in %1." ).arg( result ),
                                          i18n( "Theme Created" ), "theme_created_ok" );
            else
                KMessageBox::error( this, i18n( "An error occurred while creating your theme." ),
                                    i18n( "Theme Not Created" ) );
            delete m_theme;
            m_theme = 0;

            listThemes();
        }
    }
}
Ejemplo n.º 3
0
void SetupServer::readSettings()
{
    m_folderArchiveSettingPage->loadSettings();
    m_ui->accountName->setText(m_parentResource->name());
    m_oldResourceName = m_ui->accountName->text();

    KUser *currentUser = new KUser();
    KEMailSettings esetting;

    m_ui->imapServer->setText(
        !m_parentResource->settings()->imapServer().isEmpty() ? m_parentResource->settings()->imapServer() :
        esetting.getSetting(KEMailSettings::InServer));

    m_ui->portSpin->setValue(m_parentResource->settings()->imapPort());

    m_ui->userName->setText(
        !m_parentResource->settings()->userName().isEmpty() ? m_parentResource->settings()->userName() :
        currentUser->loginName());

    const QString safety = m_parentResource->settings()->safety();
    int i = 0;
    if (safety == QLatin1String("SSL")) {
        i = KIMAP::LoginJob::AnySslVersion;
    } else if (safety == QLatin1String("STARTTLS")) {
        i = KIMAP::LoginJob::TlsV1;
    } else {
        i = KIMAP::LoginJob::Unencrypted;
    }

    QAbstractButton *safetyButton = m_ui->safeImapGroup->button(i);
    if (safetyButton) {
        safetyButton->setChecked(true);
    }

    populateDefaultAuthenticationOptions();
    i = m_parentResource->settings()->authentication();
    qCDebug(IMAPRESOURCE_LOG) << "read IMAP auth mode: " << authenticationModeString((MailTransport::Transport::EnumAuthenticationType::type) i);
    setCurrentAuthMode(m_ui->authenticationCombo, (MailTransport::Transport::EnumAuthenticationType::type) i);

    i = m_parentResource->settings()->alternateAuthentication();
    setCurrentAuthMode(m_ui->authenticationAlternateCombo, (MailTransport::Transport::EnumAuthenticationType::type) i);

    bool rejected = false;
    const QString password = m_parentResource->settings()->password(&rejected);
    if (rejected) {
        m_ui->password->setEnabled(false);
        KMessageBox::information(Q_NULLPTR, i18n("Could not access KWallet. "
                                 "If you want to store the password permanently then you have to "
                                 "activate it. If you do not "
                                 "want to use KWallet, check the box below, but note that you will be "
                                 "prompted for your password when needed."),
                                 i18n("Do not use KWallet"), QStringLiteral("warning_kwallet_disabled"));
    } else {
        m_ui->password->insert(password);
    }

    m_ui->subscriptionEnabled->setChecked(m_parentResource->settings()->subscriptionEnabled());

    m_ui->checkInterval->setValue(m_parentResource->settings()->intervalCheckTime());
    m_ui->disconnectedModeEnabled->setChecked(m_parentResource->settings()->disconnectedModeEnabled());

    m_ui->managesieveCheck->setChecked(m_parentResource->settings()->sieveSupport());
    m_ui->sameConfigCheck->setChecked(m_parentResource->settings()->sieveReuseConfig());
    m_ui->sievePortSpin->setValue(m_parentResource->settings()->sievePort());
    m_ui->alternateURL->setText(m_parentResource->settings()->sieveAlternateUrl());
    m_vacationFileName = m_parentResource->settings()->sieveVacationFilename();

    Akonadi::Collection trashCollection(m_parentResource->settings()->trashCollection());
    if (trashCollection.isValid()) {
        Akonadi::CollectionFetchJob *fetchJob = new Akonadi::CollectionFetchJob(trashCollection, Akonadi::CollectionFetchJob::Base, this);
        connect(fetchJob, &Akonadi::CollectionFetchJob::collectionsReceived, this, &SetupServer::targetCollectionReceived);
    } else {
        Akonadi::SpecialMailCollectionsRequestJob *requestJob = new Akonadi::SpecialMailCollectionsRequestJob(this);
        connect(requestJob, &Akonadi::SpecialMailCollectionsRequestJob::result, this, &SetupServer::localFolderRequestJobFinished);
        requestJob->requestDefaultCollection(Akonadi::SpecialMailCollections::Trash);
        requestJob->start();
    }

    m_ui->useDefaultIdentityCheck->setChecked(m_parentResource->settings()->useDefaultIdentity());
    if (!m_ui->useDefaultIdentityCheck->isChecked()) {
        m_identityCombobox->setCurrentIdentity(m_parentResource->settings()->accountIdentity());
    }

    m_ui->enableMailCheckBox->setChecked(m_parentResource->settings()->intervalCheckEnabled());
    if (m_ui->enableMailCheckBox->isChecked()) {
        m_ui->checkInterval->setValue(m_parentResource->settings()->intervalCheckTime());
    } else {
        m_ui->checkInterval->setEnabled(false);
    }

    m_ui->autoExpungeCheck->setChecked(m_parentResource->settings()->automaticExpungeEnabled());

    if (m_vacationFileName.isEmpty()) {
        m_vacationFileName = QStringLiteral("kmail-vacation.siv");
    }

    m_ui->customUsername->setText(m_parentResource->settings()->sieveCustomUsername());

    rejected = false;
    const QString customPassword = m_parentResource->settings()->sieveCustomPassword(&rejected);
    if (rejected) {
        m_ui->customPassword->setEnabled(false);
        KMessageBox::information(Q_NULLPTR, i18n("Could not access KWallet. "
                                 "If you want to store the password permanently then you have to "
                                 "activate it. If you do not "
                                 "want to use KWallet, check the box below, but note that you will be "
                                 "prompted for your password when needed."),
                                 i18n("Do not use KWallet"), QStringLiteral("warning_kwallet_disabled"));
    } else {
        m_ui->customPassword->insert(customPassword);
    }

    const QString sieverCustomAuth(m_parentResource->settings()->sieveCustomAuthentification());
    if (sieverCustomAuth == QLatin1String("ImapUserPassword")) {
        m_ui->imapUserPassword->setChecked(true);
    } else if (sieverCustomAuth == QLatin1String("NoAuthentification")) {
        m_ui->noAuthentification->setChecked(true);
    } else if (sieverCustomAuth == QLatin1String("CustomUserPassword")) {
        m_ui->customUserPassword->setChecked(true);
    }

    delete currentUser;
}
void KstSettings::reload() {
  KConfig cfg("kstrc");

  cfg.setGroup("Kst");
  plotUpdateTimer = cfg.readNumEntry("Plot Update Timer", 200);
  plotFontSize    = cfg.readNumEntry("Plot Font Size", 12);
  plotFontMinSize = cfg.readNumEntry("Plot Font Min Size", 5);
  backgroundColor = cfg.readColorEntry("Background Color", &backgroundColor);
  foregroundColor = cfg.readColorEntry("Foreground Color", &foregroundColor);
  promptPlotDelete = cfg.readBoolEntry("Prompt on Plot Delete", false);
  promptWindowClose = cfg.readBoolEntry("Prompt on Window Close", true);
  showQuickStart = cfg.readBoolEntry("Show QuickStart", true);
  tiedZoomGlobal = cfg.readBoolEntry("Tied-zoom Global", true);
  curveColorSequencePalette = cfg.readEntry("Curve Color Sequence", "Kst Colors");
  
  timezone = cfg.readEntry("Timezone", "UTC");
  offsetSeconds = cfg.readNumEntry("OffsetSeconds", 0);
  
  cfg.setGroup("Grid Lines");
  xMajor = cfg.readBoolEntry("X Major", false);
  yMajor = cfg.readBoolEntry("Y Major", false);
  xMinor = cfg.readBoolEntry("X Minor", false);
  yMinor = cfg.readBoolEntry("Y Minor", false);
  majorColor = cfg.readColorEntry("Major Color", &majorColor);
  minorColor = cfg.readColorEntry("Minor Color", &minorColor);
  majorGridColorDefault = cfg.readBoolEntry("Default Major Color", true);
  minorGridColorDefault = cfg.readBoolEntry("Default Minor Color", true);

  cfg.setGroup("X Axis");
  xAxisInterpret = cfg.readBoolEntry("Interpret", false);
  xAxisInterpretation = (KstAxisInterpretation)cfg.readNumEntry("Interpretation", AXIS_INTERP_CTIME);
  xAxisDisplay = (KstAxisDisplay)cfg.readNumEntry("Display", AXIS_DISPLAY_QTLOCALDATEHHMMSS_SS);
  cfg.setGroup("Y Axis");
  yAxisInterpret = cfg.readBoolEntry("Interpret", false);
  yAxisInterpretation = (KstAxisInterpretation)cfg.readNumEntry("Interpretation", AXIS_INTERP_CTIME);
  yAxisDisplay = (KstAxisDisplay)cfg.readNumEntry("Display", AXIS_DISPLAY_QTLOCALDATEHHMMSS_SS);

  cfg.setGroup("Curve");
  defaultLineWeight = cfg.readNumEntry("DefaultLineWeight", 0);
  
  cfg.setGroup("EMail");
  KEMailSettings es;
  emailSender = cfg.readEntry("Sender", es.getSetting(KEMailSettings::EmailAddress));
  emailSMTPServer = cfg.readEntry("Server", es.getSetting(KEMailSettings::OutServer));
  emailSMTPPort = cfg.readNumEntry("Port", 25); // FIXME: no KEMailSettings for this?
  emailRequiresAuthentication = cfg.readBoolEntry("Authenticate", !es.getSetting(KEMailSettings::OutServerLogin).isEmpty());
  emailUsername = cfg.readEntry("Username", es.getSetting(KEMailSettings::OutServerLogin));
  emailPassword = cfg.readEntry("Password", es.getSetting(KEMailSettings::OutServerPass));
  emailEncryption = (EMailEncryption)cfg.readNumEntry("Encryption", es.getSetting(KEMailSettings::OutServerTLS) == "true" ? EMailEncryptionTLS : EMailEncryptionNone);
  emailAuthentication = (EMailAuthentication)cfg.readNumEntry("Authentication", EMailAuthenticationPLAIN); // FIXME: no KEMailSettings for this?

  cfg.setGroup("Printing");
  printing.pageSize = cfg.readEntry("kde-pagesize", QString::number((int)KPrinter::Letter));
  printing.orientation = cfg.readEntry("kde-orientation", "Landscape");
  printing.plotDateTimeFooter = cfg.readEntry("kst-plot-datetime-footer", "0");
  printing.maintainAspect = cfg.readEntry("kst-plot-maintain-aspect-ratio", "0");
  printing.curveWidthAdjust = cfg.readEntry("kst-plot-curve-width-adjust", "0");
  printing.monochrome = cfg.readEntry("kst-plot-monochrome", "0");
  printing.monochromeSettings.enhanceReadability = 
      cfg.readEntry("kst-plot-monochromesettings-enhancereadability", "0");
  printing.monochromeSettings.pointStyleOrder = 
      cfg.readEntry("kst-plot-monochromesettings-pointstyleorder", "0");
  printing.monochromeSettings.lineStyleOrder = 
      cfg.readEntry("kst-plot-monochromesettings-linestyleorder", "1");
  printing.monochromeSettings.lineWidthOrder = 
      cfg.readEntry("kst-plot-monochromesettings-linewidthorder", "2");
  printing.monochromeSettings.maxLineWidth = 
      cfg.readEntry("kst-plot-monochromesettings-maxlinewidth", "3");
  printing.monochromeSettings.pointDensity = 
      cfg.readEntry("kst-plot-monochromesettings-pointdensity", "2");
}
QString timetrackerstorage::load(TaskView* view, const QString &fileName)
// loads data from filename into view. If no filename is given, filename from preferences is used.
// filename might be of use if this program is run as embedded konqueror plugin.
{
    Q_UNUSED(fileName); // TODO: receive changes from akonadi
    kDebug(5970) << "Entering function";
    QString err;
    KEMailSettings settings;

    // If file doesn't exist, create a blank one to avoid ResourceLocal load
    // error.  We make it user and group read/write, others read.  This is
    // masked by the users umask.  (See man creat)
    if ( d->mCalendar )
        closeStorage();
    // Create local file resource and add to resources
    d->mICalFile = "";
    d->mCalendar = KTTCalendar::createInstance();

    QObject::connect( d->mCalendar.data(), SIGNAL(calendarChanged()),
                      view, SLOT(iCalFileModified()) );
    d->mCalendar->setTimeSpec( KSystemTimeZones::local() );
    d->mCalendar->reload();

    // Claim ownership of iCalendar file if no one else has.
    KCalCore::Person::Ptr owner = d->mCalendar->owner();
    if ( owner && owner->isEmpty() )
    {
        // TODO
        d->mCalendar->setOwner( KCalCore::Person::Ptr(
           new KCalCore::Person( settings.getSetting( KEMailSettings::RealName ),
                                 settings.getSetting( KEMailSettings::EmailAddress ) ) ) );
    }

    // TODO
    // Build task view from iCal data
    if (!err.isEmpty())
    {
        KCalCore::Todo::List todoList;
        KCalCore::Todo::List::ConstIterator todo;
        QMultiHash< QString, Task* > map;

        // Build dictionary to look up Task object from Todo uid.  Each task is a
        // QListViewItem, and is initially added with the view as the parent.
        todoList = d->mCalendar->rawTodos();
        kDebug(5970) << "timetrackerstorage::load"
            << "rawTodo count (includes completed todos) ="
            << todoList.count();
        for (todo = todoList.constBegin(); todo != todoList.constEnd(); ++todo)
        {
            Task* task = new Task(*todo, view);
            map.insert( (*todo)->uid(), task );
            view->setRootIsDecorated(true);
            task->setPixmapProgress();
        }

        // Load each task under it's parent task.
        for (todo = todoList.constBegin(); todo != todoList.constEnd(); ++todo)
        {
            Task* task = map.value( (*todo)->uid() );
            // No relatedTo incident just means this is a top-level task.
            if ( !(*todo)->relatedTo().isEmpty() )
            {
                Task *newParent = map.value( (*todo)->relatedTo() );

                // Complete the loading but return a message
                if ( !newParent )
                    err = i18n("Error loading \"%1\": could not find parent (uid=%2)",
                        task->name(), (*todo)->relatedTo()  );

                if (!err.isEmpty()) task->move( newParent );
            }
        }

        kDebug(5970) << "timetrackerstorage::load - loaded" << view->count()
            << "tasks from" << d->mICalFile;
    }

    if ( view ) buildTaskView(d->mCalendar->weakPointer(), view);

    this->save(view); // FIXME ?

    return err;
}