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
e14f4778
Commit
e14f4778
authored
Nov 30, 2010
by
Jean-Baptiste Kempf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Qt: split searchLineEdit in its own file
parent
fce89194
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
300 additions
and
209 deletions
+300
-209
modules/gui/qt4/Modules.am
modules/gui/qt4/Modules.am
+3
-0
modules/gui/qt4/components/playlist/playlist.cpp
modules/gui/qt4/components/playlist/playlist.cpp
+2
-0
modules/gui/qt4/components/preferences_widgets.cpp
modules/gui/qt4/components/preferences_widgets.cpp
+1
-0
modules/gui/qt4/dialogs/openurl.cpp
modules/gui/qt4/dialogs/openurl.cpp
+1
-1
modules/gui/qt4/dialogs/plugins.cpp
modules/gui/qt4/dialogs/plugins.cpp
+1
-1
modules/gui/qt4/util/customwidgets.cpp
modules/gui/qt4/util/customwidgets.cpp
+0
-156
modules/gui/qt4/util/customwidgets.hpp
modules/gui/qt4/util/customwidgets.hpp
+0
-51
modules/gui/qt4/util/searchlineedit.cpp
modules/gui/qt4/util/searchlineedit.cpp
+202
-0
modules/gui/qt4/util/searchlineedit.hpp
modules/gui/qt4/util/searchlineedit.hpp
+90
-0
No files found.
modules/gui/qt4/Modules.am
View file @
e14f4778
...
...
@@ -66,6 +66,7 @@ nodist_SOURCES_qt4 = \
components/sout/sout_widgets.moc.cpp \
util/input_slider.moc.cpp \
util/customwidgets.moc.cpp \
util/searchlineedit.moc.cpp \
util/qvlcapp.moc.cpp \
util/pictureflow.moc.cpp \
resources.cpp \
...
...
@@ -274,6 +275,7 @@ SOURCES_qt4 = qt4.cpp \
components/sout/sout_widgets.cpp \
util/input_slider.cpp \
util/customwidgets.cpp \
util/searchlineedit.cpp \
util/registry.cpp \
util/qt_dirs.cpp \
util/pictureflow.cpp
...
...
@@ -336,6 +338,7 @@ noinst_HEADERS = \
components/sout/profiles.hpp \
util/input_slider.hpp \
util/customwidgets.hpp \
util/searchlineedit.hpp \
util/qvlcframe.hpp \
util/qvlcapp.hpp \
util/qt_dirs.hpp \
...
...
modules/gui/qt4/components/playlist/playlist.cpp
View file @
e14f4778
...
...
@@ -32,6 +32,8 @@
#include "components/playlist/playlist_model.hpp"
/* PLModel */
#include "components/interface_widgets.hpp"
/* CoverArtLabel */
#include "util/searchlineedit.hpp"
#include "input_manager.hpp"
/* art signal */
#include "main_interface.hpp"
/* DropEvent TODO remove this*/
...
...
modules/gui/qt4/components/preferences_widgets.cpp
View file @
e14f4778
...
...
@@ -36,6 +36,7 @@
#include "components/preferences_widgets.hpp"
#include "util/customwidgets.hpp"
#include "util/searchlineedit.hpp"
#include "util/qt_dirs.hpp"
#include <vlc_keys.h>
#include <vlc_intf_strings.h>
...
...
modules/gui/qt4/dialogs/openurl.cpp
View file @
e14f4778
...
...
@@ -26,7 +26,7 @@
#endif
#include "dialogs/openurl.hpp"
#include "util/
customwidgets
.hpp"
#include "util/
searchlineedit
.hpp"
#include <QPushButton>
#include <QDialogButtonBox>
...
...
modules/gui/qt4/dialogs/plugins.cpp
View file @
e14f4778
...
...
@@ -28,7 +28,7 @@
#include "plugins.hpp"
#include "util/
customwidgets
.hpp"
#include "util/
searchlineedit
.hpp"
#include "extensions_manager.hpp"
#include <assert.h>
...
...
modules/gui/qt4/util/customwidgets.cpp
View file @
e14f4778
...
...
@@ -43,66 +43,6 @@
#include <vlc_keys.h>
#include <wctype.h>
/* twolower() */
ClickLineEdit
::
ClickLineEdit
(
const
QString
&
msg
,
QWidget
*
parent
)
:
QLineEdit
(
parent
)
{
mDrawClickMsg
=
true
;
setClickMessage
(
msg
);
}
void
ClickLineEdit
::
setClickMessage
(
const
QString
&
msg
)
{
mClickMessage
=
msg
;
repaint
();
}
void
ClickLineEdit
::
setText
(
const
QString
&
txt
)
{
mDrawClickMsg
=
txt
.
isEmpty
();
repaint
();
QLineEdit
::
setText
(
txt
);
}
void
ClickLineEdit
::
paintEvent
(
QPaintEvent
*
pe
)
{
QLineEdit
::
paintEvent
(
pe
);
if
(
mDrawClickMsg
==
true
&&
!
hasFocus
()
)
{
QPainter
p
(
this
);
QPen
tmp
=
p
.
pen
();
p
.
setPen
(
palette
().
color
(
QPalette
::
Disabled
,
QPalette
::
Text
)
);
QRect
cr
=
contentsRect
();
// Add two pixel margin on the left side
cr
.
setLeft
(
cr
.
left
()
+
3
);
p
.
drawText
(
cr
,
Qt
::
AlignLeft
|
Qt
::
AlignVCenter
,
mClickMessage
);
p
.
setPen
(
tmp
);
p
.
end
();
}
}
void
ClickLineEdit
::
dropEvent
(
QDropEvent
*
ev
)
{
mDrawClickMsg
=
false
;
QLineEdit
::
dropEvent
(
ev
);
}
void
ClickLineEdit
::
focusInEvent
(
QFocusEvent
*
ev
)
{
if
(
mDrawClickMsg
==
true
)
{
mDrawClickMsg
=
false
;
repaint
();
}
QLineEdit
::
focusInEvent
(
ev
);
}
void
ClickLineEdit
::
focusOutEvent
(
QFocusEvent
*
ev
)
{
if
(
text
().
isEmpty
()
)
{
mDrawClickMsg
=
true
;
repaint
();
}
QLineEdit
::
focusOutEvent
(
ev
);
}
QVLCFramelessButton
::
QVLCFramelessButton
(
QWidget
*
parent
)
:
QPushButton
(
parent
)
{
...
...
@@ -122,102 +62,6 @@ QSize QVLCFramelessButton::sizeHint() const
return
iconSize
();
}
SearchLineEdit
::
SearchLineEdit
(
QWidget
*
parent
)
:
QLineEdit
(
parent
)
{
clearButton
=
new
QVLCFramelessButton
(
this
);
clearButton
->
setIcon
(
QIcon
(
":/toolbar/clear"
)
);
clearButton
->
setIconSize
(
QSize
(
16
,
16
)
);
clearButton
->
setCursor
(
Qt
::
ArrowCursor
);
clearButton
->
setToolTip
(
qfu
(
vlc_pgettext
(
"Tooltip|Clear"
,
"Clear"
))
);
clearButton
->
hide
();
CONNECT
(
clearButton
,
clicked
(),
this
,
clear
()
);
int
frameWidth
=
style
()
->
pixelMetric
(
QStyle
::
PM_DefaultFrameWidth
,
0
,
this
);
QFontMetrics
metrics
(
font
()
);
QString
styleSheet
=
QString
(
"min-height: %1px; "
"padding-top: 1px; "
"padding-bottom: 1px; "
"padding-right: %2px;"
)
.
arg
(
metrics
.
height
()
+
(
2
*
frameWidth
)
)
.
arg
(
clearButton
->
sizeHint
().
width
()
+
1
);
setStyleSheet
(
styleSheet
);
setMessageVisible
(
true
);
CONNECT
(
this
,
textEdited
(
const
QString
&
),
this
,
updateText
(
const
QString
&
)
);
CONNECT
(
this
,
editingFinished
(),
this
,
searchEditingFinished
()
);
}
void
SearchLineEdit
::
clear
()
{
setText
(
QString
()
);
clearButton
->
hide
();
setMessageVisible
(
true
);
}
void
SearchLineEdit
::
setMessageVisible
(
bool
on
)
{
message
=
on
;
repaint
();
return
;
}
void
SearchLineEdit
::
updateText
(
const
QString
&
text
)
{
clearButton
->
setVisible
(
!
text
.
isEmpty
()
);
}
void
SearchLineEdit
::
resizeEvent
(
QResizeEvent
*
event
)
{
QLineEdit
::
resizeEvent
(
event
);
int
frameWidth
=
style
()
->
pixelMetric
(
QStyle
::
PM_DefaultFrameWidth
,
0
,
this
);
clearButton
->
resize
(
clearButton
->
sizeHint
().
width
(),
height
()
);
clearButton
->
move
(
width
()
-
clearButton
->
width
()
-
frameWidth
,
0
);
}
void
SearchLineEdit
::
focusInEvent
(
QFocusEvent
*
event
)
{
if
(
message
)
{
setMessageVisible
(
false
);
}
QLineEdit
::
focusInEvent
(
event
);
}
void
SearchLineEdit
::
focusOutEvent
(
QFocusEvent
*
event
)
{
if
(
text
().
isEmpty
()
)
{
setMessageVisible
(
true
);
}
QLineEdit
::
focusOutEvent
(
event
);
}
void
SearchLineEdit
::
paintEvent
(
QPaintEvent
*
event
)
{
QLineEdit
::
paintEvent
(
event
);
if
(
!
message
)
return
;
QStyleOption
option
;
option
.
initFrom
(
this
);
QRect
rect
=
style
()
->
subElementRect
(
QStyle
::
SE_LineEditContents
,
&
option
,
this
)
.
adjusted
(
3
,
0
,
clearButton
->
width
()
+
1
,
0
);
QPainter
painter
(
this
);
painter
.
setPen
(
palette
().
color
(
QPalette
::
Disabled
,
QPalette
::
Text
)
);
painter
.
drawText
(
rect
,
Qt
::
AlignLeft
|
Qt
::
AlignVCenter
,
qtr
(
I_PL_FILTER
)
);
}
void
SearchLineEdit
::
searchEditingFinished
()
{
emit
searchDelayedChanged
(
text
()
);
}
QVLCElidingLabel
::
QVLCElidingLabel
(
const
QString
&
s
,
Qt
::
TextElideMode
mode
,
QWidget
*
parent
)
:
elideMode
(
mode
),
QLabel
(
s
,
parent
)
{
}
...
...
modules/gui/qt4/util/customwidgets.hpp
View file @
e14f4778
...
...
@@ -33,32 +33,6 @@
#include <QStackedWidget>
#include <QSpinBox>
/**
This class provides a QLineEdit which contains a greyed-out hinting
text as long as the user didn't enter any text
@short LineEdit with customizable "Click here" text
@author Daniel Molkentin
*/
class
ClickLineEdit
:
public
QLineEdit
{
Q_OBJECT
Q_PROPERTY
(
QString
clickMessage
READ
clickMessage
WRITE
setClickMessage
)
public:
ClickLineEdit
(
const
QString
&
msg
,
QWidget
*
parent
);
void
setClickMessage
(
const
QString
&
msg
);
const
QString
&
clickMessage
()
const
{
return
mClickMessage
;
}
virtual
void
setText
(
const
QString
&
txt
);
protected:
virtual
void
paintEvent
(
QPaintEvent
*
e
);
virtual
void
dropEvent
(
QDropEvent
*
ev
);
virtual
void
focusInEvent
(
QFocusEvent
*
ev
);
virtual
void
focusOutEvent
(
QFocusEvent
*
ev
);
private:
QString
mClickMessage
;
bool
mDrawClickMsg
;
};
class
QVLCFramelessButton
:
public
QPushButton
{
Q_OBJECT
...
...
@@ -69,31 +43,6 @@ protected:
virtual
void
paintEvent
(
QPaintEvent
*
event
);
};
class
SearchLineEdit
:
public
QLineEdit
{
Q_OBJECT
public:
SearchLineEdit
(
QWidget
*
parent
=
NULL
);
private:
void
resizeEvent
(
QResizeEvent
*
event
);
void
focusInEvent
(
QFocusEvent
*
event
);
void
focusOutEvent
(
QFocusEvent
*
event
);
void
paintEvent
(
QPaintEvent
*
event
);
void
setMessageVisible
(
bool
on
);
QVLCFramelessButton
*
clearButton
;
bool
message
;
public
slots
:
void
clear
();
private
slots
:
void
updateText
(
const
QString
&
);
void
searchEditingFinished
();
signals:
void
searchDelayedChanged
(
const
QString
&
);
};
class
QVLCElidingLabel
:
public
QLabel
{
...
...
modules/gui/qt4/util/searchlineedit.cpp
0 → 100644
View file @
e14f4778
/*****************************************************************************
* customwidgets.cpp: Custom widgets
****************************************************************************
* Copyright (C) 2006 the VideoLAN team
* Copyright (C) 2004 Daniel Molkentin <molkentin@kde.org>
* $Id$
*
* Authors: Clément Stenac <zorglub@videolan.org>
* The "ClickLineEdit" control is based on code by Daniel Molkentin
* <molkentin@kde.org> for libkdepim
*
* 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 "searchlineedit.hpp"
#include "customwidgets.hpp"
#include "qt4.hpp"
/*needed for qtr and CONNECT, but not necessary */
#include <QPainter>
#include <QColorGroup>
#include <QRect>
#include <QKeyEvent>
#include <QWheelEvent>
#include <QHBoxLayout>
#include <QStyle>
#include <QStyleOption>
#include <vlc_intf_strings.h>
#include <vlc_keys.h>
#include <wctype.h>
/* twolower() */
ClickLineEdit
::
ClickLineEdit
(
const
QString
&
msg
,
QWidget
*
parent
)
:
QLineEdit
(
parent
)
{
mDrawClickMsg
=
true
;
setClickMessage
(
msg
);
}
void
ClickLineEdit
::
setClickMessage
(
const
QString
&
msg
)
{
mClickMessage
=
msg
;
repaint
();
}
void
ClickLineEdit
::
setText
(
const
QString
&
txt
)
{
mDrawClickMsg
=
txt
.
isEmpty
();
repaint
();
QLineEdit
::
setText
(
txt
);
}
void
ClickLineEdit
::
paintEvent
(
QPaintEvent
*
pe
)
{
QLineEdit
::
paintEvent
(
pe
);
if
(
mDrawClickMsg
==
true
&&
!
hasFocus
()
)
{
QPainter
p
(
this
);
QPen
tmp
=
p
.
pen
();
p
.
setPen
(
palette
().
color
(
QPalette
::
Disabled
,
QPalette
::
Text
)
);
QRect
cr
=
contentsRect
();
// Add two pixel margin on the left side
cr
.
setLeft
(
cr
.
left
()
+
3
);
p
.
drawText
(
cr
,
Qt
::
AlignLeft
|
Qt
::
AlignVCenter
,
mClickMessage
);
p
.
setPen
(
tmp
);
p
.
end
();
}
}
void
ClickLineEdit
::
dropEvent
(
QDropEvent
*
ev
)
{
mDrawClickMsg
=
false
;
QLineEdit
::
dropEvent
(
ev
);
}
void
ClickLineEdit
::
focusInEvent
(
QFocusEvent
*
ev
)
{
if
(
mDrawClickMsg
==
true
)
{
mDrawClickMsg
=
false
;
repaint
();
}
QLineEdit
::
focusInEvent
(
ev
);
}
void
ClickLineEdit
::
focusOutEvent
(
QFocusEvent
*
ev
)
{
if
(
text
().
isEmpty
()
)
{
mDrawClickMsg
=
true
;
repaint
();
}
QLineEdit
::
focusOutEvent
(
ev
);
}
SearchLineEdit
::
SearchLineEdit
(
QWidget
*
parent
)
:
QLineEdit
(
parent
)
{
clearButton
=
new
QVLCFramelessButton
(
this
);
clearButton
->
setIcon
(
QIcon
(
":/toolbar/clear"
)
);
clearButton
->
setIconSize
(
QSize
(
16
,
16
)
);
clearButton
->
setCursor
(
Qt
::
ArrowCursor
);
clearButton
->
setToolTip
(
qfu
(
vlc_pgettext
(
"Tooltip|Clear"
,
"Clear"
))
);
clearButton
->
hide
();
CONNECT
(
clearButton
,
clicked
(),
this
,
clear
()
);
int
frameWidth
=
style
()
->
pixelMetric
(
QStyle
::
PM_DefaultFrameWidth
,
0
,
this
);
QFontMetrics
metrics
(
font
()
);
QString
styleSheet
=
QString
(
"min-height: %1px; "
"padding-top: 1px; "
"padding-bottom: 1px; "
"padding-right: %2px;"
)
.
arg
(
metrics
.
height
()
+
(
2
*
frameWidth
)
)
.
arg
(
clearButton
->
sizeHint
().
width
()
+
1
);
setStyleSheet
(
styleSheet
);
setMessageVisible
(
true
);
CONNECT
(
this
,
textEdited
(
const
QString
&
),
this
,
updateText
(
const
QString
&
)
);
CONNECT
(
this
,
editingFinished
(),
this
,
searchEditingFinished
()
);
}
void
SearchLineEdit
::
clear
()
{
setText
(
QString
()
);
clearButton
->
hide
();
setMessageVisible
(
true
);
}
void
SearchLineEdit
::
setMessageVisible
(
bool
on
)
{
message
=
on
;
repaint
();
return
;
}
void
SearchLineEdit
::
updateText
(
const
QString
&
text
)
{
clearButton
->
setVisible
(
!
text
.
isEmpty
()
);
}
void
SearchLineEdit
::
resizeEvent
(
QResizeEvent
*
event
)
{
QLineEdit
::
resizeEvent
(
event
);
int
frameWidth
=
style
()
->
pixelMetric
(
QStyle
::
PM_DefaultFrameWidth
,
0
,
this
);
clearButton
->
resize
(
clearButton
->
sizeHint
().
width
(),
height
()
);
clearButton
->
move
(
width
()
-
clearButton
->
width
()
-
frameWidth
,
0
);
}
void
SearchLineEdit
::
focusInEvent
(
QFocusEvent
*
event
)
{
if
(
message
)
{
setMessageVisible
(
false
);
}
QLineEdit
::
focusInEvent
(
event
);
}
void
SearchLineEdit
::
focusOutEvent
(
QFocusEvent
*
event
)
{
if
(
text
().
isEmpty
()
)
{
setMessageVisible
(
true
);
}
QLineEdit
::
focusOutEvent
(
event
);
}
void
SearchLineEdit
::
paintEvent
(
QPaintEvent
*
event
)
{
QLineEdit
::
paintEvent
(
event
);
if
(
!
message
)
return
;
QStyleOption
option
;
option
.
initFrom
(
this
);
QRect
rect
=
style
()
->
subElementRect
(
QStyle
::
SE_LineEditContents
,
&
option
,
this
)
.
adjusted
(
3
,
0
,
clearButton
->
width
()
+
1
,
0
);
QPainter
painter
(
this
);
painter
.
setPen
(
palette
().
color
(
QPalette
::
Disabled
,
QPalette
::
Text
)
);
painter
.
drawText
(
rect
,
Qt
::
AlignLeft
|
Qt
::
AlignVCenter
,
qtr
(
I_PL_FILTER
)
);
}
void
SearchLineEdit
::
searchEditingFinished
()
{
emit
searchDelayedChanged
(
text
()
);
}
modules/gui/qt4/util/searchlineedit.hpp
0 → 100644
View file @
e14f4778
/*****************************************************************************
* customwidgets.h: Custom widgets
****************************************************************************
* Copyright (C) 2006 the VideoLAN team
* Copyright (C) 2004 Daniel Molkentin <molkentin@kde.org>
* $Id$
*
* Authors: Clément Stenac <zorglub@videolan.org>
* The "ClickLineEdit" control is based on code by Daniel Molkentin
* <molkentin@kde.org> for libkdepim
*
* 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 _SEARCHLINEEDIT_H_
#define _SEARCHLINEEDIT_H_
#include <QLineEdit>
#include <QPushButton>
#include <QLabel>
#include <QStackedWidget>
#include <QSpinBox>
class
QVLCFramelessButton
;
/**
This class provides a QLineEdit which contains a greyed-out hinting
text as long as the user didn't enter any text
@short LineEdit with customizable "Click here" text
@author Daniel Molkentin
*/
class
ClickLineEdit
:
public
QLineEdit
{
Q_OBJECT
Q_PROPERTY
(
QString
clickMessage
READ
clickMessage
WRITE
setClickMessage
)
public:
ClickLineEdit
(
const
QString
&
msg
,
QWidget
*
parent
);
void
setClickMessage
(
const
QString
&
msg
);
const
QString
&
clickMessage
()
const
{
return
mClickMessage
;
}
virtual
void
setText
(
const
QString
&
txt
);
protected:
virtual
void
paintEvent
(
QPaintEvent
*
e
);
virtual
void
dropEvent
(
QDropEvent
*
ev
);
virtual
void
focusInEvent
(
QFocusEvent
*
ev
);
virtual
void
focusOutEvent
(
QFocusEvent
*
ev
);
private:
QString
mClickMessage
;
bool
mDrawClickMsg
;
};
class
SearchLineEdit
:
public
QLineEdit
{
Q_OBJECT
public:
SearchLineEdit
(
QWidget
*
parent
=
NULL
);
private:
void
resizeEvent
(
QResizeEvent
*
event
);
void
focusInEvent
(
QFocusEvent
*
event
);
void
focusOutEvent
(
QFocusEvent
*
event
);
void
paintEvent
(
QPaintEvent
*
event
);
void
setMessageVisible
(
bool
on
);
QVLCFramelessButton
*
clearButton
;
bool
message
;
public
slots
:
void
clear
();
private
slots
:
void
updateText
(
const
QString
&
);
void
searchEditingFinished
();
signals:
void
searchDelayedChanged
(
const
QString
&
);
};
#endif
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