Clean up the network remote settings page, add a "Get it on Google Play" button.

This commit is contained in:
David Sansome 2013-07-27 15:27:08 +10:00
parent cf1dfe0d58
commit 1a3f6af1bd
43 changed files with 243 additions and 206 deletions

View File

@ -270,6 +270,40 @@
<file>osd_background.png</file>
<file>osd_shadow_corner.png</file>
<file>osd_shadow_edge.png</file>
<file>playstore/af_generic_rgb_wo_45.png</file>
<file>playstore/ar_generic_rgb_wo_45.png</file>
<file>playstore/be_generic_rgb_wo_45.png</file>
<file>playstore/bg_generic_rgb_wo_45.png</file>
<file>playstore/ca_generic_rgb_wo_45.png</file>
<file>playstore/cs_generic_rgb_wo_45.png</file>
<file>playstore/da_generic_rgb_wo_45.png</file>
<file>playstore/de_generic_rgb_wo_45.png</file>
<file>playstore/el_generic_rgb_wo_45.png</file>
<file>playstore/en_generic_rgb_wo_45.png</file>
<file>playstore/es_generic_rgb_wo_45.png</file>
<file>playstore/et_generic_rgb_wo_45.png</file>
<file>playstore/fa_generic_rgb_wo_45.png</file>
<file>playstore/fi_generic_rgb_wo_45.png</file>
<file>playstore/fr_generic_rgb_wo_45.png</file>
<file>playstore/hr_generic_rgb_wo_45.png</file>
<file>playstore/hu_generic_rgb_wo_45.png</file>
<file>playstore/it_generic_rgb_wo_45.png</file>
<file>playstore/ja_generic_rgb_wo_45.png</file>
<file>playstore/ko_generic_rgb_wo_45.png</file>
<file>playstore/lt_generic_rgb_wo_45.png</file>
<file>playstore/lv_generic_rgb_wo_45.png</file>
<file>playstore/ms_generic_rgb_wo_45.png</file>
<file>playstore/nl_generic_rgb_wo_45.png</file>
<file>playstore/pl_generic_rgb_wo_45.png</file>
<file>playstore/ro_generic_rgb_wo_45.png</file>
<file>playstore/ru_generic_rgb_wo_45.png</file>
<file>playstore/sk_generic_rgb_wo_45.png</file>
<file>playstore/sl_generic_rgb_wo_45.png</file>
<file>playstore/sr_generic_rgb_wo_45.png</file>
<file>playstore/sv_generic_rgb_wo_45.png</file>
<file>playstore/tr_generic_rgb_wo_45.png</file>
<file>playstore/uk_generic_rgb_wo_45.png</file>
<file>playstore/vi_generic_rgb_wo_45.png</file>
<file>providers/amazon.png</file>
<file>providers/aol.png</file>
<file>providers/bbc.png</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

@ -55,6 +55,9 @@ public:
Application(QObject* parent = NULL);
~Application();
QString language_name() const { return language_name_; }
void set_language_name(const QString& name) { language_name_ = name; }
TagReaderClient* tag_reader_client() const { return tag_reader_client_; }
Database* database() const { return database_; }
AlbumCoverLoader* album_cover_loader() const { return album_cover_loader_; }
@ -95,6 +98,8 @@ signals:
void SettingsDialogRequested(SettingsDialog::Page page);
private:
QString language_name_;
TagReaderClient* tag_reader_client_;
Database* database_;
AlbumCoverLoader* album_cover_loader_;

View File

@ -588,6 +588,20 @@ bool IsLaptop() {
#endif
}
QString SystemLanguageName() {
#if QT_VERSION >= 0x040800
QString system_language = QLocale::system().uiLanguages().empty() ?
QLocale::system().name() : QLocale::system().uiLanguages().first();
// uiLanguages returns strings with "-" as separators for language/region;
// however QTranslator needs "_" separators
system_language.replace("-", "_");
#else
QString system_language = QLocale::system().name();
#endif
return system_language;
}
} // namespace Utilities

View File

@ -138,6 +138,8 @@ namespace Utilities {
// Returns true if this machine has a battery.
bool IsLaptop();
QString SystemLanguageName();
}
class ScopedWCharArray {

View File

@ -110,7 +110,7 @@ using boost::scoped_ptr;
#endif
void LoadTranslation(const QString& prefix, const QString& path,
const QString& override_language = QString()) {
const QString& language) {
#if QT_VERSION < 0x040700
// QTranslator::load will try to open and read "clementine" if it exists,
// without checking if it's a file first.
@ -120,19 +120,6 @@ void LoadTranslation(const QString& prefix, const QString& path,
return;
#endif
#if QT_VERSION >= 0x040800
QString system_language = QLocale::system().uiLanguages().empty() ?
QLocale::system().name() : QLocale::system().uiLanguages().first();
// uiLanguages returns strings with "-" as separators for language/region;
// however QTranslator needs "_" separators
system_language.replace("-", "_");
#else
QString system_language = QLocale::system().name();
#endif
QString language = override_language.isEmpty() ?
system_language : override_language;
QTranslator* t = new PoTranslator;
if (t->load(prefix + "_" + language, path))
QCoreApplication::installTranslator(t);
@ -389,13 +376,16 @@ int main(int argc, char *argv[]) {
QSslCertificate::fromPath(":/grooveshark-valicert-ca.pem", QSsl::Pem));
// Has the user forced a different language?
QString language = options.language();
if (language.isEmpty()) {
QString override_language = options.language();
if (override_language.isEmpty()) {
QSettings s;
s.beginGroup("General");
language = s.value("language").toString();
override_language = s.value("language").toString();
}
const QString language = override_language.isEmpty() ?
Utilities::SystemLanguageName() : override_language;
// Translations
LoadTranslation("qt", QLibraryInfo::location(QLibraryInfo::TranslationsPath), language);
LoadTranslation("clementine", ":/translations", language);
@ -417,6 +407,7 @@ int main(int argc, char *argv[]) {
QtConcurrent::run(&ParseAProto);
Application app;
app.set_language_name(language);
Echonest::Config::instance()->setAPIKey("DFLFLJBUF4EGTXHIG");
Echonest::Config::instance()->setNetworkAccessManager(new NetworkAccessManager);

View File

@ -183,8 +183,10 @@ void NetworkRemote::AcceptConnection() {
bool NetworkRemote::IpIsPrivate(const QHostAddress& address) {
return
// Localhost v4
address.isInSubnet(QHostAddress::parseSubnet("127.0.0.0/8")) ||
// Link Local v4
address.isInSubnet(QHostAddress::parseSubnet("127.0.0.1/8")) ||
address.isInSubnet(QHostAddress::parseSubnet("169.254.1.0/16")) ||
// Link Local v6
address.isInSubnet(QHostAddress::parseSubnet("::1/128")) ||
address.isInSubnet(QHostAddress::parseSubnet("fe80::/10")) ||
@ -196,7 +198,7 @@ bool NetworkRemote::IpIsPrivate(const QHostAddress& address) {
address.isInSubnet(QHostAddress::parseSubnet("fc00::/7"));
}
void NetworkRemote::CreateRemoteClient(QTcpSocket *client_socket) {
void NetworkRemote::CreateRemoteClient(QTcpSocket* client_socket) {
if (client_socket) {
// Add the client to the list
RemoteClient* client = new RemoteClient(app_, client_socket);

View File

@ -21,44 +21,48 @@
#include "networkremote/networkremote.h"
#include "networkremote/networkremotehelper.h"
#include <QDesktopServices>
#include <QSettings>
#include <QHostInfo>
#include <QNetworkInterface>
const char* NetworkRemoteSettingsPage::kPlayStoreUrl =
"https://play.google.com/store/apps/details?id=de.qspool.clementineremote";
NetworkRemoteSettingsPage::NetworkRemoteSettingsPage(SettingsDialog* dialog)
: SettingsPage(dialog),
ui_(new Ui_NetworkRemoteSettingsPage)
{
ui_->setupUi(this);
setWindowIcon(IconLoader::Load("ipodtouchicon"));
ui_->play_store->installEventFilter(this);
}
NetworkRemoteSettingsPage::~NetworkRemoteSettingsPage() {
delete ui_;
}
bool NetworkRemoteSettingsPage::eventFilter(QObject* object, QEvent* event) {
if (object == ui_->play_store &&
event->type() == QEvent::MouseButtonRelease) {
QDesktopServices::openUrl(QUrl(kPlayStoreUrl));
return true;
}
return SettingsPage::eventFilter(object, event);
}
void NetworkRemoteSettingsPage::Load() {
QSettings s;
int port;
s.beginGroup(NetworkRemote::kSettingsGroup);
port = s.value("port").toInt();
if (port == 0) {
ui_->remote_port->setValue(NetworkRemote::kDefaultServerPort);
}
else {
ui_->remote_port->setValue(s.value("port").toInt());
}
ui_->use_remote->setChecked(s.value("use_remote").toBool());
if (s.contains("only_non_public_ip")) {
ui_->only_non_public_ip->setChecked(s.value("only_non_public_ip").toBool());
} else {
// Default yes
ui_->only_non_public_ip->setChecked(true);
s.setValue("only_non_public_ip", true);
}
ui_->remote_port->setValue(
s.value("port", NetworkRemote::kDefaultServerPort).toInt());
ui_->only_non_public_ip->setChecked(
s.value("only_non_public_ip", true).toBool());
// Auth Code, 5 digits
ui_->use_auth_code->setChecked(s.value("use_auth_code", false).toBool());
@ -68,9 +72,6 @@ void NetworkRemoteSettingsPage::Load() {
s.endGroup();
QPixmap android_qr_code(":clementine_remote_qr.png");
ui_->android_app_qr->setPixmap(android_qr_code);
// Get local ip addresses
QString ip_addresses;
QList<QHostAddress> addresses = QNetworkInterface::allAddresses();
@ -80,12 +81,26 @@ void NetworkRemoteSettingsPage::Load() {
!address.isInSubnet(QHostAddress::parseSubnet("127.0.0.1/8"))) {
qLog(Debug) << "IP:" << address.toString();
if (!ip_addresses.isEmpty()) {
ip_addresses.append("; ");
ip_addresses.append(", ");
}
ip_addresses.append(address.toString());
}
}
ui_->ip_address->setText(ip_addresses);
// Get the right play store badge for this language.
QString language = dialog()->app()->language_name();
const int underscore = language.indexOf('_');
if (underscore != -1) {
language = language.left(underscore);
}
QString badge_filename = ":/playstore/" + language + "_generic_rgb_wo_45.png";
if (!QFile::exists(badge_filename)) {
badge_filename = ":/playstore/en_generic_rgb_wo_45.png";
}
ui_->play_store->setPixmap(QPixmap(badge_filename));
}
void NetworkRemoteSettingsPage::Save() {

View File

@ -32,7 +32,12 @@ public:
void Load();
void Save();
protected:
bool eventFilter(QObject* object, QEvent* event);
private:
static const char* kPlayStoreUrl;
Ui_NetworkRemoteSettingsPage* ui_;
};

View File

@ -6,217 +6,170 @@
<rect>
<x>0</x>
<y>0</y>
<width>475</width>
<height>300</height>
<width>884</width>
<height>587</height>
</rect>
</property>
<property name="windowTitle">
<string>Network Remote</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="use_remote">
<property name="text">
<string>Use Remotecontrol</string>
<string>Use a network remote control</string>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="use_remote_container" native="true">
<widget class="QGroupBox" name="use_remote_container_2">
<property name="enabled">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="leftMargin">
<number>24</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_remote_port">
<property name="minimumSize">
<size>
<width>171</width>
<height>0</height>
</size>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Port</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="remote_port">
<property name="maximum">
<number>65535</number>
</property>
<property name="value">
<number>8080</number>
</property>
</widget>
</item>
</layout>
<property name="title">
<string>Settings</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_remote_port">
<property name="minimumSize">
<size>
<width>171</width>
<height>0</height>
</size>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Port</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="only_non_public_ip">
<property name="toolTip">
<string>Only accept connections from clients within the ip ranges:
<item row="0" column="1">
<widget class="QSpinBox" name="remote_port">
<property name="maximum">
<number>65535</number>
</property>
<property name="value">
<number>8080</number>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="only_non_public_ip">
<property name="toolTip">
<string>Only accept connections from clients within the ip ranges:
10.x.x.x
172.16.0.0 - 172.31.255.255
192.168.x.x</string>
</property>
<property name="text">
<string>Accept non public clients only</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</property>
<property name="text">
<string>Only allow connections from the local network</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QCheckBox" name="use_auth_code">
<property name="toolTip">
<string>A client can connect only, if the correct code was entered.</string>
</property>
<property name="text">
<string>Use authentication code</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="auth_code">
<property name="enabled">
<bool>false</bool>
</property>
<property name="suffix">
<string/>
</property>
<property name="maximum">
<number>99999</number>
</property>
</widget>
</item>
</layout>
<item row="2" column="0">
<widget class="QCheckBox" name="use_auth_code">
<property name="toolTip">
<string>A client can connect only, if the correct code was entered.</string>
</property>
<property name="text">
<string>Require authentication code</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QCheckBox" name="allow_downloads">
<property name="toolTip">
<string>Allow a client to download music from this computer.</string>
</property>
<property name="text">
<string>Allow downloads</string>
</property>
</widget>
</item>
</layout>
<item row="2" column="1">
<widget class="QSpinBox" name="auth_code">
<property name="enabled">
<bool>false</bool>
</property>
<property name="suffix">
<string/>
</property>
<property name="maximum">
<number>99999</number>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_2">
<property name="toolTip">
<string>Enter this IP in the App to connect to Clementine.</string>
</property>
<property name="text">
<string>Your IP address:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="ip_address">
<property name="text">
<string>127.0.0.1</string>
</property>
</widget>
</item>
</layout>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="allow_downloads">
<property name="toolTip">
<string>Allow a client to download music from this computer.</string>
</property>
<property name="text">
<string>Allow downloads</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_2">
<property name="toolTip">
<string>Enter this IP in the App to connect to Clementine.</string>
</property>
<property name="text">
<string>Your IP address:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="ip_address">
<property name="text">
<string>127.0.0.1</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>15</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>&lt;a href=&quot;https://play.google.com/store/apps/details?id=de.qspool.clementineremote&quot;&gt;Get the Android App now!&lt;/a&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse</set>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Download the Android app</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="play_store">
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="android_app_qr">
<property name="pixmap">
<pixmap resource="../../data/data.qrc">:/clementine_remote_qr.png</pixmap>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="android_app_qr">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_5">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>36</height>
<height>98</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="../../data/data.qrc"/>
</resources>
<connections>
<connection>
<sender>use_remote</sender>
<signal>toggled(bool)</signal>
<receiver>use_remote_container</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>199</x>
<y>19</y>
</hint>
<hint type="destinationlabel">
<x>199</x>
<y>60</y>
</hint>
</hints>
</connection>
<connection>
<sender>use_auth_code</sender>
<signal>toggled(bool)</signal>
@ -233,5 +186,21 @@
</hint>
</hints>
</connection>
<connection>
<sender>use_remote</sender>
<signal>toggled(bool)</signal>
<receiver>use_remote_container_2</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>59</x>
<y>22</y>
</hint>
<hint type="destinationlabel">
<x>57</x>
<y>43</y>
</hint>
</hints>
</connection>
</connections>
</ui>