]> git.sesse.net Git - kdenlive/commitdiff
Save color theme
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 9 Oct 2009 21:07:45 +0000 (21:07 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 9 Oct 2009 21:07:45 +0000 (21:07 +0000)
svn path=/trunk/kdenlive/; revision=4026

src/kdenlivesettings.kcfg
src/mainwindow.cpp
src/mainwindow.h

index b6e721f00f3b6bcc638e4a24aaea5745963d8062..b3dc35bd9fab77c46ee591753bf90ff24242205a 100644 (file)
       <label>List of available MLT producers.</label>
       <default></default>
     </entry>
+
+    <entry name="colortheme" type="String">
+      <label>Name of the chosen color theme.</label>
+      <default></default>
+    </entry>
   </group>
 </kcfg>
index 7d71aeebecd9baaf78e12cf7f0c6bed91dc0e741..bed6612a6cb2614a3ea406e0590c1e892b87ab58 100644 (file)
@@ -123,6 +123,7 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent
     dbus.registerObject("/MainWindow", this);
 
     setlocale(LC_NUMERIC, "POSIX");
+    slotChangePalette(NULL, KdenliveSettings::colortheme());
     setFont(KGlobalSettings::toolBarFont());
     parseProfiles(MltPath);
     m_commandStack = new QUndoGroup;
@@ -255,11 +256,11 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent
     QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
     action = new QAction(i18n("Default"), this);
     themesMenu->addAction(action);
-    fprintf(stderr, "THEMES: %s\n", KStandardDirs::installPath("data").toUtf8().data());
     KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
     QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
-    for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it) {
-        QFileInfo fi(*it);
+    for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
+    {
+       QFileInfo fi(*it);
         action = new QAction(fi.fileName(), this);
         action->setData(*it);
         themesMenu->addAction(action);
@@ -2919,34 +2920,37 @@ void MainWindow::slotUpdateTrackInfo()
         m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
 }
 
-void MainWindow::slotChangePalette(QAction *action)
+void MainWindow::slotChangePalette(QAction *action, const QString &themename)
 {
     // Load the theme file
-    QString theme = action->data().toString();
-
+    QString theme;
+    if (action == NULL) theme = themename;
+    else theme = action->data().toString();
+    KdenliveSettings::setColortheme(theme);
     // Make palette for all widgets.
     QPalette plt;
     if (theme.isEmpty())
         plt = QApplication::desktop()->palette();
-    else {
-        KConfig confFile(theme, KConfig::SimpleConfig);
+    else
+    {
+       KConfig confFile(theme, KConfig::SimpleConfig);
         plt = kapp->palette();
         int h, s, v;
         const QColor fg(confFile.entryMap().value("TextRegularColor"));
         const QColor bg(confFile.entryMap().value("BaseColor"));
 
         bg.getHsv(&h, &s, &v);
-        v += (v < 128) ? + 50 : -50;
+        v += (v < 128) ? +50 : -50;
         v &= 255; //ensures 0 <= v < 256
         const QColor highlight = QColor::fromHsv(h, s, v);
 
         fg.getHsv(&h, &s, &v);
-        v += (v < 128) ? + 150 : -150;
+        v += (v < 128) ? +150 : -150;
         v &= 255; //ensures 0 <= v < 256
         const QColor alternate = QColor::fromHsv(h, s, v);
 
         plt.setColor(QPalette::Active,   QPalette::Base,            bg);
-        plt.setColor(QPalette::Active,   QPalette::AlternateBase,   alternate);
+       plt.setColor(QPalette::Active,   QPalette::AlternateBase,   alternate);
         plt.setColor(QPalette::Active,   QPalette::Background,      bg.dark(115));
         plt.setColor(QPalette::Active,   QPalette::Foreground,      fg);
         plt.setColor(QPalette::Active,   QPalette::Highlight,       highlight);
@@ -2959,8 +2963,8 @@ void MainWindow::slotChangePalette(QAction *action)
         plt.setColor(QPalette::Active,   QPalette::LinkVisited,     confFile.entryMap().value("TextSpecialSelectedColor"));
 
         plt.setColor(QPalette::Inactive, QPalette::Base,            bg);
-        plt.setColor(QPalette::Inactive,   QPalette::AlternateBase, alternate);
-        plt.setColor(QPalette::Inactive, QPalette::Background,      bg.dark(115));
+       plt.setColor(QPalette::Inactive,   QPalette::AlternateBase, alternate);
+       plt.setColor(QPalette::Inactive, QPalette::Background,      bg.dark(115));
         plt.setColor(QPalette::Inactive, QPalette::Foreground,      fg);
         plt.setColor(QPalette::Inactive, QPalette::Highlight,       highlight);
         plt.setColor(QPalette::Inactive, QPalette::HighlightedText, confFile.entryMap().value("TextSelectedColor"));
@@ -2972,7 +2976,7 @@ void MainWindow::slotChangePalette(QAction *action)
         plt.setColor(QPalette::Inactive, QPalette::LinkVisited,     confFile.entryMap().value("TextSpecialSelectedColor"));
 
         plt.setColor(QPalette::Disabled, QPalette::Base,            bg);
-        plt.setColor(QPalette::Disabled,   QPalette::AlternateBase, alternate);
+       plt.setColor(QPalette::Disabled,   QPalette::AlternateBase, alternate);
         plt.setColor(QPalette::Disabled, QPalette::Background,      bg.dark(115));
         plt.setColor(QPalette::Disabled, QPalette::Foreground,      fg);
         plt.setColor(QPalette::Disabled, QPalette::Highlight,       highlight);
index c9ed882253966f519b5e532a8cea8a386568e8ee..ff749103fdaf8cc5ee0057a62c10b824981c1e34 100644 (file)
@@ -320,7 +320,7 @@ private slots:
     void slotShutdown();
     void slotUpdateTrackInfo();
     /** \brief Change color scheme */
-    void slotChangePalette(QAction *action);
+    void slotChangePalette(QAction *action, const QString &themename = QString());
 
 signals:
     Q_SCRIPTABLE void abortRenderJob(const QString &url);