1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-18 12:28:31 +01:00

Minimal SubsonicService and SubsonicSettingsPage to show up in UI

This commit is contained in:
Alan Briolat 2011-12-05 23:10:25 +00:00
parent dbca026a66
commit 8110cdf241
11 changed files with 262 additions and 0 deletions

View File

@ -337,5 +337,6 @@
<file>schema/schema-35.sql</file>
<file>schema/schema-36.sql</file>
<file>grooveshark-valicert-ca.pem</file>
<file>providers/subsonic.png</file>
</qresource>
</RCC>

BIN
data/providers/subsonic.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 734 B

View File

@ -169,6 +169,8 @@ set(SOURCES
internet/savedradio.cpp
internet/somafmservice.cpp
internet/somafmurlhandler.cpp
internet/subsonicservice.cpp
internet/subsonicsettingspage.cpp
library/groupbydialog.cpp
library/library.cpp
@ -411,6 +413,8 @@ set(HEADERS
internet/savedradio.h
internet/somafmservice.h
internet/somafmurlhandler.h
internet/subsonicservice.h
internet/subsonicsettingspage.h
library/groupbydialog.h
library/library.h
@ -559,6 +563,7 @@ set(UI
internet/magnatunedownloaddialog.ui
internet/magnatunesettingspage.ui
internet/spotifysettingspage.ui
internet/subsonicsettingspage.ui
library/groupbydialog.ui
library/libraryfilterwidget.ui

View File

@ -25,6 +25,7 @@
#include "savedradio.h"
#include "somafmservice.h"
#include "groovesharkservice.h"
#include "subsonicservice.h"
#include "core/logging.h"
#include "core/mergedproxymodel.h"
#include "smartplaylists/generatormimedata.h"
@ -78,6 +79,7 @@ InternetModel::InternetModel(BackgroundThread<Database>* db_thread,
#ifdef HAVE_SPOTIFY
AddService(new SpotifyService(this));
#endif
AddService(new SubsonicService(this));
}
void InternetModel::AddService(InternetService *service) {

View File

@ -0,0 +1,47 @@
#include "subsonicservice.h"
#include "internetmodel.h"
const char* SubsonicService::kServiceName = "Subsonic";
const char* SubsonicService::kSettingsGroup = "Subsonic";
const char* SubsonicService::kApiVersion = "1.6.0";
const char* SubsonicService::kApiClientName = "Clementine";
SubsonicService::SubsonicService(InternetModel *parent)
: InternetService(kServiceName, parent, parent)
{
}
SubsonicService::~SubsonicService()
{
}
QStandardItem* SubsonicService::CreateRootItem()
{
root_ = new QStandardItem(QIcon(":providers/subsonic.png"), kServiceName);
root_->setData(true, InternetModel::Role_CanLazyLoad);
return root_;
}
void SubsonicService::LazyPopulate(QStandardItem *item)
{
}
QModelIndex SubsonicService::GetCurrentIndex()
{
return context_item_;
}
QUrl SubsonicService::BuildRequestUrl(const QString &view, const RequestOptions &options)
{
QUrl url(server_url_ + "rest/" + view + ".view");
url.addQueryItem("v", kApiVersion);
url.addQueryItem("c", kApiClientName);
url.addQueryItem("u", username_);
url.addQueryItem("p", password_);
for (RequestOptions::const_iterator i = options.begin(); i != options.end(); ++i)
{
url.addQueryItem(i.key(), i.value());
}
return url;
}

View File

@ -0,0 +1,39 @@
#ifndef SUBSONICSERVICE_H
#define SUBSONICSERVICE_H
#include "internetservice.h"
class SubsonicService : public InternetService
{
Q_OBJECT
public:
SubsonicService(InternetModel *parent);
~SubsonicService();
typedef QMap<QString, QString> RequestOptions;
QStandardItem* CreateRootItem();
void LazyPopulate(QStandardItem *item);
static const char* kServiceName;
static const char* kSettingsGroup;
static const char* kApiVersion;
static const char* kApiClientName;
protected:
QModelIndex GetCurrentIndex();
private:
QUrl BuildRequestUrl(const QString &view, const RequestOptions &options);
QModelIndex context_item_;
QStandardItem* root_;
// Configuration
QString server_url_;
QString username_;
QString password_;
};
#endif // SUBSONICSERVICE_H

View File

@ -0,0 +1,39 @@
#include "subsonicsettingspage.h"
#include "ui_subsonicsettingspage.h"
#include "subsonicservice.h"
#include <QSettings>
SubsonicSettingsPage::SubsonicSettingsPage(SettingsDialog *dialog)
: SettingsPage(dialog),
ui_(new Ui_SubsonicSettingsPage)
{
ui_->setupUi(this);
setWindowIcon(QIcon(":/providers/subsonic.png"));
}
SubsonicSettingsPage::~SubsonicSettingsPage()
{
delete ui_;
}
void SubsonicSettingsPage::Load()
{
QSettings s;
s.beginGroup(SubsonicService::kSettingsGroup);
ui_->server->setText(s.value("server").toString());
ui_->username->setText(s.value("username").toString());
ui_->password->setText(s.value("password").toString());
}
void SubsonicSettingsPage::Save()
{
QSettings s;
s.beginGroup(SubsonicService::kSettingsGroup);
s.setValue("server", ui_->server->text());
s.setValue("username", ui_->username->text());
s.setValue("password", ui_->password->text());
}

View File

@ -0,0 +1,25 @@
#ifndef SUBSONICSETTINGSPAGE_H
#define SUBSONICSETTINGSPAGE_H
#include "ui/settingspage.h"
class Ui_SubsonicSettingsPage;
class SubsonicService;
class SubsonicSettingsPage : public SettingsPage
{
Q_OBJECT
public:
SubsonicSettingsPage(SettingsDialog *dialog);
~SubsonicSettingsPage();
void Load();
void Save();
private:
Ui_SubsonicSettingsPage* ui_;
SubsonicService* service_;
};
#endif // SUBSONICSETTINGSPAGE_H

View File

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SubsonicSettingsPage</class>
<widget class="QWidget" name="SubsonicSettingsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>505</width>
<height>219</height>
</rect>
</property>
<property name="windowTitle">
<string>Subsonic</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="LoginStateWidget" name="login_state" native="true"/>
</item>
<item>
<widget class="QGroupBox" name="server_group">
<property name="title">
<string>Server details</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="server_label">
<property name="text">
<string>Server</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="username_label">
<property name="text">
<string>Username</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="password_label">
<property name="text">
<string>Password</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QLineEdit" name="password">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="username"/>
</item>
<item row="0" column="1" colspan="2">
<widget class="QLineEdit" name="server"/>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="login">
<property name="text">
<string>Login</string>
</property>
</widget>
</item>
</layout>
</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>
</widget>
<customwidgets>
<customwidget>
<class>LoginStateWidget</class>
<extends>QWidget</extends>
<header>widgets/loginstatewidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>server</tabstop>
<tabstop>username</tabstop>
<tabstop>password</tabstop>
<tabstop>login</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -35,6 +35,7 @@
#include "internet/digitallyimportedsettingspage.h"
#include "internet/groovesharksettingspage.h"
#include "internet/magnatunesettingspage.h"
#include "internet/subsonicsettingspage.h"
#include "library/librarysettingspage.h"
#include "playlist/playlistview.h"
#include "songinfo/songinfosettingspage.h"
@ -149,6 +150,7 @@ SettingsDialog::SettingsDialog(BackgroundStreams* streams, QWidget* parent)
AddPage(Page_Magnatune, new MagnatuneSettingsPage(this), providers);
AddPage(Page_DigitallyImported, new DigitallyImportedSettingsPage(this), providers);
AddPage(Page_BackgroundStreams, new BackgroundStreamsSettingsPage(this), providers);
AddPage(Page_Subsonic, new SubsonicSettingsPage(this), providers);
// List box
connect(ui_->list, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),

View File

@ -75,6 +75,7 @@ public:
Page_Transcoding,
Page_Remote,
Page_Wiimotedev,
Page_Subsonic,
};
enum Role {