Skip to content

Commit

Permalink
Single Theme class with specific private impl
Browse files Browse the repository at this point in the history
  • Loading branch information
Ri0n committed May 17, 2017
1 parent 2543b84 commit 0c58a58
Show file tree
Hide file tree
Showing 17 changed files with 870 additions and 773 deletions.
26 changes: 15 additions & 11 deletions src/chatview_webkit.cpp
Expand Up @@ -73,7 +73,7 @@ class ChatViewPrivate
public:
ChatViewPrivate() {}

ChatViewTheme theme;
Theme theme;
QSharedPointer<ChatViewThemeSessionBridge> themeBridge;

WebView *webView;
Expand Down Expand Up @@ -301,6 +301,11 @@ class ChatViewThemeSessionBridge : public ChatViewThemeSession
return cv->jsBridge();
}

Theme theme() const
{
return cv->d->theme;
}

QString propsAsJsonString() const
{
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
Expand Down Expand Up @@ -430,12 +435,12 @@ ChatView::~ChatView()
// something after we know isMuc and dialog is set. kind of final step
void ChatView::init()
{
auto curTheme = d->themeProvider()->current();
if (!curTheme) {
Theme curTheme = d->themeProvider()->current();
if (curTheme.state() != Theme::Loaded) {
qDebug("ChatView theme is not loaded. this is fatal");
return;
}
d->theme = *(dynamic_cast<ChatViewTheme*>(curTheme));// TODO rewrite this pointer magic
d->theme = curTheme;// TODO rewrite this pointer magic

#ifdef HAVE_QT5
d->themeBridge.reset(new ChatViewThemeSessionBridge(this));
Expand All @@ -446,14 +451,13 @@ void ChatView::init()
#ifndef WEBENGINE
((ChatViewPage*)d->webView->page())->setCVPrivate(d.data());
#endif
d->theme.applyToWebView(d->themeBridge.dynamicCast<ChatViewThemeSession>());
ChatViewThemeSession::init(d->themeBridge);

if (d->theme.isTransparentBackground()) {
QWidget *w = this;
while (w) {
w->setAttribute(Qt::WA_TranslucentBackground, true);
w = w->parentWidget();
}
bool tbg = d->themeBridge->isTransparentBackground();
QWidget *w = this;
while (w) {
w->setAttribute(Qt::WA_TranslucentBackground, tbg);
w = w->parentWidget();
}
}

Expand Down

0 comments on commit 0c58a58

Please sign in to comment.