Skip to content
Permalink
Browse files

Merge pull request #4 from Michal-Szczepaniak/master

Update from original project
  • Loading branch information
carmenfdezb committed Sep 6, 2019
2 parents 7bb2cb0 + 0099140 commit 7178ecd59706526253b425f61bf3285b41322d06
@@ -0,0 +1,9 @@
[Desktop Entry]
Type=Application
X-Nemo-Application-Type=silica-qt5
Icon=microtube
Exec=microtube %U
Name=µTube
NotShowIn=X-MeeGo;
MimeType=x-scheme-handler/http;x-scheme-handler/https;
Hidden=true;
@@ -2,7 +2,7 @@
Type=Application
X-Nemo-Application-Type=silica-qt5
Icon=microtube
Exec=microtube
Exec=microtube %U
Name=µTube
# translation example:
# your app name in German locale (de)
@@ -93,6 +93,7 @@ SOURCES += src/microtube.cpp \
src/QEasyDownloader/src/QEasyDownloader.cc

DISTFILES += qml/microtube.qml \
microtube-url.desktop \
qml/cover/CoverPage.qml \
rpm/microtube.spec \
translations/*.ts \
@@ -104,6 +105,7 @@ DISTFILES += qml/microtube.qml \
qml/pages/VideoPlayer.qml \
qml/pages/components/VideoElement.qml \
qml/pages/components/SilicaFastListView.qml \
qml/pages/components/SharePage.qml \
qml/pages/components/private/BoundsBehavior.qml \
qml/pages/components/private/FastScrollAnimation.js \
qml/pages/components/private/FastScrollAnimation.qml \
@@ -117,6 +119,11 @@ RESOURCES += \

SAILFISHAPP_ICONS = 86x86 108x108 128x128 172x172

urlfile.files = microtube-url.desktop
urlfile.path = /home/nemo/.local/share/applications

INSTALLS += urlfile

# to disable building translations every time, comment out the
# following CONFIG line
CONFIG += sailfishapp_i18n
@@ -51,7 +51,7 @@ Page {
}

Label {
text: "microtube 1.5.2"
text: "microtube 1.7.1"
font.pixelSize: Theme.fontSizeExtraLarge
anchors.horizontalCenter: parent.horizontalCenter
wrapMode: Text.WordWrap
@@ -144,6 +144,12 @@ Page {
anchors.horizontalCenter: parent.horizontalCenter
}

Label {
text: qsTr("1Zgp for hungarian translation.")
font.pixelSize: Theme.fontSizeSmall
anchors.horizontalCenter: parent.horizontalCenter
}

Label {
text: qsTr("DylanVanAssche for help.")
font.pixelSize: Theme.fontSizeSmall
@@ -74,6 +74,20 @@ Page {
settings.relatedVideos = checked
}
}

ComboBox {
id: regions
width: parent.width
label: "Region"
currentIndex: YT.getCurrentRegion();
menu: ContextMenu {
Repeater {
model: YT.getRegions();
delegate: MenuItem { text: modelData }
}
}
onCurrentItemChanged: YT.setRegion(currentIndex)
}
}
VerticalScrollDecorator {}
}
@@ -38,13 +38,20 @@ Page {
property string author: ""
property bool subscribed: false
property bool _controlsVisible: true
property bool videoChanging: false
property bool landscape: ( page.orientation === Orientation.Landscape || page.orientation === Orientation.LandscapeInverted )
property int autoBrightness: -1
property int inactiveBrightness: -1
property int activeBrightness: -1

DisplaySettings {
id: displaySettings
onBrightnessChanged: {
if (inactiveBrightness === -1) {
inactiveBrightness = brightness
activeBrightness = brightness
}
}
}

ConfigurationGroup {
@@ -146,15 +153,13 @@ Page {
showHideControls()
hideControlsAutomatically.restart()
autoBrightness = displaySettings.autoBrightnessEnabled
inactiveBrightness = displaySettings.brightness + 0
activeBrightness = displaySettings.brightness + 0
if ( landscape )
displaySettings.autoBrightnessEnabled = false

if ( settings.relatedVideos ) {
YTPlaylist.findRecommended()
YTPlaylist.setActiveRow(0, false)
video = YTPlaylist.videoAt(0)
video = YTPlaylist.qmlVideoAt(0)
}
video.loadStreamUrl()
}
@@ -167,9 +172,9 @@ Page {
if ( settings.relatedVideos ) {
YTPlaylist.findRecommended()
YTPlaylist.setActiveRow(0, false)
video = YTPlaylist.videoAt(0)
video = YTPlaylist.qmlVideoAt(0)
} else {
video = YTPlaylist.videoAt(YTPlaylist.activeRow())
video = YTPlaylist.qmlVideoAt(YTPlaylist.activeRow())
}
video.loadStreamUrl()
title = video.getTitle()
@@ -184,6 +189,7 @@ Page {
Connections {
target: video
onStreamUrlChanged: {
if(videoChanging) videoChanging = false
mediaPlayer.videoPlay()
}
}
@@ -230,26 +236,32 @@ Page {
flickableDirection: Flickable.VerticalFlick

PullDownMenu {
id: topMenu
visible: page.orientation === Orientation.Portrait

function resolutionChange(name) {
videoChanging = true
mediaPlayer.stop()
YT.setDefinition(name)
video.loadStreamUrl()
}

MenuItem {
text: qsTr("720p")
onClicked: {
YT.setDefinition("720p")
video.loadStreamUrl()
topMenu.resolutionChange("720p")
}
}
MenuItem {
text: qsTr("480p")
onClicked: {
YT.setDefinition("480p")
video.loadStreamUrl()
topMenu.resolutionChange("480p")
}
}
MenuItem {
text: qsTr("360p")
onClicked: {
YT.setDefinition("360p")
video.loadStreamUrl()
topMenu.resolutionChange("360p");
}
}
MenuItem {
@@ -295,13 +307,17 @@ Page {

function nextVideo() {
if (!YTPlaylist.nextRowExists()) return
videoChanging = true
mediaPlayer.stop()
mediaPlayer.seek(0)
YTPlaylist.setActiveRow(YTPlaylist.nextRow())
// changeVideo()
}

function prevVideo() {
if (!YTPlaylist.previousRowExists()) return
videoChanging = true
mediaPlayer.stop()
mediaPlayer.seek(0)
YTPlaylist.setActiveRow(YTPlaylist.previousRow())
// changeVideo()
@@ -310,7 +326,7 @@ Page {
onPlaybackStateChanged: {
if (mediaPlayer.playbackState == MediaPlayer.StoppedState) {
app.playing = ""
if ( settings.autoPlay && video.streamUrl != "" )
if ( settings.autoPlay && video.streamUrl !== "" && videoChanging === false )
nextVideo()
}

@@ -759,7 +775,6 @@ Page {

Row{
width: parent.width
rightPadding: Theme.paddingLarge
Column {
id: authorViews
width: parent.width/2
@@ -788,13 +803,26 @@ Page {
bottomPadding: Theme.paddingLarge
}
}
Button {
property bool subscribed: video.isSubscribed(video.getChannelId())
text: subscribed ? qsTr("Unsubscribe") : qsTr("Subscribe")
onClicked: {

YT.toggleSubscription()
subscribed = video.isSubscribed(video.getChannelId())

Row {
width: parent.width/2
rightPadding: Theme.paddingLarge*2
layoutDirection: Qt.RightToLeft

Button {
id: subscribeButton
preferredWidth: Theme.itemSizeHuge
property bool subscribed: video.isSubscribed(video.getChannelId())
text: subscribed ? qsTr("Unsubscribe") : qsTr("Subscribe")
onClicked: {
YT.toggleSubscription()
subscribed = video.isSubscribed(video.getChannelId())
}
}

IconButton {
icon.source: "image://theme/icon-m-share"
onClicked: pageStack.push(Qt.resolvedUrl("components/SharePage.qml"), {videoUrl: video.getWebpage(), videoTitle: title})
}
}
}
@@ -0,0 +1,20 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
import Sailfish.TransferEngine 1.0

SharePage {
id: page

property string videoUrl
property string videoTitle

header: qsTr("Share")

content: {
"type": "text/x-url",
"status": page.videoUrl,
"linkTitle": page.videoTitle,
}

mimeType: "text/x-url"
}
@@ -40,16 +40,18 @@ ListItem {
}

property bool subPage: false
property bool isVideo: itemType === 1 // video type

Row {
anchors.fill: parent
Column {
id: left
width: listItem.width/2.3
width: isVideo ? listItem.width/2.3 : 0
height: Theme.paddingLarge*8
leftPadding: subPage ? 0 : Theme.paddingLarge
topPadding: Theme.paddingSmall
bottomPadding: Theme.paddingSmall
visible: isVideo

Image {
width: parent.width - Theme.paddingLarge
@@ -71,6 +73,7 @@ ListItem {
text: display
width: parent.width - Theme.paddingLarge*2
truncationMode: TruncationMode.Fade
horizontalAlignment: !isVideo ? Text.AlignHCenter : Text.AlignLeft
}

Label {
@@ -13,13 +13,13 @@ Name: microtube
%{!?qtc_make:%define qtc_make make}
%{?qtc_builddir:%define _builddir %qtc_builddir}
Summary: µTube
Version: 1.5.2
Version: 1.7.1
Release: 1
Group: Qt/Qt
License: LICENSE
URL: http://example.org/
Source0: %{name}-%{version}.tar.bz2
Requires: sailfishsilica-qt5 >= 0.10.9
Requires: sailfishsilica-qt5 >= 1.1.31.7
BuildRequires: pkgconfig(sailfishapp) >= 1.0.2
BuildRequires: pkgconfig(Qt5Core)
BuildRequires: pkgconfig(Qt5Qml)
@@ -61,11 +61,17 @@ desktop-file-install --delete-original \
--dir %{buildroot}%{_datadir}/applications \
%{buildroot}%{_datadir}/applications/*.desktop

%post
su nemo -c "xdg-mime default %{name}-url.desktop x-scheme-handler/http"
su nemo -c "xdg-mime default %{name}-url.desktop x-scheme-handler/https"
su nemo -c "update-desktop-database /home/nemo/.local/share/applications"

%files
%defattr(-,root,root,-)
%{_bindir}
%{_datadir}/%{name}
%{_datadir}/applications/%{name}.desktop
%{_datadir}/icons/hicolor/*/apps/%{name}.png
/home/nemo/.local/share/applications/%{name}-url.desktop
# >> files
# << files
@@ -40,9 +40,14 @@ int main(int argc, char *argv[])
QSharedPointer<QQuickView> view(SailfishApp::createView());

YT yt;

yt.registerObjectsInQml(view->rootContext());

if (argc == 2) {
yt.search(QString::fromUtf8(argv[1]));
} else {
yt.loadDefaultVideos();
}

PulseAudioControl pacontrol;

view->rootContext()->setContextProperty("pacontrol", &pacontrol);
@@ -67,7 +67,7 @@ QVariant PlaylistModel::data(const QModelIndex &index, int role) const {
case ItemTypeRole:
return ItemTypeShowMore;
case Qt::DisplayRole:
if (!errorMessage.isEmpty()) return errorMessage;
if (!errorMessage.isEmpty()) return tr("Check internet connection."); // errorMessage; #23 it looks ugly user shouldn't see it
if (searching) return QString(); // tr("Searching...");
if (canSearchMore) return tr("Show %1 More").arg("").simplified();
if (videos.isEmpty())
@@ -131,19 +131,12 @@ QVariant PlaylistModel::data(const QModelIndex &index, int role) const {

void PlaylistModel::setActiveRow(int row, bool notify) {
if (rowExists(row)) {
m_activeRow = row;
Video *previousVideo = m_activeVideo;
m_activeRow = row;
m_activeVideo = videoAt(row);

int oldactiverow = m_activeRow;

if (rowExists(oldactiverow))
emit dataChanged(createIndex(oldactiverow, 0),
createIndex(oldactiverow, columnCount() - 1));

emit dataChanged(createIndex(m_activeRow, 0), createIndex(m_activeRow, columnCount() - 1));
if (notify) emit activeVideoChanged(m_activeVideo, previousVideo);

if (notify) emit activeVideoChanged(m_activeVideo, m_activeVideo);
} else {
m_activeRow = -1;
m_activeVideo = nullptr;
@@ -176,6 +169,11 @@ Video *PlaylistModel::videoAt(int row) const {
return nullptr;
}

Video *PlaylistModel::qmlVideoAt(int row) const {
if (rowExists(row)) return videos.at(row)->clone();
return nullptr;
}

Video *PlaylistModel::activeVideo() const {
return m_activeVideo;
}

0 comments on commit 7178ecd

Please sign in to comment.
You can’t perform that action at this time.