예제 #1
0
TestInstallIndicator::TestInstallIndicator(int& argc, char* argv[]) : HbApplication(argc, argv),
    mMainWindow(0), mMainView(0), mIndicator(0), mSubscriber(0)
{
    mMainWindow = new HbMainWindow();
    mMainView = new HbView();
    mMainView->setTitle(tr("TestInstIndi"));

    mIndicator = new HbIndicator;

    mSubscriber = new QTM_PREPEND_NAMESPACE(QValueSpaceSubscriber(KSifUiInstallIndicatorStatusPath));
    connect(mSubscriber, SIGNAL(contentsChanged()), this, SLOT(handleIndicatorActivity()));

    QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);

    HbTextItem *infoText = new HbTextItem;
    infoText->setText("Activate/deactivate SW install indicator in universal indicator popup.");
    infoText->setTextWrapping(Hb::TextWordWrap);
    layout->addItem(infoText);

    HbPushButton *activateButton = new HbPushButton("Activate install indicator");
    connect(activateButton, SIGNAL(clicked()), this, SLOT(activatePressed()));
    layout->addItem(activateButton);

    HbPushButton *deactivateButton = new HbPushButton("Deactivate install indicator");
    connect(deactivateButton, SIGNAL(clicked()), this, SLOT(deactivatePressed()));
    layout->addItem(deactivateButton);

    HbPushButton *closeButton = new HbPushButton("Close");
    connect(closeButton, SIGNAL(clicked()), qApp, SLOT(quit()));
    layout->addItem(closeButton);

    mMainView->setLayout(layout);
    mMainWindow->addView(mMainView);
    mMainWindow->show();
}
예제 #2
0
/*!
 Initializes UI. Everything that is not done in docml files should be here.
 return true if ok, in error false.
 */
void NmHsWidget::setupUi()
{
    NM_FUNCTION;

    //main level layout needed to control docml objects
    QGraphicsLinearLayout *widgetLayout = new QGraphicsLinearLayout(Qt::Vertical);
    widgetLayout->setContentsMargins(KNmHsWidgetContentsMargin, KNmHsWidgetContentsMargin,
            KNmHsWidgetContentsMargin, KNmHsWidgetContentsMargin);
    widgetLayout->setSpacing(KNmHsWidgetContentsMargin);
    widgetLayout->addItem(mMainContainer);
    this->setLayout(widgetLayout);

    //fetch pointer to content container layout
    //to be able to add/remove email rows and no mails label
    mContentLayout = (QGraphicsLinearLayout*) mContentContainer->layout();
    
    //set noMailsLabel properties not supported by doc loader 
    QColor newFontColor;
    newFontColor = HbColorScheme::color("qtc_hs_list_item_content_normal");
    mNoMailsLabel->setTextColor(newFontColor);
    mNoMailsLabel->setVisible(true);   
    
    mContentLayout->removeItem(mNoMailsLabel);
    
    //widget background
    mBackgroundFrameDrawer = new HbFrameDrawer(KNmHsWidgetBackgroundImage,
        HbFrameDrawer::NinePieces);
    HbFrameItem* backgroundLayoutItem = new HbFrameItem(mBackgroundFrameDrawer);
    //set to NULL to indicate that ownership transferred
    mBackgroundFrameDrawer = NULL;
    mWidgetContainer->setBackgroundItem(backgroundLayoutItem);
}
void Ut_MSettingsLanguageTextFactory::testCreateWidget()
{
    // Create a settings text
    MSettingsLanguageText settingsText("TestKey", "Title");
    MSettingsLanguageWidget dds;
    MockDataStore dataStore;
    MWidget *widget = MSettingsLanguageTextFactory::createWidget(settingsText, dds, &dataStore);
    QVERIFY(widget != NULL);

    // Expecting the widget to have a layout and linear policy
    QGraphicsLinearLayout *layout = dynamic_cast<QGraphicsLinearLayout *>(widget->layout());
    QVERIFY(layout != NULL);

    // Expecting the layout to contain a MLabel and a MTextEdit
    QCOMPARE(layout->count(), 2);

    // The label's title should be the SettingsText's title
    MLabel *label = dynamic_cast<MLabel *>(layout->itemAt(0));
    QVERIFY(label != NULL);
    QCOMPARE(label->text(), settingsText.title());

    // The label's title should be the specified key's value
    MTextEdit *textEdit = dynamic_cast<MTextEdit *>(layout->itemAt(1));
    QVERIFY(textEdit != NULL);
    QCOMPARE(textEdit->text(), dataStore.value("TestKey").toString());

    delete widget;
}
예제 #4
0
void IconApplet::init()
{
    QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(this);
    layout->setContentsMargins(0, 0, 0, 0);
    layout->setSpacing(0);

    layout->addItem(m_icon);

    KConfigGroup cg = config();

    if (m_url.isValid()) {
        // we got this in via the ctor, e.g. as a result of a drop
        cg.writeEntry("Url", m_url);
        emit configNeedsSaving();
    } else {
        configChanged();
    }

    setDisplayLines(2);
    registerAsDragHandle(m_icon);
    setAspectRatioMode(Plasma::ConstrainedSquare);

    connect(KGlobalSettings::self(), SIGNAL(iconChanged(int)),
        this, SLOT(iconSizeChanged(int)));
}
MPannableViewport* StatusIndicatorMenuDropDownView::createPannableArea()
{
    // Create pannable area contents
    statusIndicatorExtensionArea = createVerticalExtensionArea();

    QGraphicsLinearLayout *contentLayout = new QGraphicsLinearLayout(Qt::Vertical);
    contentLayout->setContentsMargins(0, 0, 0, 0);
    contentLayout->setSpacing(0);
    contentLayout->addItem(statusIndicatorExtensionArea);

    MWidgetController *contentWidget = new MStylableWidget;
    contentWidget->setStyleName("StatusIndicatorMenuContentWidget");
    contentWidget->setLayout(contentLayout);

    QGraphicsLinearLayout *pannableLayout = new QGraphicsLinearLayout(Qt::Vertical);
    pannableLayout->setContentsMargins(0, 0, 0, 0);
    pannableLayout->setSpacing(0);
    pannableLayout->addItem(contentWidget);
    QGraphicsWidget *closeButtonRow = createCloseButtonRow();
    pannableLayout->addItem(closeButtonRow);
    pannableLayout->addStretch();

    // Create a container widget for the pannable area
    PannedWidgetController *pannedWidget = new PannedWidgetController;
    pannedWidget->setLayout(pannableLayout);
    pannedWidget->setBottommostWidget(closeButtonRow);
    connect(pannedWidget, SIGNAL(positionOrSizeChanged()), this, SLOT(setPannabilityAndLayout()));
    connect(pannedWidget, SIGNAL(pressedOutSideContents()), controller, SIGNAL(hideRequested()));

    // Setup the pannable viewport
    MPannableViewport *pannableViewport = new MPannableViewport;
    pannableViewport->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    pannableViewport->setWidget(pannedWidget);
    return pannableViewport;
}
예제 #6
0
void HGLayout::setSpacing(int s)
{
    HLayout::setSpacing(s);

    QGraphicsLayout* ll = layout();
    if (!ll) return ;

    switch (layoutType()) {
    case HEnums::kVBox:
    case HEnums::kHBox: {
        QGraphicsLinearLayout* l = static_cast<QGraphicsLinearLayout*>(ll);
        l->setSpacing(s);
        break;
    }
    case HEnums::kGrid: {
        QGraphicsGridLayout* l = static_cast<QGraphicsGridLayout*>(ll);
        l->setSpacing(s);
        break;
    }
    case HEnums::kAnchor: {
        QGraphicsAnchorLayout* l = static_cast<QGraphicsAnchorLayout*>(ll);
        l->setSpacing(s);
        break;
    }
    default:
        break;
    }
}
예제 #7
0
UnlockArea::UnlockArea(QGraphicsItem *parent) :
    MStylableWidget(parent),
    m_enabled(false),
    m_active(false)
{
    QGraphicsLinearLayout   *layout =
        new QGraphicsLinearLayout (Qt::Vertical);

    setObjectName ("LockLandArea");

    // Create the unlock icon
    MImageWidget    *unlock_icon;

    unlock_icon = new MImageWidget;
    unlock_icon->setImage ("icon-m-common-unlocked", QSize (32, 32));
    unlock_icon->setZoomFactor (1.0);
    unlock_icon->setObjectName ("LockScreenUnlockIcon");

    m_unlock_icon = new MWidget;
    QGraphicsLinearLayout   *icon_layout =
        new QGraphicsLinearLayout (Qt::Horizontal);
    icon_layout->addStretch ();
    icon_layout->addItem (unlock_icon);
    icon_layout->addStretch ();
    m_unlock_icon->setLayout (icon_layout);

    // Add the unlock icon centered
    layout->addStretch ();
    layout->addItem (m_unlock_icon);
    layout->addStretch ();

    setLayout (layout);

    updateState ();
}
UIGInformationElementPreview::UIGInformationElementPreview(UIGInformationSet *pParent, bool fOpened)
    : UIGInformationElement(pParent, DetailsElementType_Preview, fOpened)
{
    /* Assign corresponding icon: */
    setIcon(gpConverter->toIcon(elementType()));

    /* Create layout: */
    QGraphicsLinearLayout *pLayout = new QGraphicsLinearLayout;
    AssertPtr(pLayout);
    {
        /* Prepare layout: */
        const int iMargin = data(ElementData_Margin).toInt();
        pLayout->setContentsMargins(iMargin, 2 * iMargin + minimumHeaderHeight(), iMargin, iMargin);
        /* Assign layout to widget: */
        setLayout(pLayout);
        /* Create preview: */
        m_pPreview = new UIGInformationPreview(this);
        AssertPtr(m_pPreview);
        {
            /* Prepare preview: */
            connect(m_pPreview, SIGNAL(sigSizeHintChanged()),
                    this, SLOT(sltPreviewSizeHintChanged()));
            /* Add preview into layout: */
            pLayout->addItem(m_pPreview);
        }
    }

    /* Set fixed size policy finally (after all content constructed): */
    setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

    /* Translate finally: */
    retranslateUi();
}
예제 #9
0
파일: sxeditor.cpp 프로젝트: kxtry/sxnote
SxEditor::SxEditor( const QString& file, const QString& name, QObject *parent /*= NULL*/ )
: QObject(parent)
, m_szFile(file)
, m_pTextEdit(NULL)
{
	m_pWindow = KXmlUI::windowFromFile("res:/Resources/layout/sxeditor.xml");
	KXmlUI::setPropertyEx(m_pWindow, "titlebar.title", name);

	KWidget *rootWidget = m_pWindow->rootWidget();
	KToolBar *toolbar = rootWidget->findChild<KToolBar*>("edittoolbar");
	QGraphicsLinearLayout *linear = dynamic_cast<QGraphicsLinearLayout*>(toolbar->layout());
	for(int i = 0; i < linear->count(); i++)
	{
		QGraphicsLayoutItem * item = linear->itemAt(i);
		KPushButton *button = dynamic_cast<KPushButton*>(item);
		if(button)
		{
			bool bok = QObject::connect(button, SIGNAL(clicked()), this, SLOT(on_common_command_clicked()));
		}
	}

	m_pTextEdit = rootWidget->findChild<SxRichEdit*>("richtexteditor");
	QObject::connect(m_pTextEdit, SIGNAL(contextMenu(QMenu*,bool*)), this, SLOT(on_editor_contextMenu(QMenu*,bool*)));

	QFont font("SimSun", 9);
	m_pTextEdit->setFont(font);

	QPoint pt = KUtility::nextCascadesWindowPosition();
	m_pWindow->move(pt);
	m_pWindow->show();

	QObject::connect(m_pWindow, SIGNAL(aboutToClose()), this, SLOT(on_aboutToClose_triggered()));
	
	QMetaObject::invokeMethod(this, "asynOpen", Qt::QueuedConnection);
}
예제 #10
0
KBItemWidget::KBItemWidget(QGraphicsWidget *parent)
    : Frame(parent),
      m_isHovered(false),
      m_detailsWidget(0)
{
    setAcceptHoverEvents(true);
    setMinimumHeight(40);
    setMinimumWidth(120);
    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);

    m_layout = new QGraphicsLinearLayout(Qt::Vertical, this);
    QGraphicsLinearLayout *titleLayout = new QGraphicsLinearLayout;


    m_title = new KBItemTitle(this);
    connect(m_title, SIGNAL(clicked()), this, SLOT(toggleDetails()));
    m_openBrowser = new Plasma::IconWidget(this);
    m_openBrowser->setIcon("applications-internet");
    m_openBrowser->setVisible(false);
    m_openBrowser->setMaximumSize(KIconLoader::SizeSmall, KIconLoader::SizeSmall);
    connect(m_openBrowser, SIGNAL(clicked()), this, SLOT(openBrowser()));

    m_category = new Label;

    titleLayout->addItem(m_title);
    titleLayout->addItem(m_openBrowser);

    m_layout->addItem(titleLayout);
    m_layout->addItem(m_category);

}
예제 #11
0
void WaitWidget::setupScene()
{
	// Creamos el objeto efecto
	d->m_effect = new QGraphicsOpacityEffect;
	d->m_effect->setOpacity(0);
	d->m_effect->setEnabled(true);

	// Ahora creamos los proxys para gráficos que nos permita incluirlos en la escena
	QGraphicsProxyWidget *pFrame = d->m_scene.addWidget(d->m_widget);
	pFrame->resize(d->m_widget->width(), d->m_widget->height());

	// Y lo agregamos a un layout gráfico
	QGraphicsLinearLayout *gLayout = new QGraphicsLinearLayout;
	gLayout->setOrientation(Qt::Vertical);
	gLayout->addItem(pFrame);

	// Creamos finalmente un objeto gráfico que lo contiene todo, y lo agregamos a la escena
	QGraphicsWidget *form = new QGraphicsWidget;
	form->setLayout(gLayout);
	form->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
	d->m_scene.addItem(form);

	// Agregamos el efecto de opacidad al aparecer
	form->setGraphicsEffect(d->m_effect);
	form->resize(d->m_widget->width(), d->m_widget->height());
}
예제 #12
0
SN_DrawingTool::SN_DrawingTool(quint64 gaid, const QSettings *s, QGraphicsItem *parent, Qt::WindowFlags wf)
    : SN_BaseWidget(gaid, s, parent, wf)
    , _brushIcon(0)
    , _eraserIcon(0)
    , _pointerIcon(0)
{
//	setWindowFrameMargins(0,0,0,0);
	setContentsMargins(1, 64, 1, 1); // 64 pixel at the top


	_pointerIcon = new SN_PixmapButton(":/resources/cursor_arrow_48x48.png", 0, "", this);
	_brushIcon = new SN_PixmapButton(":/resources/brush_48x48.png", 0, "", this);
	_eraserIcon = new SN_PixmapButton(":/resources/eraser_48x48.png", 0, "", this);

	//
	// these buttons don't need to receive mouse events.
	// Instead this widget must be visible when SN_PolygonArrowPointer::setAppUnderPointer() is called.
	//
	//
	_pointerIcon->setFlag(QGraphicsItem::ItemStacksBehindParent);
	_brushIcon->setFlag(QGraphicsItem::ItemStacksBehindParent);
	_eraserIcon->setFlag(QGraphicsItem::ItemStacksBehindParent);

	QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Horizontal, this);
	layout->setContentsMargins(10,10,10,10);

	layout->addItem(_pointerIcon);
	layout->addItem(_brushIcon);
	layout->addItem(_eraserIcon);

	setLayout(layout);
}
GalleryEnlargeShrinkAboutWidget::GalleryEnlargeShrinkAboutWidget() :
    MWidgetController(),
    m_aboutLabel(new MLabel),
    m_disclaimerLabel(new MLabel)
{
    m_disclaimerLabel->setStyleName("EnlargeShrinkAboutDisclaimer");
    m_disclaimerLabel->setText("Enlarge Shrink plugin has been proudly brought to you "
                               "by <a href=\"http://www.igalia.com\">Igalia</a>");

    m_aboutLabel->setStyleName("EnlargeShrinkAboutLink");
    m_aboutLabel->setText("<a href=\"about\">About</a>");


    connect(m_disclaimerLabel, SIGNAL(linkActivated(QString)),
            this, SIGNAL(linkActivated(QString)));
    connect(m_aboutLabel, SIGNAL(linkActivated(QString)),
            this, SIGNAL(linkActivated(QString)));

    QGraphicsLinearLayout* mainLayout = new QGraphicsLinearLayout(Qt::Horizontal);
    mainLayout->setContentsMargins(0, 0, 0, 0);
    mainLayout->addItem(m_disclaimerLabel);
    mainLayout->addStretch();
    mainLayout->addItem(m_aboutLabel);

    setLayout(mainLayout);
}
예제 #14
0
FmDriveQuery::FmDriveQuery( QGraphicsItem *parent ) : FmDialog( parent )
{
    setObjectName( "driveQueryDialog" );
	mContentWidget = new QGraphicsWidget();
	mContentWidget->setObjectName( "driveQueryContentWidget" );
	setContentWidget(mContentWidget);

	QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout();
    vLayout->setOrientation( Qt::Vertical );

    mListView = new HbListView();
    mListView->setObjectName( "driveQueryListView" );
	vLayout->addItem( mListView );

	mListView->setFontSpec( HbFontSpec( HbFontSpec::Primary ) );

	this->setTimeout( NoTimeout );
	mContentWidget->setLayout( vLayout );

	connect( mListView, SIGNAL( activated  ( const QModelIndex& ) ), this, SLOT( activated( const QModelIndex& ) ) );
    this->setDismissPolicy( NoDismiss );

    
    mDriveModel = new FmDriveModel( this, 
            FmDriveModel::FillWithVolume | FmDriveModel::FillWithDefaultVolume, this );
    mListView->setModel( mDriveModel );
    
    // connect refreshModel signal of viewmanager  for drive insert/remove event.
    connect( FmViewManager::viewManager(), SIGNAL( refreshModel( QString ) ), 
            this, SLOT( refreshModel( QString ) ) );
}
예제 #15
0
bool HGLayout::removeItem(QGraphicsLayoutItem *item)
{
    if (!layout()) return false;

    switch (layoutType()) {
    case HEnums::kVBox:
    case HEnums::kHBox: {
        QGraphicsLinearLayout* l = static_cast<QGraphicsLinearLayout*>(layout());
        l->removeItem(item);
        break;
    }
    case HEnums::kGrid: {
        QGraphicsGridLayout* l = static_cast<QGraphicsGridLayout*>(layout());
        l->removeItem(item);
        break;
    }
    case HEnums::kAnchor: {//"anchor layout can't remove item now!"
        QGraphicsAnchorLayout* l = static_cast<QGraphicsAnchorLayout*>(layout());
        Q_UNUSED(l);

        return false;
    }
    default:
        return false;
    }
    return true;
}
예제 #16
0
int HGLayout::insertItem(QGraphicsLayoutItem* item, const HLayoutConfig& conf)
{
    if (!layout()) return -1;

    switch (layoutType()) {
    case HEnums::kVBox:
    case HEnums::kHBox: {
        QGraphicsLinearLayout* l = static_cast<QGraphicsLinearLayout*>(layout());
        l->insertItem(conf.index(),item);
        l->setAlignment(item,alignment());
        break;
    }
    case HEnums::kGrid: {
        QGraphicsGridLayout* l = static_cast<QGraphicsGridLayout*>(layout());
        l->addItem(item,conf.row(),conf.column(),alignment());
        break;
    }
    case HEnums::kAnchor: {
        //anchor layout can't add item here, add item in setAnchor
        QGraphicsAnchorLayout* l = static_cast<QGraphicsAnchorLayout*>(layout());
        Q_UNUSED(l);

        return -1;
    }
    default:
        return -1;
    }
    return 0;
}
void ponycountdownplasma::show_thirdrow()
{
    QGraphicsLinearLayout *thirdrow = new QGraphicsLinearLayout();
    
    m_label_ep = new Plasma::Label;
    m_label_name = new Plasma::Label;
    m_label_season = new Plasma::Label;
  
    //Setting text for label of third row. 
    m_label_season->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
    m_label_season->setText(i18n("Season №%1", info("season")));
    
    m_label_name->setAlignment(Qt::AlignCenter);
    m_label_name->setText(i18n("Episode Name: %1", info("name")));
    
    m_label_ep->setAlignment(Qt::AlignVCenter | Qt::AlignRight);
    m_label_ep->setText(i18n("Episode №%1", info("episode")));
    
    
    layout->addItem(thirdrow, 3, 1, 1, 4);
    layout->setAlignment(thirdrow, Qt::AlignTop);
    //layout->setRowMaximumHeight(3, 12);
    
    thirdrow->setOrientation(Qt::Horizontal);
    thirdrow->addItem(m_label_season);
    thirdrow->addItem(m_label_name);
    thirdrow->addItem(m_label_ep);
}
예제 #18
0
파일: Albums.cpp 프로젝트: cancamilo/amarok
void Albums::closeFilterBar()
{
    filterTextChanged( QString() );
    AlbumsFilterBar *bar = static_cast<AlbumsFilterBar*>( sender() );
    QGraphicsLinearLayout *l = static_cast<QGraphicsLinearLayout*>( layout() );
    l->removeItem( bar );
    bar->deleteLater();
    m_filterIcon->setEnabled( true );
}
예제 #19
0
QGraphicsWidget *StackFolder::graphicsWidget()
{
    if (m_graphicsWidget) {
        return m_graphicsWidget;
    }

    setAcceptDrops(true);

    PreviewGenerator *previewGenerator = PreviewGenerator::createInstance();
    previewGenerator->setPlugins(m_previewPlugins);

    TypeImageProvider *typeImageProvider = new TypeImageProvider();
    ModeImageProvider *modeImageProvider = new ModeImageProvider();
    PreviewImageProvider *previewImageProvider = new PreviewImageProvider();

    m_viewer = new Viewer;

    m_directory = new Directory(this);
    m_directory->setModel(m_model);
    m_directory->setTopUrl(m_url);
    m_directory->setUrl(m_url);
    connect(m_directory, SIGNAL(fileActivated()), this, SLOT(fileActivated()));
    connect(m_directory, SIGNAL(dataAdded(const QModelIndex&, int, int)), this, SLOT(dataAdded(const QModelIndex&, int, int)));
    connect(m_directory, SIGNAL(viewerRequested(const QString&, int, int, int, int)), this, SLOT(runViewer(const QString&, int, int, int, int)));
    connect(m_directory, SIGNAL(viewerCanceled()), this, SLOT(stopViewer()));
    connect(m_directory, SIGNAL(activatedDragAndDrop(const KFileItem&)), this, SLOT(activatedDragAndDrop(const KFileItem&)));

    qmlRegisterType<File>("File", 1, 0, "File");
    qmlRegisterType<QGraphicsDropShadowEffect>("Effects", 1, 0, "DropShadow");

    QDeclarativeEngine *m_engine = new QDeclarativeEngine;
    m_engine->addImageProvider("type", typeImageProvider);
    m_engine->addImageProvider("mode", modeImageProvider);
    m_engine->addImageProvider("preview", previewImageProvider);
    m_engine->rootContext()->setContextProperty("directory", m_directory);
    QString qmlMainFilePath = KStandardDirs::locate("data", "plasma/packages/org.kde.stackfolder/contents/ui/main.qml");
    QDeclarativeComponent component(m_engine, QUrl::fromLocalFile(qmlMainFilePath));
    QObject *object = component.create();
    QGraphicsLayoutItem *graphicsObject = qobject_cast<QGraphicsLayoutItem*>(object);

    QObject::connect(object, SIGNAL(currentChanged()), m_viewer, SLOT(stop()));

    m_layout = new QGraphicsLinearLayout(Qt::Vertical);
    m_layout->setContentsMargins(10, 0, 10, 0);
    m_layout->addItem(graphicsObject);


    m_graphicsWidget = new QGraphicsWidget(this);
    m_graphicsWidget->setLayout(m_layout);

    QGraphicsLinearLayout *lay = dynamic_cast<QGraphicsLinearLayout *>(layout());
    //lay->setContentsMargins(3, 0, 3, 6);
    lay->setContentsMargins(0, 0, 0, 0);
    lay->setSpacing(0);

    return m_graphicsWidget;
}
예제 #20
0
QGraphicsWidget *KdeObservatory::graphicsWidget()
{
    if (!m_mainContainer)
    {
        m_mainContainer = new QGraphicsWidget(this);
        m_mainContainer->installEventFilter(this);

        m_viewContainer = new QGraphicsWidget(m_mainContainer);
        m_viewContainer->setAcceptHoverEvents(true);
        m_viewContainer->setHandlesChildEvents(true);
        m_viewContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
        m_viewContainer->setFlag(QGraphicsItem::ItemClipsChildrenToShape, true);

        m_right = new Plasma::PushButton(m_mainContainer);
        m_right->setIcon(KIcon("go-next-view"));
        m_right->setToolTip(i18n("Go to previous view"));
        m_right->setMaximumSize(22, 22);
        m_right->hide();
        connect(m_right, SIGNAL(clicked()), this, SLOT(moveViewRightClicked()));

        m_left = new Plasma::PushButton(m_mainContainer);
        m_left->setIcon(KIcon("go-previous-view"));
        m_left->setToolTip(i18n("Go to next view"));
        m_left->setMaximumSize(22, 22);
        m_left->hide();
        connect(m_left, SIGNAL(clicked()), this, SLOT(moveViewLeftClicked()));

        m_collectorProgress = new Plasma::Meter(m_mainContainer);
        m_collectorProgress->hide();
        m_collectorProgress->setMeterType(Plasma::Meter::BarMeterHorizontal);
        m_collectorProgress->setMaximumHeight(22);
        m_collectorProgress->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
        m_collectorProgress->setValue(0);

        m_updateLabel = new Plasma::Label(m_mainContainer);
        m_updateLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
        m_updateLabel->setFont(KGlobalSettings::smallestReadableFont());
        m_updateLabel->setAlignment(Qt::AlignCenter);

        m_horizontalLayout = new QGraphicsLinearLayout(Qt::Horizontal);
        m_horizontalLayout->addItem(m_left);
        m_horizontalLayout->addItem(m_updateLabel);
        m_horizontalLayout->addItem(m_right);
        m_horizontalLayout->setMaximumHeight(22);

        QGraphicsLinearLayout *verticalLayout = new QGraphicsLinearLayout(Qt::Vertical);
        verticalLayout->addItem(m_viewContainer);
        verticalLayout->addItem(m_horizontalLayout);

        m_mainContainer->setLayout(verticalLayout);
        m_mainContainer->setPreferredSize(300, 200);
        m_mainContainer->setMinimumSize(300, 200);
    }

    return m_mainContainer;
}
예제 #21
0
/**
 * Constructor
 */
ResourceView::ResourceView(HbMainWindow *mainWindow, HbView* parent): HbView(parent)
{
    mMainWindow = mainWindow;
    mParentView = parent;
    QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);

    this->setTitle(tr("Resource lookup"));

    HbAction *act = new HbAction(Hb::BackNaviAction);
    connect(act, SIGNAL(triggered()), this, SLOT(close()));

    this->setNavigationAction(act);

    act = new HbAction(tr("Icons"));
        connect(act, SIGNAL(triggered()), this, SLOT(iconModeSelected()));
        this->toolBar()->addAction(act);

    act = new HbAction(tr("Colors"));
        connect(act, SIGNAL(triggered()), this, SLOT(colorModeSelected()));
        this->toolBar()->addAction(act);

    act = new HbAction(tr("Effects"));
        connect(act, SIGNAL(triggered()), this, SLOT(effectModeSelected()));
        this->toolBar()->addAction(act);

    act = new HbAction(tr("Animations"));
        connect(act, SIGNAL(triggered()), this, SLOT(animationModeSelected()));
        this->toolBar()->addAction(act);


    loadThemedIcons();
    loadThemedColors();
    loadThemedEffects();
    loadThemedAnimations();
    mAnimator = new HbIconAnimator();
    mResourceItem = new HbLabel(this);
    mResourceItem->setIcon(HbIcon(mThemedIcons.size()?mThemedIcons[0]:""));
    mResourceItem->setAlignment(Qt::AlignCenter);
    mResourceItem->setFontSpec(HbFontSpec(HbFontSpec::Secondary));
    mResourcesList = new HbTumbleView(mThemedIcons, this);

    layout->addItem(mResourceItem);
    layout->addItem(mResourcesList);

    mSearchPanel = new HbSearchPanel(this);
    mSearchPanel->setCancelEnabled(false);
    mSearchPanel->setPlaceholderText(tr("Search"));
    layout->addItem(mSearchPanel);
    this->setLayout(layout);

    connect(mSearchPanel, SIGNAL(criteriaChanged(const QString &)), this, SLOT(criteriaChanged(const QString &)));
    connect(mResourcesList, SIGNAL(itemSelected(int)), this, SLOT(iconItemSelected(int)));
    mMode = iconMode;

    mMainWindow->addView(this);
}
// Start of snippet 1
HelloWorldWidget::HelloWorldWidget(QGraphicsItem* parent, Qt::WindowFlags flags)
    : HbWidget(parent, flags)
{
    QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
    setLayout(layout);
    HbLabel *helloWorld = new HbLabel("Hello World!");
    helloWorld->setPreferredSize(QSizeF(130.0,20.0));
    layout->setContentsMargins(0.0, 0.0, 0.0, 0.0);
    layout->addItem(helloWorld);
}
예제 #23
0
void
PhotosApplet::init()
{
    DEBUG_BLOCK

    // Call the base implementation.
    Context::Applet::init();

    // Create label
    enableHeader( true );
    setHeaderText( i18n( "Photos" ) );

    // Set the collapse size
    setCollapseHeight( m_header->height() );
    setCollapseOffHeight( 220 );
    setMaximumHeight( 220 );
    setMinimumHeight( collapseHeight() );
    setPreferredHeight( collapseHeight() );

    // Icon
    QAction* settingsAction = new QAction( this );
    settingsAction->setIcon( KIcon( "preferences-system" ) );
    settingsAction->setVisible( true );
    settingsAction->setEnabled( true );
    settingsAction->setText( i18n( "Settings" ) );
    m_settingsIcon = addRightHeaderAction( settingsAction );
    connect( m_settingsIcon, SIGNAL( clicked() ), this, SLOT( showConfigurationInterface() ) );

    m_widget = new PhotosScrollWidget( this );
    m_widget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
    m_widget->setContentsMargins( 0, 0, 0, 0 );
    connect( m_widget, SIGNAL(photoAdded()), SLOT(photoAdded()) );

    QGraphicsLinearLayout *layout = new QGraphicsLinearLayout( Qt::Vertical, this );
    layout->addItem( m_header );
    layout->addItem( m_widget );

    // Read config and inform the engine.
    KConfigGroup config = Amarok::config("Photos Applet");
    m_nbPhotos = config.readEntry( "NbPhotos", "10" ).toInt();
    m_Animation = config.readEntry( "Animation", "Fading" );
    m_KeyWords = config.readEntry( "KeyWords", QStringList() );

    if( m_Animation == i18nc( "animation type", "Automatic" ) )
        m_widget->setMode( 0 );
    else if( m_Animation == i18n( "Interactive" ) )
        m_widget->setMode( 1 );
    else // fading
        m_widget->setMode( 2 );

    Plasma::DataEngine *engine = dataEngine( "amarok-photos" );
    engine->setProperty( "fetchSize", m_nbPhotos );
    engine->setProperty( "keywords", m_KeyWords );
    engine->connectSource( "photos", this );
}
예제 #24
0
파일: simplelist.cpp 프로젝트: fluxer/katie
SimpleList::SimpleList(QGraphicsWidget *parent)
  : GvbWidget(parent),
    m_list(new ListWidget(this))
{
    QGraphicsLinearLayout *layout = new QGraphicsLinearLayout();
    layout->setContentsMargins(0,0,0,0);
    setContentsMargins(0,0,0,0);
    setLayout(layout);
    layout->addItem(m_list);
    setObjectName("SimpleList");
}
예제 #25
0
MenuWidget::MenuWidget(QGraphicsWidget *parent)
        : QGraphicsWidget(parent),
          menuBar(new Plasma::TabBar)
{
    // Only show categories if more than one is available
    this->menuBar->setTabBarShown(false);

    // Add the widget
    QGraphicsLinearLayout *l = new QGraphicsLinearLayout(this);
    l->addItem(this->menuBar);
    this->setLayout(l);
}
예제 #26
0
파일: kwidget.cpp 프로젝트: kxtry/kxmob
void KWidget::setSpacing( int space )
{
    QGraphicsLayout *tmpLayout = layout();
    if(d_func()->layoutType == VBox || d_func()->layoutType == HBox)
    {
        QGraphicsLinearLayout *boxLayout = dynamic_cast<QGraphicsLinearLayout*>(tmpLayout);
        if(boxLayout)
        {
            return boxLayout->setSpacing(space);
        }
    }
}
예제 #27
0
bool ImageStripScene::setCurrentDirectory(const QString& path)
{
    QMutexLocker locker(&m_mutex);
    QDir         directory(path);
    QImageReader reader;
    
    if(directory.exists()) {
        clear();
        
        if(m_loader) {
            m_loader->disconnect(this);
            m_loader->stopExecution();
            
            if(!m_loader->wait(500)) {
                m_loader->terminate();
                m_loader->wait();
            }
        }
        
        delete m_loader;
        
        m_numItems = 0;
        m_loader   = new ImageLoader(m_imgSize);
        connect(m_loader, SIGNAL(sigItemContentChanged(ImageItem*)), SLOT(slotItemContentChanged(ImageItem*)));
        
        QStringList            files  = directory.entryList(QDir::Files);
        QGraphicsLinearLayout* layout = new QGraphicsLinearLayout();
        
        for(QStringList::iterator name=files.begin(); name!=files.end(); ++name) {
            QString path = directory.absoluteFilePath(*name);
            reader.setFileName(path);
            
            if(reader.canRead()) {
                ImageItem* item = new ImageItem(m_imgSize, path, m_loader);
                m_loader->addPath(item, path);
                layout->addItem(item);
                ++m_numItems;
            }
        }
        
        QGraphicsWidget* widget = new QGraphicsWidget();
        widget->setLayout(layout);
        widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
        
        addItem(widget);
        setSceneRect(widget->boundingRect());
        
        m_loader->start(QThread::LowPriority);
        return true;
    }
    
    return false;
}
예제 #28
0
/**
 * Test to see how much time is needed to resize all widgets in a
 * layout-widget-layout-widget-.... hierarchy from the point where a
 * leaf widget changes its size hint. (updateGeometry() is called).
 *
 * If you run the test for 4.7 you'll get some really high numbers, but
 * that's because they also include painting (and possible processing of
 * some other events).
 */
void tst_QGraphicsLayout::invalidate()
{
    QGraphicsLayout::setInstantInvalidatePropagation(true);
    QGraphicsScene scene;
    QGraphicsView *view = new QGraphicsView(&scene);
    QMap<RectWidget*, QRectF> setGeometryCalls;

    RectWidget *window = new RectWidget(0, Qt::Window);
    window->setGeometryCalls = &setGeometryCalls;
    window->setData(0, QString(QChar('a')));

    scene.addItem(window);
    RectWidget *leaf = 0;
    const int depth = 100;
    RectWidget *parent = window;
    for (int i = 1; i < depth; ++i) {
        QGraphicsLinearLayout *l = new QGraphicsLinearLayout(parent);
        l->setContentsMargins(0,0,0,0);
        RectWidget *child = new RectWidget;
        child->setData(0, QString(QChar('a' + i)));
        child->setGeometryCalls = &setGeometryCalls;
        l->addItem(child);
        parent = child;
    }
    leaf = parent;
    leaf->setMinimumSize(QSizeF(1,1));

    view->show();

    QTest::qWaitForWindowShown(view);

    // ...then measure...

    int pass = 1;

    // should be as small as possible, to reduce overhead of painting
    QSizeF size(1, 1);
    setGeometryCalls.clear();
    QBENCHMARK {
        leaf->setMinimumSize(size);
        leaf->setMaximumSize(size);
        while (setGeometryCalls.count() < depth) {
            QApplication::sendPostedEvents();
        }
        // force a resize on each widget, this will ensure
        // that each iteration will resize all 50 widgets
        int w = int(size.width());
        w^=2;
        size.setWidth(w);
    }
    delete view;
    QGraphicsLayout::setInstantInvalidatePropagation(false);
}
예제 #29
0
파일: Albums.cpp 프로젝트: cancamilo/amarok
void Albums::showFilterBar()
{
    m_filterIcon->setEnabled( false );
    AlbumsFilterBar *bar = new AlbumsFilterBar( this );
    bar->setContentsMargins( 0, 0, 0, 0 );
    QGraphicsLinearLayout *l = static_cast<QGraphicsLinearLayout*>( layout() );
    l->setItemSpacing( 1, 0 );
    l->addItem( bar );
    connect( bar, SIGNAL(filterTextChanged(QString)), this, SLOT(filterTextChanged(QString)) );
    connect( bar, SIGNAL(closeRequested()), this, SLOT(closeFilterBar()) );
    bar->focusEditor();
}
예제 #30
0
void ActivityManager::sortActivities() {
  QGraphicsLinearLayout *layout = static_cast<QGraphicsLinearLayout *>(static_cast<QGraphicsWidget *>(extender()->item("Activities")->widget())->layout());
  // remove all activities from the layout
  while (layout->count())
    layout->removeAt(0);
  // insert all activities to a map
  QMap<QString, ActivityWidget *> activities;
  foreach (ActivityWidget *activity, m_activities.values())
    activities.insertMulti(activity->name(), activity);
  // add activities into the layout at ascending order of their names
  foreach (ActivityWidget *activity, activities.values())
    layout->addItem(activity);
}