示例#1
0
	bool TrayIcon::canShowNotifications() const
	{
        // TODO: must be based on the type of notification - is it message, birthday-notify or contact-coming-notify.
        if (!get_gui_settings()->get_value<bool>(settings_notify_new_messages, true))  return false;

#ifdef _WIN32
		if (QSysInfo().windowsVersion() >= QSysInfo::WV_VISTA)
		{
			static QueryUserNotificationState query;
			if (!query)
			{
				HINSTANCE shell32 = LoadLibraryW(L"shell32.dll");
				if (shell32)
				{
					query = (QueryUserNotificationState)GetProcAddress(shell32, "SHQueryUserNotificationState");
				}
			}

			if (query)
			{
				QUERY_USER_NOTIFICATION_STATE state;
				if (query(&state) == S_OK && state != QUNS_ACCEPTS_NOTIFICATIONS)
					return false;
			}
		}
        else if (QSysInfo().windowsVersion() == QSysInfo::WV_XP)
        {
            static QuerySystemParametersInfo query;
            if (!query)
            {
                HINSTANCE user32 = LoadLibraryW(L"user32.dll");
                if (user32)
                {
                    query = (QuerySystemParametersInfo)GetProcAddress(user32, "SystemParametersInfoW");
                }
            }

            if (query)
            {
                BOOL result = FALSE;      
                if (query(SPI_GETSCREENSAVERRUNNING, 0, &result, 0) && result)
                    return false;
            }
        }

#endif //_WIN32
		return Icon_->isSystemTrayAvailable() && Icon_->supportsMessages() && !MainWindow_->isActive();
	}
示例#2
0
PLATFORM_NS_BEGIN

OsxVersion osxVersion()
{
    #if defined(__APPLE__)
        return (OsxVersion)QSysInfo().macVersion();
    #else
        assert(!"this is not osx dude");
        return OsxVersion::UNKNOWN;
    #endif
}
示例#3
0
 bool TrayIcon::ncSupported()
 {
     if (QSysInfo().macVersion() > QSysInfo::MV_10_7)
     {
         if (!NotificationCenterManager_.get())
         {
             NotificationCenterManager_.reset(new NotificationCenterManager());
             connect(NotificationCenterManager_.get(), SIGNAL(messageClicked(QString)), this, SLOT(messageClicked(QString)), Qt::QueuedConnection);
         }
         return true;
     }
     return false;
 }
示例#4
0
	bool TrayIcon::toastSupported()
	{
		return false;
		if (QSysInfo().windowsVersion() > QSysInfo::WV_WINDOWS8_1)
		{
			if (!ToastManager_.get())
			{
				ToastManager_.reset(new ToastManager());
				connect(ToastManager_.get(), SIGNAL(messageClicked(QString)), this, SLOT(messageClicked(QString)), Qt::QueuedConnection);
			}
			return true;
		}
		return false;
	}
示例#5
0
	TrayIcon::TrayIcon(MainWindow* parent)
		: QObject(parent)
		, MainWindow_(parent)
		, Icon_(new QSystemTrayIcon(this))
		, Menu_(new ContextMenu(0))
		, MessageAlert_(new RecentMessagesAlert(new Logic::RecentItemDelegate(this)))
		, Base_(new QIcon(":/resources/main_window/appicon.ico"))
		, Unreads_(new QIcon(":/resources/main_window/appicon_unread.ico"))
#ifdef _WIN32
		, TrayBase_(new QIcon(":/resources/main_window/appicon_tray.ico"))
        , TrayUnreads_(new QIcon(":/resources/main_window/appicon_tray_unread.ico"))
#else
        , TrayBase_(new QIcon(":/resources/main_window/appicon.ico"))
        , TrayUnreads_(new QIcon(":/resources/main_window/appicon_unread.ico"))
#endif //_WIN32
        , TaskBarOverlay_(new QPixmap(":/resources/main_window/appicon_overlay.png"))
		, HaveUnreads_(false)
#ifdef _WIN32
        , ptbl(0)
#endif //_WIN32
	{
#ifdef _WIN32
        if (QSysInfo().windowsVersion() >= QSysInfo::WV_WINDOWS7)
        {
            HRESULT hr = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&ptbl));
            if (FAILED(hr))
                ptbl = 0;
        }
#endif //_WIN32
		init();
        
        connect(Ui::GetDispatcher(), SIGNAL(login_complete()), this, SLOT(loggedIn()), Qt::QueuedConnection);
		connect(MessageAlert_, SIGNAL(messageClicked(QString)), this, SLOT(messageClicked(QString)), Qt::QueuedConnection);
		connect(Logic::GetContactListModel(), SIGNAL(selectedContactChanged(QString)), this, SLOT(clearNotifications(QString)), Qt::QueuedConnection);
		connect(Logic::GetContactListModel(), SIGNAL(contactChanged(QString)), this, SLOT(updateIcon()), Qt::QueuedConnection);
        connect(Ui::GetDispatcher(), SIGNAL(myInfo()), this, SLOT(myInfo()));
        connect(Ui::GetDispatcher(), SIGNAL(needLogin()), this, SLOT(loggedOut()), Qt::QueuedConnection);
	}
示例#6
0
    void Application::initMainWindow()
    {
        double dpi = app_->primaryScreen()->logicalDotsPerInchX();
#ifdef __APPLE__
        if (QSysInfo().macVersion() >= QSysInfo().MV_10_11)
        {
            QFontDatabase().addApplicationFont("/System/Library/Fonts/SFNSDisplay-Medium.otf");
            QFontDatabase().addApplicationFont("/System/Library/Fonts/SFNSDisplay-Regular.otf");
            QFontDatabase().addApplicationFont("/System/Library/Fonts/SFNSDisplay-Light.otf");
            QFontDatabase().addApplicationFont("/System/Library/Fonts/SFNSDisplay-Thin.otf");
            QFontDatabase().addApplicationFont("/System/Library/Fonts/SFNSDisplay-Ultralight.otf");

            QFontDatabase().addApplicationFont(":/resources/fonts/OpenSans-Semibold.ttf");
            QFontDatabase().addApplicationFont(":/resources/fonts/OpenSans-Bold.ttf");
            QFontDatabase().addApplicationFont(":/resources/fonts/OpenSans-Light.ttf");
            QFontDatabase().addApplicationFont(":/resources/fonts/OpenSans-Regular.ttf");
            
#ifdef DEBUG
            qDebug() << "Installed fonts:";
            
            QStringList families = QFontDatabase().families();
            for (QStringList::iterator i = families.begin(); i != families.end(); i++)
            {
                qDebug() << (*i);
            }

            qDebug() << "Available styles for font " << Utils::appFontFamily(FontsFamily::SEGOE_UI);
            
            QStringList list = QFontDatabase().styles(Utils::appFontFamily(FontsFamily::SEGOE_UI));
            for (QStringList::iterator i = list.begin(); i != list.end(); i++)
            {
                qDebug() << (*i);
            }
#endif
        }
        
        dpi = 96;
        Utils::set_mac_retina(app_->primaryScreen()->devicePixelRatio() == 2);
        if (Utils::is_mac_retina())
        {
            app_->setAttribute(Qt::AA_UseHighDpiPixmaps);
        }
#endif

        Utils::InterConnector::instance().setUrlHandler();

        const auto guiScaleCoefficient = std::min(dpi / 96.0, 2.0);

        Utils::init_basic_scale_coefficient(guiScaleCoefficient);
        
        Utils::set_scale_coefficient(Ui::get_gui_settings()->get_value<double>(settings_scale_coefficient, Utils::get_basic_scale_coefficient()));
        app_->setStyleSheet(Utils::LoadStyle(":/resources/qss/styles.qss", Utils::get_scale_coefficient(), true));

        Themes::SetCurrentThemeId(Themes::ThemeId::Default);
        Emoji::InitializeSubsystem();

        Ui::get_gui_settings()->set_shadow_width(Utils::scale_value(shadow_width));

        Utils::GetTranslator()->init();
        main_window_.reset(new Ui::MainWindow(app_.get()));
        main_window_->show();
        main_window_->activateWindow();
#ifdef _WIN32
        peer_->set_main_window(main_window_.get());
#endif //_WIN32
    }