Skip to content
Permalink
Browse files

Update subtitle support

  • Loading branch information...
3unjee committed Apr 26, 2019
1 parent 06fb438 commit 44bfcd37d2dac7a8a51d6c51012fffa0c6799777
Showing with 189 additions and 48 deletions.
  1. +28 −5 content/Gui.qml
  2. +105 −29 content/PageSubtitles.qml
  3. +37 −13 content/PageSubtitlesSearch.qml
  4. +18 −0 content/PanelGet.qml
  5. +1 −1 src/io/DataLocal.cpp
@@ -2483,13 +2483,30 @@ Item

var text = event.text;

if (controllerPlaylist.urlIsSubtitle(text))
{
if (playerTab.currentIndex == -1) return;

event.accepted = true;

bordersDrop.setItem(gui);

toolTip.show(qsTr("Open Subtitle"), st.icon32x32_track, 32, 32);

dragType = 2;

panelGet.selectTab(0);

panelGet.expose();

return;
}

event.accepted = true;

bordersDrop.setItem(gui);

var isTrack = controllerPlaylist.urlIsTrack(text);

if (isTrack)
if (controllerPlaylist.urlIsTrack(text))
{
if (player.isPlaying && highlightedTab == null)
{
@@ -2533,9 +2550,15 @@ Item
{
var url = event.text;

if (dragType)
if (dragType == 1)
{
panelBrowse.search(panelSearch.backendAt(0), url, true, true);
panelBrowse.search(panelSearch.backendAt(0), url, true, true);
}
else if (dragType == 2)
{
panelGet.page.hideSearch();

playerTab.subtitle = url;
}
else panelBrowse.search(panelSearch.backendAt(0), url, true, false);
}
@@ -23,7 +23,7 @@ Item
// Properties private
//---------------------------------------------------------------------------------------------

property bool pEnable: (playerTab && playerTab.currentIndex != -1)
property bool pEnable: (playerTab.currentIndex != -1)

property bool pSearch: false

@@ -33,6 +33,10 @@ Item

property variant pItem: loader.item

property string pQuery

property bool pEvents: true

//---------------------------------------------------------------------------------------------
// Settings
//---------------------------------------------------------------------------------------------
@@ -43,14 +47,7 @@ Item
// Events
//---------------------------------------------------------------------------------------------

onVisibleChanged:
{
if (visible || pSearch == false) return;

pSearchHide();
}

onPEnableChanged: if (pSearch) pSearchHide()
onPEnableChanged: hideSearch()

//---------------------------------------------------------------------------------------------
// Connections
@@ -60,35 +57,58 @@ Item
{
target: player

onTabChanged: pUpdateText()
onTabChanged: pUpdateSearch()
}

Connections
{
target: playerTab

onSubtitleChanged: pUpdateText()
onCurrentBookmarkChanged: pUpdateSearch()

onSubtitleChanged:
{
if (pEvents == false || pSearch) return;

pSetText(playerTab.subtitle);
}
}

//---------------------------------------------------------------------------------------------
// Functions private
// Functions
//---------------------------------------------------------------------------------------------

function showSearch()
{
if (pSearch == false) pSearchShow();
}

function hideSearch()
{
if (pSearch) pSearchHide();
}

//---------------------------------------------------------------------------------------------
// Private

function pStartSearch(query)
{
if (query == "") return;

if (core.checkUrl(query) == false)
if (controllerPlaylist.urlIsSubtitle(query))
{
if (pSearch)
{
pItem.hideCompletion();
}
else pSearchShow();
hideSearch();

playerTab.subtitle = query;
}
else
{
showSearch();

pItem.search(query);

pQuery = query;
}
else pSearchHide();
}

//---------------------------------------------------------------------------------------------
@@ -99,38 +119,60 @@ Item
loader.visible = true;

pSearch = true;

var title = playerTab.title;

if (controllerPlaylist.urlIsVideo(title) == false) return;

title = controllerNetwork.removeFileExtension(title);

pSetText(title);

pItem.search(title);

pQuery = title;

lineEdit.selectAll();
}

function pSearchHide()
{
pQuery = "";

if (lineEdit.isFocused)
{
window.clearFocus();
}

pSearch = false;

lineEdit.text = playerTab.subtitle;
pSetText(playerTab.subtitle);
}

function pSearchToogle()
{
if (pSearch == false)
{
lineEdit.text = "";
pSetText("");

lineEdit.focus();

pSearchShow();
}
else pSearchHide();
}

//---------------------------------------------------------------------------------------------

function pUpdateText()
function pUpdateSearch()
{
if (pSearch) return;
if (pEvents == false) return;

lineEdit.text = playerTab.subtitle;
if (pSearch)
{
pSearchHide();
}
else pSetText(playerTab.subtitle);
}

//---------------------------------------------------------------------------------------------
@@ -144,6 +186,15 @@ Item
else return qsTr("No track selected");
}

function pSetText(text)
{
pEvents = false;

lineEdit.text = text;

pEvents = true;
}

//---------------------------------------------------------------------------------------------
// Childs
//---------------------------------------------------------------------------------------------
@@ -155,7 +206,7 @@ Item
anchors.left : parent.left
anchors.right: buttonAdd.left

enabled: (pEnable && (pSearch || text == ""))
enabled: pEnable

text: playerTab.subtitle

@@ -174,9 +225,32 @@ Item

itemTextDefault.elide: Text.ElideLeft

onIsFocusedChanged: if (isFocused && pSearch == false) pSearchShow()
onIsFocusedChanged:
{
if (isFocused)
{
if (pSearch || text != "") return;

pSearchShow();
}
else if (pSearch)
{
pSetText(pQuery);

pItem.hideCompletion();
}
}

onTextChanged:
{
if (isFocused == false || pEvents == false) return;

onTextChanged: if (pSearch) pItem.applyText(text)
if (pSearch)
{
pItem.applyText(text);
}
else pSearchShow();
}

function onKeyPressed(event)
{
@@ -242,9 +316,11 @@ Item

if (path == "") return;

playerTab.subtitle = path;

pSearch = false;

playerTab.subtitle = path;
pSetText(path);
}
else playerTab.subtitle = "";
}
@@ -315,7 +391,7 @@ Item
{
property: "height"

duration: st.duration_faster
duration: st.duration_fast

easing.type: st.easing
}
Oops, something went wrong.

0 comments on commit 44bfcd3

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