示例#1
0
void PsMainWindow::psUpdateCounter() {
    setWindowIcon(wndIcon);

	int32 counter = App::histories().unreadFull;

    setWindowTitle((counter > 0) ? qsl("Telegram (%1)").arg(counter) : qsl("Telegram"));
    if (_psUnityLauncherEntry) {
        if (counter > 0) {
            ps_unity_launcher_entry_set_count(_psUnityLauncherEntry, (counter > 9999) ? 9999 : counter);
            ps_unity_launcher_entry_set_count_visible(_psUnityLauncherEntry, TRUE);
        } else {
            ps_unity_launcher_entry_set_count_visible(_psUnityLauncherEntry, FALSE);
        }
    }

    if (noQtTrayIcon) {
        if (useAppIndicator) {
            if (getms() > _psLastIndicatorUpdate + 1000) {
                psUpdateIndicator();
            } else if (!_psUpdateIndicatorTimer.isActive()) {
                _psUpdateIndicatorTimer.start(100);
            }
        } else if (useStatusIcon && trayIconChecked) {
            loadPixbuf(_trayIconImageGen());
            ps_gtk_status_icon_set_from_pixbuf(_trayIcon, _trayPixbuf);
        }
    } else if (trayIcon) {
        int32 counter = App::histories().unreadFull;
        style::color bg = (App::histories().unreadMuted < counter) ? st::counterBG : st::counterMuteBG;
        QIcon iconSmall;
        iconSmall.addPixmap(QPixmap::fromImage(iconWithCounter(16, counter, bg, true), Qt::ColorOnly));
        iconSmall.addPixmap(QPixmap::fromImage(iconWithCounter(32, counter, bg, true), Qt::ColorOnly));
        trayIcon->setIcon(iconSmall);
    }
}
示例#2
0
EditPartFactory::EditPartFactory()
{
	registerFactory (shared_ptr< ModelElementType >(
		new ModelElementType( typeid(RectangleShape).name(), 
			Glib::ustring(_("Rectangle")),
			loadPixbuf ("draw-rectangle.png"),
			shared_ptr< IBoundsModelElement >( new BoundsShape() ) )), 
		&createObject< RectangleShapeEditPart >);

	registerFactory (shared_ptr< ModelElementType >(
		new ModelElementType( typeid(EllipseShape).name(), 
			Glib::ustring(_("Ellipse")),
			loadPixbuf ("draw-ellipse.png"),
			shared_ptr< IBoundsModelElement >( new BoundsShape() ) )), 
		&createObject< EllipseShapeEditPart >);
		
	registerFactory (shared_ptr< ModelElementType >(
		new ModelElementType( typeid(Frame).name(), 
			Glib::ustring(_("Frame")),
			loadPixbuf ("draw-rectangle.png"),
			shared_ptr< IBoundsModelElement >( new BoundsFrame() ) )), 
		&createObject< FrameEditPart >);
		
	registerFactory (shared_ptr< ModelElementType >(
		new ModelElementType( typeid(LineBase).name(), 
			Glib::ustring(_("Line")),
			loadPixbuf ("draw-line.png"),
			shared_ptr< IBoundsModelElement >( new BoundsLine() ) )), 
		&createObject< LineEditPart >);
		
	registerFactory (shared_ptr< ModelElementType >(
		new ModelElementType( typeid(CurveLine).name(), 
			Glib::ustring(_("Curve")),
			loadPixbuf ("draw-curve.png"),
			&createInsertTool< InsertCurveTool > )), 
		&createObject< CurveEditPart >);

	registerFactory (shared_ptr< ModelElementType >(
		new ModelElementType( typeid(TextShape).name(), 
			Glib::ustring(_("Text")),
			loadPixbuf ("draw-text.png"),
			shared_ptr< IBoundsModelElement >( new BoundsShape() ) )), 
		&createObject< TextEditPart >);
		
	registerFactory (shared_ptr< ModelElementType >(
		new ModelElementType( typeid(Diagram).name(), Glib::ustring(_("Diagram")), true)), 
		&createObject< DiagramEditPart >);
}
示例#3
0
void PsMainWindow::psCreateTrayIcon() {
    if (!noQtTrayIcon) {
        cSetSupportTray(QSystemTrayIcon::isSystemTrayAvailable());
        return;
    }

    if (useAppIndicator) {
        DEBUG_LOG(("Trying to create AppIndicator"));
        if (ps_gtk_init_check(0, 0)) {
            DEBUG_LOG(("Checked gtk with gtk_init_check!"));
            _trayMenu = ps_gtk_menu_new();
            if (_trayMenu) {
                DEBUG_LOG(("Created gtk menu for appindicator!"));
                QFileInfo f(_trayIconImageFile());
                if (f.exists()) {
                    QByteArray path = QFile::encodeName(f.absoluteFilePath());
                   _trayIndicator = ps_app_indicator_new("Telegram Desktop", path.constData(), APP_INDICATOR_CATEGORY_APPLICATION_STATUS);
                   if (_trayIndicator) {
                       DEBUG_LOG(("Created appindicator!"));
                   } else {
                       DEBUG_LOG(("Failed to app_indicator_new()!"));
                   }
                } else {
                    useAppIndicator = false;
                    DEBUG_LOG(("Failed to create image file!"));
                }
            } else {
                DEBUG_LOG(("Failed to gtk_menu_new()!"));
            }
        } else {
            DEBUG_LOG(("Failed to gtk_init_check(0, 0)!"));
        }
        if (_trayMenu && _trayIndicator) {
            ps_app_indicator_set_status(_trayIndicator, APP_INDICATOR_STATUS_ACTIVE);
            ps_app_indicator_set_menu(_trayIndicator, PS_GTK_MENU(_trayMenu));
            useStatusIcon = false;
        } else {
            DEBUG_LOG(("AppIndicator failed!"));
            useAppIndicator = false;
        }
    }
    if (useStatusIcon) {
        if (ps_gtk_init_check(0, 0) && ps_gdk_init_check(0, 0)) {
            if (!_trayMenu) _trayMenu = ps_gtk_menu_new();
            if (_trayMenu) {
                loadPixbuf(_trayIconImageGen());
                _trayIcon = ps_gtk_status_icon_new_from_pixbuf(_trayPixbuf);
                if (_trayIcon) {
                    ps_g_signal_connect(_trayIcon, "popup-menu", GCallback(_trayIconPopup), _trayMenu);
                    ps_g_signal_connect(_trayIcon, "activate", GCallback(_trayIconActivate), _trayMenu);
                    ps_g_signal_connect(_trayIcon, "size-changed", GCallback(_trayIconResized), _trayMenu);

                    ps_gtk_status_icon_set_title(_trayIcon, "Telegram Desktop");
                    ps_gtk_status_icon_set_tooltip_text(_trayIcon, "Telegram Desktop");
                    ps_gtk_status_icon_set_visible(_trayIcon, true);
                } else {
                    useStatusIcon = false;
                }
            } else {
                useStatusIcon = false;
            }
        } else {
            useStatusIcon = false;
        }
    }
    if (!useStatusIcon && !useAppIndicator) {
        if (_trayMenu) {
            ps_g_object_ref_sink(_trayMenu);
            ps_g_object_unref(_trayMenu);
            _trayMenu = 0;
        }
    }
    cSetSupportTray(useAppIndicator);
    if (useStatusIcon) {
        ps_g_idle_add((GSourceFunc)_trayIconCheck, 0);
        _psCheckStatusIconTimer.start(100);
    } else {
        psUpdateWorkmode();
    }
}