Ejemplo n.º 1
0
QAction* MenuCallback::addCustomAction(QString commandId,
                                       QString label,
                                       QString tooltip)
{

   QAction* pAction = NULL;
   if (commandId == QString::fromAscii("zoomIn"))
   {
      pAction = menuStack_.top()->addAction(QIcon(),
                                            label,
                                            this,
                                            SIGNAL(zoomIn()),
                                            QKeySequence::ZoomIn);
   }
   else if (commandId == QString::fromAscii("zoomOut"))
   {
      pAction = menuStack_.top()->addAction(QIcon(),
                                            label,
                                            this,
                                            SIGNAL(zoomOut()),
                                            QKeySequence::ZoomOut);
   }
#ifdef Q_OS_LINUX
   else if (commandId == QString::fromAscii("nextTab"))
   {
      pAction = menuStack_.top()->addAction(QIcon(),
                                            label,
                                            this,
                                            SLOT(actionInvoked()),
                                            QKeySequence(Qt::CTRL +
                                                         Qt::Key_PageDown));
   }
   else if (commandId == QString::fromAscii("previousTab"))
   {
      pAction = menuStack_.top()->addAction(QIcon(),
                                            label,
                                            this,
                                            SLOT(actionInvoked()),
                                            QKeySequence(Qt::CTRL +
                                                         Qt::Key_PageUp));
   }
#endif

   if (pAction != NULL)
   {
      pAction->setData(commandId);
      pAction->setToolTip(tooltip);
      return pAction;
   }
   else
   {
      return NULL;
   }
}
Ejemplo n.º 2
0
void MenuCallback::addCommand(QString commandId,
                              QString label,
                              QString tooltip,
                              QString shortcut)
{
   shortcut = shortcut.replace(QString::fromUtf8("Enter"), QString::fromAscii("\n"));

   QKeySequence keySequence(shortcut);
#ifndef Q_WS_MAC
   if (shortcut.contains(QString::fromAscii("\n")))
   {
      int value = (keySequence[0] & Qt::MODIFIER_MASK) + Qt::Key_Enter;
      keySequence = QKeySequence(value);
   }
#endif

   QAction* pAction = menuStack_.top()->addAction(QIcon(),
                                                  label,
                                                  this,
                                                  SLOT(actionInvoked()),
                                                  keySequence);
   pAction->setData(commandId);
   pAction->setToolTip(tooltip);

   MenuActionBinder* pBinder = new MenuActionBinder(menuStack_.top(), pAction);
   connect(pBinder, SIGNAL(manageCommand(QString,QAction*)),
           this, SIGNAL(manageCommand(QString,QAction*)));
}
Ejemplo n.º 3
0
void MenuCallback::addCommand(QString commandId,
                              QString label,
                              QString tooltip,
                              QString shortcut)
{
   shortcut = shortcut.replace(QString::fromUtf8("Enter"), QString::fromAscii("\n"));

   QKeySequence keySequence(shortcut);
#ifndef Q_WS_MAC
   if (shortcut.contains(QString::fromAscii("\n")))
   {
      int value = (keySequence[0] & Qt::MODIFIER_MASK) + Qt::Key_Enter;
      keySequence = QKeySequence(value);
   }
#endif

   // allow custom action handlers first shot
   QAction* pAction = addCustomAction(commandId, label, tooltip);

   // if there was no custom handler then do stock command-id processing
   if (pAction == NULL)
   {
      pAction = menuStack_.top()->addAction(QIcon(),
                                            label,
                                            this,
                                            SLOT(actionInvoked()),
                                            keySequence);
      pAction->setData(commandId);
      pAction->setToolTip(tooltip);

      MenuActionBinder* pBinder = new MenuActionBinder(menuStack_.top(), pAction);
      connect(pBinder, SIGNAL(manageCommand(QString,QAction*)),
              this, SIGNAL(manageCommand(QString,QAction*)));

   }
Ejemplo n.º 4
0
SnoreNotifyPlugin::SnoreNotifyPlugin()
    : InfoPlugin(),
      m_defaultIcon( RESPATH "icons/tomahawk-icon-512x512.png" )
{
    tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
    m_supportedPushTypes << InfoNotifyUser << InfoNowPlaying << InfoTrackUnresolved << InfoNowStopped << InfoInboxReceived;

    Snore::SnoreCore &snore = Snore::SnoreCore::instance();
    snore.loadPlugins( Snore::SnorePlugin::Backend | Snore::SnorePlugin::SecondaryBackend );
    snore.setDefaultSettingsValue("Silent", true, Snore::LocalSetting );

    m_application = Snore::Application( qApp->applicationName(), m_defaultIcon );
    m_application.hints().setValue( "use-markup", true );
    m_application.hints().setValue( "windows-app-id", TOMAHAWK_APPLICATION_PACKAGE_NAME );
    m_application.hints().setValue( "desktop-entry", TOMAHAWK_APPLICATION_NAME );

    addAlert( InfoNotifyUser, tr( "Notify User" ) );
    addAlert( InfoNowPlaying, tr( "Now Playing" ) );
    addAlert( InfoTrackUnresolved, tr( "Unresolved track" ) );
    addAlert( InfoNowStopped, tr( "Playback Stopped" ) );
    addAlert( InfoInboxReceived, tr( "You received a Song recommendation" ) );

    snore.registerApplication( m_application );
    snore.setDefaultApplication( m_application );

    connect( &snore, SIGNAL( actionInvoked( Snore::Notification ) ), this, SLOT( slotActionInvoked( Snore::Notification ) ) );
}
Ejemplo n.º 5
0
void MenuCallback::addCommand(QString commandId,
                              QString label,
                              QString tooltip,
                              QString shortcut)
{
   shortcut = shortcut.replace("Enter", "\n");

   QKeySequence keySequence(shortcut);
#ifndef Q_WS_MAC
   if (shortcut.contains("\n"))
   {
      int value = (keySequence[0] & Qt::MODIFIER_MASK) + Qt::Key_Enter;
      keySequence = QKeySequence(value);
   }
#endif

   QAction* pAction = menuStack_.top()->addAction(QIcon(),
                                                  label,
                                                  this,
                                                  SLOT(actionInvoked()),
                                                  keySequence);
   pAction->setData(commandId);
   pAction->setToolTip(tooltip);

   menuActions_[menuStack_.first()].append(pAction);
}
Ejemplo n.º 6
0
void MockNotification::invokeAction(const QString &action) {
    for(int i=0; i<p->actions.size(); i++) {
        if(p->actions[i] == action) {
            Q_EMIT actionInvoked(action);
            qDebug() << "Info: invoked action" << action;
            return;
        }
    }
    fprintf(stderr, "Error: tried to invoke action not in actionList.\n");
}
Ejemplo n.º 7
0
void Bubble::mousePressEvent(QMouseEvent *)
{
    if (!m_defaultAction.isEmpty()) {
        Q_EMIT actionInvoked(m_entity->id().toUInt(), m_defaultAction);
        m_defaultAction.clear();
    } else {
        Q_EMIT dismissed(m_entity->id().toInt());
    }

    m_outTimer->stop();
}
void NotificationLayout::notificationActionCalled(const QString &actionKey)
{
    Notification *n = qobject_cast<Notification*>(sender());
    if (!n)
    {
        qDebug() << "Oooook! USERACTION Expecting instance of notification, got:" << sender();
        return;
    }

    emit actionInvoked(m_notifications.key(n), actionKey);
}
BubbleManager::BubbleManager(QObject *parent)
    : QObject(parent)
{
    m_bubble = new Bubble;
    m_persistence = new Persistence;
    m_dockPosition = DockPosition::Bottom;

    m_dbusDaemonInterface = new DBusDaemonInterface(DBusDaemonDBusService, DBusDaemonDBusPath,
                                                    QDBusConnection::sessionBus(), this);

    m_dbusdockinterface = new DBusDockInterface(DBbsDockDBusServer, DBusDockDBusPath,
                                                QDBusConnection::sessionBus(), this);

    m_login1ManagerInterface = new Login1ManagerInterface(Login1DBusService, Login1DBusPath,
                                                          QDBusConnection::systemBus(), this);

    m_dbusControlCenter = new DBusControlCenter(ControlCenterDBusService, ControlCenterDBusPath,
                                                    QDBusConnection::sessionBus(), this);

    m_dockDeamonInter = new DockDaemonInter(DockDaemonDBusServie, DockDaemonDBusPath,
                                            QDBusConnection::sessionBus(), this);
    m_dockDeamonInter->setSync(false);

    connect(m_bubble, SIGNAL(expired(int)), this, SLOT(bubbleExpired(int)));
    connect(m_bubble, SIGNAL(dismissed(int)), this, SLOT(bubbleDismissed(int)));
    connect(m_bubble, SIGNAL(replacedByOther(int)), this, SLOT(bubbleReplacedByOther(int)));
    connect(m_bubble, SIGNAL(actionInvoked(uint, QString)), this, SLOT(bubbleActionInvoked(uint, QString)));

    connect(m_dbusDaemonInterface, SIGNAL(NameOwnerChanged(QString, QString, QString)),
            this, SLOT(onDbusNameOwnerChanged(QString, QString, QString)));

    connect(m_login1ManagerInterface, SIGNAL(PrepareForSleep(bool)),
            this, SLOT(onPrepareForSleep(bool)));

    connect(m_dbusdockinterface, &DBusDockInterface::geometryChanged, this, &BubbleManager::onDockRectChanged);
    connect(m_persistence, &Persistence::RecordAdded, this, &BubbleManager::onRecordAdded);

    connect(m_dockDeamonInter, &DockDaemonInter::PositionChanged, this, &BubbleManager::onDockPositionChanged);

    // get correct value for m_dockGeometry, m_dockPosition, m_ccGeometry
    if (m_dbusdockinterface->isValid())
        onDockRectChanged(m_dbusdockinterface->geometry());
    if (m_dockDeamonInter->isValid())
        m_dockPosition = static_cast<DockPosition>(m_dockDeamonInter->position());
    if (m_dbusControlCenter->isValid())
        onCCDestRectChanged(m_dbusControlCenter->rect());

    registerAsService();
}
Ejemplo n.º 10
0
Notifyd::Notifyd(QObject* parent)
    : QObject(parent),
      mId(0)
{
    m_area = new NotificationArea();
    ReloadSettings();

    connect(this, SIGNAL(notificationAdded(uint,QString,QString,QString,QString,int,QStringList,QVariantMap)),
            m_area->layout(), SLOT(addNotification(uint,QString,QString,QString,QString,int,QStringList,QVariantMap)));
    connect(this, SIGNAL(notificationClosed(uint, uint)),
            m_area->layout(), SLOT(removeNotification(uint, uint)));
    // feedback for original caller
    connect(m_area->layout(), SIGNAL(notificationClosed(uint,uint)),
            this, SIGNAL(NotificationClosed(uint,uint)));
    connect(m_area->layout(), SIGNAL(actionInvoked(uint, QString)),
            this, SIGNAL(ActionInvoked(uint,QString)));

}
Ejemplo n.º 11
0
void MenuCallback::addCommand(QString commandId,
                              QString label,
                              QString tooltip,
                              QString shortcut)
{
   shortcut = shortcut.replace("Enter", "\n");

   QKeySequence keySequence(shortcut);

   QAction* pAction = menuStack_.top()->addAction(QIcon(),
                                                  label,
                                                  this,
                                                  SLOT(actionInvoked()),
                                                  keySequence);
   pAction->setData(commandId);
   pAction->setToolTip(tooltip);

   menuActions_[menuStack_.first()].append(pAction);
}
Ejemplo n.º 12
0
void Bubble::onActionButtonClicked(const QString &actionId)
{
    QMap<QString, QVariant> hints = m_entity->hints();
    QMap<QString, QVariant>::const_iterator i = hints.constBegin();
    while (i != hints.constEnd()) {
        QStringList args = i.value().toString().split(",");
        if (!args.isEmpty()) {
            QString cmd = args.first();
            args.removeFirst();
            if (i.key() == "x-deepin-action-" + actionId) {
                QProcess::startDetached(cmd, args);
            }
        }
        ++i;
    }

    m_outTimer->stop();
    Q_EMIT actionInvoked(m_entity->id().toUInt(), actionId);
}
Ejemplo n.º 13
0
uint NotificationManager::Notify(const QString &appName, uint replacesId, const QString &appIcon, const QString &summary, const QString &body, const QStringList &actions, const QVariantHash &originalHints, int expireTimeout)
{
    uint id = replacesId != 0 ? replacesId : nextAvailableNotificationID();

    if (replacesId == 0 || notifications.contains(id)) {
        // Apply a category definition, if any, to the hints
        QVariantHash hints(originalHints);
        applyCategoryDefinition(hints);

        // Ensure the hints contain a timestamp
        addTimestamp(hints);

        if (replacesId == 0) {
            // Create a new notification
            Notification *notification = new Notification(appName, id, appIcon, summary, body, actions, hints, expireTimeout, this);
            connect(notification, SIGNAL(actionInvoked(QString)), this, SLOT(invokeAction(QString)));
            notifications.insert(id, notification);
        } else {
            // Only replace an existing notification if it really exists
            Notification *notification = notifications.value(id);
            notification->setAppName(appName);
            notification->setAppIcon(appIcon);
            notification->setSummary(summary);
            notification->setBody(body);
            notification->setActions(actions);
            notification->setHints(hints);
            notification->setExpireTimeout(expireTimeout);

            // Delete the existing notification from the database
            execSQL(QString("DELETE FROM notifications WHERE id=?"), QVariantList() << id);
            execSQL(QString("DELETE FROM actions WHERE id=?"), QVariantList() << id);
            execSQL(QString("DELETE FROM hints WHERE id=?"), QVariantList() << id);
        }

        // Add the notification, its actions and its hints to the database
        execSQL("INSERT INTO notifications VALUES (?, ?, ?, ?, ?, ?)", QVariantList() << id << appName << appIcon << summary << body << expireTimeout);
        foreach (const QString &action, actions) {
            execSQL("INSERT INTO actions VALUES (?, ?)", QVariantList() << id << action);
        }
Ejemplo n.º 14
0
/////////////////////////////////////// PUBLIC FUNCTIONS ////////////////////////////////
//
// Function to connect to a notification server.
void NotifyClient::connectToServer()
{
	// return now if we already have a valid connection
  if (b_validconnection) return;

  notifyclient = new QDBusInterface(DBUS_NOTIFY_SERVICE, DBUS_NOTIFY_PATH, DBUS_NOTIFY_INTERFACE, QDBusConnection::sessionBus(), this); 
  if (notifyclient->isValid() ) {
    b_validconnection = true;
    getServerInformation();
    getCapabilities();  
    QDBusConnection::sessionBus().connect(DBUS_NOTIFY_SERVICE, DBUS_NOTIFY_PATH, DBUS_NOTIFY_INTERFACE, "NotificationClosed", this, SLOT(notificationClosed(quint32, quint32)));
    QDBusConnection::sessionBus().connect(DBUS_NOTIFY_SERVICE, DBUS_NOTIFY_PATH, DBUS_NOTIFY_INTERFACE, "ActionInvoked", this, SLOT(actionInvoked(quint32, QString)));
    } // if connection is valid 
  else {
    notifyclient->deleteLater();
    b_validconnection = false;
  }	// else connection not valid
}
AsemanLinuxNativeNotification::AsemanLinuxNativeNotification(QObject *parent) :
    QObject(parent)
{
    p = new AsemanLinuxNativeNotificationPrivate;

    p->connection = new QDBusConnection( QDBusConnection::sessionBus() );
    p->connection->connect( DBUS_SERVICE , DBUS_PATH , DBUS_OBJECT , DBUS_CLOSED , this , SLOT(notificationClosed(QDBusMessage)) );
    p->connection->connect( DBUS_SERVICE , DBUS_PATH , DBUS_OBJECT , DBUS_ACTION , this , SLOT(actionInvoked(QDBusMessage))      );
}