Field::Field(QColor color, int row, int column) : QLabel() { this->setFixedSize(Data::WIDTH_FIELD, Data::HEIGTH_FIELD); internColor = color; this->row = row; this->column = column; isFree = true; isClicked = false; tile = 0; if (internColor == Qt::black){ QPixmap blackPixmap(":/images/black.bmp"); this->setPixmap(blackPixmap); } else if (internColor == Qt::white){ QPixmap whitePixmap(":/images/white.bmp"); this->setPixmap(whitePixmap); } //connect(this, SIGNAL(clicked()), this , SLOT(changePixmap())); }
/*! Constructor */ NmEditorTextEdit::NmEditorTextEdit(QGraphicsItem *parent) : HbTextEdit(parent) { NM_FUNCTION; HbStyleLoader::registerFilePath(FILE_PATH_WIDGETML); HbStyleLoader::registerFilePath(FILE_PATH_CSS_DEFAULT); mCustomTextColor = QPair<bool, QColor>(false, Qt::black); // Disable HbTextEdit scrolling. Background scroll area will handle scrolling. setScrollable(false); scrollArea()->setScrollDirections(0); // set background colour to plain white QPixmap whitePixmap(10,10); whitePixmap.fill(Qt::white); QGraphicsPixmapItem *pixmapItem = new QGraphicsPixmapItem (whitePixmap); setBackgroundItem(pixmapItem); // Create custom palette based on the current one QPalette testPalette = QApplication::palette(); // Sets the selection background colour testPalette.setColor(QPalette::Active, QPalette::Highlight, Qt::cyan); testPalette.setColor(QPalette::Inactive, QPalette::Highlight, Qt::cyan); // Sets the link and visited link colours testPalette.setColor(QPalette::Active, QPalette::Link, Qt::darkBlue); testPalette.setColor(QPalette::Inactive, QPalette::Link, Qt::darkBlue); testPalette.setColor(QPalette::Active, QPalette::LinkVisited, Qt::darkMagenta); testPalette.setColor(QPalette::Inactive, QPalette::LinkVisited, Qt::darkMagenta); // Update custom palette for this widget setPalette(testPalette); }
/*! View layout loading from XML */ void NmViewerView::loadViewLayout() { NM_FUNCTION; // Use document loader to load the view bool ok(false); setObjectName(QString(NMUI_MESSAGE_VIEWER_VIEW)); QObjectList objectList; objectList.append(this); // Pass the view to documentloader. Document loader uses this view // when docml is parsed, instead of creating new view. // documentloader is created in constructor mDocumentLoader->setObjectTree(objectList); mWidgetList = mDocumentLoader->load(NMUI_MESSAGE_VIEWER_XML, &ok); if (ok) { // Create content and content layout // qobject_cast not work in this case, using reinterpret_cast mViewerContent = reinterpret_cast<HbWidget *>( mDocumentLoader->findObject(NMUI_MESSAGE_VIEWER_CONTENT)); // Find scroll area mScrollArea = reinterpret_cast<HbScrollArea *>( mDocumentLoader->findObject(NMUI_MESSAGE_VIEWER_SCROLL_AREA)); if (mScrollArea) { mScrollArea->setParentItem(this); mScrollArea->setScrollDirections(Qt::Vertical | Qt::Horizontal); connect(mScrollArea, SIGNAL(scrollPositionChanged(QPointF)), this, SLOT(contentScrollPositionChanged(QPointF))); // Get scroll area contents and set layout margins mScrollAreaContents = qobject_cast<HbWidget *>( mDocumentLoader->findObject(NMUI_MESSAGE_VIEWER_SCROLL_AREA_CONTENTS)); if (mScrollAreaContents) { QGraphicsLayout *layout = mScrollAreaContents->layout(); if (layout){ layout->setContentsMargins(0,0,0,0); } // Set white pixmap to backgrounditem QPixmap whitePixmap(NmWhitePixmapSize,NmWhitePixmapSize); whitePixmap.fill(Qt::white); QGraphicsPixmapItem *pixmapItem = new QGraphicsPixmapItem(whitePixmap); mScrollAreaContents->setBackgroundItem(pixmapItem); } // Load headerwidget mHeaderWidget = qobject_cast<NmViewerHeader *>( mDocumentLoader->findObject(NMUI_MESSAGE_VIEWER_HEADER)); if (mHeaderWidget) { mHeaderWidget->setView(this); mHeaderWidget->rescaleHeader(mScreenSize); mHeaderWidget->setMessage(mMessage); QPointF headerStartPos = mHeaderWidget->scenePos(); mHeaderStartScenePos = QPointF(0,headerStartPos.y()); } // Load webview mWebView = reinterpret_cast<NmMailViewerWK *>( mDocumentLoader->findObject(QString(NMUI_MESSAGE_VIEWER_SCROLL_WEB_VIEW))); if (mWebView) { // Set auto load images and private browsing(no history) attributes QWebSettings *settings = mWebView->settings(); if (settings) { settings->setAttribute(QWebSettings::AutoLoadImages, true); settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true); } QWebPage *page = mWebView->page(); if (page) { QWebFrame *frame = page->mainFrame(); if (frame) { frame->setScrollBarPolicy(Qt::Vertical,Qt::ScrollBarAlwaysOff); frame->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); frame->setTextSizeMultiplier(NmZoomFactor); connect(mWebView->page()->mainFrame(), SIGNAL(contentsSizeChanged(const QSize&)), this, SLOT(scaleWebViewWhenLoading(const QSize&))); } } } } } }