Settings for autopausing
authorNikolay Tischenko <niktischenko@gmail.com>
Sun, 28 Nov 2010 13:48:29 +0000 (19:48 +0600)
committerNikolay Tischenko <niktischenko@gmail.com>
Sun, 28 Nov 2010 13:48:29 +0000 (19:48 +0600)
resources/someplayer_ru.ts
src/dbusadaptor.cpp
src/settingsform.cpp
src/settingsform.h
src/ui/settingsform.ui

index 477fb02..198428e 100644 (file)
         <translation>Аудиоклипы</translation>
     </message>
     <message>
-        <location filename="../src/directoryview.cpp" line="290"/>
+        <location filename="../src/directoryview.cpp" line="306"/>
         <source>Inner memory</source>
         <translation>Внутренняя память</translation>
     </message>
     <message>
-        <location filename="../src/directoryview.cpp" line="292"/>
+        <location filename="../src/directoryview.cpp" line="308"/>
         <source>Memory card</source>
         <translation>Карта памяти</translation>
     </message>
         <translation>Ctrl+S</translation>
     </message>
     <message>
-        <location filename="../src/mainwindow.cpp" line="253"/>
+        <location filename="../src/mainwindow.cpp" line="254"/>
         <source>Music off: </source>
         <translation>Отключение: </translation>
     </message>
     </message>
     <message>
         <location filename="../src/playerform.cpp" line="90"/>
-        <location filename="../src/playerform.cpp" line="739"/>
+        <location filename="../src/playerform.cpp" line="743"/>
         <source>Clear playlist</source>
         <translation>Очистить плейлист</translation>
     </message>
     <message>
         <location filename="../src/playerform.cpp" line="91"/>
-        <location filename="../src/playerform.cpp" line="740"/>
+        <location filename="../src/playerform.cpp" line="744"/>
         <source>Delete</source>
         <translation>Удалить</translation>
     </message>
     <message>
         <location filename="../src/playerform.cpp" line="92"/>
         <location filename="../src/playerform.cpp" line="230"/>
-        <location filename="../src/playerform.cpp" line="299"/>
-        <location filename="../src/playerform.cpp" line="741"/>
+        <location filename="../src/playerform.cpp" line="303"/>
+        <location filename="../src/playerform.cpp" line="745"/>
         <source>Add to favorites</source>
         <translation>В избранное</translation>
     </message>
     <message>
         <location filename="../src/playerform.cpp" line="93"/>
-        <location filename="../src/playerform.cpp" line="742"/>
+        <location filename="../src/playerform.cpp" line="746"/>
         <source>Enqueue</source>
         <translation>В очередь</translation>
     </message>
     <message>
         <location filename="../src/playerform.cpp" line="94"/>
-        <location filename="../src/playerform.cpp" line="743"/>
+        <location filename="../src/playerform.cpp" line="747"/>
         <source>Add to playlists</source>
         <translation>Добавить в плейлисты</translation>
     </message>
     <message>
         <location filename="../src/playerform.cpp" line="95"/>
-        <location filename="../src/playerform.cpp" line="744"/>
+        <location filename="../src/playerform.cpp" line="748"/>
         <source>Edit tags</source>
         <translation>Редактировать теги</translation>
     </message>
     <message>
         <location filename="../src/playerform.cpp" line="230"/>
-        <location filename="../src/playerform.cpp" line="299"/>
+        <location filename="../src/playerform.cpp" line="303"/>
         <source>Remove from favorites</source>
         <translation>Удалить из избранного</translation>
     </message>
     <message>
         <location filename="../src/ui/settingsform.ui" line="111"/>
         <location filename="../src/ui/settingsform.ui" line="359"/>
+        <location filename="../src/ui/settingsform.ui" line="436"/>
         <source>Yes</source>
         <translation>Да</translation>
     </message>
     <message>
         <location filename="../src/ui/settingsform.ui" line="118"/>
         <location filename="../src/ui/settingsform.ui" line="366"/>
+        <location filename="../src/ui/settingsform.ui" line="443"/>
         <source>No</source>
         <translation>Нет</translation>
     </message>
         <source>Russian</source>
         <translation>Русский</translation>
     </message>
+    <message>
+        <location filename="../src/ui/settingsform.ui" line="427"/>
+        <source>Pause when headphones unplugged:</source>
+        <translation>Пауза при отключении наушников:</translation>
+    </message>
 </context>
 <context>
     <name>TimerDialog</name>
index 3ca01fa..8286441 100644 (file)
@@ -26,6 +26,7 @@
 #include <QtCore/QStringList>
 #include <QtCore/QVariant>
 #include <QDebug>
+#include "config.h"
 
 /*
  * Implementation of adaptor class DBusAdaptop
@@ -109,6 +110,10 @@ void DBusAdaptop::processBTSignal(QString event, QString state) {
                        } else if (state == "play-cd" || state == "pause-cd") {
                                toggle();
                        } else if (state == "connection") {
+                               SomePlayer::Storage::Config config;
+                               if (config.getValue("playback/hpautopause").toString() != "yes") {
+                                       return;
+                               }
                                bool present = QDBusInterface ("org.freedesktop.Hal",
                                                               "/org/freedesktop/Hal/devices/platform_headphone",
                                                               "org.freedesktop.Hal.Device",
index dde85ef..2d5978b 100644 (file)
@@ -46,6 +46,7 @@ SettingsForm::SettingsForm(QWidget *parent) :
        ui->gradientYButton->setChecked(true);
        ui->engLangButton->setChecked(true);
        ui->cBlueButton->setChecked(true);
+       ui->pauseHPNoButton->setChecked(true);
        if (albumSorting == "alphabet") {
                ui->albumsSortAButton->setChecked(true);
        }
@@ -81,6 +82,9 @@ SettingsForm::SettingsForm(QWidget *parent) :
        } else if (track_color == "light") {
                ui->cLightButton->setChecked(true);
        }
+       if (config.getValue("playback/hpautopause").toString() == "yes") {
+               ui->pauseHPYesButton->setChecked(true);
+       }
        if (!QFile::exists(QString(_APPLICATION_PATH_)+"/someplayer_ru.qm")) {
                ui->langBox->hide();
        } // refactor this when more translations will be added
@@ -105,6 +109,8 @@ SettingsForm::SettingsForm(QWidget *parent) :
        connect (ui->cRedButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_red(bool)));
        connect (ui->cWhiteButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_white(bool)));
        connect (ui->cYellowButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_yellow(bool)));
+       connect (ui->pauseHPNoButton, SIGNAL(toggled(bool)), this, SLOT(_set_pause_hp_no(bool)));
+       connect (ui->pauseHPYesButton, SIGNAL(toggled(bool)), this, SLOT(_set_pause_hp_yes(bool)));
        setAttribute(Qt::WA_Maemo5StackedWindow);
        setWindowFlags(Qt::Window | windowFlags());
 }
@@ -261,6 +267,18 @@ void SettingsForm::_set_lang_ru(bool checked) {
        emit translationChanged();
 }
 
+void SettingsForm::_set_pause_hp_no(bool checked) {
+       if (!checked) return;
+       Config config;
+       config.setValue("playback/hpautopause", "no");
+}
+
+void SettingsForm::_set_pause_hp_yes(bool checked) {
+       if (!checked) return;
+       Config config;
+       config.setValue("playback/hpautopause", "yes");
+}
+
 void SettingsForm::updateTranslations() {
        ui->retranslateUi(this);
 }
index e0f3b58..1ade75d 100644 (file)
@@ -73,6 +73,8 @@ private slots:
        void _set_color_black(bool);
        void _set_color_light(bool);
        void _set_color_dark(bool);
+       void _set_pause_hp_yes(bool);
+       void _set_pause_hp_no(bool);
 };
 
 #endif // SETTINGSFORM_H
index 4ac5d69..d434d76 100644 (file)
@@ -32,9 +32,9 @@
       <property name="geometry">
        <rect>
         <x>0</x>
-        <y>-47</y>
+        <y>-97</y>
         <width>780</width>
-        <height>403</height>
+        <height>474</height>
        </rect>
       </property>
       <layout class="QVBoxLayout" name="verticalLayout_6">
          </layout>
         </widget>
        </item>
+       <item>
+        <widget class="QGroupBox" name="groupBox_5">
+         <property name="title">
+          <string/>
+         </property>
+         <layout class="QVBoxLayout" name="verticalLayout_9">
+          <item>
+           <widget class="QLabel" name="label_8">
+            <property name="text">
+             <string>Pause when headphones unplugged:</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <layout class="QHBoxLayout" name="horizontalLayout_2">
+            <item>
+             <widget class="QRadioButton" name="pauseHPYesButton">
+              <property name="text">
+               <string>Yes</string>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <widget class="QRadioButton" name="pauseHPNoButton">
+              <property name="text">
+               <string>No</string>
+              </property>
+             </widget>
+            </item>
+           </layout>
+          </item>
+         </layout>
+        </widget>
+       </item>
       </layout>
      </widget>
     </widget>