Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Changes: Improved the example call status indicator menu extension to…

… reflect current design

RevBy: TrustMe
  • Loading branch information...
commit 8b65e2fe8ec9c58fee33854e48e10a9efd6d3fd5 1 parent 5c150f6
Vesa Halttunen authored
Showing with 36 additions and 40 deletions.
  1. +31 −34 demos/plugins/call/call.cpp
  2. +5 −6 demos/plugins/call/call.h
View
65 demos/plugins/call/call.cpp
@@ -19,54 +19,51 @@
#include "call.h"
#include "callplugin.h"
-#include <MLabel>
-#include <MButton>
#include <QGraphicsLinearLayout>
-#include <MLayout>
-#include <MLinearLayoutPolicy>
-#include <MDialog>
+#include <MBasicListItem>
+#include <MImageWidget>
+#include <QTimer>
Call::Call(CallPlugin *callPlugin, QGraphicsItem *parent) :
MWidget(parent),
- plugin(callPlugin)
+ plugin(callPlugin),
+ item(new MBasicListItem(MBasicListItem::IconWithTitleAndSubtitle))
{
- // Create a layout for the button
- MLayout *mainLayout = new MLayout();
+ // Create a layout for the plugin
+ QGraphicsLinearLayout *mainLayout = new QGraphicsLinearLayout(Qt::Vertical);
+ mainLayout->setContentsMargins(0, 0, 0, 0);
+ mainLayout->setSpacing(0);
setLayout(mainLayout);
- MLinearLayoutPolicy *linearPolicy = new MLinearLayoutPolicy(mainLayout, Qt::Horizontal);
- // Place the button into the layout
- linearPolicy->addItem(new MLabel("Ongoing Call"));
- linearPolicy->addStretch();
- MButton *button = new MButton("Options");
- connect(button, SIGNAL(clicked()), this, SLOT(showCallDialog()));
- linearPolicy->addItem(button);
+ // Set up an item for the call
+ item->setTitle("Ongoing call");
+ item->setSubtitle("00:52");
+ item->imageWidget()->setImage("icon-m-status-menu-settings");
+ item->setStyleName("CommonBasicListItemInverted");
+ connect(item, SIGNAL(clicked()), this, SLOT(hideItem()));
+ mainLayout->addItem(item);
+
+ hideItem();
}
Call::~Call()
{
}
-void Call::showCallDialog()
+QSizeF Call::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
{
- // Create a dialog for choosing the call
- MDialog* dialog = new MDialog("Call", M::NoStandardButton);
- MWidget *centralWidget = new MWidget;
- QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
- centralWidget->setLayout(layout);
- dialog->setCentralWidget(centralWidget);
-
- // Place the buttons in the button group and in the layout
- MButton *button;
- button = new MButton("End Call");
- connect(button, SIGNAL(clicked()), dialog, SLOT(accept()));
- layout->addItem(button);
+ return item->isVisible() ? MWidget::sizeHint(which, constraint) : QSizeF(0, 0);
+}
- // Show the dialog
- dialog->exec();
+void Call::hideItem()
+{
+ item->hide();
+ updateGeometry();
+ QTimer::singleShot(10000, this, SLOT(showItem()));
+}
- // Hide the status indicator menu
- if(MStatusIndicatorMenuInterface *menu = plugin->statusIndicatorMenuInterface()) {
- menu->hideStatusIndicatorMenu();
- }
+void Call::showItem()
+{
+ item->show();
+ updateGeometry();
}
View
11 demos/plugins/call/call.h
@@ -22,8 +22,7 @@
#include <MWidget>
-class MStatusIndicatorMenuInterface;
-class MButton;
+class MBasicListItem;
class CallPlugin;
/*!
@@ -37,16 +36,16 @@ class Call : public MWidget
public:
Call(CallPlugin *callPlugin, QGraphicsItem *parent = NULL);
virtual ~Call();
+ virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
private slots:
- /*!
- * \brief Shows the call dialog
- */
- void showCallDialog();
+ void hideItem();
+ void showItem();
private:
//! The call plugin for accessing the status indicator menu
CallPlugin *plugin;
+ MBasicListItem *item;
};
#endif // CALL_H
Please sign in to comment.
Something went wrong with that request. Please try again.