Пример #1
0
void VConfigManager::readCustomColors()
{
    m_customColors.clear();
    QStringList str = getConfigFromSettings("global", "custom_colors").toStringList();

    for (auto const & item : str) {
        QStringList parts = item.split(':', QString::SkipEmptyParts);
        if (parts.size() != 2) {
            continue;
        }

        if (!QColor(parts[1]).isValid()) {
            continue;
        }

        VColor color;
        color.m_name = parts[0];
        color.m_color = parts[1];
        m_customColors.append(color);
    }
}
Пример #2
0
void VConfigManager::initDocSuffixes()
{
    m_docSuffixes.clear();

    QStringList mdSuffix = getConfigFromSettings("global",
                                                 "markdown_suffix").toStringList();
    if (mdSuffix.isEmpty()) {
        mdSuffix = getDefaultConfig("global",
                                    "markdown_suffix").toStringList();
    }

    for (auto it = mdSuffix.begin(); it != mdSuffix.end();) {
        if (it->isEmpty()) {
            it = mdSuffix.erase(it);
        } else {
            *it = it->toLower();
            ++it;
        }
    }

    Q_ASSERT(!mdSuffix.isEmpty());

    mdSuffix.removeDuplicates();

    m_docSuffixes[(int)DocType::Markdown] = mdSuffix;

    QList<QString> list;
    list << "ls" << "list";
    m_docSuffixes[(int)DocType::List] = list;

    QList<QString> container;
    container << "co" << "container" << "con";
    m_docSuffixes[(int)DocType::Container] = container;

    QList<QString> html;
    html << "html";
    m_docSuffixes[(int)DocType::Html] = html;

    qDebug() << "doc suffixes" << m_docSuffixes;
}
EditableFilterDialog::EditableFilterDialog(Filters::EditableFilter * f, QWidget *parent) :
    BaseFilterDialog(tr("Editable filter dialog"), parent),
    ui(new Ui_EditableFilterDialog),
    _configDialog(new BuildConfigDialog()),
    _errorWidget(new BuildErrorWidget()),
    _model(f)
{

    ui->setupUi(this);

    setupEditor();

    // connect to model:
    connect(_model, &Filters::EditableFilter::badConfiguration, this, &EditableFilterDialog::onBadConfiguration);
    connect(_model, &Filters::EditableFilter::workFinished, this, &EditableFilterDialog::onWorkFinished);
    connect(_model, &Filters::EditableFilter::buildError, this, &EditableFilterDialog::onBuildError);

    // Configure the model:
    getConfigFromSettings();
    _model->runTestCmake();

    refreshCode();
}
Пример #4
0
void VConfigManager::initialize()
{
    initSettings();

    initThemes();

    initEditorStyles();

    initCssStyles();

    initCodeBlockCssStyles();

    m_theme = getConfigFromSettings("global", "theme").toString();

    m_editorStyle = getConfigFromSettings("global", "editor_style").toString();

    m_cssStyle = getConfigFromSettings("global", "css_style").toString();

    m_codeBlockCssStyle = getConfigFromSettings("global", "code_block_css_style").toString();

    m_defaultEditPalette = QTextEdit().palette();

    welcomePagePath = getConfigFromSettings("global", "welcome_page_path").toString();

    markdownExtensions = hoedown_extensions(HOEDOWN_EXT_TABLES | HOEDOWN_EXT_FENCED_CODE |
                                            HOEDOWN_EXT_HIGHLIGHT | HOEDOWN_EXT_AUTOLINK |
                                            HOEDOWN_EXT_QUOTE | HOEDOWN_EXT_MATH | HOEDOWN_EXT_MATH_EXPLICIT);
    mdConverterType = (MarkdownConverterType)getConfigFromSettings("global", "markdown_converter").toInt();

    tabStopWidth = getConfigFromSettings("global", "tab_stop_width").toInt();
    isExpandTab = getConfigFromSettings("global", "is_expand_tab").toBool();
    m_highlightCursorLine = getConfigFromSettings("global", "highlight_cursor_line").toBool();
    m_highlightSelectedWord = getConfigFromSettings("global", "highlight_selected_word").toBool();
    m_highlightSearchedWord = getConfigFromSettings("global", "highlight_searched_word").toBool();
    m_autoIndent = getConfigFromSettings("global", "auto_indent").toBool();
    m_autoList = getConfigFromSettings("global", "auto_list").toBool();

    readCustomColors();

    curBackgroundColor = getConfigFromSettings("global", "current_background_color").toString();

    updateEditStyle();

    curRenderBackgroundColor = getConfigFromSettings("global",
                                                     "current_render_background_color").toString();

    m_toolsDockChecked = getConfigFromSettings("global", "tools_dock_checked").toBool();

    m_findCaseSensitive = getConfigFromSettings("global",
                                                "find_case_sensitive").toBool();
    m_findWholeWordOnly = getConfigFromSettings("global",
                                                "find_whole_word_only").toBool();
    m_findRegularExpression = getConfigFromSettings("global",
                                                    "find_regular_expression").toBool();
    m_findIncrementalSearch = getConfigFromSettings("global",
                                                    "find_incremental_search").toBool();

    m_language = getConfigFromSettings("global", "language").toString();

    m_enableMermaid = getConfigFromSettings("global", "enable_mermaid").toBool();

    m_enableFlowchart = getConfigFromSettings("global", "enable_flowchart").toBool();

    m_enableMathjax = getConfigFromSettings("global", "enable_mathjax").toBool();

    m_webZoomFactor = getConfigFromSettings("global", "web_zoom_factor").toReal();
    if (!isCustomWebZoomFactor()) {
        // Calculate the zoom factor based on DPI.
        m_webZoomFactor = VUtils::calculateScaleFactor();
        qDebug() << "set WebZoomFactor to" << m_webZoomFactor;
    }

    m_enableCodeBlockHighlight = getConfigFromSettings("global",
                                                       "enable_code_block_highlight").toBool();

    m_enablePreviewImages = getConfigFromSettings("global",
                                                  "enable_preview_images").toBool();

    m_enablePreviewImageConstraint = getConfigFromSettings("global",
                                                           "enable_preview_image_constraint").toBool();

    m_enableImageConstraint = getConfigFromSettings("global",
                                                    "enable_image_constraint").toBool();

    m_enableImageCaption = getConfigFromSettings("global",
                                                 "enable_image_caption").toBool();

    m_imageFolder = getConfigFromSettings("global",
                                          "image_folder").toString();

    m_imageFolderExt = getConfigFromSettings("global",
                                             "external_image_folder").toString();

    m_attachmentFolder = getConfigFromSettings("global",
                                               "attachment_folder").toString();
    if (m_attachmentFolder.isEmpty()) {
        // Reset the default folder.
        m_attachmentFolder = resetDefaultConfig("global", "attachment_folder").toString();
    }

    m_enableTrailingSpaceHighlight = getConfigFromSettings("global",
                                                           "enable_trailing_space_highlight").toBool();

    m_enableVimMode = getConfigFromSettings("global",
                                            "enable_vim_mode").toBool();

    m_enableSmartImInVimMode = getConfigFromSettings("global",
                                                     "enable_smart_im_in_vim_mode").toBool();

    m_editorLineNumber = getConfigFromSettings("global",
                                               "editor_line_number").toInt();

    m_minimizeToSystemTray = getConfigFromSettings("global",
                                                   "minimize_to_system_tray").toInt();
    if (m_minimizeToSystemTray > 1 || m_minimizeToSystemTray < -1) {
        setMinimizeToSystemTray(0);
    }

    readShortcutsFromSettings();

    readCaptainShortcutsFromSettings();

    initDocSuffixes();

    m_markdownHighlightInterval = getConfigFromSettings("global",
                                                        "markdown_highlight_interval").toInt();

    m_lineDistanceHeight = getConfigFromSettings("global",
                                                 "line_distance_height").toInt();

    m_insertTitleFromNoteName = getConfigFromSettings("global",
                                                      "insert_title_from_note_name").toBool();

    int openMode = getConfigFromSettings("global",
                                         "note_open_mode").toInt();
    if (openMode == 1) {
        m_noteOpenMode = OpenFileMode::Edit;
    } else {
        m_noteOpenMode = OpenFileMode::Read;
    }

    int tmpHeadingSequenceType = getConfigFromSettings("global",
                                                       "heading_sequence_type").toInt();
    if (tmpHeadingSequenceType < (int)HeadingSequenceType::Invalid
        && tmpHeadingSequenceType >= (int)HeadingSequenceType::Disabled) {
        m_headingSequenceType = (HeadingSequenceType)tmpHeadingSequenceType;
    } else {
        m_headingSequenceType = HeadingSequenceType::Disabled;
    }

    m_headingSequenceBaseLevel = getConfigFromSettings("global",
                                                       "heading_sequence_base_level").toInt();

    m_colorColumn = getConfigFromSettings("global", "color_column").toInt();

    m_enableCodeBlockLineNumber = getConfigFromSettings("global",
                                                        "enable_code_block_line_number").toBool();

    m_toolBarIconSize = getConfigFromSettings("global",
                                              "tool_bar_icon_size").toInt();

    m_markdownitOptHtml = getConfigFromSettings("global",
                                                "markdownit_opt_html").toBool();

    m_markdownitOptBreaks = getConfigFromSettings("global",
                                                  "markdownit_opt_breaks").toBool();

    m_markdownitOptLinkify = getConfigFromSettings("global",
                                                   "markdownit_opt_linkify").toBool();

    m_recycleBinFolder = getConfigFromSettings("global",
                                               "recycle_bin_folder").toString();

    m_recycleBinFolderExt = getConfigFromSettings("global",
                                                  "external_recycle_bin_folder").toString();

    m_confirmImagesCleanUp = getConfigFromSettings("global",
                                                   "confirm_images_clean_up").toBool();

    m_confirmReloadFolder = getConfigFromSettings("global",
                                                  "confirm_reload_folder").toBool();

    m_mathjaxJavascript = getConfigFromSettings("web",
                                                "mathjax_javascript").toString();

    m_doubleClickCloseTab = getConfigFromSettings("global",
                                                  "double_click_close_tab").toBool();

    m_enableCompactMode = getConfigFromSettings("global",
                                                "enable_compact_mode").toBool();

    int tmpStartupPageMode = getConfigFromSettings("global",
                                                   "startup_page_type").toInt();
    if (tmpStartupPageMode < (int)StartupPageType::Invalid
        && tmpStartupPageMode >= (int)StartupPageType::None) {
        m_startupPageType = (StartupPageType)tmpStartupPageMode;
    } else {
        m_startupPageType = StartupPageType::None;
    }

    m_startupPages = getConfigFromSettings("global",
                                           "startup_pages").toStringList();

    initFromSessionSettings();

    m_fileTimerInterval = getConfigFromSettings("global",
                                                "file_timer_interval").toInt();
    if (m_fileTimerInterval < 100) {
        m_fileTimerInterval = 100;
    }

    m_backupDirectory = getConfigFromSettings("global",
                                              "backup_directory").toString();

    m_backupExtension = getConfigFromSettings("global",
                                              "backup_extension").toString();
    if (m_backupExtension.isEmpty()) {
        m_backupExtension = ".";
    }

    m_enableBackupFile = getConfigFromSettings("global",
                                               "enable_backup_file").toBool();

    m_vimExemptionKeys = getConfigFromSettings("global",
                                               "vim_exemption_keys").toString();

    m_closeBeforeExternalEditor = getConfigFromSettings("global",
                                                        "close_before_external_editor").toBool();

    m_fixImageSrcInWebWhenCopied = getConfigFromSettings("web",
                                                         "fix_img_src_when_copied").toBool();

    m_stylesToRemoveWhenCopied = getConfigFromSettings("web",
                                                       "styles_to_remove_when_copied").toStringList();

    m_stylesToInlineWhenCopied = getConfigFromSettings("web",
                                                       "styles_to_inline_when_copied").toStringList().join(",");
}