[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/jackcoolpython/ghostwriter/master/src/PreferencesDialog.cpp [Back]  [Original]

/***********************************************************************
 *
 * Copyright (C) 2016 wereturtle
 * Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Graeme Gott 
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see .
 *
 ***********************************************************************/

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include "PreferencesDialog.h"
#include "AppSettings.h"
#include "LocaleDialog.h"
#include "MessageBoxHelper.h"
#include "dictionary_manager.h"

PreferencesDialog::PreferencesDialog(QWidget* parent)
    : QDialog(parent)
{
    this->setWindowTitle(tr("Preferences"));
    appSettings = AppSettings::getInstance();

    QTabWidget* tabWidget = new QTabWidget(this);

    QVBoxLayout* layout = new QVBoxLayout();
    layout->addWidget(tabWidget);
    this->setLayout(layout);

    tabWidget->addTab(initializeGeneralTab(), tr("General"));
    tabWidget->addTab(initializeEditorTab(), tr("Editor"));
    tabWidget->addTab(initializeSpellCheckTab(), tr("Spell Check"));
    tabWidget->addTab(initializeHudTab(), tr("HUD"));

    QDialogButtonBox* buttonBox = new QDialogButtonBox(Qt::Horizontal, this);
    buttonBox->addButton(QDialogButtonBox::Close);
    layout->addWidget(buttonBox);

    connect(buttonBox->button(QDialogButtonBox::Close), SIGNAL(clicked()), this, SLOT(close()));

    tabWidget->setCurrentIndex(0);
}

PreferencesDialog::~PreferencesDialog()
{

}

void PreferencesDialog::onFocusModeChanged(int index)
{
    QComboBox* combo = (QComboBox*) sender();
    appSettings->setFocusMode((FocusMode) combo->itemData(index).toInt());
}

void PreferencesDialog::onEditorWidthChanged(int index)
{
    QComboBox* combo = (QComboBox*) sender();
    appSettings->setEditorWidth((EditorWidth) combo->itemData(index).toInt());
}

void PreferencesDialog::onInterfaceStyleChanged(int index)
{
    QComboBox* combo = (QComboBox*) sender();
    appSettings->setInterfaceStyle((InterfaceStyle) combo->itemData(index).toInt());
}

void PreferencesDialog::onBlockquoteStyleChanged(int index)
{
    QComboBox* combo = (QComboBox*) sender();
    appSettings->setBlockquoteStyle((BlockquoteStyle) combo->itemData(index).toInt());
}

void PreferencesDialog::onEmphasisStyleChanged(int index)
{
    QComboBox* combo = (QComboBox*) sender();
    appSettings->setUseUnderlineForEmphasis(combo->itemData(index).toBool());
}

void PreferencesDialog::onDictionaryChanged(int index)
{
    QComboBox* combo = (QComboBox*) sender();
    QString language = combo->itemData(index).toString();

    DictionaryManager::instance().setDefaultLanguage(language);
    appSettings->setDictionaryLanguage(language);
}

void PreferencesDialog::onHudWindowButtonLayoutChanged(int index)
{
    QComboBox* combo = (QComboBox*) sender();
    appSettings->setHudButtonLayout((HudWindowButtonLayout) combo->itemData(index).toInt());
}

void PreferencesDialog::showAutoMatchFilterDialog()
{
    QDialog autoMatchFilterDialog(this);
    autoMatchFilterDialog.setWindowTitle(tr("Matched Characters"));

    QGridLayout* layout = new QGridLayout();

    QCheckBox* autoMatchDoubleQuotesCheckbox = new QCheckBox("\"");
    autoMatchDoubleQuotesCheckbox->setCheckable(true);
    autoMatchDoubleQuotesCheckbox->setChecked(appSettings->getAutoMatchCharEnabled('\"'));
    layout->addWidget(autoMatchDoubleQuotesCheckbox, 0, 0);

    QCheckBox* autoMatchSingleQuotesCheckbox = new QCheckBox("\'");
    autoMatchSingleQuotesCheckbox->setCheckable(true);
    autoMatchSingleQuotesCheckbox->setChecked(appSettings->getAutoMatchCharEnabled('\''));
    layout->addWidget(autoMatchSingleQuotesCheckbox, 1, 0);

    QCheckBox* autoMatchParenthesesCheckbox = new QCheckBox("( )");
    autoMatchParenthesesCheckbox->setCheckable(true);
    autoMatchParenthesesCheckbox->setChecked(appSettings->getAutoMatchCharEnabled('('));
    layout->addWidget(autoMatchParenthesesCheckbox, 2, 0);

    QCheckBox* autoMatchSquareBracketsCheckbox = new QCheckBox("[ ]");
    autoMatchSquareBracketsCheckbox->setCheckable(true);
    autoMatchSquareBracketsCheckbox->setChecked(appSettings->getAutoMatchCharEnabled('['));
    layout->addWidget(autoMatchSquareBracketsCheckbox, 0, 1);

    QCheckBox* autoMatchBracesCheckbox = new QCheckBox("{ }");
    autoMatchBracesCheckbox->setCheckable(true);
    autoMatchBracesCheckbox->setChecked(appSettings->getAutoMatchCharEnabled('{'));
    layout->addWidget(autoMatchBracesCheckbox, 1, 1);

    QCheckBox* autoMatchAsterisksCheckbox = new QCheckBox("*");
    autoMatchAsterisksCheckbox->setCheckable(true);
    autoMatchAsterisksCheckbox->setChecked(appSettings->getAutoMatchCharEnabled('*'));
    layout->addWidget(autoMatchAsterisksCheckbox, 2, 1);

    QCheckBox* autoMatchUnderscoresCheckbox = new QCheckBox("_");
    autoMatchUnderscoresCheckbox->setCheckable(true);
    autoMatchUnderscoresCheckbox->setChecked(appSettings->getAutoMatchCharEnabled('_'));
    layout->addWidget(autoMatchUnderscoresCheckbox, 0, 2);

    QCheckBox* autoMatchBackticksCheckbox = new QCheckBox("`");
    autoMatchBackticksCheckbox->setCheckable(true);
    autoMatchBackticksCheckbox->setChecked(appSettings->getAutoMatchCharEnabled('`'));
    layout->addWidget(autoMatchBackticksCheckbox, 1, 2);

    QCheckBox* autoMatchAngleBracketsCheckbox = new QCheckBox("< >");
    autoMatchAngleBracketsCheckbox->setCheckable(true);
    autoMatchAngleBracketsCheckbox->setChecked(appSettings->getAutoMatchCharEnabled('

Web Proxy Viewer  |  New URL  |  Original Page