From af742011a52f23feb7230a8073ca93df6c3857c9 Mon Sep 17 00:00:00 2001 From: Dave Page Date: Fri, 22 Jan 2016 14:21:34 +0000 Subject: [PATCH] Further UI improvements for the runtime. --- runtime/BrowserWindow.cpp | 17 +++++++---------- runtime/TabWindow.cpp | 40 +++++++++++++++++++++++++++++++++++++++ runtime/TabWindow.h | 13 +++++++++++++ 3 files changed, 60 insertions(+), 10 deletions(-) diff --git a/runtime/BrowserWindow.cpp b/runtime/BrowserWindow.cpp index 4143b0262..4d0aea38b 100644 --- a/runtime/BrowserWindow.cpp +++ b/runtime/BrowserWindow.cpp @@ -63,10 +63,6 @@ BrowserWindow::BrowserWindow(QString url) m_tabWidget->setTabText(0, PGA_APP_NAME); m_tabWidget->setTabToolTipText(0, PGA_APP_NAME) ; -#ifndef __APPLE__ - m_tabWidget->setStyleSheet("QTabBar::tab{max-height:24px;max-width:250px;}"); -#endif - setCentralWidget(m_tabWidget); connect(m_mainWebView, SIGNAL(loadFinished(bool)), SLOT(finishLoading(bool))); @@ -364,24 +360,25 @@ void BrowserWindow::urlLinkClicked(const QUrl &name) m_widget = new QWidget(m_addNewTab); m_toolBtnBack = new QToolButton(m_widget); - m_toolBtnBack->setFixedHeight(16); - m_toolBtnBack->setFixedWidth(16); + m_toolBtnBack->setFixedHeight(PGA_BTN_SIZE); + m_toolBtnBack->setFixedWidth(PGA_BTN_SIZE); m_toolBtnBack->setText(PGA_BTN_BACK); m_toolBtnBack->setDisabled(true); m_toolBtnForward = new QToolButton(m_widget); - m_toolBtnForward->setFixedHeight(16); - m_toolBtnForward->setFixedWidth(16); + m_toolBtnForward->setFixedHeight(PGA_BTN_SIZE); + m_toolBtnForward->setFixedWidth(PGA_BTN_SIZE); m_toolBtnForward->setText(PGA_BTN_FORWARD); m_toolBtnForward->setDisabled(true); QPushButton *m_btnClose = new QPushButton(m_widget); m_btnClose->setText(PGA_BTN_CLOSE); - m_btnClose->setFixedHeight(16); - m_btnClose->setFixedWidth(16); + m_btnClose->setFixedHeight(PGA_BTN_SIZE); + m_btnClose->setFixedWidth(PGA_BTN_SIZE); m_horizontalLayout = new QHBoxLayout(m_widget); m_horizontalLayout->setSizeConstraint(QLayout::SetMinAndMaxSize); + m_horizontalLayout->setSpacing(1); m_horizontalLayout->addWidget(m_toolBtnBack); m_horizontalLayout->addWidget(m_toolBtnForward); diff --git a/runtime/TabWindow.cpp b/runtime/TabWindow.cpp index 7252689a2..85c21356d 100644 --- a/runtime/TabWindow.cpp +++ b/runtime/TabWindow.cpp @@ -21,11 +21,51 @@ TabWindow::TabWindow(QWidget *parent) : setParent(parent); setTabsClosable(false); setElideMode(Qt::ElideRight); + + // Get the system colours we need + QPalette palette = QApplication::palette("QPushButton"); + QColor activebg = palette.color(QPalette::Button); + QColor activefg = palette.color(QPalette::ButtonText); + QColor inactivebg = palette.color(QPalette::Dark); + QColor inactivefg = palette.color(QPalette::ButtonText); + QColor border = palette.color(QPalette::Mid); + + setStyleSheet( + "QTabBar::tab { " + "background-color: " + inactivebg.name() + "; " + "color: " + inactivefg.name() + "; " + "border: 1px solid " + border.name() + "; " + "padding: 1px 0px; " + "margin-left: 0px; " + "margin-top: 1px; " +#ifndef __APPLE__ + "width: 15em; " +#ifdef _WIN32 + "height: 1.5em; " +#else + "height: 1em; " +#endif +#endif + "} " + "QTabBar::tab:selected { " + "background-color: " + activebg.name() + "; " + "color: " + activefg.name() + "; " + "border-bottom-style: none; " + "} " + "QTabWidget::pane { " + "border: 0; " + "} " + "QTabWidget::tab-bar {" + "alignment: left; " + "}" + ); #ifdef __APPLE__ m_testTabBar = new TabBar(); setTabBar(m_testTabBar); #endif + // Hide the default tab + tabBar()->setAutoHide(true); } // Hide the close button of given index displayed on right side of tab diff --git a/runtime/TabWindow.h b/runtime/TabWindow.h index 9fd10e33d..3af6eb420 100644 --- a/runtime/TabWindow.h +++ b/runtime/TabWindow.h @@ -16,9 +16,22 @@ #include "WebViewWindow.h" // Define button characters +#ifdef _WIN32 +const QString PGA_BTN_FORWARD = QString(">"); +const QString PGA_BTN_BACK = QString("<"); +const QString PGA_BTN_CLOSE = QString("x"); +#else const QString PGA_BTN_FORWARD = QString("\u2192"); const QString PGA_BTN_BACK = QString("\u2190"); const QString PGA_BTN_CLOSE = QString("\u2715"); +#endif + +// Define button sizes +#ifdef _WIN32 +const int PGA_BTN_SIZE = 18; +#else +const int PGA_BTN_SIZE = 16; +#endif class TabBar : public QTabBar {