2021-06-12 22:36:23 +08:00
|
|
|
#include "editorclipboardwidget.h"
|
|
|
|
#include "ui_editorclipboardwidget.h"
|
|
|
|
#include "../settings.h"
|
|
|
|
#include "../mainwindow.h"
|
2021-06-20 22:54:16 +08:00
|
|
|
#include "../colorscheme.h"
|
2021-06-12 22:36:23 +08:00
|
|
|
|
|
|
|
EditorClipboardWidget::EditorClipboardWidget(const QString& name, const QString& group, QWidget *parent) :
|
|
|
|
SettingsWidget(name,group,parent),
|
|
|
|
ui(new Ui::EditorClipboardWidget)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
ui->cbCopyWithFormatAs->addItem("None");
|
|
|
|
ui->cbCopyWithFormatAs->addItem("HTML");
|
2021-06-20 22:54:16 +08:00
|
|
|
|
|
|
|
for (QString name: pColorManager->getSchemes()) {
|
|
|
|
ui->cbHTMLColorScheme->addItem(name);
|
|
|
|
ui->cbRTFColorScheme->addItem(name);
|
|
|
|
}
|
|
|
|
connect(ui->chkCopyRTFUseEditorColor,
|
|
|
|
&QCheckBox::stateChanged,
|
|
|
|
this,
|
|
|
|
&EditorClipboardWidget::onUseSchemeChanged);
|
|
|
|
connect(ui->chkCopyHTMLUseEditorColor,
|
|
|
|
&QCheckBox::stateChanged,
|
|
|
|
this,
|
|
|
|
&EditorClipboardWidget::onUseSchemeChanged);
|
2021-06-12 22:36:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
EditorClipboardWidget::~EditorClipboardWidget()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2021-06-20 22:54:16 +08:00
|
|
|
void EditorClipboardWidget::onUseSchemeChanged()
|
|
|
|
{
|
|
|
|
ui->cbRTFColorScheme->setEnabled(!ui->chkCopyRTFUseEditorColor->isChecked());
|
|
|
|
ui->cbHTMLColorScheme->setEnabled(!ui->chkCopyHTMLUseEditorColor->isChecked());
|
|
|
|
}
|
|
|
|
|
2021-06-12 22:36:23 +08:00
|
|
|
void EditorClipboardWidget::doLoad()
|
|
|
|
{
|
|
|
|
//pSettings->editor().load();
|
|
|
|
//copy
|
2021-06-20 14:30:47 +08:00
|
|
|
QString mCopyHTMLColorScheme;
|
2021-06-12 22:36:23 +08:00
|
|
|
|
|
|
|
ui->grpCopySizeLimit->setChecked(pSettings->editor().copySizeLimit());
|
|
|
|
ui->spinCopyCharLimits->setValue(pSettings->editor().copyCharLimits());
|
|
|
|
ui->spinCopyLineLimits->setValue(pSettings->editor().copyLineLimits());
|
|
|
|
ui->cbCopyWithFormatAs->setCurrentIndex(std::max(0,std::min(ui->cbCopyWithFormatAs->count(),
|
|
|
|
pSettings->editor().copyWithFormatAs())) );
|
|
|
|
ui->chkCopyRTFUseBackground->setChecked(pSettings->editor().copyRTFUseBackground());
|
|
|
|
ui->chkCopyRTFUseEditorColor->setChecked(pSettings->editor().copyRTFUseEditorColor());
|
2021-06-20 23:07:30 +08:00
|
|
|
ui->cbRTFColorScheme->setCurrentText(pSettings->editor().copyRTFColorScheme());
|
2021-06-12 22:36:23 +08:00
|
|
|
ui->chkCopyHTMLUseBackground->setChecked(pSettings->editor().copyHTMLUseBackground());
|
|
|
|
ui->chkCopyHTMLUseEditorColor->setChecked(pSettings->editor().copyHTMLUseEditorColor());
|
2021-06-20 23:07:30 +08:00
|
|
|
ui->cbHTMLColorScheme->setCurrentText(pSettings->editor().copyHTMLColorScheme());
|
2021-06-20 22:54:16 +08:00
|
|
|
onUseSchemeChanged();
|
2021-06-12 22:36:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void EditorClipboardWidget::doSave()
|
|
|
|
{
|
|
|
|
//copy
|
|
|
|
pSettings->editor().setCopySizeLimit(ui->grpCopySizeLimit->isChecked());
|
|
|
|
pSettings->editor().setCopyCharLimits(ui->spinCopyCharLimits->value());
|
|
|
|
pSettings->editor().setCopyLineLimits(ui->spinCopyLineLimits->value());
|
|
|
|
pSettings->editor().setCopyWithFormatAs(ui->cbCopyWithFormatAs->currentIndex());
|
|
|
|
|
|
|
|
pSettings->editor().setCopyRTFUseBackground(ui->chkCopyRTFUseBackground->isChecked());
|
|
|
|
pSettings->editor().setCopyRTFUseEditorColor(ui->chkCopyRTFUseEditorColor->isChecked());
|
2021-06-20 22:54:16 +08:00
|
|
|
pSettings->editor().setCopyRTFColorScheme(ui->cbRTFColorScheme->currentText());
|
|
|
|
|
2021-06-12 22:36:23 +08:00
|
|
|
pSettings->editor().setCopyHTMLUseBackground(ui->chkCopyHTMLUseBackground->isChecked());
|
|
|
|
pSettings->editor().setCopyHTMLUseEditorColor(ui->chkCopyHTMLUseEditorColor->isChecked());
|
2021-06-20 22:54:16 +08:00
|
|
|
pSettings->editor().setCopyHTMLColorScheme(ui->cbHTMLColorScheme->currentText());
|
2021-06-12 22:36:23 +08:00
|
|
|
|
|
|
|
pSettings->editor().save();
|
|
|
|
pMainWindow->updateEditorSettings();
|
|
|
|
}
|