HEADERS += src/video.h \
src/searchlineedit.h \
- src/urllineedit.h \
src/spacer.h \
src/constants.h \
src/playlistitemdelegate.h \
src/yt3.h \
src/paginatedvideosource.h \
src/compatibility/qurlqueryhelper.h \
- src/compatibility/pathsservice.h
+ src/compatibility/pathsservice.h \
+ src/searchwidget.h \
+ src/exlineedit.h
SOURCES += src/main.cpp \
src/searchlineedit.cpp \
- src/urllineedit.cpp \
src/spacer.cpp \
src/video.cpp \
src/videomimedata.cpp \
src/ytchannel.cpp \
src/yt3.cpp \
src/paginatedvideosource.cpp \
- src/compatibility/pathsservice.cpp
+ src/compatibility/pathsservice.cpp \
+ src/exlineedit.cpp \
+ src/searchwidget.cpp
RESOURCES += resources.qrc
DESTDIR = build/target/
OBJECTS_DIR = build/obj/
}
#endif
-AutoComplete::AutoComplete(SearchLineEdit *buddy, QLineEdit *lineEdit):
- QObject(buddy), buddy(buddy), lineEdit(lineEdit), enabled(true), suggester(0), itemHovering(false) {
+AutoComplete::AutoComplete(SearchWidget *buddy, QLineEdit *lineEdit):
+ QObject(lineEdit), buddy(buddy), lineEdit(lineEdit), enabled(true), suggester(0), itemHovering(false) {
popup = new QListWidget();
popup->setWindowFlags(Qt::Popup);
- popup->setFocusProxy(buddy);
+ popup->setFocusProxy(buddy->toWidget());
popup->installEventFilter(this);
- buddy->window()->installEventFilter(this);
+ buddy->toWidget()->window()->installEventFilter(this);
popup->setMouseTracking(true);
// style
timer->setSingleShot(true);
timer->setInterval(500);
connect(timer, SIGNAL(timeout()), SLOT(suggest()));
- connect(buddy, SIGNAL(textEdited(QString)), timer, SLOT(start()));
+ connect(buddy->toWidget(), SIGNAL(textEdited(QString)), timer, SLOT(start()));
}
bool AutoComplete::eventFilter(QObject *obj, QEvent *ev) {
popup->setCurrentItem(0);
popup->clearSelection();
buddy->setText(originalText);
- buddy->setFocus();
+ buddy->toWidget()->setFocus();
consumed = true;
}
break;
}
void AutoComplete::showSuggestions(const QList<Suggestion *> &suggestions) {
+ qDebug() << __PRETTY_FUNCTION__;
if (suggestions.isEmpty()) {
hideSuggestions();
return;
for (int i = 0; i < suggestions.count(); ++i)
h += popup->sizeHintForRow(i);
- popup->resize(buddy->width(), h);
+ popup->resize(buddy->toWidget()->width(), h);
adjustPosition();
popup->setUpdatesEnabled(true);
qDeleteAll(this->suggestions);
this->suggestions = suggestions;
if (!enabled) return;
- if (!buddy->hasFocus()) return;
+ if (!buddy->toWidget()->hasFocus() && buddy->toWidget()->isVisible()) return;
showSuggestions(suggestions);
}
void AutoComplete::adjustPosition() {
- popup->move(buddy->mapToGlobal(QPoint(0, buddy->height())));
+ popup->move(buddy->toWidget()->mapToGlobal(QPoint(0, buddy->toWidget()->height())));
}
void AutoComplete::enableItemHovering() {
buddy->setText(originalText);
originalText.clear();
}
- buddy->setFocus();
+ buddy->toWidget()->setFocus();
timer->stop();
}
class Suggester;
class Suggestion;
-class SearchLineEdit;
+class SearchWidget;
QT_FORWARD_DECLARE_CLASS(QListWidget)
QT_FORWARD_DECLARE_CLASS(QListWidgetItem)
Q_OBJECT
public:
- AutoComplete(SearchLineEdit *buddy, QLineEdit *lineEdit);
+ AutoComplete(SearchWidget *buddy, QLineEdit *lineEdit);
void setSuggester(Suggester* suggester);
QListWidget* getPopup() { return popup; }
void preventSuggest();
void showSuggestions(const QList<Suggestion*> &suggestions);
void hideSuggestions();
- SearchLineEdit *buddy;
+ SearchWidget *buddy;
QLineEdit *lineEdit;
QString originalText;
QListWidget *popup;
--- /dev/null
+#include "exlineedit.h"
+#include "iconutils.h"
+
+ClearButton::ClearButton(QWidget *parent) : QAbstractButton(parent), hovered(false), mousePressed(false) {
+ setCursor(Qt::ArrowCursor);
+ setToolTip(tr("Clear"));
+ setVisible(false);
+ setFocusPolicy(Qt::NoFocus);
+}
+
+void ClearButton::paintEvent(QPaintEvent *e) {
+ Q_UNUSED(e);
+ QPainter painter(this);
+ const int h = height();
+ int iconSize = 16;
+ if (h > 30) iconSize = 22;
+ QIcon::Mode iconMode = QIcon::Normal;
+ if (mousePressed) iconMode = QIcon::Active;
+ QPixmap p = IconUtils::icon("edit-clear").pixmap(iconSize, iconSize, iconMode);
+ int x = (width() - p.width()) / 2;
+ int y = (h - p.height()) / 2;
+ painter.drawPixmap(x, y, p);
+}
+
+void ClearButton::textChanged(const QString &text) {
+ setVisible(!text.isEmpty());
+}
+
+void ClearButton::enterEvent(QEvent *e) {
+ Q_UNUSED(e);
+ hovered = true;
+}
+
+void ClearButton::leaveEvent(QEvent *e) {
+ Q_UNUSED(e);
+ hovered = false;
+}
+
+void ClearButton::mousePressEvent(QMouseEvent *e) {
+ Q_UNUSED(e);
+ mousePressed = true;
+}
+
+void ClearButton::mouseReleaseEvent(QMouseEvent *e) {
+ Q_UNUSED(e);
+ mousePressed = false;
+}
+
+ExLineEdit::ExLineEdit(QWidget *parent)
+ : QWidget(parent)
+ , m_leftWidget(0)
+ , m_lineEdit(new QLineEdit(this))
+ , m_clearButton(new ClearButton(this)) {
+ setFocusPolicy(m_lineEdit->focusPolicy());
+ setAttribute(Qt::WA_InputMethodEnabled);
+ setSizePolicy(m_lineEdit->sizePolicy());
+ setBackgroundRole(m_lineEdit->backgroundRole());
+ setMouseTracking(true);
+ setAcceptDrops(true);
+ setAttribute(Qt::WA_MacShowFocusRect, true);
+ QPalette p = m_lineEdit->palette();
+ setPalette(p);
+
+ // line edit
+ m_lineEdit->setFrame(false);
+ m_lineEdit->setFocusProxy(this);
+ m_lineEdit->setAttribute(Qt::WA_MacShowFocusRect, false);
+ m_lineEdit->setStyleSheet("background:transparent");
+ QPalette clearPalette = m_lineEdit->palette();
+ clearPalette.setBrush(QPalette::Base, QBrush(Qt::transparent));
+ m_lineEdit->setPalette(clearPalette);
+
+ // clearButton
+ connect(m_clearButton, SIGNAL(clicked()), m_lineEdit, SLOT(clear()));
+ connect(m_lineEdit, SIGNAL(textChanged(const QString&)), m_clearButton, SLOT(textChanged(const QString&)));
+}
+
+void ExLineEdit::setFont(const QFont &font) {
+ m_lineEdit->setFont(font);
+ updateGeometries();
+}
+
+void ExLineEdit::setLeftWidget(QWidget *widget) {
+ m_leftWidget = widget;
+}
+
+QWidget *ExLineEdit::leftWidget() const {
+ return m_leftWidget;
+}
+
+void ExLineEdit::clear() {
+ m_lineEdit->clear();
+}
+
+QString ExLineEdit::text() {
+ return m_lineEdit->text();
+}
+
+void ExLineEdit::resizeEvent(QResizeEvent *e) {
+ Q_ASSERT(m_leftWidget);
+ updateGeometries();
+ QWidget::resizeEvent(e);
+}
+
+void ExLineEdit::updateGeometries() {
+ QStyleOptionFrameV2 panel;
+ initStyleOption(&panel);
+ QRect rect = style()->subElementRect(QStyle::SE_LineEditContents, &panel, this);
+
+ int padding = 3;
+ // int height = rect.height() + padding*2;
+ int width = rect.width();
+
+ // int m_leftWidgetHeight = m_leftWidget->height();
+ m_leftWidget->setGeometry(rect.x() + 2, 0,
+ m_leftWidget->width(), m_leftWidget->height());
+
+ int clearButtonWidth = this->height();
+ m_lineEdit->setGeometry(m_leftWidget->x() + m_leftWidget->width(), padding,
+ width - clearButtonWidth - m_leftWidget->width(), this->height() - padding*2);
+
+ m_clearButton->setGeometry(this->width() - clearButtonWidth, 0,
+ clearButtonWidth, this->height());
+}
+
+void ExLineEdit::initStyleOption(QStyleOptionFrameV2 *option) const {
+ option->initFrom(this);
+ option->rect = contentsRect();
+ option->lineWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, option, this);
+ option->midLineWidth = 0;
+ option->state |= QStyle::State_Sunken;
+ if (m_lineEdit->isReadOnly())
+ option->state |= QStyle::State_ReadOnly;
+#ifdef QT_KEYPAD_NAVIGATION
+ if (hasEditFocus())
+ option->state |= QStyle::State_HasEditFocus;
+#endif
+ option->features = QStyleOptionFrameV2::None;
+}
+
+QSize ExLineEdit::sizeHint() const {
+ m_lineEdit->setFrame(true);
+ QSize size = m_lineEdit->sizeHint();
+ m_lineEdit->setFrame(false);
+ size = size + QSize(3, 3);
+ return size;
+}
+
+void ExLineEdit::focusInEvent(QFocusEvent *e) {
+ m_lineEdit->event(e);
+ QWidget::focusInEvent(e);
+}
+
+void ExLineEdit::focusOutEvent(QFocusEvent *e) {
+ m_lineEdit->event(e);
+
+ if (m_lineEdit->completer()) {
+ connect(m_lineEdit->completer(), SIGNAL(activated(QString)),
+ m_lineEdit, SLOT(setText(QString)));
+ connect(m_lineEdit->completer(), SIGNAL(highlighted(QString)),
+ m_lineEdit, SLOT(_q_completionHighlighted(QString)));
+ }
+ QWidget::focusOutEvent(e);
+}
+
+void ExLineEdit::keyPressEvent(QKeyEvent *e) {
+ if (e->key() == Qt::Key_Escape && !m_lineEdit->text().isEmpty()) {
+ m_lineEdit->clear();
+ }
+ m_lineEdit->event(e);
+ QWidget::keyPressEvent(e);
+}
+
+bool ExLineEdit::event(QEvent *e) {
+ if (e->type() == QEvent::ShortcutOverride || e->type() == QEvent::InputMethod)
+ m_lineEdit->event(e);
+ return QWidget::event(e);
+}
+
+void ExLineEdit::paintEvent(QPaintEvent *e) {
+ Q_UNUSED(e);
+ QPainter p(this);
+ QStyleOptionFrameV2 panel;
+ initStyleOption(&panel);
+ style()->drawPrimitive(QStyle::PE_PanelLineEdit, &panel, &p, this);
+}
--- /dev/null
+#ifndef EXLINEEDIT_H
+#define EXLINEEDIT_H
+
+#include <QtGui>
+#if QT_VERSION >= 0x050000
+#include <QtWidgets>
+#endif
+
+class ClearButton : public QAbstractButton {
+
+ Q_OBJECT
+
+public:
+ ClearButton(QWidget *parent = 0);
+
+public slots:
+ void textChanged(const QString &text);
+
+protected:
+ void paintEvent(QPaintEvent *e);
+ void enterEvent(QEvent *e);
+ void leaveEvent(QEvent *e);
+ void mousePressEvent(QMouseEvent *e);
+ void mouseReleaseEvent(QMouseEvent *e);
+
+private:
+ bool hovered;
+ bool mousePressed;
+};
+
+class ExLineEdit : public QWidget {
+
+ Q_OBJECT
+
+public:
+ ExLineEdit(QWidget *parent = 0);
+ QLineEdit *lineEdit() const { return m_lineEdit; }
+ void setLeftWidget(QWidget *widget);
+ QWidget *leftWidget() const;
+ void clear();
+ QString text();
+ QSize sizeHint() const;
+ void updateGeometries();
+ void setFont(const QFont &font);
+
+protected:
+ void focusInEvent(QFocusEvent *e);
+ void focusOutEvent(QFocusEvent *e);
+ void keyPressEvent(QKeyEvent *e);
+ void paintEvent(QPaintEvent *e);
+ void resizeEvent(QResizeEvent *e);
+ bool event(QEvent *e);
+ void initStyleOption(QStyleOptionFrameV2 *option) const;
+
+ QWidget *m_leftWidget;
+ QLineEdit *m_lineEdit;
+ ClearButton *m_clearButton;
+};
+
+#endif // EXLINEEDIT_H
+
#include "ytsuggester.h"
#include "updatechecker.h"
#include "temporary.h"
-#ifdef APP_MAC_SEARCHFIELD
+#if defined(APP_MAC_SEARCHFIELD) && !defined(APP_MAC_QMACTOOLBAR)
#include "searchlineedit_mac.h"
#else
#include "searchlineedit.h"
volumeSlider->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
#endif
-#ifdef APP_MAC_SEARCHFIELD
+#if defined(APP_MAC_SEARCHFIELD) && !defined(APP_MAC_QMACTOOLBAR)
SearchWrapper* searchWrapper = new SearchWrapper(this);
toolbarSearch = searchWrapper->getSearchLineEdit();
#else
toolbarSearch = new SearchLineEdit(this);
+ qDebug() << "Qt SearchLineEdit" << toolbarSearch;
#endif
toolbarSearch->setMinimumWidth(toolbarSearch->fontInfo().pixelSize()*15);
toolbarSearch->setSuggester(new YTSuggester(this));
// Add widgets to toolbar
#ifdef APP_MAC_QMACTOOLBAR
- searchWrapper->hide();
currentTime->hide();
toolbarSearch->hide();
volumeSlider->hide();
mainToolBar->addWidget(new Spacer());
-#ifdef APP_MAC_SEARCHFIELD
+#if defined(APP_MAC_SEARCHFIELD) && !defined(APP_MAC_QMACTOOLBAR)
mainToolBar->addWidget(searchWrapper);
#else
mainToolBar->addWidget(toolbarSearch);
statusToolBar = new QToolBar(this);
statusToolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
statusToolBar->setIconSize(QSize(16, 16));
- statusToolBar->addAction(The::globalActions()->value("downloads"));
+ // statusToolBar->addAction(The::globalActions()->value("downloads"));
regionAction = new QAction(this);
regionAction->setStatusTip(tr("Choose your content location"));
#endif
if (show) {
statusToolBar->insertAction(statusToolBar->actions().first(), action);
- if (statusBar()->isHidden())
+ if (statusBar()->isHidden() && !m_fullscreen)
setStatusBarVisibility(true);
} else {
statusToolBar->removeAction(action);
if (statusBar()->isVisible() && !needStatusBar())
- setStatusBarVisibility(false);
+ if (m_fullscreen && views->currentWidget() == mediaView)
+ setStatusBarVisibility(false);
}
}
int w = qMin(2000, desktopSize.width());
int h = qMin(w / 3, desktopSize.height());
setGeometry(
- QStyle::alignedRect(
- Qt::LeftToRight,
- Qt::AlignTop,
- QSize(w, h),
- desktopSize)
- );
+ QStyle::alignedRect(
+ Qt::LeftToRight,
+ Qt::AlignTop,
+ QSize(w, h),
+ desktopSize)
+ );
}
const VideoDefinition& firstDefinition = VideoDefinition::getDefinitions().first();
setDefinitionMode(settings.value("definition", firstDefinition.getName()).toString());
updateUIForFullscreen();
}
}
+#endif
+#ifdef APP_MAC_QMACTOOLBAR
+ toolbarSearch->move(width() - toolbarSearch->width() - 13, -38);
#endif
adjustMessageLabelPosition();
}
}
bool MainWindow::needStatusBar() {
- // 1 fixed action: downloadAction
- return statusToolBar->actions().size() > 1;
+ return !statusToolBar->actions().isEmpty();
}
void MainWindow::adjustMessageLabelPosition() {
MediaView* getMediaView() { return mediaView; }
QToolButton* getRegionButton() { return regionButton; }
QAction* getRegionAction() { return regionAction; }
+ SearchLineEdit *getToolbarSearch() { return toolbarSearch; }
+
void showActionInStatusBar(QAction*, bool show);
void setStatusBarVisibility(bool show);
void adjustStatusBarVisibility();
Video* video = playlistModel->activeVideo();
if (!video) return;
DownloadManager::instance()->addItem(video);
- The::globalActions()->value("downloads")->setVisible(true);
+ MainWindow::instance()->showActionInStatusBar(The::globalActions()->value("downloads"), true);
QString message = tr("Downloading %1").arg(video->title());
MainWindow::instance()->showMessage(message);
}
#include "searchlineedit.h"
-
-#include <QPainter>
-#include <QMouseEvent>
-#include <QMenu>
-#include <QStyle>
-#include <QStyleOptionFrameV2>
-
#include "autocomplete.h"
#include "iconutils.h"
-ClearButton::ClearButton(QWidget *parent) : QAbstractButton(parent), hovered(false), mousePressed(false) {
- setCursor(Qt::ArrowCursor);
- setToolTip(tr("Clear"));
- setVisible(false);
- setFocusPolicy(Qt::NoFocus);
-}
-
-void ClearButton::paintEvent(QPaintEvent *e) {
- Q_UNUSED(e);
- QPainter painter(this);
- const int h = height();
- int iconSize = 16;
- if (h > 30) iconSize = 22;
- QIcon::Mode iconMode = QIcon::Normal;
- if (mousePressed) iconMode = QIcon::Active;
- QPixmap p = IconUtils::icon("edit-clear").pixmap(iconSize, iconSize, iconMode);
- // QPixmap p = IconUtils::tintedIcon("edit-clear", Qt::black, QSize(iconSize, iconSize)).pixmap(iconSize, iconSize, iconMode);
- int x = (width() - p.width()) / 2;
- int y = (h - p.height()) / 2;
- painter.drawPixmap(x, y, p);
-}
-
-void ClearButton::textChanged(const QString &text) {
- setVisible(!text.isEmpty());
-}
-
-void ClearButton::enterEvent(QEvent *e) {
- Q_UNUSED(e);
- hovered = true;
-}
-
-void ClearButton::leaveEvent(QEvent *e) {
- Q_UNUSED(e);
- hovered = false;
-}
-
-void ClearButton::mousePressEvent(QMouseEvent *e) {
- Q_UNUSED(e);
- mousePressed = true;
-}
-
-void ClearButton::mouseReleaseEvent(QMouseEvent *e) {
- Q_UNUSED(e);
- mousePressed = false;
-}
-
-/*
- Search icon on the left hand side of the search widget
- When a menu is set a down arrow appears
- */
class SearchButton : public QAbstractButton {
+
public:
SearchButton(QWidget *parent = 0);
- void paintEvent(QPaintEvent *event);
QMenu *m_menu;
protected:
- void mousePressEvent(QMouseEvent *event);
+ void paintEvent(QPaintEvent *e);
+ void mousePressEvent(QMouseEvent *e);
+
};
SearchButton::SearchButton(QWidget *parent)
setFocusPolicy(Qt::NoFocus);
}
-void SearchButton::mousePressEvent(QMouseEvent *event) {
- if (m_menu && event->button() == Qt::LeftButton) {
+void SearchButton::mousePressEvent(QMouseEvent *e) {
+ if (m_menu && e->button() == Qt::LeftButton) {
QWidget *p = parentWidget();
if (p) {
QPoint r = p->mapToGlobal(QPoint(0, p->height()));
m_menu->exec(QPoint(r.x() + height() / 2, r.y()));
}
- event->accept();
+ e->accept();
}
- QAbstractButton::mousePressEvent(event);
+ QAbstractButton::mousePressEvent(e);
}
-void SearchButton::paintEvent(QPaintEvent *event) {
- Q_UNUSED(event);
+void SearchButton::paintEvent(QPaintEvent *e) {
+ Q_UNUSED(e);
QPainter painter(this);
const int h = height();
int iconSize = 16;
painter.drawPixmap(x, y, p);
}
-/*
- SearchLineEdit is an enhanced QLineEdit
- - A Search icon on the left with optional menu
- - When there is no text and doesn't have focus an "inactive text" is displayed
- - When there is text a clear button is displayed on the right hand side
- */
-SearchLineEdit::SearchLineEdit(QWidget *parent) : ExLineEdit(parent),
-searchButton(new SearchButton(this)) {
- connect(lineEdit(), SIGNAL(textChanged(const QString &)), SIGNAL(textChanged(const QString &)));
- connect(lineEdit(), SIGNAL(textEdited(const QString &)), SIGNAL(textEdited(const QString &)));
- connect(lineEdit(), SIGNAL(returnPressed()), SLOT(returnPressed()));
+SearchLineEdit::SearchLineEdit(QWidget *parent) : ExLineEdit(parent), searchButton(new SearchButton(this)) {
+ connect(m_lineEdit, SIGNAL(textChanged(const QString &)), SIGNAL(textChanged(const QString &)));
+ connect(m_lineEdit, SIGNAL(textEdited(const QString &)), SIGNAL(textEdited(const QString &)));
+ connect(m_lineEdit, SIGNAL(returnPressed()), SLOT(returnPressed()));
setLeftWidget(searchButton);
inactiveText = tr("Search");
connect(autoComplete, SIGNAL(suggestionAccepted(Suggestion*)), SIGNAL(suggestionAccepted(Suggestion*)));
}
-void SearchLineEdit::paintEvent(QPaintEvent *event) {
- if (lineEdit()->text().isEmpty() && !hasFocus() && !inactiveText.isEmpty()) {
- ExLineEdit::paintEvent(event);
+void SearchLineEdit::paintEvent(QPaintEvent *e) {
+ if (m_lineEdit->text().isEmpty() && !hasFocus() && !inactiveText.isEmpty()) {
+ ExLineEdit::paintEvent(e);
QStyleOptionFrameV2 panel;
initStyleOption(&panel);
QRect r = style()->subElementRect(QStyle::SE_LineEditContents, &panel, this);
QFontMetrics fm = fontMetrics();
- int horizontalMargin = lineEdit()->x();
+ int horizontalMargin = m_lineEdit->x();
QRect lineRect(horizontalMargin + r.x(), r.y() + (r.height() - fm.height() + 1) / 2,
r.width() - 2 * horizontalMargin, fm.height());
QPainter painter(this);
painter.setPen(palette().brush(QPalette::Disabled, QPalette::Text).color());
- painter.drawText(lineRect, Qt::AlignLeft|Qt::AlignVCenter, inactiveText);
+ painter.drawText(lineRect, Qt::AlignLeft | Qt::AlignVCenter, inactiveText);
} else {
- ExLineEdit::paintEvent(event);
+ ExLineEdit::paintEvent(e);
}
}
-void SearchLineEdit::resizeEvent(QResizeEvent *event) {
+void SearchLineEdit::resizeEvent(QResizeEvent *e) {
updateGeometries();
- ExLineEdit::resizeEvent(event);
+ ExLineEdit::resizeEvent(e);
}
void SearchLineEdit::updateGeometries() {
inactiveText = text;
}
+void SearchLineEdit::setText(const QString &text) {
+ m_lineEdit->setText(text);
+}
+
+AutoComplete *SearchLineEdit::getAutoComplete() {
+ return autoComplete;
+}
+
void SearchLineEdit::setMenu(QMenu *menu) {
if (searchButton->m_menu)
searchButton->m_menu->deleteLater();
}
void SearchLineEdit::returnPressed() {
- if (!lineEdit()->text().isEmpty()) {
+ QString text = m_lineEdit->text().simplified();
+ if (!text.isEmpty()) {
autoComplete->preventSuggest();
- emit search(lineEdit()->text());
+ emit search(text);
}
}
autoComplete->preventSuggest();
}
-void SearchLineEdit::focusInEvent(QFocusEvent *event) {
- ExLineEdit::focusInEvent(event);
+void SearchLineEdit::selectAll() {
+ m_lineEdit->selectAll();
+}
+
+void SearchLineEdit::setSuggester(Suggester *suggester) {
+ autoComplete->setSuggester(suggester);
+}
+
+void SearchLineEdit::focusInEvent(QFocusEvent *e) {
+ ExLineEdit::focusInEvent(e);
enableSuggest();
}
+
+void SearchLineEdit::emitTextChanged(const QString &text) {
+ autoComplete->enableSuggest();
+ emit textEdited(text);
+}
+
+QString SearchLineEdit::text() {
+ return m_lineEdit->text();
+}
+
+QLineEdit *SearchLineEdit::getLineEdit() {
+ return m_lineEdit;
+}
#ifndef SEARCHLINEEDIT_H
#define SEARCHLINEEDIT_H
-#include "urllineedit.h"
-#include "autocomplete.h"
+#include <QtGui>
+#if QT_VERSION >= 0x050000
+#include <QtWidgets>
+#endif
-#include <QLineEdit>
-#include <QAbstractButton>
-
-QT_BEGIN_NAMESPACE
-class QMenu;
-QT_END_NAMESPACE
+#include "exlineedit.h"
+#include "searchwidget.h"
class SearchButton;
class Suggester;
+class AutoComplete;
-/*
- Clear button on the right hand side of the search widget.
- Hidden by default
- */
-class ClearButton : public QAbstractButton {
+class SearchLineEdit : public ExLineEdit, public SearchWidget {
Q_OBJECT
public:
- ClearButton(QWidget *parent = 0);
- void paintEvent(QPaintEvent *e);
+ SearchLineEdit(QWidget *parent = 0);
+ QMenu *menu() const;
+ void setMenu(QMenu *menu);
+ void enableSuggest();
+ void preventSuggest();
+ void selectAll();
+ void setSuggester(Suggester *suggester);
+ void setInactiveText(const QString &text);
+ void setText(const QString &text);
+ AutoComplete *getAutoComplete();
+ void emitTextChanged(const QString &text);
+ QString text();
+ QLineEdit *getLineEdit();
public slots:
- void textChanged(const QString &text);
-
-protected:
- void enterEvent(QEvent *e);
- void leaveEvent(QEvent *e);
-
- void mousePressEvent(QMouseEvent *e);
- void mouseReleaseEvent(QMouseEvent *e);
-
-private:
- bool hovered;
- bool mousePressed;
-};
-
-class SearchLineEdit : public ExLineEdit {
-
- Q_OBJECT
+ void returnPressed();
signals:
void textChanged(const QString &text);
void search(const QString &text);
void suggestionAccepted(Suggestion *suggestion);
-public:
- SearchLineEdit(QWidget *parent = 0);
-
- void setInactiveText(const QString &text);
-
- QMenu *menu() const;
- void setMenu(QMenu *menu);
- void updateGeometries();
- void enableSuggest();
- void preventSuggest();
- void selectAll() { lineEdit()->selectAll(); }
- void setSuggester(Suggester *suggester) { autoComplete->setSuggester(suggester); }
- void setText(const QString &text) { lineEdit()->setText(text); }
-
protected:
- void resizeEvent(QResizeEvent *event);
- void paintEvent(QPaintEvent *event);
- void focusInEvent(QFocusEvent *event);
-
-private slots:
- void returnPressed();
+ void updateGeometries();
+ void resizeEvent(QResizeEvent *e);
+ void paintEvent(QPaintEvent *e);
+ void focusInEvent(QFocusEvent *e);
private:
SearchButton *searchButton;
QBoxLayout *tipLayout = new QHBoxLayout();
tipLayout->setSpacing(10);
+ const QFont &biggerFont = FontUtils::big();
+
//: "Enter", as in "type". The whole phrase says: "Enter a keyword to start watching videos"
QLabel *tipLabel = new QLabel(tr("Enter"), this);
#ifndef APP_MAC
- const QFont &biggerFont = FontUtils::big();
tipLabel->setFont(biggerFont);
#endif
tipLayout->addWidget(tipLabel);
QHBoxLayout *searchLayout = new QHBoxLayout();
searchLayout->setAlignment(Qt::AlignVCenter);
+#ifdef APP_MAC_SEARCHFIELD
+ queryEdit = new SearchLineEditMac(this);
+#else
queryEdit = new SearchLineEdit(this);
-#ifndef APP_MAC_SEARCHFIELD
- queryEdit->setFont(biggerFont);
+ queryEdit->toWidget()->setFont(biggerFont);
#endif
- connect(queryEdit, SIGNAL(search(const QString&)), SLOT(watch(const QString&)));
- connect(queryEdit, SIGNAL(textEdited(const QString &)), SLOT(textChanged(const QString &)));
- connect(queryEdit, SIGNAL(suggestionAccepted(Suggestion*)), SLOT(suggestionAccepted(Suggestion*)));
+
+ qDebug() << "queryEdit->toWidget()" << (queryEdit->toWidget() == 0) << queryEdit->toWidget();
+ connect(queryEdit->toWidget(), SIGNAL(search(const QString&)), SLOT(watch(const QString&)));
+ connect(queryEdit->toWidget(), SIGNAL(textEdited(const QString &)), SLOT(textChanged(const QString &)));
+ connect(queryEdit->toWidget(), SIGNAL(suggestionAccepted(Suggestion*)), SLOT(suggestionAccepted(Suggestion*)));
youtubeSuggest = new YTSuggester(this);
channelSuggest = new ChannelSuggest(this);
searchTypeChanged(0);
- searchLayout->addWidget(queryEdit);
+ searchLayout->addWidget(queryEdit->toWidget());
searchLayout->addSpacing(10);
watchButton = new QPushButton(tr("Watch"), this);
queryEdit->selectAll();
queryEdit->enableSuggest();
- if (!queryEdit->hasFocus()) queryEdit->setFocus();
+ if (!queryEdit->toWidget()->hasFocus()) queryEdit->toWidget()->setFocus();
}
void SearchView::disappear() {
+ display + "</a>", this);
itemLabel->setAttribute(Qt::WA_DeleteOnClose);
itemLabel->setProperty("recentItem", true);
- itemLabel->setMaximumWidth(queryEdit->width() + watchButton->width());
+ itemLabel->setMaximumWidth(queryEdit->toWidget()->width() + watchButton->width());
// itemLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
// Make links navigable with the keyboard too
itemLabel->setTextInteractionFlags(Qt::LinksAccessibleByKeyboard | Qt::LinksAccessibleByMouse);
+ display + "</a>", this);
itemLabel->setAttribute(Qt::WA_DeleteOnClose);
itemLabel->setProperty("recentItem", true);
- itemLabel->setMaximumWidth(queryEdit->width() + watchButton->width());
+ itemLabel->setMaximumWidth(queryEdit->toWidget()->width() + watchButton->width());
// itemLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
// Make links navigable with the keyboard too
itemLabel->setTextInteractionFlags(Qt::LinksAccessibleByKeyboard | Qt::LinksAccessibleByMouse);
// check for empty query
if (q.length() == 0) {
- queryEdit->setFocus(Qt::OtherFocusReason);
+ queryEdit->toWidget()->setFocus(Qt::OtherFocusReason);
return;
}
void SearchView::watchChannel(const QString &channelId) {
if (channelId.length() == 0) {
- queryEdit->setFocus(Qt::OtherFocusReason);
+ queryEdit->toWidget()->setFocus(Qt::OtherFocusReason);
return;
}
// check for empty query
if (query.length() == 0) {
- queryEdit->setFocus(Qt::OtherFocusReason);
+ queryEdit->toWidget()->setFocus(Qt::OtherFocusReason);
return;
}
queryEdit->setSuggester(channelSuggest);
}
queryEdit->selectAll();
- queryEdit->setFocus();
+ queryEdit->toWidget()->setFocus();
}
void SearchView::suggestionAccepted(Suggestion *suggestion) {
#endif
#include "view.h"
-class SearchLineEdit;
+class SearchWidget;
class SearchParams;
class YTSuggester;
class ChannelSuggest;
ChannelSuggest *channelSuggest;
QComboBox *typeCombo;
- SearchLineEdit *queryEdit;
+ SearchWidget *queryEdit;
QLabel *recentKeywordsLabel;
QBoxLayout *recentKeywordsLayout;
QLabel *recentChannelsLabel;
--- /dev/null
+#include "searchwidget.h"
+
+/*
+SearchWidget::SearchWidget(QWidget *parent, SearchWidgetInterface *interface) : QWidget(parent), interface(interface) {
+ QLayout *l = new QVBoxLayout(this);
+ l->setMargin(0);
+ QWidget *w = qobject_cast<QWidget*>(interface);
+ l->addWidget(w);
+}
+
+QMenu *SearchWidget::menu() const {
+ return interface->menu();
+}
+
+void SearchWidget::setMenu(QMenu *menu) {
+ interface->setMenu(menu);
+}
+*/
--- /dev/null
+#ifndef SEARCHWIDGET
+#define SEARCHWIDGET
+
+#include <QtGui>
+#if QT_VERSION >= 0x050000
+#include <QtWidgets>
+#endif
+
+class SearchButton;
+class Suggester;
+class Suggestion;
+class AutoComplete;
+
+class SearchWidget {
+
+public:
+ virtual QMenu *menu() const = 0;
+ virtual void setMenu(QMenu *menu) = 0;
+ virtual void enableSuggest() = 0;
+ virtual void preventSuggest() = 0;
+ virtual void selectAll() = 0;
+ virtual void setSuggester(Suggester *suggester) = 0;
+ virtual void setInactiveText(const QString &text) = 0;
+ virtual void setText(const QString &text) = 0;
+ virtual AutoComplete *getAutoComplete() = 0;
+ virtual void emitTextChanged(const QString &text) = 0;
+ virtual void returnPressed() = 0;
+ virtual QString text() = 0;
+ virtual QLineEdit *getLineEdit() = 0;
+
+ QWidget *toWidget() {
+ return dynamic_cast<QWidget*>(this);
+ }
+
+signals:
+ void textChanged(const QString &text);
+ void textEdited(const QString &text);
+ void search(const QString &text);
+ void suggestionAccepted(Suggestion *suggestion);
+
+};
+/*
+class SearchWidget : public QWidget, public SearchWidgetInterface {
+
+public:
+ SearchWidget(QWidget *parent = 0);
+ QMenu *menu() const;
+ void setMenu(QMenu *menu);
+ void enableSuggest();
+ void preventSuggest();
+ void selectAll();
+ void setSuggester(Suggester *suggester);
+ void setInactiveText(const QString &text);
+ void setText(const QString &text);
+ AutoComplete *getAutoComplete();
+ void emitTextChanged(const QString &text);
+ void returnPressed();
+ QString text();
+
+private:
+ SearchWidgetInterface *interface;
+
+};
+*/
+
+#endif // SEARCHWIDGET
#include "segmentedcontrol.h"
#include "mainwindow.h"
#include "painterutils.h"
+#include "fontutils.h"
-static const QColor borderColor = QColor(0x26, 0x26, 0x26);
+static const QColor borderColor = QColor(158, 157, 159);
class SegmentedControl::Private {
public:
SegmentedControl::SegmentedControl (QWidget *parent)
: QWidget(parent), d(new SegmentedControl::Private) {
+ setFont(FontUtils::small());
+
setMouseTracking(true);
d->hoveredAction = 0;
QPainter p(this);
QLinearGradient linearGrad(rect().topLeft(), rect().bottomLeft());
- linearGrad.setColorAt(0, borderColor);
- linearGrad.setColorAt(1, QColor(0x3c, 0x3c, 0x3c));
+ linearGrad.setColorAt(0, QColor(185, 183, 185));
+ linearGrad.setColorAt(1, QColor(176, 176, 178));
p.fillRect(rect(), QBrush(linearGrad));
// Calculate Buttons Size & Location
const int actionCount = d->actionList.size();
for (int i = 0; i < actionCount; i++) {
QAction *action = d->actionList.at(i);
-
if (i + 1 == actionCount) {
rect.setWidth(width - buttonWidth * (actionCount-1));
drawButton(&p, rect, action);
drawButton(&p, rect, action);
rect.moveLeft(rect.x() + rect.width());
}
-
}
-
}
void SegmentedControl::mouseMoveEvent (QMouseEvent *event) {
void SegmentedControl::drawUnselectedButton (QPainter *painter,
const QRect& rect,
const QAction *action) {
+ painter->setPen(QPen(QColor(0, 0, 0, 128), 1));
paintButton(painter, rect, action);
}
QRadialGradient gradient(hCenter, 0,
width,
hCenter, 0);
- gradient.setColorAt(1, Qt::black);
- gradient.setColorAt(0, QColor(0x33, 0x33, 0x33));
+ gradient.setColorAt(1, QColor(212, 210, 212));
+ gradient.setColorAt(0, QColor(203, 203, 205));
painter->fillRect(0, 0, width, height, QBrush(gradient));
painter->restore();
+ painter->setPen(QPen(QColor(0, 0, 0, 232), 1));
paintButton(painter, rect, action);
}
const int height = rect.height();
const int width = rect.width();
- if (action == d->pressedAction && action != d->checkedAction) {
- const int hCenter = width * .5;
- QRadialGradient gradient(hCenter, 0,
- width,
- hCenter, 0);
- gradient.setColorAt(1, QColor(0x00, 0x00, 0x00, 0));
- gradient.setColorAt(0, QColor(0x00, 0x00, 0x00, 16));
- painter->fillRect(0, 0, width, height, QBrush(gradient));
- } else if (action == d->hoveredAction && action != d->checkedAction) {
- const int hCenter = width * .5;
- QRadialGradient gradient(hCenter, 0,
- width,
- hCenter, 0);
- gradient.setColorAt(1, QColor(0xff, 0xff, 0xff, 0));
- gradient.setColorAt(0, QColor(0xff, 0xff, 0xff, 16));
- painter->fillRect(0, 0, width, height, QBrush(gradient));
- }
-
+ painter->save();
painter->setPen(borderColor);
#if defined(APP_MAC) | defined(APP_WIN)
painter->drawRect(-1, -1, width, height);
#else
painter->drawRect(0, 0, width, height - 1);
#endif
+ painter->restore();
const QString text = action->text();
// text shadow
+ /*
painter->setPen(QColor(0, 0, 0, 128));
painter->drawText(0, -1, width, height, Qt::AlignCenter, text);
+ */
- painter->setPen(QPen(Qt::white, 1));
painter->drawText(0, 0, width, height, Qt::AlignCenter, text);
if (action->property("notifyCount").isValid()) {
PainterUtils::paintBadge(painter, action->property("notifyCount").toString());
}
+ if (action == d->pressedAction && action != d->checkedAction) {
+ const int hCenter = width * .5;
+ QRadialGradient gradient(hCenter, 0,
+ width,
+ hCenter, 0);
+ gradient.setColorAt(1, QColor(0x00, 0x00, 0x00, 0));
+ gradient.setColorAt(0, QColor(0x00, 0x00, 0x00, 32));
+ painter->fillRect(0, 0, width, height, QBrush(gradient));
+ } else if (action == d->hoveredAction && action != d->checkedAction) {
+ const int hCenter = width * .5;
+ QRadialGradient gradient(hCenter, 0,
+ width,
+ hCenter, 0);
+ gradient.setColorAt(1, QColor(0x00, 0x00, 0x00, 0));
+ gradient.setColorAt(0, QColor(0x00, 0x00, 0x00, 16));
+ painter->fillRect(0, 0, width, height, QBrush(gradient));
+ }
+
painter->restore();
}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial Usage
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "urllineedit.h"
-#include "searchlineedit.h"
-
-#include <QEvent>
-
-#include <QApplication>
-#include <QCompleter>
-#include <QFocusEvent>
-#include <QHBoxLayout>
-#include <QLabel>
-#include <QLineEdit>
-#include <QPainter>
-#include <QStyle>
-#include <QStyleOptionFrameV2>
-
-#include <QtCore/QDebug>
-
-ExLineEdit::ExLineEdit(QWidget *parent)
- : QWidget(parent)
- , m_leftWidget(0)
- , m_lineEdit(new QLineEdit(this))
- , m_clearButton(0)
-{
- setFocusPolicy(m_lineEdit->focusPolicy());
- setAttribute(Qt::WA_InputMethodEnabled);
- setSizePolicy(m_lineEdit->sizePolicy());
- setBackgroundRole(m_lineEdit->backgroundRole());
- setMouseTracking(true);
- setAcceptDrops(true);
- setAttribute(Qt::WA_MacShowFocusRect, true);
- QPalette p = m_lineEdit->palette();
- setPalette(p);
-
- // line edit
- m_lineEdit->setFrame(false);
- m_lineEdit->setFocusProxy(this);
- m_lineEdit->setAttribute(Qt::WA_MacShowFocusRect, false);
- m_lineEdit->setStyleSheet("background:transparent");
- QPalette clearPalette = m_lineEdit->palette();
- clearPalette.setBrush(QPalette::Base, QBrush(Qt::transparent));
- m_lineEdit->setPalette(clearPalette);
-
- // clearButton
- m_clearButton = new ClearButton(this);
- connect(m_clearButton, SIGNAL(clicked()),
- m_lineEdit, SLOT(clear()));
- connect(m_lineEdit, SIGNAL(textChanged(const QString&)),
- m_clearButton, SLOT(textChanged(const QString&)));
-}
-
-void ExLineEdit::setFont(const QFont &font) {
- m_lineEdit->setFont(font);
- updateGeometries();
-}
-
-void ExLineEdit::setLeftWidget(QWidget *widget)
-{
- m_leftWidget = widget;
-}
-
-QWidget *ExLineEdit::leftWidget() const
-{
- return m_leftWidget;
-}
-
-void ExLineEdit::resizeEvent(QResizeEvent *event)
-{
- Q_ASSERT(m_leftWidget);
- updateGeometries();
- QWidget::resizeEvent(event);
-}
-
-void ExLineEdit::updateGeometries()
-{
- QStyleOptionFrameV2 panel;
- initStyleOption(&panel);
- QRect rect = style()->subElementRect(QStyle::SE_LineEditContents, &panel, this);
-
- int padding = 3;
- // int height = rect.height() + padding*2;
- int width = rect.width();
-
- // int m_leftWidgetHeight = m_leftWidget->height();
- m_leftWidget->setGeometry(rect.x() + 2, 0,
- m_leftWidget->width(), m_leftWidget->height());
-
- int clearButtonWidth = this->height();
- m_lineEdit->setGeometry(m_leftWidget->x() + m_leftWidget->width(), padding,
- width - clearButtonWidth - m_leftWidget->width(), this->height() - padding*2);
-
- m_clearButton->setGeometry(this->width() - clearButtonWidth, 0,
- clearButtonWidth, this->height());
-}
-
-void ExLineEdit::initStyleOption(QStyleOptionFrameV2 *option) const
-{
- option->initFrom(this);
- option->rect = contentsRect();
- option->lineWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, option, this);
- option->midLineWidth = 0;
- option->state |= QStyle::State_Sunken;
- if (m_lineEdit->isReadOnly())
- option->state |= QStyle::State_ReadOnly;
-#ifdef QT_KEYPAD_NAVIGATION
- if (hasEditFocus())
- option->state |= QStyle::State_HasEditFocus;
-#endif
- option->features = QStyleOptionFrameV2::None;
-}
-
-QSize ExLineEdit::sizeHint() const
-{
- m_lineEdit->setFrame(true);
- QSize size = m_lineEdit->sizeHint();
- m_lineEdit->setFrame(false);
- size = size + QSize(3, 3);
- return size;
-}
-
-void ExLineEdit::focusInEvent(QFocusEvent *event)
-{
- m_lineEdit->event(event);
- QWidget::focusInEvent(event);
-}
-
-void ExLineEdit::focusOutEvent(QFocusEvent *event)
-{
- m_lineEdit->event(event);
-
- if (m_lineEdit->completer()) {
- connect(m_lineEdit->completer(), SIGNAL(activated(QString)),
- m_lineEdit, SLOT(setText(QString)));
- connect(m_lineEdit->completer(), SIGNAL(highlighted(QString)),
- m_lineEdit, SLOT(_q_completionHighlighted(QString)));
- }
- QWidget::focusOutEvent(event);
-}
-
-void ExLineEdit::keyPressEvent(QKeyEvent *event)
-{
- if (event->key() == Qt::Key_Escape && !m_lineEdit->text().isEmpty()) {
- m_lineEdit->clear();
- }
- m_lineEdit->event(event);
- QWidget::keyPressEvent(event);
-}
-
-bool ExLineEdit::event(QEvent *event)
-{
- if (event->type() == QEvent::ShortcutOverride ||
- event->type() == QEvent::InputMethod)
- m_lineEdit->event(event);
- return QWidget::event(event);
-}
-
-void ExLineEdit::paintEvent(QPaintEvent *)
-{
- QPainter p(this);
- QStyleOptionFrameV2 panel;
- initStyleOption(&panel);
- style()->drawPrimitive(QStyle::PE_PanelLineEdit, &panel, &p, this);
-}
+++ /dev/null
-/* $BEGIN_LICENSE
-
-This file is part of Minitube.
-Copyright 2009, Flavio Tordini <flavio.tordini@gmail.com>
-
-Minitube 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 3 of the License, or
-(at your option) any later version.
-
-Minitube 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 Minitube. If not, see <http://www.gnu.org/licenses/>.
-
-$END_LICENSE */
-
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial Usage
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef URLLINEEDIT_H
-#define URLLINEEDIT_H
-
-#include <QUrl>
-#include <QWidget>
-#include <QLineEdit>
-#include <QStyleOptionFrame>
-
-QT_BEGIN_NAMESPACE
-class QLineEdit;
-QT_END_NAMESPACE
-
-class ClearButton;
-class ExLineEdit : public QWidget
-{
- Q_OBJECT
-
-public:
- ExLineEdit(QWidget *parent = 0);
-
- inline QLineEdit *lineEdit() const { return m_lineEdit; }
-
- void setLeftWidget(QWidget *widget);
- QWidget *leftWidget() const;
- void clear() {
- m_lineEdit->clear();
- }
- QString text() {
- return m_lineEdit->text();
- }
- QSize sizeHint() const;
- void updateGeometries();
- void setFont(const QFont &);
-
-protected:
- void focusInEvent(QFocusEvent *event);
- void focusOutEvent(QFocusEvent *event);
- void keyPressEvent(QKeyEvent *event);
- void paintEvent(QPaintEvent *event);
- void resizeEvent(QResizeEvent *event);
- bool event(QEvent *event);
- void initStyleOption(QStyleOptionFrameV2 *option) const;
-
- QWidget *m_leftWidget;
- QLineEdit *m_lineEdit;
- ClearButton *m_clearButton;
-};
-
-#endif // URLLINEEDIT_H
-