diff options
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/urllineedit.cpp | 43 | ||||
-rw-r--r-- | src/widgets/urllineedit.h | 23 | ||||
-rw-r--r-- | src/widgets/webviewtabbar.cpp | 6 | ||||
-rw-r--r-- | src/widgets/webviewtabbar.h | 3 |
4 files changed, 75 insertions, 0 deletions
diff --git a/src/widgets/urllineedit.cpp b/src/widgets/urllineedit.cpp new file mode 100644 index 0000000..25bf157 --- /dev/null +++ b/src/widgets/urllineedit.cpp @@ -0,0 +1,43 @@ +#include "urllineedit.h" +#include <QUrl> + +UrlLineEdit::UrlLineEdit(QWidget *parent) : + QLineEdit(parent) +{ + //setStyleSheet("color: #808080"); +} + +void UrlLineEdit::setUrl(const QUrl &url) +{ + QString urlText = url.toString(); + QString domain = url.host(); + + QTextCharFormat f_host; + + f_host.setFontWeight(QFont::Bold); + //f_host.setForeground(QBrush(QColor::fromRgb(255, 255, 255))); + + QTextLayout::FormatRange fr_tracker; + fr_tracker.start = urlText.indexOf(domain); + fr_tracker.length = domain.length(); + fr_tracker.format = f_host; + + clear(); + clearTextFormat(); + setTextFormat(fr_tracker); + setText(urlText); +} + +void UrlLineEdit::setTextFormat(const QTextLayout::FormatRange &format) +{ + QList<QInputMethodEvent::Attribute> attributes; + attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, format.start, format.length, format.format)); + QInputMethodEvent ev(QString(), attributes); + event(&ev); + +} + +void UrlLineEdit::clearTextFormat() +{ + setTextFormat(QTextLayout::FormatRange()); +} diff --git a/src/widgets/urllineedit.h b/src/widgets/urllineedit.h new file mode 100644 index 0000000..e7dcf36 --- /dev/null +++ b/src/widgets/urllineedit.h @@ -0,0 +1,23 @@ +#ifndef URLLINEEDIT_H +#define URLLINEEDIT_H + +#include <QLineEdit> +#include <QTextLayout> + +class UrlLineEdit : public QLineEdit +{ + Q_OBJECT +public: + explicit UrlLineEdit(QWidget *parent = 0); + +signals: + +public slots: + void setUrl(const QUrl &url); + +private: + void setTextFormat(const QTextLayout::FormatRange &format); + void clearTextFormat(); +}; + +#endif // URLLINEEDIT_H diff --git a/src/widgets/webviewtabbar.cpp b/src/widgets/webviewtabbar.cpp index d3747cc..a050a76 100644 --- a/src/widgets/webviewtabbar.cpp +++ b/src/widgets/webviewtabbar.cpp @@ -70,6 +70,12 @@ QWebEngineView *WebViewTabBar::currentView() return m_views.at(currentIndex()); } +QSize WebViewTabBar::tabSizeHint(int index) const +{ + Q_UNUSED(index) + return QSize(200, this->height()); +} + void WebViewTabBar::handleCurrentChanged(int index) { emit(currentTabChanged(m_views.at(index))); diff --git a/src/widgets/webviewtabbar.h b/src/widgets/webviewtabbar.h index 58d85a8..8b32e7a 100644 --- a/src/widgets/webviewtabbar.h +++ b/src/widgets/webviewtabbar.h @@ -40,6 +40,9 @@ public: signals: void currentTabChanged(QWebEngineView *view); +protected: + QSize tabSizeHint(int index) const; + private slots: void handleCurrentChanged(int index); void handleTabClose(int index); |