Beispiel #1
0
void Cutegram::init_systray()
{
    if( p->desktop->desktopSession() == AsemanDesktopTools::Unity || p->desktop->desktopSession() == AsemanDesktopTools::GnomeFallBack )
    {
        QFile::remove(UNITY_ICON_PATH(0));
        QFile::copy(SYSTRAY_ICON,UNITY_ICON_PATH(0));

        p->unityTray = new UnitySystemTray( QCoreApplication::applicationName(), UNITY_ICON_PATH(0) );
        if( !p->unityTray->pntr() )
            QGuiApplication::setQuitOnLastWindowClosed(true);

        p->unityTray->addMenu( tr("Show"), this, "active" );
        p->unityTray->addMenu( tr("Configure"), this, "configure" );
        p->unityTray->addMenu( tr("Contact"), this, "contact" );
        p->unityTray->addMenu( tr("About"), this, "about" );
        p->unityTray->addMenu( tr("About Aseman"), this, "aboutAseman" );
        p->unityTray->addMenu( tr("Quit"), this, "quit" );
    }
    if( !p->unityTray || !p->unityTray->pntr() )
    {
        p->sysTray = new QSystemTrayIcon( QIcon(SYSTRAY_ICON), this );
        p->sysTray->setContextMenu(contextMenu());
#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0))
        p->sysTray->setToolTip(tr("Cutegram"));
#endif
#ifndef Q_OS_MAC
        p->sysTray->show();
#endif

        connect( p->sysTray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), SLOT(systray_action(QSystemTrayIcon::ActivationReason)) );
    }
}
Beispiel #2
0
void TelegramGui::start()
{
    if( p->engine )
        return;

    p->tg = new Telegram(1,&(p->args));
    p->userdata = new UserData(this);
    p->emojis = new Emojis(this);
    p->version_checker = new VersionChecker(this);
    p->countries = new Countries(this);

    p->engine = new QQmlApplicationEngine(this);
    p->engine->rootContext()->setContextProperty( "Telegram", p->tg );
    p->engine->rootContext()->setContextProperty( "Gui", this );
    p->engine->rootContext()->setContextProperty( "UserData", p->userdata );
    p->engine->rootContext()->setContextProperty( "Emojis", p->emojis );
    p->engine->rootContext()->setContextProperty( "VersionChecker", p->version_checker );
    p->engine->rootContext()->setContextProperty( "Countries", p->countries );
    p->engine->load(QUrl(QStringLiteral("qrc:///main.qml")));

    p->root = static_cast<QQuickWindow*>(p->engine->rootObjects().first());

    if( desktopSession() == Enums::Unity )
    {
        QFile::copy(":/files/sys_tray.png","/tmp/sialan-telegram-client-trayicon.png");

        p->unityTray = new UnitySystemTray( QCoreApplication::applicationName(), "/tmp/sialan-telegram-client-trayicon.png" );
        p->unityTray->addMenu( tr("Show"), this, "show" );
        p->unityTray->addMenu( tr("Configure"), this, "configure" );
        p->unityTray->addMenu( tr("About"), this, "about" );
        p->unityTray->addMenu( tr("About Sialan"), this, "aboutSialan" );
        p->unityTray->addMenu( tr("License"), this, "showLicense" );
        if( donate() )
            p->unityTray->addMenu( tr("Donate"), this, "showDonate" );
        p->unityTray->addMenu( tr("Quit"), this, "quit" );
    }
    else
    {
        p->sysTray = new QSystemTrayIcon( QIcon(":/files/sys_tray.png"), this );
        p->sysTray->show();

        connect( p->sysTray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), SLOT(systray_action(QSystemTrayIcon::ActivationReason)) );
    }
}