extended setup dialog
authorIonutz Borcoman <iborco@gmail.com>
Sat, 19 Mar 2011 11:32:07 +0000 (13:32 +0200)
committerIonutz Borcoman <iborco@gmail.com>
Sat, 19 Mar 2011 11:32:07 +0000 (13:32 +0200)
* extended setup dialog
* save and restore all values from the setup dialog
* implemented notification timeout via the setup

src/constants.h
src/genericnotify.cpp
src/qtc_packaging/debian_fremantle/changelog
src/setupdialog.cpp
src/setupdialog.ui
src/xbmc.cpp
src/xbmc.h

index ce76f3e..ef597e5 100644 (file)
 #define SETUP_XBMC_PORT "xbmc/port"
 #define SETUP_XBMC_PORT_DEFAULT "8080"
 
+#define SETUP_XBMC_REQUIRES_AUTHENTICATION "xbmc/requires_authetication"
+#define SETUP_XBMC_REQUIRES_AUTHENTICATION_DEFAULT false
+#define SETUP_XBMC_USERNAME "xbmc/username"
+#define SETUP_XBMC_USERNAME_DEFAULT ""
+#define SETUP_XBMC_PASSWORD "xbmc/password"
+#define SETUP_XBMC_PASSWORD_DEFAULT ""
+
+#define SETUP_SCREEN_DISABLE_SCREENSAVER "screen/disable_screensaver"
+#define SETUP_SCREEN_DISABLE_SCREENSAVER_DEFAULT false
+#define SETUP_SCREEN_DIM_TIMEOUT "screen/dim_timeout"
+#define SETUP_SCREEN_DIM_TIMEOUT_DEFAULT 5
+#define SETUP_SCREEN_DIM_PERCENT "screen/dim_percent"
+#define SETUP_SCREEN_DIM_PERCENT_DEFAULT 20
+
 #define SETUP_NOTIFICATION_TIMEOUT "notification/timeout"
-#define SETUP_NOTIFICATION_TIMEOUT_DEFAULT 3000
+#define SETUP_NOTIFICATION_TIMEOUT_DEFAULT 3
 
 #endif // CONSTANTS_H
index bdefdb7..1f0787b 100644 (file)
@@ -19,26 +19,31 @@ void notify::init()
 
 void notify::notify(const QString& msg)
 {
+    QSettings settings;
+
+    // SETUP_NOTIFICATION_TIMEOUT is in seconds
+    int timeout = 1000 * settings.value(SETUP_NOTIFICATION_TIMEOUT, SETUP_NOTIFICATION_TIMEOUT_DEFAULT).toInt();
+    if (timeout != 0) {
 #ifdef Q_WS_MAEMO_5
-    QMaemo5InformationBox::information (0, msg);
+        QMaemo5InformationBox::information(0, msg, timeout);
 #else
-    /* Create notification */
-    NotifyNotification *notification = notify_notification_new(APPLICATION_NAME, qPrintable(msg), 0, 0);
-    if (notification) {
-        QSettings settings;
-        int timeout = settings.value(SETUP_NOTIFICATION_TIMEOUT, SETUP_NOTIFICATION_TIMEOUT_DEFAULT).toInt();
+        /* Create notification */
+        NotifyNotification *notification = notify_notification_new(APPLICATION_NAME, qPrintable(msg), 0, 0);
+        if (notification) {
+            /* Set timeout */
+            notify_notification_set_timeout(notification, timeout);
 
-        /* Set timeout */
-        notify_notification_set_timeout(notification, timeout);
+            /* Schedule notification for showing */
+            if (!notify_notification_show(notification, NULL)) {
+                qDebug("Failed to show notification");
+            }
 
-        /* Schedule notification for showing */
-        if (!notify_notification_show(notification, NULL)) {
-            qDebug("Failed to send notification");
+            /* Clean up the memory */
+            g_object_unref(notification);
+        } else {
+            qDebug("Failed to create notification");
         }
-
-        /* Clean up the memory */
-        g_object_unref(notification);
-    }
 #endif
+    }
     qDebug(qPrintable(msg));
 }
index 0f4d68c..2ab4d9f 100644 (file)
@@ -4,13 +4,13 @@ simplexbmcremote (0.8.2) unstable; urgency=low
 
  -- Ionutz Borcoman <iborco+maemo@gmail.com>  Thu, 17 Mar 2011 09:00:00 +0200
 
-simplexbmcremote (0.8.1) unstable; urgency=low
+simplexbmcremote (0.8.2) unstable; urgency=low
 
   * Preparing for garage upload.
 
  -- Ionutz Borcoman <iborco+maemo@gmail.com>  Wed, 09 Mar 2011 09:16:53 +0200
 
-simplexbmcremote (0.8.0) unstable; urgency=low
+simplexbmcremote (0.8.2) unstable; urgency=low
 
   * Initial Release.
 
index a8ba697..4f7c34a 100644 (file)
@@ -22,6 +22,16 @@ void SetupDialog::save()
     QSettings settings;
     settings.setValue(SETUP_XBMC_SERVER, ui->xbmcServerEdit->text());
     settings.setValue(SETUP_XBMC_PORT, ui->xbmcPortEdit->text());
+
+    settings.setValue(SETUP_XBMC_REQUIRES_AUTHENTICATION, ui->xbmcRequiresAuthenticationBox->isChecked());
+    settings.setValue(SETUP_XBMC_USERNAME, ui->xbmcUsernameEdit->text());
+    settings.setValue(SETUP_XBMC_PASSWORD, ui->xbmcPasswordEdit->text());
+
+    settings.setValue(SETUP_SCREEN_DISABLE_SCREENSAVER, ui->screenDisableScreensaverBox->isChecked());
+    settings.setValue(SETUP_SCREEN_DIM_TIMEOUT, ui->screenDimTimeoutSlider->value());
+    settings.setValue(SETUP_SCREEN_DIM_PERCENT, ui->screenDimPercentSlider->value());
+
+    settings.setValue(SETUP_NOTIFICATION_TIMEOUT, ui->notificationTimeoutSlider->value());
 }
 
 void SetupDialog::load()
@@ -29,4 +39,14 @@ void SetupDialog::load()
     QSettings settings;
     ui->xbmcServerEdit->setText(settings.value(SETUP_XBMC_SERVER, SETUP_XBMC_SERVER_DEFAULT).toString());
     ui->xbmcPortEdit->setText(settings.value(SETUP_XBMC_PORT, SETUP_XBMC_PORT_DEFAULT).toString());
+
+    ui->xbmcRequiresAuthenticationBox->setChecked(settings.value(SETUP_XBMC_REQUIRES_AUTHENTICATION, SETUP_XBMC_REQUIRES_AUTHENTICATION_DEFAULT).toBool());
+    ui->xbmcUsernameEdit->setText(settings.value(SETUP_XBMC_USERNAME, SETUP_XBMC_USERNAME_DEFAULT).toString());
+    ui->xbmcPasswordEdit->setText(settings.value(SETUP_XBMC_PASSWORD, SETUP_XBMC_PASSWORD_DEFAULT).toString());
+
+    ui->screenDisableScreensaverBox->setChecked(settings.value(SETUP_SCREEN_DISABLE_SCREENSAVER, SETUP_SCREEN_DISABLE_SCREENSAVER_DEFAULT).toBool());
+    ui->screenDimTimeoutSlider->setValue(settings.value(SETUP_SCREEN_DIM_TIMEOUT, SETUP_SCREEN_DIM_TIMEOUT_DEFAULT).toInt());
+    ui->screenDimPercentSlider->setValue(settings.value(SETUP_SCREEN_DIM_PERCENT, SETUP_SCREEN_DIM_PERCENT_DEFAULT).toInt());
+
+    ui->notificationTimeoutSlider->setValue(settings.value(SETUP_NOTIFICATION_TIMEOUT, SETUP_NOTIFICATION_TIMEOUT_DEFAULT).toInt());
 }
index dfa5ea6..261ad5f 100644 (file)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>329</width>
-    <height>111</height>
+    <width>395</width>
+    <height>439</height>
    </rect>
   </property>
   <property name="windowTitle">
   </property>
   <layout class="QHBoxLayout" name="horizontalLayout">
    <item>
-    <layout class="QVBoxLayout" name="verticalLayout">
-     <item>
-      <widget class="QLabel" name="label">
-       <property name="text">
-        <string>XBMC</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <layout class="QFormLayout" name="formLayout">
-       <item row="0" column="0">
-        <widget class="QLabel" name="xbmcServerLabel">
-         <property name="text">
-          <string>Server:</string>
+    <widget class="QScrollArea" name="scrollArea">
+     <property name="frameShape">
+      <enum>QFrame::NoFrame</enum>
+     </property>
+     <property name="verticalScrollBarPolicy">
+      <enum>Qt::ScrollBarAlwaysOff</enum>
+     </property>
+     <property name="horizontalScrollBarPolicy">
+      <enum>Qt::ScrollBarAlwaysOff</enum>
+     </property>
+     <property name="widgetResizable">
+      <bool>true</bool>
+     </property>
+     <widget class="QWidget" name="scrollAreaWidgetContents">
+      <property name="geometry">
+       <rect>
+        <x>0</x>
+        <y>0</y>
+        <width>286</width>
+        <height>421</height>
+       </rect>
+      </property>
+      <layout class="QVBoxLayout" name="verticalLayout_4">
+       <item>
+        <widget class="QGroupBox" name="groupBox">
+         <property name="title">
+          <string>XBMC</string>
          </property>
+         <layout class="QVBoxLayout" name="verticalLayout">
+          <item>
+           <layout class="QFormLayout" name="formLayout">
+            <item row="0" column="1">
+             <widget class="QLineEdit" name="xbmcServerEdit"/>
+            </item>
+            <item row="1" column="0">
+             <widget class="QLabel" name="xbmcPortLabel">
+              <property name="text">
+               <string>Port:</string>
+              </property>
+             </widget>
+            </item>
+            <item row="1" column="1">
+             <widget class="QLineEdit" name="xbmcPortEdit"/>
+            </item>
+            <item row="0" column="0">
+             <widget class="QLabel" name="xbmcServerLabel">
+              <property name="text">
+               <string>Server:</string>
+              </property>
+             </widget>
+            </item>
+           </layout>
+          </item>
+          <item>
+           <widget class="QGroupBox" name="xbmcRequiresAuthenticationBox">
+            <property name="title">
+             <string>Requires authentication</string>
+            </property>
+            <property name="checkable">
+             <bool>true</bool>
+            </property>
+            <property name="checked">
+             <bool>false</bool>
+            </property>
+            <layout class="QVBoxLayout" name="verticalLayout_2">
+             <property name="leftMargin">
+              <number>0</number>
+             </property>
+             <property name="rightMargin">
+              <number>0</number>
+             </property>
+             <item>
+              <layout class="QFormLayout" name="formLayout_2">
+               <item row="0" column="1">
+                <widget class="QLineEdit" name="xbmcUsernameEdit"/>
+               </item>
+               <item row="1" column="0">
+                <widget class="QLabel" name="label_3">
+                 <property name="text">
+                  <string>Password:</string>
+                 </property>
+                </widget>
+               </item>
+               <item row="1" column="1">
+                <widget class="QLineEdit" name="xbmcPasswordEdit">
+                 <property name="echoMode">
+                  <enum>QLineEdit::Password</enum>
+                 </property>
+                </widget>
+               </item>
+               <item row="0" column="0">
+                <widget class="QLabel" name="label_2">
+                 <property name="text">
+                  <string>Username:</string>
+                 </property>
+                </widget>
+               </item>
+              </layout>
+             </item>
+            </layout>
+           </widget>
+          </item>
+         </layout>
         </widget>
        </item>
-       <item row="0" column="1">
-        <widget class="QLineEdit" name="xbmcServerEdit"/>
+       <item>
+        <widget class="QGroupBox" name="screenDisableScreensaverBox">
+         <property name="title">
+          <string>Disable screensaver</string>
+         </property>
+         <property name="checkable">
+          <bool>true</bool>
+         </property>
+         <property name="checked">
+          <bool>false</bool>
+         </property>
+         <layout class="QVBoxLayout" name="verticalLayout_3">
+          <item>
+           <widget class="QLabel" name="label_5">
+            <property name="text">
+             <string>Dim Timeout (1-30 secs):</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QSlider" name="screenDimTimeoutSlider">
+            <property name="maximum">
+             <number>30</number>
+            </property>
+            <property name="value">
+             <number>15</number>
+            </property>
+            <property name="orientation">
+             <enum>Qt::Horizontal</enum>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QLabel" name="label_6">
+            <property name="text">
+             <string>Dimmed % (0-100, 100 is no dim):</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QSlider" name="screenDimPercentSlider">
+            <property name="maximum">
+             <number>100</number>
+            </property>
+            <property name="value">
+             <number>20</number>
+            </property>
+            <property name="orientation">
+             <enum>Qt::Horizontal</enum>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </widget>
        </item>
-       <item row="1" column="0">
-        <widget class="QLabel" name="xbmcPortLabel">
+       <item>
+        <widget class="QLabel" name="label">
          <property name="text">
-          <string>Port:</string>
+          <string>Notifications (0 - 10 sec, 0 is disabled):</string>
          </property>
         </widget>
        </item>
-       <item row="1" column="1">
-        <widget class="QLineEdit" name="xbmcPortEdit"/>
+       <item>
+        <widget class="QSlider" name="notificationTimeoutSlider">
+         <property name="maximum">
+          <number>10</number>
+         </property>
+         <property name="value">
+          <number>3</number>
+         </property>
+         <property name="orientation">
+          <enum>Qt::Horizontal</enum>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <spacer name="verticalSpacer">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>20</width>
+           <height>40</height>
+          </size>
+         </property>
+        </spacer>
        </item>
       </layout>
-     </item>
-     <item>
-      <spacer name="verticalSpacer">
-       <property name="orientation">
-        <enum>Qt::Vertical</enum>
-       </property>
-       <property name="sizeHint" stdset="0">
-        <size>
-         <width>20</width>
-         <height>40</height>
-        </size>
-       </property>
-      </spacer>
-     </item>
-    </layout>
+     </widget>
+    </widget>
    </item>
    <item>
     <widget class="QDialogButtonBox" name="buttonBox">
index ce7d41f..d547022 100644 (file)
@@ -53,7 +53,7 @@ Xbmc::~Xbmc()
     delete m_manager;
 }
 
-void Xbmc::commandActionFinished()
+void Xbmc::commandFinished()
 {
     QNetworkReply* reply = qobject_cast<QNetworkReply *>(sender());
     if (reply) {
@@ -68,21 +68,6 @@ void Xbmc::commandActionFinished()
     }
 }
 
-void Xbmc::do_command_action(int action)
-{
-    QSettings settings;
-    QString server = settings.value(SETUP_XBMC_SERVER, SETUP_XBMC_SERVER_DEFAULT).toString();
-    QString port = settings.value(SETUP_XBMC_PORT, SETUP_XBMC_PORT_DEFAULT).toString();
-
-    QUrl url = QUrl(QString("http://%1:%2/xbmcCmds/xbmcHttp?command=Action(%3)").arg(server).arg(port).arg(action));
-
-    QNetworkRequest request;
-    request.setUrl(url);
-
-    QNetworkReply *reply = m_manager->get(request);
-    connect(reply, SIGNAL(finished()), this, SLOT(commandActionFinished()));
-}
-
 void Xbmc::actionRight()
 {
     do_command_action(ACTION_MOVE_RIGHT);
@@ -154,7 +139,7 @@ void Xbmc::actionShowGui()
 
 void Xbmc::actionSendKeyEsc()
 {
-    do_send_key(KEY_ASCII + 0x1B); // ESC
+    do_command_send_key(KEY_ASCII + 0x1B); // ESC
 }
 
 void Xbmc::actionContextMenu()
@@ -162,17 +147,29 @@ void Xbmc::actionContextMenu()
     do_command_action(ACTION_CONTEXT_MENU);
 }
 
-void Xbmc::do_send_key(int key)
+void Xbmc::do_command_send_key(int key)
+{
+    do_command1("SendKey", key);
+}
+
+void Xbmc::do_command_action(int action)
+{
+    do_command1("Action", action);
+}
+
+void Xbmc::do_command1(const QString &command, int id)
 {
     QSettings settings;
     QString server = settings.value(SETUP_XBMC_SERVER, SETUP_XBMC_SERVER_DEFAULT).toString();
     QString port = settings.value(SETUP_XBMC_PORT, SETUP_XBMC_PORT_DEFAULT).toString();
 
-    QUrl url = QUrl(QString("http://%1:%2/xbmcCmds/xbmcHttp?command=SendKey(%3)").arg(server).arg(port).arg(key));
+    QUrl url = QUrl(QString("http://%1:%2/xbmcCmds/xbmcHttp?command=%3(%4)").arg(server).arg(port).arg(command).arg(id));
+
+    qDebug("executing command: %s", qPrintable(url.toString()));
 
     QNetworkRequest request;
     request.setUrl(url);
 
     QNetworkReply *reply = m_manager->get(request);
-    connect(reply, SIGNAL(finished()), this, SLOT(commandActionFinished()));
+    connect(reply, SIGNAL(finished()), this, SLOT(commandFinished()));
 }
index 33fcf41..f06b4e7 100644 (file)
@@ -33,11 +33,13 @@ public:
     void actionContextMenu();
 
 private slots:
-    void commandActionFinished();
+    void commandFinished();
 
 private:
+    void do_command1(const QString& command, int id);
+
     void do_command_action(int action);
-    void do_send_key(int key);
+    void do_command_send_key(int key);
 
     QNetworkAccessManager *m_manager;
 };