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 )
...
@@ -74,7 +74,8 @@ void PLSelItem::addAction( ItemAction act, const QString& tooltip )
icon
=
QIcon
(
":/buttons/playlist/playlist_remove"
);
break
;
icon
=
QIcon
(
":/buttons/playlist/playlist_remove"
);
break
;
}
}
lblAction
=
new
QVLCIconLabel
(
icon
);
lblAction
=
new
QVLCFramelessButton
();
lblAction
->
setIcon
(
icon
);
if
(
!
tooltip
.
isEmpty
()
)
lblAction
->
setToolTip
(
tooltip
);
if
(
!
tooltip
.
isEmpty
()
)
lblAction
->
setToolTip
(
tooltip
);
...
...
modules/gui/qt4/components/playlist/selector.hpp
View file @
b639f729
...
@@ -42,7 +42,7 @@
...
@@ -42,7 +42,7 @@
#include "qt4.hpp"
#include "qt4.hpp"
class
PlaylistWidget
;
class
PlaylistWidget
;
class
QVLC
IconLabel
;
class
QVLC
FramelessButton
;
enum
SelectorItemType
{
enum
SelectorItemType
{
CATEGORY_TYPE
,
CATEGORY_TYPE
,
...
@@ -91,7 +91,7 @@ private:
...
@@ -91,7 +91,7 @@ private:
void
enterEvent
(
QEvent
*
);
void
enterEvent
(
QEvent
*
);
void
leaveEvent
(
QEvent
*
);
void
leaveEvent
(
QEvent
*
);
QTreeWidgetItem
*
qitem
;
QTreeWidgetItem
*
qitem
;
QVLC
IconLabel
*
lblAction
;
QVLC
FramelessButton
*
lblAction
;
QLabel
*
lbl
;
QLabel
*
lbl
;
QHBoxLayout
*
layout
;
QHBoxLayout
*
layout
;
};
};
...
...
modules/gui/qt4/util/customwidgets.cpp
View file @
b639f729
...
@@ -32,13 +32,13 @@
...
@@ -32,13 +32,13 @@
#include "qt4.hpp"
/*needed for qtr and CONNECT, but not necessary */
#include "qt4.hpp"
/*needed for qtr and CONNECT, but not necessary */
#include <QPainter>
#include <QPainter>
#include <QLineEdit>
#include <QColorGroup>
#include <QColorGroup>
#include <QRect>
#include <QRect>
#include <QKeyEvent>
#include <QKeyEvent>
#include <QWheelEvent>
#include <QWheelEvent>
#include <QToolButton>
#include <QHBoxLayout>
#include <QHBoxLayout>
#include <QStyle>
#include <QStyleOption>
#include <vlc_intf_strings.h>
#include <vlc_intf_strings.h>
...
@@ -104,85 +104,109 @@ void ClickLineEdit::focusOutEvent( QFocusEvent *ev )
...
@@ -104,85 +104,109 @@ void ClickLineEdit::focusOutEvent( QFocusEvent *ev )
QLineEdit
::
focusOutEvent
(
ev
);
QLineEdit
::
focusOutEvent
(
ev
);
}
}
SearchLineEdit
::
SearchLineEdit
(
QWidget
*
parent
)
:
QFrame
(
parent
)
QVLCFramelessButton
::
QVLCFramelessButton
(
QWidget
*
parent
)
:
QPushButton
(
parent
)
{
{
setFrameStyle
(
QFrame
::
WinPanel
|
QFrame
::
Sunken
);
setSizePolicy
(
QSizePolicy
::
Preferred
,
QSizePolicy
::
Preferred
);
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
);
searchLine
=
new
ClickLineEdit
(
qtr
(
I_PL_FILTER
),
0
);
void
QVLCFramelessButton
::
paintEvent
(
QPaintEvent
*
event
)
searchLine
->
setFrame
(
false
);
{
searchLine
->
setMinimumWidth
(
80
);
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
&
),
QSize
QVLCFramelessButton
::
sizeHint
()
const
this
,
updateText
(
const
QString
&
)
);
{
frameLayout
->
addWidget
(
searchLine
);
return
iconSize
();
}
clearButton
=
new
QToolButton
;
SearchLineEdit
::
SearchLineEdit
(
QWidget
*
parent
)
:
QLineEdit
(
parent
)
clearButton
->
setAutoRaise
(
true
);
{
clearButton
->
setMaximumWidth
(
30
);
clearButton
=
new
QVLCFramelessButton
(
this
);
clearButton
->
setIcon
(
QIcon
(
":/toolbar/clear"
)
);
clearButton
->
setIcon
(
QIcon
(
":/toolbar/clear"
)
);
clearButton
->
setIconSize
(
QSize
(
16
,
16
)
);
clearButton
->
setCursor
(
Qt
::
ArrowCursor
);
clearButton
->
setToolTip
(
qfu
(
vlc_pgettext
(
"Tooltip|Clear"
,
"Clear"
))
);
clearButton
->
setToolTip
(
qfu
(
vlc_pgettext
(
"Tooltip|Clear"
,
"Clear"
))
);
clearButton
->
hide
();
clearButton
->
hide
();
CONNECT
(
clearButton
,
clicked
(),
searchLine
,
clear
()
);
CONNECT
(
clearButton
,
clicked
(),
this
,
clear
()
);
frameLayout
->
addWidget
(
clearButton
);
}
void
SearchLineEdit
::
updateText
(
const
QString
&
text
)
int
frameWidth
=
style
()
->
pixelMetric
(
QStyle
::
PM_DefaultFrameWidth
,
0
,
this
);
{
clearButton
->
setVisible
(
!
text
.
isEmpty
()
);
QFontMetrics
metrics
(
font
()
);
emit
textChanged
(
text
);
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
)
void
SearchLineEdit
::
clear
()
:
QLabel
(
p
),
icon
(
i
),
iconMode
(
QIcon
::
Normal
)
{
{
updatePixmap
();
QLineEdit
::
clear
();
clearButton
->
hide
();
setMessageVisible
(
true
);
}
}
void
QVLCIconLabel
::
setIcon
(
const
QIcon
&
i
)
void
SearchLineEdit
::
setMessageVisible
(
bool
on
)
{
{
icon
=
i
;
message
=
on
;
updatePixmap
();
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
;
QLineEdit
::
resizeEvent
(
event
);
updatePixmap
();
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
;
if
(
message
)
updatePixmap
();
{
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 @@
...
@@ -28,8 +28,7 @@
#define _CUSTOMWIDGETS_H_
#define _CUSTOMWIDGETS_H_
#include <QLineEdit>
#include <QLineEdit>
#include <QLabel>
#include <QPushButton>
#include <QIcon>
/**
/**
This class provides a QLineEdit which contains a greyed-out hinting
This class provides a QLineEdit which contains a greyed-out hinting
...
@@ -58,41 +57,39 @@ private:
...
@@ -58,41 +57,39 @@ private:
bool
mDrawClickMsg
;
bool
mDrawClickMsg
;
};
};
class
QToolButton
;
class
QVLCFramelessButton
:
public
QPushButton
class
SearchLineEdit
:
public
QFrame
{
{
Q_OBJECT
Q_OBJECT
;
public:
public:
SearchLineEdit
(
QWidget
*
parent
);
QVLCFramelessButton
(
QWidget
*
parent
=
NULL
);
QSize
sizeHint
()
const
;
private:
private:
ClickLineEdit
*
searchLine
;
void
paintEvent
(
QPaintEvent
*
event
);
QToolButton
*
clearButton
;
private
slots
:
void
updateText
(
const
QString
&
);
signals:
void
textChanged
(
const
QString
&
);
};
};
class
QVLCIconLabel
:
public
QLabel
class
QLabel
;
class
SearchLineEdit
:
public
QLineEdit
{
{
Q_OBJECT
Q_OBJECT
public:
public:
QVLCIconLabel
(
const
QIcon
&
,
QWidget
*
parent
=
0
);
SearchLineEdit
(
QWidget
*
parent
=
NULL
);
void
setIcon
(
const
QIcon
&
);
signals:
void
clicked
();
protected:
virtual
void
enterEvent
(
QEvent
*
);
virtual
void
leaveEvent
(
QEvent
*
);
virtual
void
mouseReleaseEvent
(
QMouseEvent
*
);
virtual
void
resizeEvent
(
QResizeEvent
*
);
private:
private:
inline
void
updatePixmap
(
);
void
resizeEvent
(
QResizeEvent
*
event
);
QIcon
icon
;
void
focusInEvent
(
QFocusEvent
*
event
);
QIcon
::
Mode
iconMode
;
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 */
/* 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