void TelegramGui::sendNotify(quint64 msg_id) { QStringList actions; if( desktopSession() != Enums::Unity ) { actions << QString("%1:%2").arg(NOTIFY_ACT_SHOW).arg(msg_id) << tr("Show"); actions << QString("%1:%2").arg(NOTIFY_ACT_MUTE).arg(msg_id) << tr("Mute"); // actions << QString("%1:%2").arg(NOTIFY_ACT_RMND).arg(msg_id) << tr("Mute & Remind"); } int to_id = p->tg->messageToId(msg_id); int from_id = p->tg->messageFromId(msg_id); if( from_id == p->tg->me() ) return; if( isMuted(to_id) || isMuted(from_id) ) return; QString title = p->tg->messageFromName(msg_id); QString icon = p->tg->getPhotoPath(from_id); QString body = p->tg->messageBody(msg_id); if( p->tg->dialogIsChat(to_id) ) title += tr("at %1").arg(p->tg->dialogTitle(to_id)); else if( p->tg->dialogIsChat(from_id) ) title += tr("at %1").arg(p->tg->dialogTitle(from_id)); p->notify->sendNotify( title, body, icon, 0, 3000, actions ); }
QString AsemanDesktopTools::getOpenFileName(QWindow *window, const QString & title, const QString &filter, const QString &startPath) { #ifdef DESKTOP_DEVICE const int dsession = desktopSession(); switch( dsession ) { case AsemanDesktopTools::Kde: if( QFileInfo::exists("/usr/bin/kdialog") ) { QStringList args = QStringList()<< "--title" << title << "--getopenfilename" << startPath << filter; if( window ) args << "--attach" << QString::number(window->winId()); QProcess process; QEventLoop loop; connect(&process, SIGNAL(finished(int)), &loop, SLOT(quit()), Qt::QueuedConnection ); process.start("/usr/bin/kdialog", args ); loop.exec(QEventLoop::ExcludeUserInputEvents); if( process.exitStatus() == QProcess::NormalExit ) return QString(process.readAll()).remove("\n"); else return QFileDialog::getOpenFileName(0, title, startPath, filter); } else return QFileDialog::getOpenFileName(0, title, startPath, filter);
QColor AsemanDesktopTools::titleBarColor() const { #ifdef DESKTOP_DEVICE const int dsession = desktopSession(); switch( dsession ) { case AsemanDesktopTools::Mac: return QColor("#C8C8C8"); break; case AsemanDesktopTools::Windows: return QColor("#E5E5E5"); break; case AsemanDesktopTools::Kde: return QPalette().window().color(); break; case AsemanDesktopTools::Unity: case AsemanDesktopTools::GnomeFallBack: case AsemanDesktopTools::Gnome: { static QColor *res = 0; if( !res ) { QProcess prc; prc.start( "dconf", QStringList()<< "read"<< "/org/gnome/desktop/interface/gtk-theme" ); prc.waitForStarted(); prc.waitForFinished(); QString sres = prc.readAll(); sres.remove("\n").remove("'"); sres = sres.toLower(); if( sres == "ambiance" ) res = new QColor("#403F3A"); else if( sres == "radiance" ) res = new QColor("#DFD7CF"); else if( sres == "adwaita" ) res = new QColor("#EDEDED"); else if( dsession == AsemanDesktopTools::Unity ) res = new QColor("#403F3A"); else res = new QColor("#EDEDED"); } return *res; } break; } return QColor("#EDEDED"); #else return QColor("#111111"); #endif }
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)) ); } }