[Pkg-owncloud-commits] [owncloud-client] 128/470: New GUI class NotificationWidget.
Sandro Knauß
hefee-guest at moszumanska.debian.org
Thu May 12 16:24:53 UTC 2016
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit 688c5502a86e50a5ab6134a2987da17f7f741e90
Author: Klaas Freitag <freitag at owncloud.com>
Date: Fri Mar 4 17:40:29 2016 +0100
New GUI class NotificationWidget.
It displays a server notification that can come with a dynamic
set of buttons next to a message and a subject (=header)
---
src/gui/notificationwidget.cpp | 83 +++++++++++++++++++++++++++++++++
src/gui/notificationwidget.h | 51 +++++++++++++++++++++
src/gui/notificationwidget.ui | 101 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 235 insertions(+)
diff --git a/src/gui/notificationwidget.cpp b/src/gui/notificationwidget.cpp
new file mode 100644
index 0000000..4160968
--- /dev/null
+++ b/src/gui/notificationwidget.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) by Klaas Freitag <freitag at owncloud.com>
+ *
+ * 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; version 2 of the License.
+ *
+ * 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.
+ */
+
+#include "notificationwidget.h"
+
+#include <QPushButton>
+
+namespace OCC {
+
+NotificationWidget::NotificationWidget(QWidget *parent) : QWidget(parent)
+{
+ _ui.setupUi(this);
+}
+
+void NotificationWidget::setAccountName( const QString& name )
+{
+ _accountName = name;
+}
+
+void NotificationWidget::setActivity(const Activity& activity)
+{
+ _myActivity = activity;
+
+ Q_ASSERT( !activity._accName.isEmpty() );
+ _accountName = activity._accName;
+
+ // _ui._headerLabel->setText( );
+ _ui._subjectLabel->setText(activity._subject);
+ if( activity._message.isEmpty()) {
+ _ui._messageLabel->hide();
+ } else {
+ _ui._messageLabel->setText(activity._message);
+ }
+ _ui._notifIcon->setPixmap(QPixmap(":/client/resources/bell.png"));
+ _ui._notifIcon->setMinimumWidth(64);
+ _ui._notifIcon->setMinimumHeight(64);
+ _ui._notifIcon->show();
+
+ // always remove the buttons
+ foreach( auto button, _ui._buttonBox->buttons() ) {
+ _ui._buttonBox->removeButton(button);
+ }
+
+ // display buttons for the links
+ foreach( auto link, activity._links ) {
+ QPushButton *b = _ui._buttonBox->addButton( link._label, QDialogButtonBox::AcceptRole);
+ b->setDefault(link._isPrimary);
+ connect(b, SIGNAL(clicked()), this, SLOT(slotButtonClicked()));
+ _buttons.append(b);
+ }
+}
+
+void NotificationWidget::slotButtonClicked()
+{
+ QObject *buttonWidget = QObject::sender();
+ int index = -1;
+ if( buttonWidget ) {
+ for( int i = 0; i < _buttons.count(); i++ ) {
+ if( _buttons.at(i) == buttonWidget ) {
+ index = i;
+ break;
+ }
+ }
+ if( index > -1 && index < _myActivity._links.count() ) {
+ ActivityLink triggeredLink = _myActivity._links.at(index);
+ qDebug() << "Notification Link: "<< triggeredLink._verb << triggeredLink._link;
+
+ emit sendNotificationRequest( _accountName, triggeredLink._link, triggeredLink._verb );
+ }
+ }
+}
+
+}
diff --git a/src/gui/notificationwidget.h b/src/gui/notificationwidget.h
new file mode 100644
index 0000000..63f4e14
--- /dev/null
+++ b/src/gui/notificationwidget.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) by Klaas Freitag <freitag at owncloud.com>
+ *
+ * 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; version 2 of the License.
+ *
+ * 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.
+ */
+
+#ifndef NOTIFICATIONWIDGET_H
+#define NOTIFICATIONWIDGET_H
+
+#include <QWidget>
+
+#include "activitywidget.h"
+
+#include "ui_notificationwidget.h"
+
+namespace OCC {
+
+class NotificationWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit NotificationWidget(QWidget *parent = 0);
+
+ void setAccountName( const QString& name );
+
+signals:
+ void sendNotificationRequest( const QString&, const QString& link, const QString& verb);
+
+public slots:
+ void setActivity(const Activity& activity);
+
+private slots:
+ void slotButtonClicked();
+
+private:
+ Ui_NotificationWidget _ui;
+ Activity _myActivity;
+ QList<QPushButton*> _buttons;
+ QString _accountName;
+};
+
+}
+
+#endif // NOTIFICATIONWIDGET_H
diff --git a/src/gui/notificationwidget.ui b/src/gui/notificationwidget.ui
new file mode 100644
index 0000000..8867772
--- /dev/null
+++ b/src/gui/notificationwidget.ui
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>NotificationWidget</class>
+ <widget class="QWidget" name="NotificationWidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>725</width>
+ <height>159</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="_notifIcon">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="pixmap">
+ <pixmap>../../resources/bell.png</pixmap>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="_subjectLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Lorem ipsum dolor sit amet</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="_messageLabel">
+ <property name="text">
+ <string>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam </string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="_buttonBox">
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="0">
+ <widget class="QFrame" name="frame">
+ <property name="frameShape">
+ <enum>QFrame::HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <property name="lineWidth">
+ <number>4</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>25</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list