Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
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
Commits
b639f729
Commit
b639f729
authored
Feb 08, 2010
by
Jakob Leben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Qt: properly styled SearchLineEdit
And replaced QVLCIconLabel with QVLCFramelessButton.
parent
cc7f8d5d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
104 additions
and
82 deletions
+104
-82
modules/gui/qt4/components/playlist/selector.cpp
modules/gui/qt4/components/playlist/selector.cpp
+2
-1
modules/gui/qt4/components/playlist/selector.hpp
modules/gui/qt4/components/playlist/selector.hpp
+2
-2
modules/gui/qt4/util/customwidgets.cpp
modules/gui/qt4/util/customwidgets.cpp
+75
-51
modules/gui/qt4/util/customwidgets.hpp
modules/gui/qt4/util/customwidgets.hpp
+25
-28
No files found.
modules/gui/qt4/components/playlist/selector.cpp
View file @
b639f729
...
...
@@ -74,7 +74,8 @@ void PLSelItem::addAction( ItemAction act, const QString& tooltip )
icon
=
QIcon
(
":/buttons/playlist/playlist_remove"
);
break
;
}
lblAction
=
new
QVLCIconLabel
(
icon
);
lblAction
=
new
QVLCFramelessButton
();
lblAction
->
setIcon
(
icon
);
if
(
!
tooltip
.
isEmpty
()
)
lblAction
->
setToolTip
(
tooltip
);
...
...
modules/gui/qt4/components/playlist/selector.hpp
View file @
b639f729
...
...
@@ -42,7 +42,7 @@
#include "qt4.hpp"
class
PlaylistWidget
;
class
QVLC
IconLabel
;
class
QVLC
FramelessButton
;
enum
SelectorItemType
{
CATEGORY_TYPE
,
...
...
@@ -91,7 +91,7 @@ private:
void
enterEvent
(
QEvent
*
);
void
leaveEvent
(
QEvent
*
);
QTreeWidgetItem
*
qitem
;
QVLC
IconLabel
*
lblAction
;
QVLC
FramelessButton
*
lblAction
;
QLabel
*
lbl
;
QHBoxLayout
*
layout
;
};
...
...
modules/gui/qt4/util/customwidgets.cpp
View file @
b639f729
...
...
@@ -32,13 +32,13 @@
#include "qt4.hpp"
/*needed for qtr and CONNECT, but not necessary */
#include <QPainter>
#include <QLineEdit>
#include <QColorGroup>
#include <QRect>
#include <QKeyEvent>
#include <QWheelEvent>
#include <QToolButton>
#include <QHBoxLayout>
#include <QStyle>
#include <QStyleOption>
#include <vlc_intf_strings.h>
...
...
@@ -104,85 +104,109 @@ void ClickLineEdit::focusOutEvent( QFocusEvent *ev )
QLineEdit
::
focusOutEvent
(
ev
);
}
SearchLineEdit
::
SearchLineEdit
(
QWidget
*
parent
)
:
QFrame
(
parent
)
QVLCFramelessButton
::
QVLCFramelessButton
(
QWidget
*
parent
)
:
QPushButton
(
parent
)
{
setFrameStyle
(
QFrame
::
WinPanel
|
QFrame
::
Sunken
);
setLineWidth
(
0
);
QHBoxLayout
*
frameLayout
=
new
QHBoxLayout
(
this
);
frameLayout
->
setMargin
(
0
);
frameLayout
->
setSpacing
(
0
);
QPalette
palette
;
QBrush
brush
(
QColor
(
255
,
255
,
255
,
255
)
);
brush
.
setStyle
(
Qt
::
SolidPattern
);
palette
.
setBrush
(
QPalette
::
Active
,
QPalette
::
Window
,
brush
);
//Qt::white
setPalette
(
palette
);
setAutoFillBackground
(
true
);
setSizePolicy
(
QSizePolicy
::
Preferred
,
QSizePolicy
::
Preferred
);
}
searchLine
=
new
ClickLineEdit
(
qtr
(
I_PL_FILTER
),
0
);
searchLine
->
setFrame
(
false
);
searchLine
->
setMinimumWidth
(
80
);
void
QVLCFramelessButton
::
paintEvent
(
QPaintEvent
*
event
)
{
QPainter
painter
(
this
);
QPixmap
pix
=
icon
().
pixmap
(
size
()
);
QPoint
pos
(
(
width
()
-
pix
.
width
())
/
2
,
(
height
()
-
pix
.
height
())
/
2
);
painter
.
drawPixmap
(
QRect
(
pos
.
x
(),
pos
.
y
(),
pix
.
width
(),
pix
.
height
()
),
pix
);
}
CONNECT
(
searchLine
,
textChanged
(
const
QString
&
),
this
,
updateText
(
const
QString
&
)
);
frameLayout
->
addWidget
(
searchLine
);
QSize
QVLCFramelessButton
::
sizeHint
()
const
{
return
iconSize
();
}
clearButton
=
new
QToolButton
;
clearButton
->
setAutoRaise
(
true
);
clearButton
->
setMaximumWidth
(
30
);
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
(),
searchLine
,
clear
()
);
frameLayout
->
addWidget
(
clearButton
);
}
CONNECT
(
clearButton
,
clicked
(),
this
,
clear
()
);
void
SearchLineEdit
::
updateText
(
const
QString
&
text
)
{
clearButton
->
setVisible
(
!
text
.
isEmpty
()
);
emit
textChanged
(
text
);
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
&
)
);
}
QVLCIconLabel
::
QVLCIconLabel
(
const
QIcon
&
i
,
QWidget
*
p
)
:
QLabel
(
p
),
icon
(
i
),
iconMode
(
QIcon
::
Normal
)
void
SearchLineEdit
::
clear
()
{
updatePixmap
();
QLineEdit
::
clear
();
clearButton
->
hide
();
setMessageVisible
(
true
);
}
void
QVLCIconLabel
::
setIcon
(
const
QIcon
&
i
)
void
SearchLineEdit
::
setMessageVisible
(
bool
on
)
{
icon
=
i
;
updatePixmap
();
message
=
on
;
repaint
();
return
;
}
void
QVLCIconLabel
::
resizeEvent
(
QResizeEvent
*
even
t
)
void
SearchLineEdit
::
updateText
(
const
QString
&
tex
t
)
{
updatePixmap
(
);
clearButton
->
setVisible
(
!
text
.
isEmpty
()
);
}
void
QVLCIconLabel
::
enterEvent
(
QEvent
*
)
void
SearchLineEdit
::
resizeEvent
(
QResizeEvent
*
event
)
{
iconMode
=
QIcon
::
Active
;
updatePixmap
();
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
QVLCIconLabel
::
leaveEvent
(
QEvent
*
)
void
SearchLineEdit
::
focusInEvent
(
QFocusEvent
*
event
)
{
iconMode
=
QIcon
::
Normal
;
updatePixmap
();
if
(
message
)
{
setMessageVisible
(
false
);
}
QLineEdit
::
focusInEvent
(
event
);
}
void
QVLCIconLabel
::
mouseReleaseEvent
(
QMouseEvent
*
)
void
SearchLineEdit
::
focusOutEvent
(
QFocusEvent
*
event
)
{
emit
clicked
();
if
(
text
().
isEmpty
()
)
{
setMessageVisible
(
true
);
}
QLineEdit
::
focusOutEvent
(
event
);
}
void
QVLCIconLabel
::
updatePixmap
(
)
void
SearchLineEdit
::
paintEvent
(
QPaintEvent
*
event
)
{
setPixmap
(
icon
.
pixmap
(
size
(),
iconMode
)
);
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
)
);
}
/***************************************************************************
...
...
modules/gui/qt4/util/customwidgets.hpp
View file @
b639f729
...
...
@@ -28,8 +28,7 @@
#define _CUSTOMWIDGETS_H_
#include <QLineEdit>
#include <QLabel>
#include <QIcon>
#include <QPushButton>
/**
This class provides a QLineEdit which contains a greyed-out hinting
...
...
@@ -58,41 +57,39 @@ private:
bool
mDrawClickMsg
;
};
class
QToolButton
;
class
SearchLineEdit
:
public
QFrame
class
QVLCFramelessButton
:
public
QPushButton
{
Q_OBJECT
Q_OBJECT
;
public:
SearchLineEdit
(
QWidget
*
parent
);
QVLCFramelessButton
(
QWidget
*
parent
=
NULL
);
QSize
sizeHint
()
const
;
private:
ClickLineEdit
*
searchLine
;
QToolButton
*
clearButton
;
private
slots
:
void
updateText
(
const
QString
&
);
signals:
void
textChanged
(
const
QString
&
);
void
paintEvent
(
QPaintEvent
*
event
);
};
class
QVLCIconLabel
:
public
QLabel
class
QLabel
;
class
SearchLineEdit
:
public
QLineEdit
{
Q_OBJECT
public:
QVLCIconLabel
(
const
QIcon
&
,
QWidget
*
parent
=
0
);
void
setIcon
(
const
QIcon
&
);
signals:
void
clicked
();
protected:
virtual
void
enterEvent
(
QEvent
*
);
virtual
void
leaveEvent
(
QEvent
*
);
virtual
void
mouseReleaseEvent
(
QMouseEvent
*
);
virtual
void
resizeEvent
(
QResizeEvent
*
);
SearchLineEdit
(
QWidget
*
parent
=
NULL
);
private:
inline
void
updatePixmap
(
);
QIcon
icon
;
QIcon
::
Mode
iconMode
;
void
resizeEvent
(
QResizeEvent
*
event
);
void
focusInEvent
(
QFocusEvent
*
event
);
void
focusOutEvent
(
QFocusEvent
*
event
);
void
paintEvent
(
QPaintEvent
*
event
);
void
setMessageVisible
(
bool
on
);
QVLCFramelessButton
*
clearButton
;
bool
message
;
QLabel
*
msg
;
public
slots
:
void
clear
();
private
slots
:
void
updateText
(
const
QString
&
);
};
/* VLC Key/Wheel hotkeys interactions */
...
...
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