int settingUp = false;
-TitleWidget::TitleWidget(KUrl url, QString projectPath, Render *render, QWidget *parent): QDialog(parent), m_render(render), m_count(0), m_projectPath(projectPath) {
+TitleWidget::TitleWidget(KUrl url, QString projectPath, Render *render, QWidget *parent): QDialog(parent), m_render(render), m_count(0), m_projectPath(projectPath), startViewport(NULL), endViewport(NULL) {
setupUi(this);
setFont(KGlobalSettings::toolBarFont());
//toolBox->setFont(KGlobalSettings::toolBarFont());
m_frameHeight = render->renderHeight();
//connect(newTextButton, SIGNAL(clicked()), this, SLOT(slotNewText()));
//connect(newRectButton, SIGNAL(clicked()), this, SLOT(slotNewRect()));
+ // kcolorbutton == The color of the background
connect(kcolorbutton, SIGNAL(clicked()), this, SLOT(slotChangeBackground())) ;
+ // horizontalslider == The alpha of the background
connect(horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(slotChangeBackground())) ;
//connect(ktextedit, SIGNAL(textChanged()), this , SLOT(textChanged()));
//connect (fontBold, SIGNAL ( clicked()), this, SLOT( setBold()) ) ;
connect(buttonUnder, SIGNAL(clicked()), this, SLOT(slotUpdateText()));
connect(displayBg, SIGNAL(stateChanged(int)), this, SLOT(displayBackgroundFrame()));
+ // mbd
+ connect(this, SIGNAL(accepted()), this, SLOT(slotAccepted()));
+
buttonFitZoom->setIcon(KIcon("zoom-fit-best"));
buttonRealSize->setIcon(KIcon("zoom-original"));
buttonBold->setIcon(KIcon("format-text-bold"));
m_frameBorder->setFlags(QGraphicsItem::ItemClipsToShape);
graphicsView->scene()->addItem(m_frameBorder);
+ // mbd: load saved settings
+ readChoices();
+
initViewports();
QTimer::singleShot(500, this, SLOT(slotAdjustZoom()));
graphicsView->show();
}
}
+TitleWidget::~TitleWidget() {
+ delete m_buttonRect;
+ delete m_buttonText;
+ delete m_buttonImage;
+ delete m_buttonCursor;
+ delete m_buttonSave;
+ delete m_buttonLoad;
+
+ delete m_frameBorder;
+ delete m_frameImage;
+ if (startViewport) delete startViewport;
+ if (endViewport) delete endViewport;
+ delete m_scene;
+}
+
//static
QStringList TitleWidget::getFreeTitleInfo(const KUrl &projectUrl) {
QStringList result;
void TitleWidget::slotUpdateZoom(int pos) {
m_scene->setZoom((double) pos / 100);
- zoom_label->setText(QString::number(pos) + "%");
+ zoom_label->setText(QString::number(pos) + '%');
}
void TitleWidget::slotZoom(bool up) {
void TitleWidget::slotNewText(QGraphicsTextItem *tt) {
QFont font = font_family->currentFont();
font.setPointSize(font_size->value());
+ // mbd: issue 551:
+ font.setBold(buttonBold->isChecked());
+ font.setItalic(buttonItalic->isChecked());
+ font.setUnderline(buttonUnder->isChecked());
+
tt->setFont(font);
QColor color = fontColorButton->color();
color.setAlpha(textAlpha->value());
void TitleWidget::setXml(QDomDocument doc) {
m_count = m_titledocument.loadFromXml(doc, startViewport, endViewport);
+ // mbd: Update the GUI color selectors to match the stuff from the loaded document
+ QColor background_color = m_titledocument.getBackgroundColor();
+ horizontalSlider->blockSignals(true);
+ kcolorbutton->blockSignals(true);
+ horizontalSlider->setValue(background_color.alpha());
+ background_color.setAlpha(255);
+ kcolorbutton->setColor(background_color);
+ horizontalSlider->blockSignals(false);
+ kcolorbutton->blockSignals(false);
+
slotSelectTool();
}
-QPixmap TitleWidget::renderedPixmap() {
- QPixmap pix(m_frameWidth, m_frameHeight);
+QImage TitleWidget::renderedPixmap() {
+ QImage pix(m_frameWidth, m_frameHeight, QImage::Format_ARGB32);
pix.fill(Qt::transparent);
QPainter painter(&pix);
- painter.setRenderHint(QPainter::Antialiasing);
+ painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::HighQualityAntialiasing);
m_scene->clearTextSelection();
QPen framepen = m_frameBorder->pen();
m_frameBorder->setPen(Qt::NoPen);
m_frameImage->setVisible(false);
m_scene->render(&painter, QRectF(), QRectF(0, 0, m_frameWidth, m_frameHeight));
+ painter.end();
m_frameBorder->setPen(framepen);
startViewport->setVisible(true);
endViewport->setVisible(true);
return pix;
}
-#include "moc_titlewidget.cpp"
+/** \brief Connected to the accepted signal - calls writeChoices */
+void TitleWidget::slotAccepted() {
+ writeChoices();
+}
+
+/** \brief Store the current choices of font, background and rect values */
+void TitleWidget::writeChoices() {
+ // Get a pointer to a shared configuration instance, then get the TitleWidget group.
+ KSharedConfigPtr config = KGlobal::config();
+ KConfigGroup titleConfig(config, "TitleWidget");
+ // Write the entries
+ titleConfig.writeEntry("font_family", font_family->currentFont());
+ titleConfig.writeEntry("font_size", font_size->value());
+ titleConfig.writeEntry("font_color", fontColorButton->color());
+ titleConfig.writeEntry("font_alpha", textAlpha->value());
+ titleConfig.writeEntry("font_bold", buttonBold->isChecked());
+ titleConfig.writeEntry("font_italic", buttonItalic->isChecked());
+ titleConfig.writeEntry("font_underlined", buttonUnder->isChecked());
+
+ titleConfig.writeEntry("rect_foreground_color", rectFColor->color());
+ titleConfig.writeEntry("rect_foreground_alpha", rectFAlpha->value());
+ titleConfig.writeEntry("rect_background_color", rectBColor->color());
+ titleConfig.writeEntry("rect_background_alpha", rectBAlpha->value());
+ titleConfig.writeEntry("rect_line_width", rectLineWidth->value());
+
+ titleConfig.writeEntry("background_color", kcolorbutton->color());
+ titleConfig.writeEntry("background_alpha", horizontalSlider->value());
+ //! \todo Not sure if I should sync - it is probably safe to do it
+ config->sync();
+
+}
+
+/** \brief Read the last stored choices into the dialog */
+void TitleWidget::readChoices() {
+ // Get a pointer to a shared configuration instance, then get the TitleWidget group.
+ KSharedConfigPtr config = KGlobal::config();
+ KConfigGroup titleConfig(config, "TitleWidget");
+ // read the entries
+ font_family->setCurrentFont(titleConfig.readEntry("font_family", font_family->currentFont()));
+ font_size->setValue(titleConfig.readEntry("font_size", font_size->value()));
+ fontColorButton->setColor(titleConfig.readEntry("font_color", fontColorButton->color()));
+ textAlpha->setValue(titleConfig.readEntry("font_alpha", textAlpha->value()));
+ buttonBold->setChecked(titleConfig.readEntry("font_bold", buttonBold->isChecked()));
+ buttonItalic->setChecked(titleConfig.readEntry("font_italic", buttonItalic->isChecked()));
+ buttonUnder->setChecked(titleConfig.readEntry("font_underlined", buttonUnder->isChecked()));
+
+ rectFColor->setColor(titleConfig.readEntry("rect_foreground_color", rectFColor->color()));
+ rectFAlpha->setValue(titleConfig.readEntry("rect_foreground_alpha", rectFAlpha->value()));
+ rectBColor->setColor(titleConfig.readEntry("rect_background_color", rectBColor->color()));
+ rectBAlpha->setValue(titleConfig.readEntry("rect_background_alpha", rectBAlpha->value()));
+ rectLineWidth->setValue(titleConfig.readEntry("rect_line_width", rectLineWidth->value()));
+
+ kcolorbutton->setColor(titleConfig.readEntry("background_color", kcolorbutton->color()));
+ horizontalSlider->setValue(titleConfig.readEntry("background_alpha", horizontalSlider->value()));
+}