From e4d1a0c4d66df55c934a5fb669b10541f27c6159 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Thu, 27 Oct 2011 10:02:52 +0200 Subject: [PATCH] Fixed some style issues --- resources/style.qss | 21 +++++++++---- src/board/UBLibraryController.cpp | 2 +- src/gui/UBLibItemProperties.cpp | 9 ++++-- src/gui/UBLibNavigatorWidget.cpp | 5 +++ src/gui/UBLibWebView.cpp | 52 ++++++++++++++++++++++++++++++- src/gui/UBLibWebView.h | 2 ++ 6 files changed, 81 insertions(+), 10 deletions(-) diff --git a/resources/style.qss b/resources/style.qss index 1c0ab3a3..8288ce28 100644 --- a/resources/style.qss +++ b/resources/style.qss @@ -1,13 +1,25 @@ QWidget#DockPaletteWidgetBox, QWidget#documentNavigator, -QWidget#UBLibraryWidget, QWidget#UBLibPathViewer, -QWidget#UBTeacherStudentAction +QWidget#UBTeacherStudentAction, +QWidget#UBLibNavigatorWidget, +QWidget#UBLibItemProperties { background: #EEEEEE; border-radius: 10px; border: 2px solid #999999; -/* padding-bottom: -2px; */ +} + +QWidget#UBLibWebView +{ + background: #EEEEEE; + border-radius : 10px; + border: 2px solid #999999; +} + +QWebView#SearchEngineView +{ + background:#EEEEEE; } QColorDialog @@ -121,8 +133,6 @@ QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical background:transparent; } - - QScrollBar::horizontal { background:transparent; @@ -166,7 +176,6 @@ QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal background:transparent; } - QSlider::handle::horizontal { background-color:#EEEEEE; diff --git a/src/board/UBLibraryController.cpp b/src/board/UBLibraryController.cpp index 26cc9452..d2d66716 100644 --- a/src/board/UBLibraryController.cpp +++ b/src/board/UBLibraryController.cpp @@ -789,7 +789,7 @@ UBChainedLibElement* UBChainedLibElement::lastElement() QUrl UBChainedLibElement::lastItemPath() { - lastElement()->element()->path(); + return lastElement()->element()->path(); } UBLibElement* UBLibElement::trashElement() diff --git a/src/gui/UBLibItemProperties.cpp b/src/gui/UBLibItemProperties.cpp index 02f3e9c3..a8cb3cb0 100644 --- a/src/gui/UBLibItemProperties.cpp +++ b/src/gui/UBLibItemProperties.cpp @@ -41,6 +41,9 @@ UBLibItemProperties::UBLibItemProperties(QWidget *parent, const char *name):QWid { setObjectName(name); + setAttribute(Qt::WA_StyledBackground, true); + setStyleSheet(UBApplication::globalStyleSheet()); + // Create the GUI mpLayout = new QVBoxLayout(this); setLayout(mpLayout); @@ -52,7 +55,8 @@ UBLibItemProperties::UBLibItemProperties(QWidget *parent, const char *name):QWid icon.scaledToWidth(THUMBNAIL_WIDTH); mpThumbnail->setPixmap(icon); - mpThumbnail->setStyleSheet(QString("background-color : white; padding : 10 px; border-radius : 10px;")); + mpThumbnail->setObjectName("DockPaletteWidgetBox"); + mpThumbnail->setStyleSheet("background:white;"); mpThumbnail->setAlignment(Qt::AlignHCenter); mpLayout->addWidget(mpThumbnail, 0); @@ -79,7 +83,8 @@ UBLibItemProperties::UBLibItemProperties(QWidget *parent, const char *name):QWid mpObjInfos = new QTextEdit(this); mpObjInfos->setReadOnly(true); - mpObjInfos->setStyleSheet(QString("background-color: white; border-radius : 10px;")); + mpObjInfos->setObjectName("DockPaletteWidgetBox"); + mpObjInfos->setStyleSheet("background:white;"); mpLayout->addWidget(mpObjInfos, 1); connect(mpAddPageButton, SIGNAL(clicked()), this, SLOT(onAddToPage())); diff --git a/src/gui/UBLibNavigatorWidget.cpp b/src/gui/UBLibNavigatorWidget.cpp index 06792143..f65c97f8 100644 --- a/src/gui/UBLibNavigatorWidget.cpp +++ b/src/gui/UBLibNavigatorWidget.cpp @@ -15,6 +15,7 @@ #include "UBLibNavigatorWidget.h" #include "UBLibWidget.h" +#include "core/UBApplication.h" #include "core/memcheck.h" static int lowBoundForSlider = 40; @@ -33,6 +34,10 @@ UBLibNavigatorWidget::UBLibNavigatorWidget(QWidget *parent, const char *name):QW , mSliderWidthSetting(NULL) { setObjectName(name); + + setAttribute(Qt::WA_StyledBackground, true); + setStyleSheet(UBApplication::globalStyleSheet()); + setAcceptDrops(true); UBLibWidget* libWidget = dynamic_cast(parentWidget()); diff --git a/src/gui/UBLibWebView.cpp b/src/gui/UBLibWebView.cpp index 8c24fe7f..d939654d 100644 --- a/src/gui/UBLibWebView.cpp +++ b/src/gui/UBLibWebView.cpp @@ -1,15 +1,36 @@ +#include + +#include "core/UBApplication.h" + #include "UBLibWebView.h" UBLibWebView::UBLibWebView(QWidget* parent, const char* name):QWidget(parent) , mpView(NULL) + , mpWebSettings(NULL) , mpLayout(NULL) { setObjectName(name); + setAttribute(Qt::WA_StyledBackground, true); + setStyleSheet(UBApplication::globalStyleSheet()); + mpLayout = new QVBoxLayout(); setLayout(mpLayout); mpView = new QWebView(this); + mpView->setObjectName("SearchEngineView"); + //mpView->setStyleSheet(QString("background-color:white;")); + + mpWebSettings = QWebSettings::globalSettings(); + mpWebSettings->setAttribute(QWebSettings::JavaEnabled, true); + mpWebSettings->setAttribute(QWebSettings::PluginsEnabled, true); + mpWebSettings->setAttribute(QWebSettings::JavaEnabled, true); + mpWebSettings->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, true); + mpWebSettings->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, true); + mpWebSettings->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true); + mpWebSettings->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true); + mpWebSettings->setAttribute(QWebSettings::DnsPrefetchEnabled, true); + mpLayout->addWidget(mpView); } @@ -31,6 +52,35 @@ void UBLibWebView::setElement(UBLibElement *elem) { if(NULL != elem) { - mpView->load(elem->path()); + QString qsWidgetName; + QString path = elem->path().toLocalFile(); + + QString qsConfigPath = QString("%0/config.xml").arg(path); + + if(QFile::exists(qsConfigPath)) + { + QFile f(qsConfigPath); + if(f.open(QIODevice::ReadOnly)) + { + QDomDocument domDoc; + domDoc.setContent(QString(f.readAll())); + QDomElement root = domDoc.documentElement(); + + QDomNode node = root.firstChild(); + while(!node.isNull()) + { + if(node.toElement().tagName() == "content") + { + QDomAttr srcAttr = node.toElement().attributeNode("src"); + qsWidgetName = srcAttr.value(); + break; + } + node = node.nextSibling(); + } + f.close(); + } + } + + mpView->load(QUrl::fromLocalFile(QString("%0/%1").arg(path).arg(qsWidgetName))); } } diff --git a/src/gui/UBLibWebView.h b/src/gui/UBLibWebView.h index e45127c3..b661125f 100644 --- a/src/gui/UBLibWebView.h +++ b/src/gui/UBLibWebView.h @@ -3,6 +3,7 @@ #include #include +#include #include #include "board/UBLibraryController.h" @@ -19,6 +20,7 @@ public: private: QWebView* mpView; + QWebSettings* mpWebSettings; QVBoxLayout* mpLayout; };