1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
|
/* This file is part of the KDE project
* Copyright (C) 2009 Ganesh Paramasivam <ganesh@crystalfab.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "ChangeConfigureDialog.h"
#include <QColorDialog>
ColorDisplayLabel::ColorDisplayLabel(QWidget *parent):QLabel(parent), labelColor(255,255,0)
{
}
ColorDisplayLabel::~ColorDisplayLabel()
{
}
void ColorDisplayLabel::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QPainter painter(this);
painter.setBrush(labelColor);
painter.drawRect(rect().x(), rect().y(), rect().width(), rect().height());
}
const QColor& ColorDisplayLabel::color() const
{
return labelColor;
}
void ColorDisplayLabel::setColor(const QColor &color)
{
labelColor = color;
}
ChangeConfigureDialog::ChangeConfigureDialog(const QColor &insertionColor, const QColor &deletionColor, const QColor &formatChangeColor, const QString &authorName, KoChangeTracker::ChangeSaveFormat changeSaveFormat, QWidget *parent):QDialog(parent)
{
ui.setupUi(this);
ui.insertionColorDisplayLabel->setColor(insertionColor);
ui.deletionColorDisplayLabel->setColor(deletionColor);
ui.formatColorDisplayLabel->setColor(formatChangeColor);
ui.authorNameLineEdit->setText(authorName);
if (changeSaveFormat == KoChangeTracker::ODF_1_2) {
ui.odf12RadioButton->setChecked(true);
} else {
ui.deltaXmlRadioButton->setChecked(true);
}
connect(ui.insertionColorButton, SIGNAL(clicked()), this, SLOT(insertionColorSelect()));
connect(ui.deletionColorButton, SIGNAL(clicked()), this, SLOT(deletionColorSelect()));
connect(ui.formatColorButton, SIGNAL(clicked()), this, SLOT(formatChangeColorSelect()));
updatePreviewText();
}
const QString ChangeConfigureDialog::authorName()
{
return ui.authorNameLineEdit->text();
}
KoChangeTracker::ChangeSaveFormat ChangeConfigureDialog::saveFormat()
{
if (ui.odf12RadioButton->isChecked()) {
return KoChangeTracker::ODF_1_2;
} else {
return KoChangeTracker::DELTAXML;
}
}
const QColor& ChangeConfigureDialog::getInsertionBgColor()
{
return ui.insertionColorDisplayLabel->color();
}
const QColor& ChangeConfigureDialog::getDeletionBgColor()
{
return ui.deletionColorDisplayLabel->color();
}
const QColor& ChangeConfigureDialog::getFormatChangeBgColor()
{
return ui.formatColorDisplayLabel->color();
}
void ChangeConfigureDialog::insertionColorSelect()
{
colorSelect(eInsert);
}
void ChangeConfigureDialog::deletionColorSelect()
{
colorSelect(eDelete);
}
void ChangeConfigureDialog::formatChangeColorSelect()
{
colorSelect(eFormatChange);
}
void ChangeConfigureDialog::colorSelect(ChangeType type)
{
QColor selectedColor;
switch (type) {
case eInsert:
selectedColor = QColorDialog::getColor(ui.insertionColorDisplayLabel->color(), this);
if (selectedColor.isValid()) {
ui.insertionColorDisplayLabel->setColor(selectedColor);
ui.insertionColorDisplayLabel->update();
}
break;
case eDelete:
selectedColor = QColorDialog::getColor(ui.deletionColorDisplayLabel->color(), this);
if (selectedColor.isValid()) {
ui.deletionColorDisplayLabel->setColor(selectedColor);
ui.deletionColorDisplayLabel->update();
}
break;
case eFormatChange:
selectedColor = QColorDialog::getColor(ui.formatColorDisplayLabel->color(), this);
if (selectedColor.isValid()) {
ui.formatColorDisplayLabel->setColor(selectedColor);
ui.formatColorDisplayLabel->update();
}
break;
case eChangeTypeNone:
break;
}
updatePreviewText();
}
void ChangeConfigureDialog::updatePreviewText(void)
{
//update the insertion-text
if (ui.previewTextEdit->find(i18n("This is a line of inserted text."))) {
ui.previewTextEdit->setTextBackgroundColor(ui.insertionColorDisplayLabel->color());
ui.previewTextEdit->moveCursor(QTextCursor::Start);
}
//update the deletion-text
if (ui.previewTextEdit->find(i18n("This is a line of deleted text."))) {
ui.previewTextEdit->setTextBackgroundColor(ui.deletionColorDisplayLabel->color());
ui.previewTextEdit->moveCursor(QTextCursor::Start);
}
//update the format-change-text
if (ui.previewTextEdit->find(i18n("This is a line of text whose format has been changed."))) {
ui.previewTextEdit->setTextBackgroundColor(ui.formatColorDisplayLabel->color());
ui.previewTextEdit->moveCursor(QTextCursor::Start);
}
}
ChangeConfigureDialog::~ChangeConfigureDialog()
{
}
|