void PluginConfiguration::readGlobalConfig()
{
    // Read global config
    kDebug(DEBUG_AREA) << "Reading global config: " << KGlobal::config()->name();
    KConfigGroup gcg(KGlobal::config(), GLOBAL_CONFIG_GROUP_NAME);
    auto dirs = gcg.readPathEntry(CONFIGURED_DIRS_ITEM, QStringList{});
    kDebug(DEBUG_AREA) << "Got global configured include path list: " << dirs;
    m_system_dirs = dirs;
    readSanitizeRulesFrom(gcg, true);
    kDebug(DEBUG_AREA) << "Got" << m_sanitize_rules.size() << "sanitize rules total";
    //
    Q_EMIT(systemDirsChanged());
}
Exemplo n.º 2
0
CloseConfirmDialog::CloseConfirmDialog(
    QList<KTextEditor::Document*>& docs
  , KToggleAction* show_confirmation_action
  , QWidget* const parent
  )
  : QDialog(parent)
  , m_docs(docs)
{
    assert("Documents container expected to be non empty" && !docs.isEmpty());
    setupUi(this);
    
    setWindowTitle(i18nc("@title:window", "Close files confirmation"));
    setModal(true);
    buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
    
    icon->setPixmap(KIconLoader::global()->loadIcon(QStringLiteral("dialog-warning"),KIconLoader::Desktop,KIconLoader::SizeLarge));

    text->setText(
        i18nc("@label:listbox", "You are about to close the following documents:")
    );
    
    QStringList headers;
    headers << i18nc("@title:column", "Document") << i18nc("@title:column", "Location");
    m_docs_tree->setHeaderLabels(headers);
    m_docs_tree->setSelectionMode(QAbstractItemView::SingleSelection);
    m_docs_tree->setRootIsDecorated(false);

    for (int i = 0; i < m_docs.size(); i++)
    {
        new KateDocItem(m_docs[i], m_docs_tree);
    }
    m_docs_tree->header()->setStretchLastSection(false);
    m_docs_tree->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
    m_docs_tree->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);

    m_dont_ask_again->setText(i18nc("option:check", "Do not ask again"));
    // NOTE If we are here, it means that 'Show Confirmation' action is enabled,
    // so not needed to read config...
    assert("Sanity check" && show_confirmation_action->isChecked());
    m_dont_ask_again->setCheckState(Qt::Unchecked);
    connect(m_dont_ask_again, SIGNAL(toggled(bool)), show_confirmation_action, SLOT(toggle()));

    // Update documents list according checkboxes
    connect(this, SIGNAL(accepted()), this, SLOT(updateDocsList()));

    KConfigGroup gcg(KSharedConfig::openConfig(), "kate-close-except-like-CloseConfirmationDialog");
    KWindowConfig::restoreWindowSize(windowHandle(),gcg);                                 // restore dialog geometry from config
}
void PluginConfiguration::writeSessionConfig(KConfigBase* config, const QString& groupPrefix)
{
    kDebug(DEBUG_AREA) << "** CONFIG-MGR **: Writing session config: " << groupPrefix;
    if (!m_config_dirty)
    {
        kDebug(DEBUG_AREA) << "Config isn't dirty!!!";
        readSessionConfig(config, groupPrefix);
        return;
    }

    // Write session config
    KConfigGroup scg(config, groupPrefix + SESSION_GROUP_SUFFIX);
    scg.writePathEntry(CONFIGURED_DIRS_ITEM, m_session_dirs);
    scg.writePathEntry(PCH_FILE_ITEM, m_pch_header.toLocalFile());
    scg.writeEntry(CLANG_CMDLINE_PARAMS_ITEM, m_clang_params);
    scg.writeEntry(IGNORE_EXTENSIONS_ITEM, m_ignore_ext);
    scg.writeEntry(MONITOR_DIRS_ITEM, int(m_monitor_flags));
    scg.writeEntry(AUTO_COMPLETIONS_ITEM, m_auto_completions);
    scg.writeEntry(HIGHLIGHT_COMPLETIONS_ITEM, m_highlight_completions);
    scg.writeEntry(INCLUDE_MACROS_ITEM, m_include_macros);
    scg.writeEntry(OPEN_FIRST_INCLUDE_ITEM, m_open_first);
    scg.writeEntry(SANITIZE_COMPLETIONS_ITEM, m_sanitize_completions);
    scg.writeEntry(USE_CWD_ITEM, m_use_cwd);
    scg.writeEntry(USE_LT_GT_ITEM, m_use_ltgt);
    scg.writeEntry(USE_PREFIX_COLUMN_ITEM, m_use_prefix_column);
    scg.writeEntry(USE_WILDCARD_SEARCH_ITEM, m_use_wildcard_search);
    scg.writeEntry(APPEND_ON_IMPORT_ITEM, m_append_sanitizer_rules_on_import);
    {
        auto enabled_indices = QStringList{};
        for (const auto& index : m_enabled_indices)
            enabled_indices << index::toString(index);
        scg.writeEntry(ENABLED_INDICES_ITEM, enabled_indices);
    }

    scg.sync();

    // Write global config
    KConfigGroup gcg(KGlobal::config(), GLOBAL_CONFIG_GROUP_NAME);
    gcg.writePathEntry(CONFIGURED_DIRS_ITEM, m_system_dirs);
    writeSanitizeRulesTo(gcg);
    gcg.sync();
    m_config_dirty = false;
}
CloseConfirmDialog::CloseConfirmDialog(
    QList<KTextEditor::Document*>& docs
  , KToggleAction* show_confirmation_action
  , QWidget* const parent
  )
  : KDialog(parent)
  , m_docs(docs)
{
    assert("Documents container expected to be non empty" && !docs.isEmpty());

    setCaption(i18n("Close files confirmation"));
    setButtons(Ok | Cancel);
    setModal(true);
    setDefaultButton(KDialog::Ok);

    KVBox* w = new KVBox(this);
    setMainWidget(w);
    w->setSpacing(KDialog::spacingHint());

    KHBox* lo1 = new KHBox(w);

    // dialog text
    QLabel* icon = new QLabel(lo1);
    icon->setPixmap(DesktopIcon("dialog-warning"));

    QLabel* t = new QLabel(
        i18n(
            "<qt>You are about to close the following documents..."
            "<p>It is last chance to uncheck those you don't want to close ;-)</p></qt>"
          )
      , lo1
      );
    lo1->setStretchFactor(t, 1000);

    // document list
    m_docs_tree = new QTreeWidget(w);
    QStringList headers;
    headers << i18n("Document") << i18n("Location");
    m_docs_tree->setHeaderLabels(headers);
    m_docs_tree->setSelectionMode(QAbstractItemView::SingleSelection);
    m_docs_tree->setRootIsDecorated(false);

    for (int i = 0; i < m_docs.size(); i++)
    {
        new KateDocItem(m_docs[i], m_docs_tree);
    }
    m_docs_tree->header()->setStretchLastSection(false);
    m_docs_tree->header()->setResizeMode(0, QHeaderView::ResizeToContents);
    m_docs_tree->header()->setResizeMode(1, QHeaderView::ResizeToContents);

    m_dont_ask_again = new QCheckBox(i18n("Do not ask again"), w);
    // NOTE If we are here, it means that 'Show Confirmation' action is enabled,
    // so not needed to read config...
    assert("Sanity check" && show_confirmation_action->isChecked());
    m_dont_ask_again->setCheckState(Qt::Checked);
    connect(m_dont_ask_again, SIGNAL(toggled(bool)), show_confirmation_action, SLOT(setChecked(bool)));

    // Update documents list according checkboxes
    connect(this, SIGNAL(accepted()), this, SLOT(updateDocsList()));

    KConfigGroup gcg(KGlobal::config(), "CloseConfirmationDialog");
    restoreDialogSize(gcg);                                 // restore dialog geometry from config
}
CloseConfirmDialog::~CloseConfirmDialog()
{
    KConfigGroup gcg(KGlobal::config(), "CloseConfirmationDialog");
    saveDialogSize(gcg);                                    // write dialog geometry to config
    gcg.sync();
}
Exemplo n.º 6
0
CloseConfirmDialog::~CloseConfirmDialog()
{
    KConfigGroup gcg(KSharedConfig::openConfig(), "kate-close-except-like-CloseConfirmationDialog");
    KWindowConfig::saveWindowSize(windowHandle(),gcg);                                    // write dialog geometry to config
    gcg.sync();
}