Exemplo n.º 1
0
void JobViewServer::setupUi() {

  // Paar allgemeine Parameter
  setBackgroundHints(DefaultBackground);
  setHasConfigurationInterface(true);
  setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
  resize(400, 80);

  // Rahmen, der das Hauptlayout enthält
  Plasma::Frame* frame = new Plasma::Frame();
  frame->setFrameShadow(Plasma::Frame::Sunken);
  QGraphicsLinearLayout* fullSpaceLayout = new QGraphicsLinearLayout();
  fullSpaceLayout->setContentsMargins(0,0,0,0);
  setLayout(fullSpaceLayout);
  fullSpaceLayout->addItem(frame);
  QGraphicsLinearLayout* layout = new QGraphicsLinearLayout();
  layout->setContentsMargins(0,0,0,0);
  frame->setLayout(layout);

  // Icon mit History und Queue Indicator
  iconWidget = new Plasma::IconWidget();
  iconWidget->setPreferredWidth(25);
  iconWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
  iconWidget->setIcon(KIcon("arrow-down"));
  layout->addItem(iconWidget);

  // Layout mit Progressbars
  meterContainer = new Plasma::Label();
  meterContainer->nativeWidget()->setWordWrap(true);
  meterLayout = new QGraphicsLinearLayout();
  meterContainer->setLayout(meterLayout);
  layout->addItem(meterContainer);

  // Popup erzeugen
  popup = new Plasma::Dialog();
  QVBoxLayout* popupLayout = new QVBoxLayout();
  popupLayout->setContentsMargins(0,0,0,0);
  popup->setLayout(popupLayout);
  popup->setWindowFlags(Qt::Popup);
  popup->resize(400, 300);

  // GraphicsView und GraphicsScene erzeugen
  QGraphicsScene* popupScene = new QGraphicsScene();
  QGraphicsView* popupView = new QGraphicsView();
  popupView->setScene(popupScene);
  popupView->setFrameStyle(QFrame::NoFrame);
  popupView->setStyleSheet("background-color: transparent;");
  popupView->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
  popupView->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
  popupView->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
  popupLayout->addWidget(popupView);

  // Container mit dem GridLayout zur Scene hinzufügen
  jobViewContainer = new QGraphicsWidget();
  jobViewLayout = new QGraphicsLinearLayout(Qt::Vertical);
  jobViewLayout->setContentsMargins(5,5,5,5);
  jobViewContainer->setLayout(jobViewLayout);
  popupScene->addItem(jobViewContainer);

  // Überschrift-/Nachrichtenbereich
  popupHeadline = new Plasma::Label();
  popupHeadline->nativeWidget()->setAlignment(Qt::AlignCenter);
  jobViewLayout->addItem(popupHeadline);

  QObject::connect(iconWidget, SIGNAL(clicked()), this, SLOT(showPopup()));
}
void PeopleGroupedView::insertCard(const QModelIndex& index) {
    // requires: model is sorted in alphabetical order
    QGraphicsLinearLayout *linear;

    SEASIDE_SHORTCUTS
    SEASIDE_SET_MODEL_AND_ROW(m_itemModel, index.row());
    QString name = SEASIDE_FIELD(FirstName, String);
    bool isSelf = SEASIDE_FIELD(isSelf, Bool);

    int section;

    //if MeCard section 0, else shift other sections down one
    if(isSelf)
        section = 0;
    else
        section = findSection(name, m_headings)+1;

    // if this is the first item in the section, add the heading
    if (m_sectionCounts[section] == 0) {
        // items from before the first heading go in an "Other" section at the beginning
        QString heading;
        if (section > 1)
            heading = m_displayHeadings[section-2];
        else if(section == 1)
            heading = "Other";  // TODO: i18n
        else
            heading = "Me";
        linear = new QGraphicsLinearLayout(Qt::Vertical);
        linear->setContentsMargins(0, 0, 0, 0);
        linear->setSpacing(0);

        m_mainLayout->addItem(linear, section, 0);
        linear->addItem(createHeader(heading));
    }

    m_sectionCounts[section]++;

    qDebug() << "section " << section << " sectionCount " << m_sectionCounts[section];

    linear = static_cast<QGraphicsLinearLayout *>(m_mainLayout->itemAt(section, 0));
    SeasidePersonCard *card = new SeasidePersonCard(index);

    int i;
    int count = linear->count();
    for (i=1; i<count; i++) {
        SeasidePersonCard *existing = static_cast<SeasidePersonCard *>(linear->itemAt(i));
        if (existing->name().localeAwareCompare(name) > 0)
            break;
    }
     qDebug() << "item at " << i;
    linear->insertItem(i, card);

    QObject::connect(card, SIGNAL(requestDetails(QModelIndex)),
                     m_controller, SIGNAL(itemClicked(QModelIndex)),
                     Qt::UniqueConnection);

    /*QObject::connect(card, SIGNAL(requestEdit(QModelIndex)),
                     m_controller, SIGNAL(editRequest(QModelIndex)),
                     Qt::UniqueConnection);*/

    QObject::connect(card, SIGNAL(requestSetFavorite(const QUuid&,bool)),
                     m_controller, SLOT(setFavorite(const QUuid&,bool)),
                     Qt::UniqueConnection);

    QObject::connect(card, SIGNAL(requestDelete(const QUuid&)),
                     m_controller, SLOT(deletePerson(const QUuid&)),
                     Qt::UniqueConnection);

    QObject::connect(card, SIGNAL(callNumber(const QString&)),
                     m_controller, SIGNAL(callNumber(const QString&)),
                     Qt::UniqueConnection);

    QObject::connect(card, SIGNAL(composeSMS(const QString&)),
                     m_controller, SIGNAL(composeSMS(const QString&)),
                     Qt::UniqueConnection);

    QObject::connect(card, SIGNAL(composeIM(const QString&)),
                     m_controller, SIGNAL(composeIM(const QString&)),
                     Qt::UniqueConnection);

    QObject::connect(card, SIGNAL(composeEmail(const QString&)),
                     m_controller, SIGNAL(composeEmail(const QString&)),
                     Qt::UniqueConnection);
}
/*!
	Creates the custom widget.
 */
HbWidget* CalenEditorCustomItem::createCustomWidget()
{
	OstTraceFunctionEntry0( CALENEDITORCUSTOMITEM_CREATECUSTOMWIDGET_ENTRY );
	HbDataFormModelItem::DataItemType itemType =
			static_cast<HbDataFormModelItem::DataItemType> (modelIndex() .data(
					HbDataFormModelItem::ItemTypeRole).toInt());

	switch (itemType) {
		case CustomWidgetFrom:
		{
			// Set the property so that the custom item layout
			// will be the same for both portrait and landscape
			setProperty("expandItem", true);
			// Create the widget
			HbWidget *widgetTop = new HbWidget();
			QGraphicsLinearLayout *layoutTop =
								new QGraphicsLinearLayout(Qt::Horizontal);
			layoutTop->setContentsMargins(0, 0, 0, 0);

			widgetTop->setLayout(layoutTop);

			// Set the button spacing.
			HbDeviceProfile deviceProfile;
			// The layout guide specifies the spacing as 2 u.
			qreal spacing = deviceProfile.unitValue() * 2 ;
			layoutTop->setSpacing(spacing);
			// Calculate the button width.
			qreal right = 0.0;
			qreal left = 0.0;
			style()->parameter("hb-param-margin-gene-right", right);
			style()->parameter("hb-param-margin-gene-left", left);
			qreal screenWidth = 0.0;
			style()->parameter("hb-param-screen-short-edge", screenWidth);
			qreal buttonWidth = (screenWidth - right - left - spacing) / 2;

			mPushButtonTime = new HbPushButton();
			mPushButtonTime->setPreferredWidth(buttonWidth);
			mPushButtonTime->setObjectName("startTime");
			connect(mPushButtonTime, SIGNAL(clicked()),
													this, SLOT(handleTime()));
			layoutTop->addItem(mPushButtonTime);

			mPushButtonDate = new HbPushButton();
			mPushButtonDate->setPreferredWidth(buttonWidth);
			mPushButtonDate->setObjectName("startDate");
			connect(mPushButtonDate, SIGNAL(clicked()),
													this, SLOT(handleDate()));
			layoutTop->addItem(mPushButtonDate);
			OstTraceFunctionExit0( CALENEDITORCUSTOMITEM_CREATECUSTOMWIDGET_EXIT );
			return widgetTop;
		}


		case CustomWidgetTo:
		{
			// Set the property so that the custom item layout
			// will be the same for both portrait and landscape
			setProperty("expandItem", true);
			// Create the widget
			HbWidget *widgetBottom = new HbWidget();
			
			QGraphicsLinearLayout *layoutBottom = 
					new QGraphicsLinearLayout(Qt::Horizontal);
			layoutBottom->setContentsMargins(0, 0, 0, 0);
			widgetBottom->setLayout(layoutBottom);

			// Set the button spacing.
			HbDeviceProfile deviceProfile;
			// The layout guide specifies the spacing as 2 u.
			qreal spacing = deviceProfile.unitValue() * 2 ;
			layoutBottom->setSpacing(spacing);
			// Calculate the button width.
			qreal right = 0.0;
			qreal left = 0.0;
			style()->parameter("hb-param-margin-gene-right", right);
			style()->parameter("hb-param-margin-gene-left", left);
			qreal screenWidth = 0.0;
			style()->parameter("hb-param-screen-short-edge", screenWidth);
			qreal buttonWidth = (screenWidth - right - left - spacing) / 2;

			mPushButtonTime = new HbPushButton(this);
			mPushButtonTime->setPreferredWidth(buttonWidth);
			mPushButtonTime->setObjectName("endTime");
			connect(mPushButtonTime, SIGNAL(clicked()),
													this, SLOT(handleTime()));
			layoutBottom->addItem(mPushButtonTime);

			mPushButtonDate = new HbPushButton(this);
			mPushButtonDate->setPreferredWidth(buttonWidth);
			mPushButtonDate->setObjectName("endDate");
			connect(mPushButtonDate, SIGNAL(clicked()),
													this, SLOT(handleDate()));
			layoutBottom->addItem(mPushButtonDate);
			OstTraceFunctionExit0( DUP1_CALENEDITORCUSTOMITEM_CREATECUSTOMWIDGET_EXIT );
			return widgetBottom;
		}
				
		case CustomWidgetLocation:
		{
			setProperty("expandItem", false);
			HbWidget *widgetLocation = new HbWidget();
			QGraphicsLinearLayout *layoutLocation = 
										new QGraphicsLinearLayout(Qt::Horizontal);
			layoutLocation->setContentsMargins(0, 0, 0, 0);
			widgetLocation->setLayout(layoutLocation);
			
			// Set the spacing between LineEdit and PushButton
			qreal spacing = 0.0;
			style()->parameter(
							"hb-param-margin-gene-middle-horizontal", spacing);
			layoutLocation->setSpacing(spacing);
			
			mLocationLineEdit = new HbLineEdit(this);
			mLocationLineEdit->setObjectName("locationLineEdit");
			mLocationLineEdit->setMaxRows(MaxRowsInTextItem);
			connect(mLocationLineEdit, SIGNAL(textChanged(const QString)),
						this, SLOT(handleLocationTextChange(const QString)));
			connect(mLocationLineEdit, SIGNAL(editingFinished()),
						this, SLOT(handleEditingFinished()));
			layoutLocation->addItem(mLocationLineEdit);
			
			mLocationPushButton = new HbPushButton(this);
			
			HbDeviceProfile deviceProfile;
			// The layout guide specifies the spacing as 9.5 u 
			// and the height as 7.4 u
			qreal width = deviceProfile.unitValue() * 9.5;
			qreal height = deviceProfile.unitValue() * 7.4 ;
			mLocationPushButton->setPreferredSize(width, height);
			mLocationPushButton->setSizePolicy(
										QSizePolicy::Fixed, QSizePolicy::Fixed);
			mLocationPushButton->setIcon( HbIcon("qtg_mono_location"));
			mLocationPushButton->setObjectName("locationIcon");
			connect(mLocationPushButton, SIGNAL(clicked()), this, 
												SLOT(launchLocationPicker()));
			layoutLocation->addItem(mLocationPushButton);
			OstTraceFunctionExit0( DUP2_CALENEDITORCUSTOMITEM_CREATECUSTOMWIDGET_EXIT );
			return widgetLocation;
		}
		
		case RepeatUntilOffset:
		{
			setProperty("expandItem", false);
			mRepeatUntilWidget = new HbPushButton(this);
			mRepeatUntilWidget->setObjectName("repeatUntilItem");
			OstTraceFunctionExit0( DUP3_CALENEDITORCUSTOMITEM_CREATECUSTOMWIDGET_EXIT );
			return mRepeatUntilWidget;
		}
				
		case ReminderTimeOffset:
		{
			setProperty("expandItem", false);
			mReminderTimeWidget = new HbPushButton(this);
			mReminderTimeWidget->setObjectName("remainderTimeItem");
			OstTraceFunctionExit0( DUP4_CALENEDITORCUSTOMITEM_CREATECUSTOMWIDGET_EXIT );
			return mReminderTimeWidget;
		}
		
		default:
			return 0;
	}
}
void
ResetWidget::addButtonContainer (
            MLinearLayoutPolicy *mainLayout,
            MButton             *button1,
            MButton             *button2)
{
    MSeparator          *spacer;
    QGraphicsLinearLayout *layout =
        new QGraphicsLinearLayout (Qt::Vertical);
    layout->setContentsMargins (0,0,0,0);
    layout->setSpacing (0);
    
    /*
     * One spacer
     */
    spacer = new MSeparator;
    spacer->setStyleName ("CommonSpacer");

    /*
     * Button 1 layout
     */
    QGraphicsLinearLayout *button1layout =
        new QGraphicsLinearLayout (Qt::Horizontal);
    button1layout->setContentsMargins (0,0,0,0);
    button1layout->setSpacing (0);

    MStylableWidget *imgSpacer1 = new MStylableWidget;
    imgSpacer1->setStyleName ("CommonLeftIcon");
    button1layout->addItem (imgSpacer1);

    button1layout->addStretch ();

    button1layout->addItem (button1);
    button1layout->setAlignment (button1, Qt::AlignCenter);

    button1layout->addStretch ();

    MHelpButton *hp1 = createHelpButton ("IDUG_MEEGO_SETT_RESTORE.html");
    button1layout->addItem (hp1);
    button1layout->setAlignment (hp1, Qt::AlignVCenter);

    layout->addItem (button1layout);
    layout->setAlignment (button1layout, Qt::AlignCenter);

    layout->addItem (spacer);

    /*
     * Button 2 layout
     */
    QGraphicsLinearLayout *button2layout =
        new QGraphicsLinearLayout (Qt::Horizontal);
    button2layout->setContentsMargins (0,0,0,0);
    button2layout->setSpacing (0);

    MStylableWidget *imgSpacer2 = new MStylableWidget;
    imgSpacer2->setStyleName ("CommonLeftIcon");
    button2layout->addItem (imgSpacer2);
    button2layout->addStretch ();

    button2layout->addItem (button2);
    button2layout->setAlignment (button2, Qt::AlignCenter);

    button2layout->addStretch ();
    MHelpButton *hp2 = createHelpButton ("IDUG_MEEGO_SETT_CLEARDEVICE.html");
    button2layout->addItem (hp2);
    button2layout->setAlignment (hp2, Qt::AlignVCenter);

    layout->addItem (button2layout);
    layout->setAlignment (button2layout, Qt::AlignCenter);

    /*
     *
     */
    mainLayout->addItem (layout);
    mainLayout->setStretchFactor (layout, 0);
}
Exemplo n.º 5
0
void PeopleApplication::createPeoplePage()
{

    //m_AccountManager = AccountManger::getInstance();
    m_mainPage = new MApplicationPage;
    m_mainPage->setTitle(QObject::tr("People","Title of the application"));

    QGraphicsLinearLayout *linear = new QGraphicsLinearLayout(Qt::Vertical);
    linear->setContentsMargins(0, 0, 0, 0);
    linear->setSpacing(0);
    m_mainPage->centralWidget()->setLayout(linear);

    m_topSpacer = new QGraphicsWidget;
    m_topSpacer->setPreferredHeight(0);
    linear->addItem(m_topSpacer);

    m_people = new SeasidePeople;
    linear->addItem(m_people);

    m_bottomSpacer = new QGraphicsWidget;
    m_bottomSpacer->setPreferredHeight(0);
    linear->addItem(m_bottomSpacer); 

    m_actionSearch = new MAction(QObject::tr("Search","Menu action to bring up search for contact list"), this);
    m_actionSearch->setLocation(MAction::ApplicationMenuLocation);
    m_mainPage->addAction(m_actionSearch);
    connect(m_actionSearch, SIGNAL(triggered()), this, SLOT(searchClicked()));

    m_actionAdd = new MAction(QObject::tr("Add Contact","Menu action to add contact"), this);
    m_actionAdd->setLocation(MAction::ApplicationMenuLocation);
    m_mainPage->addAction(m_actionAdd);
    connect(m_actionAdd, SIGNAL(triggered()), this, SLOT(addNewContact()));

    m_actionAll = new MAction(QObject::tr("<b>Show All</b>","Menu filter to show all contacts"), this);  
    m_actionAll->setLocation(MAction::ApplicationMenuLocation);
    m_actionAll->setObjectName("ShowAllFilter");
    m_actionAll->setCheckable(true);
    connect(m_actionAll, SIGNAL(triggered()), m_people, SLOT(filterAll()));

    m_actionFav = new MAction(QObject::tr("Show Favorites", "Menu filter to show all contacts marked as favorites"), this);
    m_actionFav->setLocation(MAction::ApplicationMenuLocation);
    m_actionFav->setObjectName("ShowFavoritesFilter");
    m_actionFav->setCheckable(true);
    connect(m_actionFav, SIGNAL(triggered()), m_people, SLOT(filterFavorites()));

    m_actionRecent = new MAction(QObject::tr("Show Recent","Menu filter to show all contacts with recent communications"), this);
    m_actionRecent->setLocation(MAction::ApplicationMenuLocation);
    m_actionRecent->setCheckable(true);
    m_actionRecent->setObjectName("ShowRecentFilter");
    connect(m_actionRecent, SIGNAL(triggered()), m_people, SLOT(filterRecent()));

    m_actionFilters = new QActionGroup(this);
    m_actionFilters->addAction(m_actionAll);
    m_actionFilters->addAction(m_actionRecent);
    m_actionFilters->addAction(m_actionFav);
    m_actionFilters->setExclusive(true);
    m_mainPage->addActions(m_actionFilters->actions());
    connect(m_actionFilters, SIGNAL(triggered(QAction*)), this, SLOT(menuFilterSelected(QAction*)));

    connect(m_people, SIGNAL(itemClicked(QModelIndex)),
            this, SLOT(createDetailPage(QModelIndex)));
    connect(m_people, SIGNAL(editRequest(QModelIndex)),
            this, SLOT(createEditPage(QModelIndex)));

    connect(m_people, SIGNAL(callNumber(const QString&)),
            this, SLOT(callNumber(const QString&)));
    connect(m_people, SIGNAL(composeSMS(const QString&)),
            this, SLOT(composeSMS(const QString&)));
    connect(m_people, SIGNAL(composeIM(const QString&)),
            this, SLOT(composeIM(const QString&)));
    connect(m_people, SIGNAL(composeEmail(const QString&)),
            this, SLOT(composeEmail(const QString&)));

    m_mainPage->appear();

    initSlider();
    initSearch();
    repositionOverlays();
}
void 
SliderContainer::createWidgets (MWidget *parent)
{
    QGraphicsLinearLayout   *layout;

    SYS_DEBUG ("");

    /*
     * A container for the two labels.
     */
    setContentsMargins (0, 0, 0, 0);
    //setStyleName ("CommonPanelInverted");

    layout = new QGraphicsLinearLayout (Qt::Vertical);
    layout->setContentsMargins (0,0,0,0);
    layout->setSpacing (0);
    setLayout (layout);

    /*
     * "Auto activate power save" label
     */
    m_AutoPSMLabel = new MLabel (parent);
    // This is needed to select the short translation.
    m_AutoPSMLabel->setWordWrap (true);
    m_AutoPSMLabel->setStyleName ("CommonTitleInverted");
    layout->addItem (m_AutoPSMLabel);
    layout->setAlignment (m_AutoPSMLabel, Qt::AlignLeft);

    /*
     * A subtitle that shows the current value of the slider.
     */
    m_PsmValueLabel = new MLabel (parent);
    m_PsmValueLabel->setStyleName ("CommonSubTitleInverted");
    m_PsmValueLabel->setObjectName ("PsmValueLabel");
    layout->addItem (m_PsmValueLabel);
    layout->setAlignment (m_PsmValueLabel, Qt::AlignLeft);

    /*
     * Power save mode auto activation slider
     */
    m_PSMSlider = new MSlider (parent);
    m_PSMSlider->setObjectName ("PSMSlider");
    m_PSMSlider->setStyleName ("CommonSliderInverted");
    m_PSMSlider->setOrientation (Qt::Horizontal);
    m_PSMSlider->setHandleLabelVisible (true);
    m_PSMSlider->setRange (0, m_SliderValues.size () - 1);
    m_PSMSlider->setMaxLabelIconID ("icon-s-common-add-inverse");
    m_PSMSlider->setMinLabelIconID ("icon-s-common-remove-inverse");
    m_PSMSlider->setMinLabelVisible (true);
    m_PSMSlider->setMaxLabelVisible (true);

    layout->addItem (m_PSMSlider);
    layout->setAlignment (m_PSMSlider, Qt::AlignHCenter);
    
    /*
     * .. and after connect the slidervalue changed signal
     */
    connect (m_PSMSlider, SIGNAL (valueChanged (int)),
            this, SLOT (sliderValueChanged (int)),
            Qt::DirectConnection);

    m_AutoPSMLabel->setText (qtTrId("qtn_ener_activation"));
}