diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2008-11-29 12:15:17 +0100 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2008-11-29 12:15:17 +0100 |
commit | 129932ca513ed7ef865669fa81020043bcfa7ba0 (patch) | |
tree | 03fba7638c0323672e7958245e9afb0663ca2c1a /src | |
parent | Various adjustments. Nothing really important.Various adjustments. Nothing re... (diff) | |
download | rekonq-129932ca513ed7ef865669fa81020043bcfa7ba0.tar.xz |
Fixing ToolBar, some icons and code..
Diffstat (limited to 'src')
-rw-r--r-- | src/browserapplication.cpp | 35 | ||||
-rw-r--r-- | src/browsermainwindow.cpp | 10 | ||||
-rw-r--r-- | src/urlbar.cpp | 76 | ||||
-rw-r--r-- | src/urlbar.h | 7 |
4 files changed, 66 insertions, 62 deletions
diff --git a/src/browserapplication.cpp b/src/browserapplication.cpp index 7a125bdc..3099dfc2 100644 --- a/src/browserapplication.cpp +++ b/src/browserapplication.cpp @@ -60,7 +60,8 @@ BrowserApplication::BrowserApplication(KCmdLineArgs *args, const QString &server { QLocalSocket socket; socket.connectToServer(serverName); - if (socket.waitForConnected(500)) { + if (socket.waitForConnected(500)) + { QTextStream stream(&socket); int n = args->count(); if (n > 1) @@ -96,7 +97,7 @@ BrowserApplication::BrowserApplication(KCmdLineArgs *args, const QString &server m_lastSession = settings.value(QLatin1String("lastSession")).toByteArray(); settings.endGroup(); - QTimer::singleShot(0, this, SLOT(postLaunch())); + QTimer::singleShot(0, this, SLOT( postLaunch() ) ); } @@ -111,15 +112,15 @@ BrowserApplication::~BrowserApplication() -#if defined(Q_WS_MAC) -void BrowserApplication::lastWindowClosed() -{ - clean(); - BrowserMainWindow *mw = new BrowserMainWindow; - mw->slotHome(); - m_mainWindows.prepend(mw); -} -#endif +// #if defined(Q_WS_MAC) +// void BrowserApplication::lastWindowClosed() +// { +// clean(); +// BrowserMainWindow *mw = new BrowserMainWindow; +// mw->slotHome(); +// m_mainWindows.prepend(mw); +// } +// #endif @@ -137,16 +138,18 @@ BrowserApplication *BrowserApplication::instance() void BrowserApplication::postLaunch() { QString directory = QDesktopServices::storageLocation(QDesktopServices::DataLocation); - if (directory.isEmpty()) + if ( directory.isEmpty() ) + { directory = QDir::homePath() + QLatin1String("/.") + QCoreApplication::applicationName(); + } QWebSettings::setIconDatabasePath(directory); -// setWindowIcon(QIcon(QLatin1String(":browser.svg"))); // FIXME setICON - + setWindowIcon( KIcon("rekonq") ); loadSettings(); // newMainWindow() needs to be called in main() for this to happen - if (m_mainWindows.count() > 0) { + if (m_mainWindows.count() > 0) + { KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); int n = args->count(); if (n > 1) @@ -395,7 +398,7 @@ KIcon BrowserApplication::icon(const QUrl &url) const if (!icon.isNull()) return icon; if (m_defaultIcon.isNull()) - m_defaultIcon = KIcon("rekonq"); + m_defaultIcon = KIcon("kde"); return m_defaultIcon; } diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index cbf7eb54..3a79f995 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -69,8 +69,9 @@ BrowserMainWindow::BrowserMainWindow(QWidget *parent, Qt::WindowFlags flags) , m_reload(0) , m_bookmarkMenu(0) { + // delete widget accepting close event setAttribute(Qt::WA_DeleteOnClose, true); - statusBar()->setSizeGripEnabled(true); + setupMenu(); setupToolBar(); @@ -372,7 +373,7 @@ void BrowserMainWindow::setupMenu() void BrowserMainWindow::setupToolBar() { - m_navigationBar = (KToolBar *) addToolBar(i18n("Navigation")); + m_navigationBar = new KToolBar( i18n("Navigation") , this, Qt::TopToolBarArea, true, false, false); m_historyBack = new KAction( KIcon("go-previous"), i18n("Back"), this); m_historyBackMenu = new KMenu(this); @@ -398,6 +399,11 @@ void BrowserMainWindow::setupToolBar() m_searchBar = new SearchBar(m_navigationBar); m_navigationBar->addWidget(m_searchBar); connect(m_searchBar, SIGNAL(search(const QUrl&)), this, SLOT(loadUrl(const QUrl&))); + + // UI settings + m_navigationBar->setIconDimensions(16); + m_navigationBar->setContextMenuPolicy( Qt::NoContextMenu ); + KToolBar::setToolBarsLocked( true ); } diff --git a/src/urlbar.cpp b/src/urlbar.cpp index 01675c3f..07b5168b 100644 --- a/src/urlbar.cpp +++ b/src/urlbar.cpp @@ -24,12 +24,6 @@ #include "browserapplication.h" // Qt Includes -// #include <QVBoxLayout> -// #include <QCompleter> -// #include <QFocusEvent> -// #include <QPainter> -// #include <QStyle> -// #include <QStyleOptionFrameV2> #include <QtGui> @@ -45,16 +39,19 @@ UrlBar::UrlBar(QWidget *parent) m_lineEdit = new KLineEdit; - QVBoxLayout *layout = new QVBoxLayout; + QHBoxLayout *layout = new QHBoxLayout; layout->addWidget(m_iconLabel); layout->addWidget(m_lineEdit); setLayout(layout); m_defaultBaseColor = palette().color(QPalette::Base); + setPalette( QPalette(Qt::white) ); + setAutoFillBackground( true ); webViewIconChanged(); } + UrlBar::~UrlBar() { // delete m_webView; @@ -62,11 +59,13 @@ UrlBar::~UrlBar() delete m_lineEdit; } + KLineEdit *UrlBar::lineEdit() { return m_lineEdit; } + void UrlBar::setWebView(WebView *webView) { Q_ASSERT(!m_webView); @@ -78,39 +77,6 @@ void UrlBar::setWebView(WebView *webView) connect(webView, SIGNAL(loadProgress(int)), this, SLOT(update())); } -void UrlBar::paintEvent(QPaintEvent *event) -{ - QPainter p(this); - QStyleOptionFrameV2 optionPanel; - - optionPanel.initFrom(this); - optionPanel.rect = contentsRect(); - optionPanel.lineWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, &optionPanel, this); - optionPanel.midLineWidth = 0; - optionPanel.state |= QStyle::State_Sunken; - if (m_lineEdit->isReadOnly()) - optionPanel.state |= QStyle::State_ReadOnly; - optionPanel.features = QStyleOptionFrameV2::None; - - style()->drawPrimitive(QStyle::PE_PanelLineEdit, &optionPanel, &p, (QWidget *) this); -} - -void UrlBar::focusOutEvent(QFocusEvent *event) -{ - if (m_lineEdit->text().isEmpty() && m_webView) - { - m_lineEdit->setText(m_webView->url().toString()); - } - -// m_lineEdit->event(event); // FIXME - - 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 UrlBar::webViewUrlChanged(const QUrl &url) { @@ -118,6 +84,7 @@ void UrlBar::webViewUrlChanged(const QUrl &url) m_lineEdit->setCursorPosition(0); } + void UrlBar::webViewIconChanged() { QUrl url = (m_webView) ? m_webView->url() : QUrl(); @@ -126,6 +93,7 @@ void UrlBar::webViewIconChanged() m_iconLabel->setPixmap(pixmap); } + QLinearGradient UrlBar::generateGradient(const QColor &color) const { QLinearGradient gradient(0, 0, 0, height()); @@ -137,3 +105,31 @@ QLinearGradient UrlBar::generateGradient(const QColor &color) const return gradient; } +// FIXME +// void UrlBar::paintEvent(QPaintEvent *event) +// { +// QPalette p = palette(); +// if (m_webView && m_webView->url().scheme() == QLatin1String("https")) { +// QColor lightYellow(248, 248, 210); +// p.setBrush(QPalette::Base, generateGradient(lightYellow)); +// } else { +// p.setBrush(QPalette::Base, m_defaultBaseColor); +// } +// setPalette(p); +// +// QPainter painter(this); +// QStyleOptionFrameV2 panel; +// // initStyleOption(&panel); +// QRect backgroundRect = style()->subElementRect(QStyle::SE_LineEditContents, &panel, this); +// if (m_webView && !hasFocus()) +// { +// int progress = m_webView->progress(); +// QColor loadingColor = QColor(116, 192, 250); +// painter.setBrush(generateGradient(loadingColor)); +// painter.setPen(Qt::transparent); +// int mid = backgroundRect.width() / 100 * progress; +// QRect progressRect(backgroundRect.x(), backgroundRect.y(), mid, backgroundRect.height()); +// painter.drawRect(progressRect); +// } +// } + diff --git a/src/urlbar.h b/src/urlbar.h index db6304da..56ba7686 100644 --- a/src/urlbar.h +++ b/src/urlbar.h @@ -40,12 +40,11 @@ public: ~UrlBar(); KLineEdit *lineEdit(); - void setWebView(WebView *webView); -protected: - void paintEvent(QPaintEvent *event); - void focusOutEvent(QFocusEvent *event); +// FIXME needed to color urlbar while loading urls +// protected: +// void paintEvent(QPaintEvent *event); private slots: void webViewUrlChanged(const QUrl &url); |