]> git.sesse.net Git - kdenlive/commitdiff
Work on: 551: The titlewidget (add/edit text clip dialog) should remember the last...
authorMads Bondo Dydensborg <mads@dydensborg.dk>
Thu, 1 Jan 2009 23:34:47 +0000 (23:34 +0000)
committerMads Bondo Dydensborg <mads@dydensborg.dk>
Thu, 1 Jan 2009 23:34:47 +0000 (23:34 +0000)
svn path=/branches/KDE4/; revision=2863

src/titlewidget.cpp
src/titlewidget.h

index b2fd5257262ebcb678377fdd317b206abb495c9b..145377b41e5564f2ae3602233b99256f8f1ea16d 100644 (file)
@@ -47,7 +47,9 @@ TitleWidget::TitleWidget(KUrl url, QString projectPath, Render *render, QWidget
     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()) ) ;
@@ -90,6 +92,9 @@ TitleWidget::TitleWidget(KUrl url, QString projectPath, Render *render, QWidget
     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"));
@@ -171,6 +176,9 @@ TitleWidget::TitleWidget(KUrl url, QString projectPath, Render *render, QWidget
     m_frameBorder->setFlags(QGraphicsItem::ItemClipsToShape);
     graphicsView->scene()->addItem(m_frameBorder);
 
+    // mbd: load saved settings
+    readChoices();
+    
     initViewports();
     QTimer::singleShot(500, this, SLOT(slotAdjustZoom()));
     graphicsView->show();
@@ -674,5 +682,59 @@ QPixmap TitleWidget::renderedPixmap() {
     return pix;
 }
 
+/** \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()));
+}
 #include "moc_titlewidget.cpp"
-
index 9d7770505bc30f1b1263fc2a86eae6a52e3c2d30..eaf341dcbb4f75320944bb40cf772881d4d55bcf 100644 (file)
@@ -91,6 +91,10 @@ private:
     QAction *m_buttonLoad;
     /** project path for storing title clips */
     QString m_projectPath;
+    /** \brief Store the current choices of font, background and rect values */
+    void writeChoices();
+    /** \brief Read the last stored choices into the dialog */
+    void readChoices();
 
 public slots:
     void slotNewText(QGraphicsTextItem *tt);
@@ -123,6 +127,8 @@ private slots:
     void slotRectTool();
     void slotSelectTool();
     void slotImageTool();
+    /** \brief Called when accepted, stores the user selections for next time use */
+    void slotAccepted();
 };