Exemplo n.º 1
0
void Window::onLogout() {
	if (isHidden()) showFromTray();

	ConfirmBox *box = new ConfirmBox(lang(lng_sure_logout));
	connect(box, SIGNAL(confirmed()), this, SLOT(onLogoutSure()));
	App::wnd()->showLayer(box);
}
Exemplo n.º 2
0
void PsMainWindow::psFirstShow() {
	finished = false;

    psUpdateMargins();

	bool showShadows = true;

	show();
    _private.enableShadow(winId());
	if (cWindowPos().maximized) {
		setWindowState(Qt::WindowMaximized);
	}

	if ((cFromAutoStart() && cStartMinimized()) || cStartInTray()) {
		setWindowState(Qt::WindowMinimized);
		if (cWorkMode() == dbiwmTrayOnly || cWorkMode() == dbiwmWindowAndTray) {
			hide();
		} else {
			show();
		}
		showShadows = false;
	} else {
		show();
	}

	posInited = true;

	// init global menu
	QMenu *main = psMainMenu.addMenu(qsl("Telegram"));
	main->addAction(lng_mac_menu_about_telegram(lt_telegram, qsl("Telegram")), App::wnd()->getTitle(), SLOT(onAbout()))->setMenuRole(QAction::AboutQtRole);
	main->addSeparator();
	QAction *prefs = main->addAction(lang(lng_mac_menu_preferences), App::wnd(), SLOT(showSettings()), QKeySequence(Qt::ControlModifier | Qt::Key_Comma));
	prefs->setMenuRole(QAction::PreferencesRole);

	QMenu *file = psMainMenu.addMenu(lang(lng_mac_menu_file));
	psLogout = file->addAction(lang(lng_mac_menu_logout), App::wnd(), SLOT(onLogout()));

	QMenu *edit = psMainMenu.addMenu(lang(lng_mac_menu_edit));
	psUndo = edit->addAction(lang(lng_mac_menu_undo), this, SLOT(psMacUndo()), QKeySequence::Undo);
	psRedo = edit->addAction(lang(lng_mac_menu_redo), this, SLOT(psMacRedo()), QKeySequence::Redo);
	edit->addSeparator();
	psCut = edit->addAction(lang(lng_mac_menu_cut), this, SLOT(psMacCut()), QKeySequence::Cut);
	psCopy = edit->addAction(lang(lng_mac_menu_copy), this, SLOT(psMacCopy()), QKeySequence::Copy);
	psPaste = edit->addAction(lang(lng_mac_menu_paste), this, SLOT(psMacPaste()), QKeySequence::Paste);
	psDelete = edit->addAction(lang(lng_mac_menu_delete), this, SLOT(psMacDelete()), QKeySequence(Qt::ControlModifier | Qt::Key_Backspace));
	edit->addSeparator();
	psSelectAll = edit->addAction(lang(lng_mac_menu_select_all), this, SLOT(psMacSelectAll()), QKeySequence::SelectAll);

	QMenu *window = psMainMenu.addMenu(lang(lng_mac_menu_window));
	psContacts = window->addAction(lang(lng_mac_menu_contacts), App::wnd()->getTitle(), SLOT(onContacts()));
	psAddContact = window->addAction(lang(lng_mac_menu_add_contact), App::wnd(), SLOT(onShowAddContact()));
	window->addSeparator();
	psNewGroup = window->addAction(lang(lng_mac_menu_new_group), App::wnd(), SLOT(onShowNewGroup()));
	psNewChannel = window->addAction(lang(lng_mac_menu_new_channel), App::wnd(), SLOT(onShowNewChannel()));
	window->addSeparator();
	psShowTelegram = window->addAction(lang(lng_mac_menu_show), App::wnd(), SLOT(showFromTray()));

	psMacUpdateMenu();
}
Exemplo n.º 3
0
void Window::toggleTray(QSystemTrayIcon::ActivationReason reason) {
	if (reason != QSystemTrayIcon::Context) {
		if (psIsActive()) {
			minimizeToTray();
		} else {
			showFromTray(reason);
		}
	}
}
Exemplo n.º 4
0
void Window::toggleTray(QSystemTrayIcon::ActivationReason reason) {
	if (cPlatform() == dbipMac && psIsActive()) return;
	if (reason == QSystemTrayIcon::Context) {
		updateTrayMenu(true);
		QTimer::singleShot(1, this, SLOT(psShowTrayMenu()));
	} else {
		if (psIsActive()) {
			minimizeToTray();
		} else {
			showFromTray(reason);
		}
	}
}
Exemplo n.º 5
0
void Window::setupTrayIcon() {
	if (!trayIcon) {
		if (trayIconMenu) trayIconMenu->deleteLater();
		trayIconMenu = new QMenu(this);
		trayIconMenu->setFont(QFont("Tahoma"));
		QAction *a;
		a = trayIconMenu->addAction(lang(lng_open_from_tray), this, SLOT(showFromTray()));
		a->setEnabled(true);
		a = trayIconMenu->addAction(lang(lng_quit_from_tray), this, SLOT(quitFromTray()));
		a->setEnabled(true);

		if (trayIcon) trayIcon->deleteLater();
		trayIcon = new QSystemTrayIcon(this);
		trayIcon->setIcon(this->windowIcon());
		trayIcon->setContextMenu(trayIconMenu);
		trayIcon->setToolTip(QString::fromStdWString(AppName));

		connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(toggleTray(QSystemTrayIcon::ActivationReason)));
		connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(showFromTray()));
	}
	psUpdateCounter();
	trayIcon->show();
}	
Exemplo n.º 6
0
void Window::firstShow() {
#ifdef Q_OS_WIN
    trayIconMenu = new ContextMenu(this);
#else
	trayIconMenu = new QMenu(this);
	trayIconMenu->setFont(QFont("Tahoma"));
#endif
    if (cPlatform() == dbipWindows || cPlatform() == dbipMac) {
        trayIconMenu->addAction(lang(lng_minimize_to_tray), this, SLOT(minimizeToTray()))->setEnabled(true);
        trayIconMenu->addAction(lang(lng_quit_from_tray), this, SLOT(quitFromTray()))->setEnabled(true);
    } else {
        trayIconMenu->addAction(lang(lng_open_from_tray), this, SLOT(showFromTray()))->setEnabled(true);
        trayIconMenu->addAction(lang(lng_minimize_to_tray), this, SLOT(minimizeToTray()))->setEnabled(true);
        trayIconMenu->addAction(lang(lng_quit_from_tray), this, SLOT(quitFromTray()))->setEnabled(true);
    }

	psFirstShow();

	updateTrayMenu();
}
Exemplo n.º 7
0
void Window::showSettings() {
	if (isHidden()) showFromTray();

	App::wnd()->hideLayer();
	if (settings) {
		return hideSettings();
	}
	QPixmap bg = myGrab(this, QRect(0, st::titleHeight, width(), height() - st::titleHeight));

	if (intro) {
		anim::stop(intro);
		intro->hide();
	} else if (main) {
		anim::stop(main);
		main->hide();
	}
	settings = new SettingsWidget(this);
	settings->animShow(bg);

	fixOrder();
}
Exemplo n.º 8
0
void PsMainWindow::psSetupTrayIcon() {
    if (noQtTrayIcon) {
        if (!cSupportTray()) return;
        psUpdateCounter();
    } else {
        if (!trayIcon) {
            trayIcon = new QSystemTrayIcon(this);

            QIcon icon(QPixmap::fromImage(App::wnd()->iconLarge(), Qt::ColorOnly));

            trayIcon->setIcon(icon);
            trayIcon->setToolTip(QString::fromStdWString(AppName));
            connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(toggleTray(QSystemTrayIcon::ActivationReason)), Qt::UniqueConnection);
            connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(showFromTray()));
            App::wnd()->updateTrayMenu();
        }
        psUpdateCounter();

        trayIcon->show();
        psUpdateDelegate();
    }
}
Exemplo n.º 9
0
void Window::setupTrayIcon() {
	if (!trayIcon) {
		if (trayIcon) trayIcon->deleteLater();
		trayIcon = new QSystemTrayIcon(this);
#ifdef Q_OS_MAC
		QIcon icon(QPixmap::fromImage(psTrayIcon()));
		icon.addPixmap(QPixmap::fromImage(psTrayIcon(true)), QIcon::Selected);
#else
		QIcon icon(QPixmap::fromImage(iconLarge()));
#endif

		trayIcon->setIcon(icon);
		trayIcon->setToolTip(QString::fromStdWString(AppName));
		connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(toggleTray(QSystemTrayIcon::ActivationReason)), Qt::UniqueConnection);
		if (cPlatform() != dbipMac) {
			connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(showFromTray()));
		}
		updateTrayMenu();
	}
	psUpdateCounter();

	trayIcon->show();
	psUpdateDelegate();
}
Exemplo n.º 10
0
void Window::onShowNewGroup() {
	if (isHidden()) showFromTray();

	if (main) main->showNewGroup();
}
Exemplo n.º 11
0
void Window::onShowAddContact() {
	if (isHidden()) showFromTray();

	if (main) main->showAddContact();
}