From a9ba75acbb6337f29964ca11803e5afd49d7b57b Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Wed, 11 Apr 2012 09:48:39 +0200 Subject: [PATCH] removed globalStyleSheet() --- src/core/UBApplication.cpp | 26 ++++--------------- src/core/UBApplication.h | 1 - src/customWidgets/UBMediaWidget.cpp | 3 +-- src/globals/UBGlobals.h | 35 +++++++++++++++++++++++--- src/gui/UBCachePropertiesWidget.cpp | 9 ++++--- src/gui/UBDockDownloadWidget.cpp | 5 ++-- src/gui/UBDockTeacherGuideWidget.cpp | 3 +-- src/gui/UBDownloadWidget.cpp | 7 +++--- src/gui/UBLibItemProperties.cpp | 7 +++--- src/gui/UBLibNavigatorWidget.cpp | 7 +++--- src/gui/UBLibWebView.cpp | 9 ++++--- src/gui/UBLibWidget.cpp | 7 +++--- src/gui/UBPageNavigationWidget.cpp | 9 ++++--- src/gui/UBTeacherGuideWidget.cpp | 7 ++++-- src/gui/UBTeacherGuideWidgetsTools.cpp | 2 ++ 15 files changed, 81 insertions(+), 56 deletions(-) diff --git a/src/core/UBApplication.cpp b/src/core/UBApplication.cpp index b8a3e257..05e5f8fb 100644 --- a/src/core/UBApplication.cpp +++ b/src/core/UBApplication.cpp @@ -257,10 +257,10 @@ int UBApplication::exec(const QString& pFileToImport) applicationController = new UBApplicationController(boardController->controlView(), boardController->displayView(), mainWindow, staticMemoryCleaner); - connect(applicationController, SIGNAL(mainModeChanged(UBApplicationController::MainMode)), + connect(applicationController, SIGNAL(mainModeChanged(UBApplicationController::MainMode)), boardController->paletteManager(), SLOT(slot_changeMainMode(UBApplicationController::MainMode))); - connect(applicationController, SIGNAL(desktopMode(bool)), + connect(applicationController, SIGNAL(desktopMode(bool)), boardController->paletteManager(), SLOT(slot_changeDesktopMode(bool))); @@ -283,8 +283,8 @@ int UBApplication::exec(const QString& pFileToImport) connect(mainWindow->actionSankoreEditor, SIGNAL(triggered()), applicationController, SLOT(showSankoreEditor())); connect(mainWindow->actionCheckUpdate, SIGNAL(triggered()), applicationController, SLOT(checkUpdateRequest())); - - + + toolBarPositionChanged(UBSettings::settings()->appToolBarPositionedAtTop->get()); bool bUseMultiScreen = UBSettings::settings()->appUseMultiscreen->get().toBool(); @@ -645,29 +645,13 @@ void UBStyle::drawItemText(QPainter *painter, const QRect &rect, int alignment, painter->setPen(savedPen); } -QString UBApplication::globalStyleSheet() -{ - QString style; - - QFile f(":style.qss"); - if(f.exists()) - { - if(f.open(QIODevice::ReadOnly)) - { - style = QString(f.readAll()); - } - } - - return style; -} - QString UBApplication::urlFromHtml(QString html) { QString _html; QRegExp comments("\\"); QString url; QDomDocument domDoc; - + // We remove all the comments & CRLF of this html _html = html.remove(comments); domDoc.setContent(_html.remove(QRegExp("[\\0]"))); diff --git a/src/core/UBApplication.h b/src/core/UBApplication.h index 0ca7ac37..ee4dba22 100644 --- a/src/core/UBApplication.h +++ b/src/core/UBApplication.h @@ -78,7 +78,6 @@ class UBApplication : public QtSingleApplication static void setDisabled(bool disable); static QObject* staticMemoryCleaner; - static QString globalStyleSheet(); void decorateActionMenu(QAction* action); void insertSpaceToToolbarBeforeAction(QToolBar* toolbar, QAction* action, int width = -1); diff --git a/src/customWidgets/UBMediaWidget.cpp b/src/customWidgets/UBMediaWidget.cpp index 4bef693b..fe96d6e9 100644 --- a/src/customWidgets/UBMediaWidget.cpp +++ b/src/customWidgets/UBMediaWidget.cpp @@ -35,8 +35,7 @@ UBMediaWidget::UBMediaWidget(eMediaType type, QWidget *parent, const char *name) , mpMediaContainer(NULL) , mpCover(NULL) { - setAttribute(Qt::WA_StyledBackground, true); - setStyleSheet(UBApplication::globalStyleSheet()); + SET_STYLE_SHEET(); addAction(eAction_Close); mType = type; diff --git a/src/globals/UBGlobals.h b/src/globals/UBGlobals.h index 5a98fd10..93ebcb84 100644 --- a/src/globals/UBGlobals.h +++ b/src/globals/UBGlobals.h @@ -1,11 +1,38 @@ +/* + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #ifndef UBGLOBALS_H #define UBGLOBALS_H +#include +#include + #define DELETEPTR(ptr) if(NULL != ptr){ \ delete ptr; \ ptr = NULL; \ } +#define SET_STYLE_SHEET() {\ + setAttribute(Qt::WA_StyledBackground, true);\ + QString style;\ + QFile f(":style.qss");\ + if(f.exists() && f.open(QIODevice::ReadOnly))\ + style = QString(f.readAll());\ + setStyleSheet(style);\ +} + #ifdef Q_WS_WIN #define WARNINGS_DISABLE __pragma(warning(push, 0)); @@ -14,7 +41,7 @@ #ifdef NO_THIRD_PARTY_WARNINGS // disabling warning level to 0 and save old state #define THIRD_PARTY_WARNINGS_DISABLE WARNINGS_DISABLE -#else +#else // just save old state (needs for not empty define) #define THIRD_PARTY_WARNINGS_DISABLE __pragma(warning(push)); #endif //#ifdef NO_THIRD_PARTY_WARNINGS @@ -24,9 +51,9 @@ #define WARNINGS_DISABLE _Pragma("GCC diagnostic push"); \ _Pragma("GCC diagnostic ignored \"-Wunused-parameter\""); \ _Pragma("GCC diagnostic ignored \"-Wunused-variable\""); \ -_Pragma("GCC diagnostic ignored \"-Wsign-compare\""); +_Pragma("GCC diagnostic ignored \"-Wsign-compare\""); -#define WARNINGS_ENABLE _Pragma("GCC diagnostic pop"); +#define WARNINGS_ENABLE _Pragma("GCC diagnostic pop"); #ifdef NO_THIRD_PARTY_WARNINGS //disabling some warnings @@ -43,4 +70,4 @@ _Pragma("GCC diagnostic ignored \"-Wsign-compare\""); #define THIRD_PARTY_WARNINGS_ENABLE WARNINGS_ENABLE #endif // UBGLOBALS_H - + diff --git a/src/gui/UBCachePropertiesWidget.cpp b/src/gui/UBCachePropertiesWidget.cpp index e0c74986..ada7f785 100644 --- a/src/gui/UBCachePropertiesWidget.cpp +++ b/src/gui/UBCachePropertiesWidget.cpp @@ -7,6 +7,7 @@ #include "core/UBApplication.h" #include "core/UBApplicationController.h" +#include "globals/UBGlobals.h" #include "board/UBBoardController.h" #include "domain/UBGraphicsScene.h" @@ -34,8 +35,8 @@ UBCachePropertiesWidget::UBCachePropertiesWidget(QWidget *parent, const char *na , mpCurrentCache(NULL) { setObjectName(name); - setAttribute(Qt::WA_StyledBackground, true); - setStyleSheet(UBApplication::globalStyleSheet()); + + SET_STYLE_SHEET(); mName = "CachePropWidget"; mVisibleState = false; @@ -283,7 +284,7 @@ void UBCachePropertiesWidget::updateCurrentCache() if( UBApplication::applicationController != NULL ) { // if app controller is available, and current mode is Board, and no show desktop, than all ok, just process - if( UBApplication::applicationController->displayMode() == UBApplicationController::Board && + if( UBApplication::applicationController->displayMode() == UBApplicationController::Board && !UBApplication::applicationController->isShowingDesktop()) isBoardMode = true; } @@ -348,4 +349,4 @@ void UBCachePropertiesWidget::onCacheEnabled() { emit showTab(this); } - + diff --git a/src/gui/UBDockDownloadWidget.cpp b/src/gui/UBDockDownloadWidget.cpp index 01b5d0ac..4ce9d07e 100644 --- a/src/gui/UBDockDownloadWidget.cpp +++ b/src/gui/UBDockDownloadWidget.cpp @@ -15,6 +15,8 @@ #include "UBDockDownloadWidget.h" #include "core/UBApplication.h" +#include "globals/UBGlobals.h" + UBDockDownloadWidget::UBDockDownloadWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent, name) , mpLayout(NULL) , mpDLWidget(NULL) @@ -22,8 +24,7 @@ UBDockDownloadWidget::UBDockDownloadWidget(QWidget *parent, const char *name):UB mName = "DownloadWidget"; mVisibleState = false; - setAttribute(Qt::WA_StyledBackground, true); - setStyleSheet(UBApplication::globalStyleSheet()); + SET_STYLE_SHEET(); mIconToLeft = QPixmap(":images/download_open.png"); mIconToRight = QPixmap(":images/download_close.png"); diff --git a/src/gui/UBDockTeacherGuideWidget.cpp b/src/gui/UBDockTeacherGuideWidget.cpp index 27842025..f8ad4f43 100644 --- a/src/gui/UBDockTeacherGuideWidget.cpp +++ b/src/gui/UBDockTeacherGuideWidget.cpp @@ -26,8 +26,7 @@ UBDockTeacherGuideWidget::UBDockTeacherGuideWidget(QWidget* parent, const char* { mName = "TeacherGuide"; - setAttribute(Qt::WA_StyledBackground, true); - setStyleSheet(UBApplication::globalStyleSheet()); + SET_STYLE_SHEET(); mIconToLeft = QPixmap(":images/teacher_open.png"); mIconToRight = QPixmap(":images/teacher_close.png"); diff --git a/src/gui/UBDownloadWidget.cpp b/src/gui/UBDownloadWidget.cpp index 286b9f20..00da5b01 100644 --- a/src/gui/UBDownloadWidget.cpp +++ b/src/gui/UBDownloadWidget.cpp @@ -18,8 +18,10 @@ #include #include "UBDownloadWidget.h" -#include "core/UBApplication.h" +#include "globals/UBGlobals.h" + +#include "core/UBApplication.h" #include "core/memcheck.h" /** @@ -36,8 +38,7 @@ UBDownloadWidget::UBDownloadWidget(QWidget *parent, const char *name):QWidget(pa { setObjectName(name); setWindowTitle(tr("Downloading files")); - setAttribute(Qt::WA_StyledBackground, true); - setStyleSheet(UBApplication::globalStyleSheet()); + SET_STYLE_SHEET(); resize(400, 300); mpLayout = new QVBoxLayout(this); diff --git a/src/gui/UBLibItemProperties.cpp b/src/gui/UBLibItemProperties.cpp index b37747ff..4d2eada3 100644 --- a/src/gui/UBLibItemProperties.cpp +++ b/src/gui/UBLibItemProperties.cpp @@ -18,10 +18,12 @@ #include "core/UBApplication.h" #include "core/UBDownloadManager.h" +#include "core/memcheck.h" #include "frameworks/UBFileSystemUtils.h" -#include "core/memcheck.h" +#include "globals/UBGlobals.h" + /** * \brief Constructor @@ -43,8 +45,7 @@ UBLibItemProperties::UBLibItemProperties(QWidget *parent, const char *name):QWid { setObjectName(name); - setAttribute(Qt::WA_StyledBackground, true); - setStyleSheet(UBApplication::globalStyleSheet()); + SET_STYLE_SHEET(); // Create the GUI mpLayout = new QVBoxLayout(this); diff --git a/src/gui/UBLibNavigatorWidget.cpp b/src/gui/UBLibNavigatorWidget.cpp index 8b36dd07..5974c4ea 100644 --- a/src/gui/UBLibNavigatorWidget.cpp +++ b/src/gui/UBLibNavigatorWidget.cpp @@ -18,6 +18,8 @@ #include "core/UBApplication.h" #include "core/memcheck.h" +#include "globals/UBGlobals.h" + static int lowBoundForSlider = 40; static int topBoundForSlider = 120; static int tickIntervalForSlider = 10; @@ -35,8 +37,7 @@ UBLibNavigatorWidget::UBLibNavigatorWidget(QWidget *parent, const char *name):QW { setObjectName(name); - setAttribute(Qt::WA_StyledBackground, true); - setStyleSheet(UBApplication::globalStyleSheet()); + SET_STYLE_SHEET(); setAcceptDrops(true); @@ -62,7 +63,7 @@ UBLibNavigatorWidget::UBLibNavigatorWidget(QWidget *parent, const char *name):QW connect(mLibWidget, SIGNAL(propertiesRequested(UBLibElement*)), this, SLOT(onPropertiesRequested(UBLibElement*))); - connect(mLibWidget, SIGNAL(displaySearchEngine(UBLibElement*)), this, SLOT(onDisplaySearchEngine(UBLibElement*))); + connect(mLibWidget, SIGNAL(displaySearchEngine(UBLibElement*)), this, SLOT(onDisplaySearchEngine(UBLibElement*))); connect(mSlider,SIGNAL(valueChanged(int)),this,SLOT(updateThumbnailsSize(int))); connect(libWidget->pathViewer(), SIGNAL(mouseClick(UBChainedLibElement*)), this, SLOT(onPathItemClicked(UBChainedLibElement*))); connect(libWidget->pathViewer(), SIGNAL(elementsDropped(QList,UBLibElement*)), mLibWidget, SLOT(onElementsDropped(QList,UBLibElement*))); diff --git a/src/gui/UBLibWebView.cpp b/src/gui/UBLibWebView.cpp index b02af11d..ac6e11a5 100644 --- a/src/gui/UBLibWebView.cpp +++ b/src/gui/UBLibWebView.cpp @@ -1,11 +1,15 @@ #include #include "core/UBApplication.h" +#include "core/memcheck.h" + #include "board/UBBoardController.h" +#include "globals/UBGlobals.h" + #include "UBLibWebView.h" -#include "core/memcheck.h" + UBLibWebView::UBLibWebView(QWidget* parent, const char* name):QWidget(parent) , mpView(NULL) @@ -15,8 +19,7 @@ UBLibWebView::UBLibWebView(QWidget* parent, const char* name):QWidget(parent) { setObjectName(name); - setAttribute(Qt::WA_StyledBackground, true); - setStyleSheet(UBApplication::globalStyleSheet()); + SET_STYLE_SHEET(); mpLayout = new QVBoxLayout(); setLayout(mpLayout); diff --git a/src/gui/UBLibWidget.cpp b/src/gui/UBLibWidget.cpp index 4e8ffc08..9765bae4 100644 --- a/src/gui/UBLibWidget.cpp +++ b/src/gui/UBLibWidget.cpp @@ -15,10 +15,12 @@ #include #include "UBLibWidget.h" -#include "core/UBApplication.h" +#include "core/UBApplication.h" #include "core/memcheck.h" +#include "globals/UBGlobals.h" + /** * \brief Constructor * @param parent as the parent widget @@ -37,8 +39,7 @@ UBLibWidget::UBLibWidget(QWidget *parent, const char *name):UBDockPaletteWidget( mName = "LibWidget"; mVisibleState = true; - setAttribute(Qt::WA_StyledBackground, true); - setStyleSheet(UBApplication::globalStyleSheet()); + SET_STYLE_SHEET(); mIconToLeft = QPixmap(":images/library_open.png"); mIconToRight = QPixmap(":images/library_close.png"); diff --git a/src/gui/UBPageNavigationWidget.cpp b/src/gui/UBPageNavigationWidget.cpp index 77c378c2..6ff72dd8 100644 --- a/src/gui/UBPageNavigationWidget.cpp +++ b/src/gui/UBPageNavigationWidget.cpp @@ -14,9 +14,12 @@ */ #include "UBPageNavigationWidget.h" #include "core/UBApplication.h" -#include "board/UBBoardController.h" #include "core/memcheck.h" +#include "board/UBBoardController.h" + +#include "globals/UBGlobals.h" + /** * \brief Constructor * @param parent as the parent widget @@ -32,8 +35,8 @@ UBPageNavigationWidget::UBPageNavigationWidget(QWidget *parent, const char *name setObjectName(name); mName = "PageNavigator"; mVisibleState = true; - setAttribute(Qt::WA_StyledBackground, true); - setStyleSheet(UBApplication::globalStyleSheet()); + + SET_STYLE_SHEET(); mIconToRight = QPixmap(":images/pages_open.png"); mIconToLeft = QPixmap(":images/pages_close.png"); diff --git a/src/gui/UBTeacherGuideWidget.cpp b/src/gui/UBTeacherGuideWidget.cpp index 940297fe..f67c8d54 100644 --- a/src/gui/UBTeacherGuideWidget.cpp +++ b/src/gui/UBTeacherGuideWidget.cpp @@ -87,7 +87,8 @@ UBTeacherGuideEditionWidget::UBTeacherGuideEditionWidget(QWidget *parent, const mpTreeWidget->setColumnCount(2); mpTreeWidget->header()->setStretchLastSection(false); mpTreeWidget->header()->setResizeMode(0, QHeaderView::Stretch); - mpTreeWidget->header()->setResizeMode(1, QHeaderView::Custom); + mpTreeWidget->header()->setResizeMode(1, QHeaderView::Fixed); + mpTreeWidget->header()->setDefaultSectionSize(32); connect(mpTreeWidget,SIGNAL(itemClicked(QTreeWidgetItem*,int)),this,SLOT(onAddItemClicked(QTreeWidgetItem*,int))); @@ -158,7 +159,9 @@ QVector UBTeacherGuideEditionWidget::getData() children << getChildrenList(mpAddALinkItem); result << getPageAndCommentData(); foreach(QTreeWidgetItem* widgetItem, children){ - result << dynamic_cast(mpTreeWidget->itemWidget(widgetItem,0))->saveData(); + tUBGEElementNode* node = dynamic_cast(mpTreeWidget->itemWidget(widgetItem,0))->saveData(); + if(node) + result << node; } return result; } diff --git a/src/gui/UBTeacherGuideWidgetsTools.cpp b/src/gui/UBTeacherGuideWidgetsTools.cpp index 2134f8f6..60c9f89b 100644 --- a/src/gui/UBTeacherGuideWidgetsTools.cpp +++ b/src/gui/UBTeacherGuideWidgetsTools.cpp @@ -198,6 +198,8 @@ UBTGMediaWidget::~UBTGMediaWidget() tUBGEElementNode* UBTGMediaWidget::saveData() { + if(!mpTitle) + return 0; tUBGEElementNode* result = new tUBGEElementNode(); result->type = "media"; result->attributes.insert("title",mpTitle->toPlainText());