Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
1c6b27d3
Commit
1c6b27d3
authored
Jan 22, 2009
by
Jean-Philippe Andre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Qt: add a new "Open URL" dialog
Triggered by Ctrl+V, it automatically selects the clipboard content
parent
9b6f20a1
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
247 additions
and
0 deletions
+247
-0
modules/gui/qt4/Modules.am
modules/gui/qt4/Modules.am
+3
-0
modules/gui/qt4/dialogs/openurl.cpp
modules/gui/qt4/dialogs/openurl.cpp
+148
-0
modules/gui/qt4/dialogs/openurl.hpp
modules/gui/qt4/dialogs/openurl.hpp
+67
-0
modules/gui/qt4/dialogs_provider.cpp
modules/gui/qt4/dialogs_provider.cpp
+26
-0
modules/gui/qt4/dialogs_provider.hpp
modules/gui/qt4/dialogs_provider.hpp
+1
-0
modules/gui/qt4/menus.cpp
modules/gui/qt4/menus.cpp
+2
-0
No files found.
modules/gui/qt4/Modules.am
View file @
1c6b27d3
...
...
@@ -33,6 +33,7 @@ nodist_SOURCES_qt4 = \
dialogs/gototime.moc.cpp \
dialogs/toolbar.moc.cpp \
dialogs/open.moc.cpp \
dialogs/openurl.moc.cpp \
dialogs/podcast_configuration.moc.cpp \
dialogs/vlm.moc.cpp \
components/extended_panels.moc.cpp \
...
...
@@ -199,6 +200,7 @@ SOURCES_qt4 = qt4.cpp \
dialogs/gototime.cpp \
dialogs/toolbar.cpp \
dialogs/open.cpp \
dialogs/openurl.cpp \
dialogs/vlm.cpp \
dialogs/podcast_configuration.cpp \
components/extended_panels.cpp \
...
...
@@ -241,6 +243,7 @@ noinst_HEADERS = \
dialogs/gototime.hpp \
dialogs/toolbar.hpp \
dialogs/open.hpp \
dialogs/openurl.hpp \
dialogs/vlm.hpp \
dialogs/podcast_configuration.hpp \
components/extended_panels.hpp \
...
...
modules/gui/qt4/dialogs/openurl.cpp
0 → 100644
View file @
1c6b27d3
/*****************************************************************************
* openurl.cpp: Open a MRL or clipboard content
*****************************************************************************
* Copyright © 2009 the VideoLAN team
* $Id$
*
* Authors: Jean-Philippe André <jpeg@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "dialogs/openurl.hpp"
#include "util/customwidgets.hpp"
#include <QPushButton>
#include <QDialogButtonBox>
#include <QApplication>
#include <QClipboard>
#include <QMimeData>
#include <QList>
#include <QUrl>
#include <QFile>
#include <QLabel>
OpenUrlDialog
*
OpenUrlDialog
::
instance
=
NULL
;
OpenUrlDialog
*
OpenUrlDialog
::
getInstance
(
QWidget
*
parent
,
intf_thread_t
*
p_intf
,
bool
bClipboard
)
{
/* Creation */
if
(
!
instance
)
instance
=
new
OpenUrlDialog
(
parent
,
p_intf
,
bClipboard
);
else
instance
->
bClipboard
=
bClipboard
;
return
instance
;
}
OpenUrlDialog
::
OpenUrlDialog
(
QWidget
*
parent
,
intf_thread_t
*
_p_intf
,
bool
bClipboard
)
:
QVLCDialog
(
parent
,
_p_intf
)
{
this
->
bClipboard
=
bClipboard
;
this
->
setWindowTitle
(
qtr
(
"Open URL"
)
);
/* Buttons */
QPushButton
*
but
;
QDialogButtonBox
*
box
=
new
QDialogButtonBox
(
this
);
but
=
box
->
addButton
(
QDialogButtonBox
::
Ok
);
CONNECT
(
but
,
clicked
(),
this
,
play
()
);
but
=
box
->
addButton
(
QDialogButtonBox
::
Cancel
);
but
=
box
->
addButton
(
qtr
(
"&Enqueue"
),
QDialogButtonBox
::
AcceptRole
);
CONNECT
(
but
,
clicked
(),
this
,
enqueue
()
);
CONNECT
(
box
,
rejected
(),
this
,
reject
()
);
/* Info label and line edit */
edit
=
new
ClickLineEdit
(
qtr
(
"Enter URL here..."
),
this
);
QLabel
*
info
=
new
QLabel
(
qtr
(
"Please enter the URL or path "
"to the media you want to play"
),
this
);
this
->
setToolTip
(
qtr
(
"If your clipboard contains a valid URL
\n
"
"or the path to a file on your computer,
\n
"
"it will be automatically selected."
)
);
/* Layout */
QVBoxLayout
*
vlay
=
new
QVBoxLayout
(
this
);
vlay
->
addWidget
(
info
);
vlay
->
addWidget
(
edit
);
vlay
->
addWidget
(
box
);
}
void
OpenUrlDialog
::
enqueue
()
{
bShouldEnqueue
=
true
;
lastUrl
=
edit
->
text
();
accept
();
}
void
OpenUrlDialog
::
play
()
{
lastUrl
=
edit
->
text
();
accept
();
}
QString
OpenUrlDialog
::
url
()
const
{
return
lastUrl
;
}
bool
OpenUrlDialog
::
shouldEnqueue
()
const
{
return
bShouldEnqueue
;
}
/** Show Event:
* When the dialog is shown, try to extract an URL from the clipboard
* and paste it in the Edit box.
* showEvent can happen not only on exec() but I think it's cool to
* actualize the URL on showEvent (eg. change virtual desktop...)
**/
void
OpenUrlDialog
::
showEvent
(
QShowEvent
*
ev
)
{
(
void
)
ev
;
bShouldEnqueue
=
false
;
edit
->
setFocus
(
Qt
::
OtherFocusReason
);
if
(
!
lastUrl
.
isEmpty
()
&&
edit
->
text
().
isEmpty
()
)
{
/* The text should not have been changed, excepted if the user
has clicked Cancel before */
edit
->
setText
(
lastUrl
);
}
else
edit
->
clear
();
if
(
bClipboard
)
{
QClipboard
*
clipboard
=
QApplication
::
clipboard
();
const
QMimeData
*
data
=
clipboard
->
mimeData
(
QClipboard
::
Selection
);
QString
txt
=
data
->
text
().
trimmed
();
if
(
txt
.
isEmpty
()
||
(
!
txt
.
contains
(
"://"
)
&&
!
QFile
::
exists
(
txt
)
)
)
txt
=
clipboard
->
mimeData
()
->
text
().
trimmed
();
if
(
txt
.
contains
(
"://"
)
||
QFile
::
exists
(
txt
)
)
edit
->
setText
(
txt
);
}
}
modules/gui/qt4/dialogs/openurl.hpp
0 → 100644
View file @
1c6b27d3
/*****************************************************************************
* openurl.hpp: Open a MRL or clipboard content
****************************************************************************
* Copyright © 2009 the VideoLAN team
* $Id$
*
* Authors: Jean-Philippe André <jpeg@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
******************************************************************************/
#ifndef _OPEN_URL_H
#define _OPEN_URL_H_
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include "util/qvlcframe.hpp"
class
ClickLineEdit
;
class
OpenUrlDialog
:
public
QVLCDialog
{
Q_OBJECT
private:
OpenUrlDialog
(
QWidget
*
,
intf_thread_t
*
,
bool
bClipboard
=
true
);
QString
lastUrl
;
bool
bClipboard
,
bShouldEnqueue
;
ClickLineEdit
*
edit
;
static
OpenUrlDialog
*
instance
;
private
slots
:
void
enqueue
();
void
play
();
public:
virtual
~
OpenUrlDialog
()
{}
static
OpenUrlDialog
*
getInstance
(
QWidget
*
parent
,
intf_thread_t
*
p_intf
,
bool
bClipboard
=
true
);
QString
url
()
const
;
bool
shouldEnqueue
()
const
;
void
showEvent
(
QShowEvent
*
ev
);
public
slots
:
virtual
void
close
()
{
play
();
};
};
#endif
modules/gui/qt4/dialogs_provider.cpp
View file @
1c6b27d3
...
...
@@ -45,6 +45,7 @@
#include "dialogs/vlm.hpp"
#include "dialogs/sout.hpp"
#include "dialogs/open.hpp"
#include "dialogs/openurl.hpp"
#include "dialogs/help.hpp"
#include "dialogs/gototime.hpp"
#include "dialogs/podcast_configuration.hpp"
...
...
@@ -423,6 +424,31 @@ void DialogsProvider::simpleMLAppendDialog()
addFromSimple
(
false
,
false
);
}
/* Url & Clipboard */
/**
* Open a MRL.
* If the clipboard contains URLs, the first is automatically 'preselected'.
**/
void
DialogsProvider
::
openUrlDialog
()
{
OpenUrlDialog
*
oud
=
OpenUrlDialog
::
getInstance
(
p_intf
->
p_sys
->
p_mi
,
p_intf
);
if
(
oud
->
exec
()
==
QDialog
::
Accepted
)
{
QString
url
=
oud
->
url
();
if
(
!
url
.
isEmpty
()
)
{
playlist_Add
(
THEPL
,
qtu
(
toNativeSeparators
(
url
)
),
NULL
,
!
oud
->
shouldEnqueue
()
?
(
PLAYLIST_APPEND
|
PLAYLIST_GO
)
:
(
PLAYLIST_APPEND
|
PLAYLIST_PREPARSE
),
PLAYLIST_END
,
true
,
false
);
RecentsMRL
::
getInstance
(
p_intf
)
->
addRecent
(
toNativeSeparators
(
url
)
);
}
}
}
/* Directory */
/**
* Open a directory,
...
...
modules/gui/qt4/dialogs_provider.hpp
View file @
1c6b27d3
...
...
@@ -165,6 +165,7 @@ public slots:
void
openDialog
();
void
openDiscDialog
();
void
openFileDialog
();
void
openUrlDialog
();
void
openNetDialog
();
void
openCaptureDialog
();
...
...
modules/gui/qt4/menus.cpp
View file @
1c6b27d3
...
...
@@ -314,6 +314,8 @@ QMenu *QVLCMenu::FileMenu( intf_thread_t *p_intf )
#else
":/file-asym"
,
SLOT
(
openFileDialog
()
),
"Ctrl+O"
);
#endif
addDPStaticEntry
(
menu
,
qtr
(
"Open &URL"
),
NULL
,
SLOT
(
openUrlDialog
()
),
"Ctrl+V"
);
addDPStaticEntry
(
menu
,
qtr
(
I_OPEN_FOLDER
),
":/folder-grey"
,
SLOT
(
PLOpenDir
()
),
"Ctrl+F"
);
addDPStaticEntry
(
menu
,
qtr
(
"Open &Disc..."
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment