Ejemplo n.º 1
0
TelegramGui::TelegramGui(QObject *parent) :
    QObject(parent)
{
    p = new TelegramGuiPrivate;
    p->engine = 0;
    p->tg = 0;
    p->quit_state = false;
    p->args = QGuiApplication::arguments().first().toUtf8().data();
    p->doc = new QTextDocument(this);
    p->translator = new QTranslator(this);

    QDir().mkpath(HOME_PATH);
    QDir().mkpath(HOME_PATH + "/downloads");
    if( !tg_settings )
        tg_settings = new QSettings( HOME_PATH + "/telegram.conf", QSettings::IniFormat, this);

    p->background = tg_settings->value( "General/background", QString() ).toString();
    p->firstTime = tg_settings->value( "General/firstTime", true ).toBool();
    p->width = tg_settings->value( "General/width", 1024 ).toInt();
    p->height = tg_settings->value( "General/height", 600 ).toInt();
    p->visible = tg_settings->value( "General/visible", true ).toBool();
    p->notify = new Notification(this);

    connect( p->notify, SIGNAL(notifyAction(uint,QString)), SLOT(notify_action(uint,QString)) );

    qmlRegisterType<Enums>("org.sialan.telegram", 1, 0, "Enums");
    qmlRegisterType<SetObject>("org.sialan.telegram", 1, 0, "SetObject");

    init_languages();
}
Ejemplo n.º 2
0
void AsemanNativeNotification::actionTriggered(const QString &action)
{
    AsemanNativeNotificationItem *item = static_cast<AsemanNativeNotificationItem*>(sender());
    if(!item)
        return;

    uint id = p->items.key(item);
    if(!id)
        return;

    emit notifyAction(id, action);
    item->close();
}
void AsemanMacNativeNotification::messageClicked()
{
    AsemanMacNativeNotificationItem *item = static_cast<AsemanMacNativeNotificationItem*>(sender());
    if(!item)
        return;

    const uint id = p->items.key(item);
    if(!id)
        return;

    const QStringList & actions = item->actions;
    if(!actions.isEmpty())
        emit notifyAction(id, actions.first());

    item->deleteLater();
}
void AsemanLinuxNativeNotification::actionInvoked(const QDBusMessage &dmsg)
{
    if( dmsg.type() != QDBusMessage::SignalMessage )
        return ;

    const QVariantList & args = dmsg.arguments();
    if( args.count() != 2 )
        return ;

    uint id = args.at(0).toUInt();
    if( !p->notifies.contains(id) )
        return;

    QString action = args.at(1).toString();
    Q_EMIT notifyAction(id, action);
}