Correctly style the first tab (contentManager)

It would be nice to be able to style it using css (QTabBar::tab:first)
but I can't figure how :/

We need to :
- hardcore the size of the tabs using `tabSizeHint`.
- "deactivate" the tab button with `setTabButton`
- set the size of the icons.

Fix #73
This commit is contained in:
Matthieu Gautier 2018-12-11 18:00:18 +01:00
parent 4b9cc80f66
commit 3f9072f978
3 changed files with 9 additions and 4 deletions

View File

@ -123,10 +123,6 @@ QTabWidget::pane {
} }
QTabBar::tab { QTabBar::tab {
min-width: 205px;
max-width: 205px;
min-height: 40px;
max-height: 40px;
border: none; border: none;
border-right: 2px solid #ccc; border-right: 2px solid #ccc;
border-bottom: 2px solid #ccc; border-bottom: 2px solid #ccc;

View File

@ -15,6 +15,7 @@ TabBar::TabBar(QWidget *parent) :
setElideMode(Qt::ElideNone); setElideMode(Qt::ElideNone);
setDocumentMode(true); setDocumentMode(true);
setFocusPolicy(Qt::NoFocus); setFocusPolicy(Qt::NoFocus);
setIconSize(QSize(30, 30));
connect(this, &QTabBar::tabCloseRequested, this, &TabBar::closeTab); connect(this, &QTabBar::tabCloseRequested, this, &TabBar::closeTab);
connect(this, &QTabBar::currentChanged, this, &TabBar::onCurrentChanged); connect(this, &QTabBar::currentChanged, this, &TabBar::onCurrentChanged);
auto app = KiwixApp::instance(); auto app = KiwixApp::instance();
@ -76,6 +77,7 @@ void TabBar::setContentManagerView(ContentManagerView* view)
mp_stackedWidget->addWidget(mp_contentManagerView); mp_stackedWidget->addWidget(mp_contentManagerView);
mp_stackedWidget->show(); mp_stackedWidget->show();
addTab(QIcon(":/icons/kiwix/app_icon.svg"), ""); addTab(QIcon(":/icons/kiwix/app_icon.svg"), "");
setTabButton(0, RightSide, nullptr);
} }
WebView* TabBar::createNewTab(bool setCurrent) WebView* TabBar::createNewTab(bool setCurrent)
@ -152,6 +154,12 @@ QString TabBar::currentArticleTitle()
return currentWidget()->title(); return currentWidget()->title();
} }
QSize TabBar::tabSizeHint(int index) const {
if (index)
return QSize(205, 40);
return QSize(40, 40);
}
void TabBar::triggerWebPageAction(QWebEnginePage::WebAction action, WebView *webView) void TabBar::triggerWebPageAction(QWebEnginePage::WebAction action, WebView *webView)
{ {
CURRENTIFNULL(webView); CURRENTIFNULL(webView);

View File

@ -33,6 +33,7 @@ public:
void triggerWebPageAction(QWebEnginePage::WebAction action, WebView* webView=nullptr); void triggerWebPageAction(QWebEnginePage::WebAction action, WebView* webView=nullptr);
QString currentArticleUrl(); QString currentArticleUrl();
QString currentArticleTitle(); QString currentArticleTitle();
virtual QSize tabSizeHint(int index) const;
signals: signals:
void webActionEnabledChanged(QWebEnginePage::WebAction action, bool enabled); void webActionEnabledChanged(QWebEnginePage::WebAction action, bool enabled);
void currentZimIdChanged(const QString& zimId); void currentZimIdChanged(const QString& zimId);