mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
refactor: port away from extlineedit
* the main feature of extlineedit.cc was having icons on left and right side which is already provided by QLineEdit::addAction after Qt5.2
This commit is contained in:
parent
9b7b64e174
commit
4f2c8d55aa
|
@ -283,8 +283,6 @@ set(PROJECT_SOURCES
|
|||
externalaudioplayer.hh
|
||||
externalviewer.cc
|
||||
externalviewer.hh
|
||||
extlineedit.cc
|
||||
extlineedit.hh
|
||||
favoritespanewidget.cc
|
||||
favoritespanewidget.hh
|
||||
file.cc
|
||||
|
|
191
extlineedit.cc
191
extlineedit.cc
|
@ -1,191 +0,0 @@
|
|||
/* This file is (c) 2012 Tvangeste <i.4m.l33t@yandex.ru>
|
||||
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
||||
|
||||
#include "extlineedit.hh"
|
||||
#include <QPainter>
|
||||
#include <QPropertyAnimation>
|
||||
|
||||
ExtLineEdit::ExtLineEdit(QWidget *parent) :
|
||||
QLineEdit(parent)
|
||||
{
|
||||
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
iconButtons[i] = new IconButton(this);
|
||||
iconButtons[i]->installEventFilter(this);
|
||||
iconButtons[i]->hide();
|
||||
iconButtons[i]->setAutoHide(false);
|
||||
iconEnabled[i] = false;
|
||||
}
|
||||
|
||||
ensurePolished();
|
||||
updateMargins();
|
||||
|
||||
connect( iconButtons[ Left ], &QAbstractButton::clicked, this, &ExtLineEdit::iconClicked );
|
||||
connect( iconButtons[ Right ], &QAbstractButton::clicked, this, &ExtLineEdit::iconClicked );
|
||||
|
||||
connect( this, &QLineEdit::textChanged, this, &ExtLineEdit::updateButtons );
|
||||
}
|
||||
|
||||
ExtLineEdit::~ExtLineEdit()
|
||||
{
|
||||
}
|
||||
|
||||
void ExtLineEdit::setButtonVisible(Side side, bool visible)
|
||||
{
|
||||
iconButtons[side]->setVisible(visible);
|
||||
iconEnabled[side] = visible;
|
||||
updateMargins();
|
||||
}
|
||||
|
||||
bool ExtLineEdit::isButtonVisible(Side side) const
|
||||
{
|
||||
return iconEnabled[side];
|
||||
}
|
||||
|
||||
void ExtLineEdit::setButtonAutoHide(Side side, bool autohide)
|
||||
{
|
||||
iconButtons[side]->setAutoHide(autohide);
|
||||
|
||||
if (autohide)
|
||||
{
|
||||
iconButtons[side]->setOpacity( text().isEmpty() ? 0.0 : 1.0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
iconButtons[side]->setOpacity( 1.0 );
|
||||
}
|
||||
}
|
||||
|
||||
void ExtLineEdit::updateButtons(QString text)
|
||||
{
|
||||
if ( oldText.isEmpty() || text.isEmpty() ) {
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
if ( iconButtons[i]->isAutoHide() )
|
||||
{
|
||||
iconButtons[i]->animate( !text.isEmpty() );
|
||||
}
|
||||
}
|
||||
oldText = text;
|
||||
}
|
||||
}
|
||||
|
||||
void ExtLineEdit::iconClicked()
|
||||
{
|
||||
IconButton * button = qobject_cast<IconButton *>( sender() );
|
||||
int index = -1;
|
||||
for (int i = 0; i < 2; ++i)
|
||||
if (iconButtons[i] == button)
|
||||
index = i;
|
||||
|
||||
if (index == -1)
|
||||
return;
|
||||
|
||||
if (index == Left)
|
||||
emit leftButtonClicked();
|
||||
else if (index == Right)
|
||||
emit rightButtonClicked();
|
||||
}
|
||||
|
||||
void ExtLineEdit::updateMargins()
|
||||
{
|
||||
bool leftToRight = (layoutDirection() == Qt::LeftToRight);
|
||||
Side realLeft = (leftToRight ? Left : Right);
|
||||
Side realRight = (leftToRight ? Right : Left);
|
||||
|
||||
int widgetHeight=height();
|
||||
int leftMargin = widgetHeight + 8;
|
||||
int rightMargin = widgetHeight + 8;
|
||||
|
||||
setTextMargins(
|
||||
(iconEnabled[realLeft] ? leftMargin : 0), 1,
|
||||
(iconEnabled[realRight] ? rightMargin : 0), 1);
|
||||
}
|
||||
|
||||
void ExtLineEdit::updateButtonPositions()
|
||||
{
|
||||
QRect contentRect = rect();
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
Side iconPos = (Side)i;
|
||||
if (layoutDirection() == Qt::RightToLeft)
|
||||
iconPos = (iconPos == Left ? Right : Left);
|
||||
|
||||
if (iconPos == ExtLineEdit::Right) {
|
||||
QMargins qm=textMargins();
|
||||
const int iconoffset = qm.right() + 4;
|
||||
iconButtons[i]->setGeometry(contentRect.adjusted(width() - iconoffset, 0, 0, 0));
|
||||
} else {
|
||||
QMargins qm=textMargins();
|
||||
const int iconoffset = qm.left() + 4;
|
||||
iconButtons[i]->setGeometry(contentRect.adjusted(0, 0, -width() + iconoffset, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ExtLineEdit::resizeEvent(QResizeEvent *)
|
||||
{
|
||||
updateButtonPositions();
|
||||
}
|
||||
|
||||
void ExtLineEdit::setButtonPixmap(Side side, const QPixmap &buttonPixmap)
|
||||
{
|
||||
iconButtons[side]->setPixmap(buttonPixmap);
|
||||
updateMargins();
|
||||
updateButtonPositions();
|
||||
update();
|
||||
}
|
||||
|
||||
QPixmap ExtLineEdit::buttonPixmap(Side side) const
|
||||
{
|
||||
return pixmaps[side];
|
||||
}
|
||||
|
||||
void ExtLineEdit::setButtonToolTip(Side side, const QString &tip)
|
||||
{
|
||||
iconButtons[side]->setToolTip(tip);
|
||||
}
|
||||
|
||||
void ExtLineEdit::setButtonFocusPolicy(Side side, Qt::FocusPolicy policy)
|
||||
{
|
||||
iconButtons[side]->setFocusPolicy(policy);
|
||||
}
|
||||
|
||||
IconButton::IconButton(QWidget *parent)
|
||||
: QAbstractButton(parent)
|
||||
{
|
||||
setCursor(Qt::ArrowCursor);
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
setFocusProxy(parent);
|
||||
}
|
||||
|
||||
void IconButton::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::RenderHint::Antialiasing);
|
||||
painter.setRenderHint(QPainter::RenderHint::TextAntialiasing);
|
||||
painter.setRenderHint(QPainter::RenderHint::SmoothPixmapTransform);
|
||||
painter.setRenderHint(QPainter::RenderHint::LosslessImageRendering);
|
||||
QRect pixmapRect = QRect(0, 0, height(), height());
|
||||
pixmapRect.moveCenter(rect().center());
|
||||
|
||||
if (m_autohide)
|
||||
{
|
||||
painter.setOpacity(m_opacity);
|
||||
}
|
||||
|
||||
painter.drawPixmap(pixmapRect, m_pixmap);
|
||||
}
|
||||
|
||||
void IconButton::animate(bool visible)
|
||||
{
|
||||
QPropertyAnimation *animation = new QPropertyAnimation(this, "opacity");
|
||||
animation->setDuration(250);
|
||||
if (visible)
|
||||
{
|
||||
animation->setEndValue(1.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
animation->setEndValue(0.0);
|
||||
}
|
||||
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
/* This file is (c) 2012 Tvangeste <i.4m.l33t@yandex.ru>
|
||||
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
||||
|
||||
#ifndef EXTLINEEDIT_H
|
||||
#define EXTLINEEDIT_H
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QAbstractButton>
|
||||
|
||||
class IconButton: public QAbstractButton
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap)
|
||||
Q_PROPERTY(float opacity READ opacity WRITE setOpacity)
|
||||
|
||||
public:
|
||||
explicit IconButton(QWidget * parent = 0);
|
||||
void paintEvent(QPaintEvent * event);
|
||||
void animate(bool visible);
|
||||
|
||||
void setPixmap(const QPixmap & pixmap) { m_pixmap = pixmap; update(); }
|
||||
QPixmap pixmap() const { return m_pixmap; }
|
||||
|
||||
void setAutoHide(bool autohide) { m_autohide = autohide; update(); }
|
||||
bool isAutoHide() const { return m_autohide; }
|
||||
|
||||
float opacity() { return m_opacity; }
|
||||
void setOpacity(float opacity) { m_opacity = opacity; update(); }
|
||||
|
||||
private:
|
||||
QPixmap m_pixmap;
|
||||
bool m_autohide;
|
||||
float m_opacity;
|
||||
};
|
||||
|
||||
class ExtLineEdit : public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_ENUMS(Side)
|
||||
|
||||
public:
|
||||
enum Side { Left = 0, Right = 1 };
|
||||
|
||||
explicit ExtLineEdit(QWidget * parent = 0);
|
||||
~ExtLineEdit();
|
||||
|
||||
QPixmap buttonPixmap(Side side) const;
|
||||
void setButtonPixmap(Side side, const QPixmap &pixmap);
|
||||
|
||||
void setButtonVisible(Side side, bool visible);
|
||||
bool isButtonVisible(Side side) const;
|
||||
|
||||
void setButtonToolTip(Side side, const QString &);
|
||||
void setButtonFocusPolicy(Side side, Qt::FocusPolicy policy);
|
||||
|
||||
void setButtonAutoHide(Side side, bool autohide);
|
||||
|
||||
signals:
|
||||
void leftButtonClicked();
|
||||
void rightButtonClicked();
|
||||
|
||||
private slots:
|
||||
void iconClicked();
|
||||
void updateButtons(QString text);
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent( QResizeEvent * e );
|
||||
|
||||
private:
|
||||
void updateMargins();
|
||||
void updateButtonPositions();
|
||||
QPixmap pixmaps[2];
|
||||
IconButton * iconButtons[2];
|
||||
bool iconEnabled[2];
|
||||
QString oldText;
|
||||
};
|
||||
|
||||
#endif // EXTLINEEDIT_H
|
|
@ -380,7 +380,6 @@ HEADERS += folding.hh \
|
|||
dictinfo.hh \
|
||||
zipsounds.hh \
|
||||
stylescombobox.hh \
|
||||
extlineedit.hh \
|
||||
translatebox.hh \
|
||||
historypanewidget.hh \
|
||||
wordlist.hh \
|
||||
|
@ -517,7 +516,6 @@ SOURCES += folding.cc \
|
|||
dictinfo.cc \
|
||||
zipsounds.cc \
|
||||
stylescombobox.cc \
|
||||
extlineedit.cc \
|
||||
translatebox.cc \
|
||||
historypanewidget.cc \
|
||||
wordlist.cc \
|
||||
|
|
|
@ -1016,7 +1016,7 @@ void DictGroupsWidget::tabDataChanged()
|
|||
setTabToolTip( currentIndex(), toolTipStr );
|
||||
}
|
||||
|
||||
QuickFilterLine::QuickFilterLine( QWidget * parent ): ExtLineEdit( parent ), m_focusAction(this)
|
||||
QuickFilterLine::QuickFilterLine( QWidget * parent ): QLineEdit( parent ), m_focusAction(this)
|
||||
{
|
||||
m_proxyModel.setFilterCaseSensitivity( Qt::CaseInsensitive );
|
||||
|
||||
|
@ -1025,17 +1025,11 @@ QuickFilterLine::QuickFilterLine( QWidget * parent ): ExtLineEdit( parent ), m_f
|
|||
m_focusAction.setShortcut( QKeySequence( "Ctrl+F" ) );
|
||||
connect( &m_focusAction, &QAction::triggered, this, &QuickFilterLine::focusFilterLine );
|
||||
|
||||
QPixmap image(":/icons/system-search.svg");
|
||||
setButtonPixmap(ExtLineEdit::Left, image.scaled(18, 18, Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
||||
setButtonToolTip(ExtLineEdit::Left, tr("Quick Search"));
|
||||
setButtonVisible(ExtLineEdit::Left, true);
|
||||
QAction * clear = new QAction( QIcon(":/icons/clear.png"), tr("Clear Search"),this);
|
||||
connect(clear,&QAction::triggered,this, &QLineEdit::clear);
|
||||
|
||||
QPixmap right(":/icons/clear.png");
|
||||
setButtonPixmap(ExtLineEdit::Right, right);
|
||||
setButtonToolTip(ExtLineEdit::Right, tr("Clear Search"));
|
||||
setButtonVisible(ExtLineEdit::Right, true);
|
||||
setButtonAutoHide(ExtLineEdit::Right, true);
|
||||
connect( this, &ExtLineEdit::rightButtonClicked, this, &QLineEdit::clear );
|
||||
addAction(clear,QLineEdit::TrailingPosition);
|
||||
addAction(new QAction(QIcon(":/icons/system-search.svg"),"",this),QLineEdit::LeadingPosition);
|
||||
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
|
||||
|
@ -1095,6 +1089,6 @@ void QuickFilterLine::keyPressEvent( QKeyEvent * event )
|
|||
}
|
||||
break;
|
||||
default:
|
||||
ExtLineEdit::keyPressEvent( event );
|
||||
QLineEdit::keyPressEvent( event );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,11 +10,11 @@
|
|||
|
||||
#include <QAction>
|
||||
#include <QListWidget>
|
||||
#include <QLineEdit>
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
#include "config.hh"
|
||||
#include "dictionary.hh"
|
||||
#include "extlineedit.hh"
|
||||
|
||||
/// A model to be projected into the view, according to Qt's MVC model
|
||||
class DictListModel: public QAbstractListModel
|
||||
|
@ -200,7 +200,7 @@ signals:
|
|||
void showDictionaryInfo( QString const & id );
|
||||
};
|
||||
|
||||
class QuickFilterLine: public ExtLineEdit
|
||||
class QuickFilterLine: public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
|
|
@ -1,91 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="512"
|
||||
height="512"
|
||||
id="svg2"
|
||||
version="1.1"
|
||||
inkscape:version="1.2.2 (732a01da63, 2022-12-09)"
|
||||
sodipodi:docname="1downarrow.svg"
|
||||
inkscape:export-filename="C:\Documents and Settings\bstawarz\Bureau\Projects\Projet Site\v1.0\arrow.png"
|
||||
inkscape:export-xdpi="90"
|
||||
inkscape:export-ydpi="90"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/">
|
||||
<defs
|
||||
id="defs4">
|
||||
<linearGradient
|
||||
id="linearGradient13128"
|
||||
inkscape:swatch="solid">
|
||||
<stop
|
||||
style="stop-color:#222222;stop-opacity:0.49019608;"
|
||||
offset="0"
|
||||
id="stop13126" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient13128"
|
||||
id="linearGradient13130"
|
||||
x1="53.278525"
|
||||
y1="796.3622"
|
||||
x2="458.72148"
|
||||
y2="796.3622"
|
||||
gradientUnits="userSpaceOnUse" />
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="0.9899495"
|
||||
inkscape:cx="17.172593"
|
||||
inkscape:cy="263.64981"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1017"
|
||||
inkscape:window-x="-8"
|
||||
inkscape:window-y="-8"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:pagecheckerboard="true"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:deskcolor="#d1d1d1" />
|
||||
<metadata
|
||||
id="metadata7">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Calque 1"
|
||||
id="layer1"
|
||||
transform="translate(0,-540.3622)"
|
||||
style="display:inline">
|
||||
<path
|
||||
style="display:inline;opacity:0.80000001;fill:url(#linearGradient13130);fill-opacity:1;stroke:#222222;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.540323"
|
||||
d="M 72.71772,732.21344 255.99937,915.49506 439.28228,732.21344 384.29689,677.22934 255.99937,805.52686 127.70315,677.22934 Z"
|
||||
id="path3766-1"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="ccccccc" />
|
||||
<path
|
||||
style="fill:#cccccc;stroke-width:2.02031;opacity:0.80000001"
|
||||
d="m 165.15092,282.32871 -90.400836,-90.41758 26.759056,-26.75906 26.75905,-26.75904 64.15527,64.13178 64.15528,64.13178 64.16457,-64.14106 64.16455,-64.14106 26.73985,26.795 26.73984,26.79499 -90.40766,90.39092 c -49.72419,49.715 -90.86226,90.39091 -91.41789,90.39091 -0.55563,0 -41.69062,-40.68792 -91.41108,-90.41758 z"
|
||||
id="path247"
|
||||
transform="translate(0,540.3622)" />
|
||||
</g>
|
||||
<svg width="48" height="48" version="1.1" viewBox="0 96 960 960" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="m480 869.41-480-480 121.82-121.82 358.18 360 358.18-358.18 121.82 121.82z"
|
||||
fill="DarkGray" stroke-width="1.8182"/>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 240 B |
|
@ -5,7 +5,6 @@ list:
|
|||
internet.svg
|
||||
home.svg
|
||||
configure.svg
|
||||
system-search.svg
|
||||
fileopen.svg
|
||||
addtab.svg
|
||||
wizard.svg
|
||||
|
@ -71,3 +70,7 @@ book.svg https://github.com/johnfactotum/foliate
|
|||
lingualibre.svg https://en.m.wikipedia.org/wiki/File:Lingualibre-logo-no-text.svg
|
||||
|
||||
|
||||
Apache License Version 2.0
|
||||
1downarrow.svg
|
||||
system-search.svg
|
||||
Modified from https://github.com/google/material-design-icons
|
||||
|
|
|
@ -1,46 +1,4 @@
|
|||
<?xml version="1.0"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48">
|
||||
<defs>
|
||||
<linearGradient id="k" y2="30.6" gradientUnits="userSpaceOnUse" x2="31.3" y1="23.35" x1="27.01">
|
||||
<stop stop-color="#8a8a8a" offset="0"/>
|
||||
<stop stop-color="#484848" offset="1"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="SVGID_3_" y2="55.65" gradientUnits="userSpaceOnUse" x2="-144.3" gradientTransform="matrix(1.335 0 0-1.291 229.6 104.1)" y1="52.71" x1="-146.9">
|
||||
<stop stop-color="#7d7d7d" offset="0"/>
|
||||
<stop stop-color="#b1b1b1" offset=".5"/>
|
||||
<stop stop-color="#686868" offset="1"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="c" y2="25.86" gradientUnits="userSpaceOnUse" x2="17.83" y1="10.73" x1="18.81">
|
||||
<stop stop-color="#fff" offset="0"/>
|
||||
<stop stop-color="#fff" stop-opacity=".22" offset=".5"/>
|
||||
<stop stop-color="#fff" offset="1"/>
|
||||
</linearGradient>
|
||||
<radialGradient id="r" gradientUnits="userSpaceOnUse" cy="81.5" cx="-171.7" gradientTransform="matrix(1.399 0 0-1.399 259.5 136.2)" r="8.31">
|
||||
<stop stop-color="#729fcf" stop-opacity=".21" offset="0"/>
|
||||
<stop stop-color="#729fcf" stop-opacity=".68" offset="1"/>
|
||||
</radialGradient>
|
||||
<radialGradient id="b" gradientUnits="userSpaceOnUse" cy="-511.6" cx="-174.5" gradientTransform="matrix(1.446 0 0-.362 276.2-145.1)" r="16.53">
|
||||
<stop offset="0"/>
|
||||
<stop stop-opacity="0" offset="1"/>
|
||||
</radialGradient>
|
||||
<radialGradient id="g" gradientUnits="userSpaceOnUse" cy="166.4" cx="-296.8" gradientTransform="matrix(2.593 0 0-2.252 784.6 385.3)" r="6.66">
|
||||
<stop stop-color="#fff" offset="0"/>
|
||||
<stop stop-color="#fff" stop-opacity=".25" offset="1"/>
|
||||
</radialGradient>
|
||||
<radialGradient id="s" gradientUnits="userSpaceOnUse" cy="-1674" cx="314.9" gradientTransform="matrix(.498 0 0-.145-135.8-204.1)" r="16.53">
|
||||
<stop stop-color="#fff" offset="0"/>
|
||||
<stop stop-color="#fff" stop-opacity="0" offset="1"/>
|
||||
</radialGradient>
|
||||
</defs>
|
||||
<ellipse opacity=".17" rx="23.9" ry="5.98" cy="39.96" cx="23.92" fill="url(#b)"/>
|
||||
<g fill="#dcdcdc">
|
||||
<path d="m18.63 3.14c-8.14 0-14.75 6.61-14.75 14.75s6.61 14.74 14.75 14.74c3.48 0 6.55-1.38 9.1-3.4-0.2 1-0.08 2.04 0.76 2.76l10.96 9.53c1.23 1.07 3.09 0.93 4.16-0.3 1.07-1.24 0.93-3.09-0.3-4.16l-10.97-9.53c-0.67-0.58-1.49-0.76-2.3-0.64 1.98-2.52 3.36-5.55 3.36-9 0-8.14-6.6-14.75-14.74-14.75zm-0.08 1.23c7.64 0 13.29 4.79 13.29 13.29 0 8.68-5.81 13.29-13.29 13.29-7.3 0-13.29-5.47-13.29-13.29 0-7.98 5.82-13.29 13.29-13.29z" stroke="url(#k)" stroke-linecap="round" stroke-width="2"/>
|
||||
<path d="m18.6 3.08c-8.16 0-14.79 6.63-14.79 14.79 0 8.17 6.63 14.8 14.79 14.8 3.49 0 6.58-1.39 9.11-3.42-0.21 1-0.08 2.04 0.75 2.77l11 9.56c1.24 1.07 3.1 0.93 4.18-0.3 1.07-1.24 0.93-3.1-0.31-4.18l-11-9.56c-0.67-0.58-1.49-0.75-2.31-0.64 1.99-2.52 3.38-5.57 3.38-9 0-8.16-6.63-14.79-14.8-14.79m-0.07 3.19c6.28 0 11.38 5.09 11.38 11.38 0 6.28-5.1 11.37-11.38 11.37s-11.38-5.09-11.38-11.37c0-6.29 5.1-11.38 11.38-11.38"/>
|
||||
</g>
|
||||
<path d="m39.51 41.58c-0.48-2.28 1.39-4.81 3.58-4.79l-10.76-9.26c-2.94-0.06-4.27 2.27-3.78 4.6l10.96 9.45" fill="url(#SVGID_3_)"/>
|
||||
<circle cy="17.4" stroke="url(#c)" cx="18.38" r="13.77" fill="none"/>
|
||||
<ellipse rx="8.23" ry="2.4" cy="38.77" cx="20.99" fill="url(#s)"/>
|
||||
<circle cy="17.55" stroke="#3063a3" cx="18.38" r="11.62" fill="url(#r)"/>
|
||||
<path opacity=".83" d="m18.2 7.4c-5.21 0-9.43 4.21-9.43 9.42 0 1.51 0.42 2.89 1.05 4.15 1.25 0.46 2.58 0.78 3.99 0.78 6.18 0 11.1-4.86 11.48-10.94-1.73-2.05-4.21-3.41-7.09-3.41" fill="url(#g)"/>
|
||||
<rect opacity="0.43" rx="2.468" transform="matrix(.7530 .6580 -.6489 .7609 0 0)" height="5" width="19" stroke="#fff" y="-.13" x="40.5" fill="none"/>
|
||||
<svg width="48" height="48" version="1.1" viewBox="0 96 960 960" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="m874.78 1055.4-337.13-335.87q-36.345 28.729-85.797 45.07-49.453 16.34-107.21 16.34-144.33 0-244.49-100.26-100.16-100.26-100.16-241.88 0-141.62 100.26-241.88 100.26-100.26 242.51-100.26 142.25 0 241.88 100.26 99.634 100.26 99.634 242.07 0 56.209-15.666 104.46-15.666 48.251-46.997 90.862l338.38 335.87zm-530.94-392.27q93.866 0 158.25-65.483t64.386-158.85q0-93.368-64.571-158.85-64.571-65.483-158.07-65.483-94.541 0-160.29 65.483-65.744 65.483-65.744 158.85 0 93.368 65.559 158.85 65.561 65.483 160.47 65.483z"
|
||||
fill="DarkGray" stroke-width="1.2533"/>
|
||||
</svg>
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 674 B |
|
@ -19,7 +19,7 @@
|
|||
#translateLine {
|
||||
color: palette(Text); /* ensure the text is inverse of the background, and also placehold text is grey */
|
||||
margin-left: 0;
|
||||
padding: 1px 3px 1px 3px;
|
||||
padding: 1px;
|
||||
|
||||
border: 1px solid gray;
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "translatebox.hh"
|
||||
|
||||
#include <QAction>
|
||||
#include <QHBoxLayout>
|
||||
#include <QEvent>
|
||||
#include <QKeyEvent>
|
||||
|
@ -87,8 +88,11 @@ bool CompletionList::acceptCurrentEntry()
|
|||
return true;
|
||||
}
|
||||
|
||||
TranslateBox::TranslateBox(QWidget *parent) : QWidget(parent),
|
||||
word_list(new CompletionList(this)), translate_line(new ExtLineEdit(this)), m_popupEnabled(false)
|
||||
TranslateBox::TranslateBox( QWidget * parent ):
|
||||
QWidget( parent ),
|
||||
word_list( new CompletionList( this ) ),
|
||||
translate_line( new QLineEdit( this ) ),
|
||||
m_popupEnabled( false )
|
||||
{
|
||||
// initially hidden
|
||||
word_list->hide();
|
||||
|
@ -114,18 +118,11 @@ TranslateBox::TranslateBox(QWidget *parent) : QWidget(parent),
|
|||
layout->setContentsMargins(0,0,0,0);
|
||||
layout->addWidget(translate_line);
|
||||
|
||||
QPixmap image(":/icons/system-search.svg");
|
||||
QAction * dropdown = new QAction( QIcon(":/icons/1downarrow.svg"), tr("Drop-down"),this);
|
||||
connect( dropdown,&QAction::triggered,this, &TranslateBox::rightButtonClicked );
|
||||
|
||||
translate_line->setButtonPixmap(ExtLineEdit::Left, image);
|
||||
// translate_line->setButtonToolTip(ExtLineEdit::Left, tr("Options"));
|
||||
translate_line->setButtonVisible(ExtLineEdit::Left, true);
|
||||
translate_line->setButtonFocusPolicy(ExtLineEdit::Left, Qt::ClickFocus);
|
||||
|
||||
QPixmap right(":/icons/1downarrow.svg");
|
||||
translate_line->setButtonPixmap(ExtLineEdit::Right, right);
|
||||
translate_line->setButtonToolTip(ExtLineEdit::Right, tr("Drop-down"));
|
||||
translate_line->setButtonVisible(ExtLineEdit::Right, true);
|
||||
translate_line->setButtonFocusPolicy(ExtLineEdit::Right, Qt::NoFocus);
|
||||
translate_line->addAction( dropdown,QLineEdit::TrailingPosition);
|
||||
translate_line->addAction( new QAction(QIcon(":/icons/system-search.svg"),"",this),QLineEdit::LeadingPosition);
|
||||
|
||||
translate_line->setFocusPolicy(Qt::ClickFocus);
|
||||
|
||||
|
@ -134,7 +131,6 @@ TranslateBox::TranslateBox(QWidget *parent) : QWidget(parent),
|
|||
|
||||
connect( translate_line, &QLineEdit::textChanged, this, &TranslateBox::onTextEdit );
|
||||
|
||||
connect( translate_line, &ExtLineEdit::rightButtonClicked, this, &TranslateBox::rightButtonClicked );
|
||||
|
||||
connect( word_list, &WordList::contentChanged, this, &TranslateBox::showPopup );
|
||||
}
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
#ifndef TRANSLATEBOX_HH
|
||||
#define TRANSLATEBOX_HH
|
||||
|
||||
#include "extlineedit.hh"
|
||||
#include "wordlist.hh"
|
||||
#include "mutex.hh"
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QWidget>
|
||||
#include <QListWidget>
|
||||
#include <QFocusEvent>
|
||||
|
@ -62,7 +62,7 @@ private slots:
|
|||
private:
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
CompletionList * word_list;
|
||||
ExtLineEdit * translate_line;
|
||||
QLineEdit * translate_line;
|
||||
bool m_popupEnabled;
|
||||
Mutex translateBoxMutex;
|
||||
// QCompleter * completer; // disabled for now
|
||||
|
|
Loading…
Reference in a new issue