Exemple #1
0
void KviMainWindow::changeEvent(QEvent * e)
{
#ifndef COMPILE_ON_MAC
	// For Qt5 this should be used to minimize to tray
	if(
			(e->type() == QEvent::WindowStateChange) &&
			(windowState() & Qt::WindowMinimized) &&
			KVI_OPTION_BOOL(KviOption_boolMinimizeInTray) &&
			e->spontaneous()
		)
	{
		
		if(!trayIcon())
		{
			executeInternalCommand(KVI_INTERNALCOMMAND_TRAYICON_SHOW);
		}
		if(trayIcon())
		{
			QWindowStateChangeEvent * ev = (QWindowStateChangeEvent *)e;
			KVI_OPTION_BOOL(KviOption_boolFrameIsMaximized) = ev->oldState() & Qt::WindowMaximized;
			QTimer::singleShot( 0, this, SLOT(hide()) );
		}
		return;
	}
#endif
	if (e->type() == QEvent::ActivationChange)
	{
		//WINDOW (DE)ACTIVATION
		// if we have just been activated by the WM
		// then update the active window task bar item
		// It will then reset its highlight state
		// and hopefully make the dock widget work correctly
		// in this case.
		// This will also trigger the OnWindowActivated event :)
		if(isActiveWindow())
		{
			if(g_pActiveWindow)
				childWindowActivated(g_pActiveWindow, true);
		} else {
			if(g_pActiveWindow)
				g_pActiveWindow->lostUserFocus();
		}
	}
	KviTalMainWindow::changeEvent(e);
}
Exemple #2
0
// For Qt4, see changeEvent method for Qt5
void KviMainWindow::hideEvent(QHideEvent * e)
{
#ifndef COMPILE_ON_MAC
	if(KVI_OPTION_BOOL(KviOption_boolMinimizeInTray) && e->spontaneous())
	{
		if(!trayIcon())
		{
			executeInternalCommand(KVI_INTERNALCOMMAND_TRAYICON_SHOW);
		}
		if(trayIcon())
		{
			KVI_OPTION_BOOL(KviOption_boolFrameIsMaximized) = isMaximized();
			QTimer::singleShot(0, this, SLOT(hide()));
		}
		return;
	}
#endif
}
void WindowsPlatformIntegration::showNotification(Notification *notification)
{
	TrayIcon *trayIcon(Application::getInstance()->getTrayIcon());

	if (trayIcon && QSystemTrayIcon::supportsMessages())
	{
		trayIcon->showMessage(notification);
	}
	else
	{
		NotificationDialog *dialog(new NotificationDialog(notification));
		dialog->show();
	}
}
Exemple #4
0
void KviMainWindow::closeEvent(QCloseEvent * e)
{
	//check if the user just want us to minimize in tray; if we're not the sender
	//of this signal (sender!=0), it has been generated by a "quit" action in a menu
	if(KVI_OPTION_BOOL(KviOption_boolCloseInTray) && QObject::sender() == nullptr && e->spontaneous())
	{
		if(!trayIcon())
		{
			executeInternalCommand(KVI_INTERNALCOMMAND_TRAYICON_SHOW);
		}
		if(trayIcon())
		{
			e->ignore();
			KVI_OPTION_BOOL(KviOption_boolFrameIsMaximized) = isMaximized();
			QTimer::singleShot(0, this, SLOT(hide()));
		}
		return;
	}

	if(KVI_OPTION_BOOL(KviOption_boolConfirmCloseWhenThereAreConnections))
	{
		// check for running connections
		bool bGotRunningConnection = false;
		for(KviWindow * w = m_pWinList->first(); w; w = m_pWinList->next())
		{
			if(w->type() == KviWindow::Console)
			{
				if(((KviConsoleWindow *)w)->connectionInProgress())
				{
					bGotRunningConnection = true;
					break;
				}
			}
		}

		if(bGotRunningConnection)
		{
			QString txt;
			txt += __tr2qs("There are active connections, are you sure you wish to quit KVIrc?");

			switch(QMessageBox::warning(this, __tr2qs("Confirm Close - KVIrc"), txt, __tr2qs("&Yes"), __tr2qs("&Always"), __tr2qs("&No"), 2, 2))
			{
				case 0:
					// ok to close
					break;
				case 1:
					// ok to close but don't ask again
					KVI_OPTION_BOOL(KviOption_boolConfirmCloseWhenThereAreConnections) = false;
					break;
				case 2:
					e->ignore();
					return;
					break;
			}
		}
	}

	e->accept();

	if(g_pApp)
	{
		g_pApp->setKviClosingDown();
		g_pApp->quit();
	}
}
Exemple #5
0
int main (int argc, char *argv[])
{
	bindtextdomain(PACKAGE, Tools::getDirPath("locale").c_str());
	bind_textdomain_codeset(PACKAGE, CODEC);
	textdomain(PACKAGE);
#ifndef IS_GTK_2
	Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.alsavolume");
	Glib::ustring slider_ui_ = Tools::getResPath("gladefiles/SliderFrame.glade");
	Glib::ustring settings_ui_ = Tools::getResPath("gladefiles/SettingsFrame.glade");
#else
	Gtk::Main app(argc, argv);
	Glib::ustring slider_ui_ = Tools::getResPath("gladefiles/SliderFrame_2.glade");
	Glib::ustring settings_ui_ = Tools::getResPath("gladefiles/SettingsFrame_2.glade");
#endif
	if (slider_ui_.empty()) {
		std::cerr << "No SliderFrame.glade file found" << std::endl;
		return 1;
	}
	if (settings_ui_.empty()) {
		std::cerr << "No SettingsFrame.glade file found" << std::endl;
		return 1;
	}
	Glib::RefPtr<Gtk::Builder> refBuilder = Gtk::Builder::create();
	try {
		refBuilder->add_from_file(slider_ui_);
		refBuilder->add_from_file(settings_ui_);
	}
	catch(const Gtk::BuilderError& ex) {
		std::cerr << "BuilderError::main.cpp::62 " << ex.what() << std::endl;
		return 1;
	}
	catch(const Glib::MarkupError& ex) {
		std::cerr << "MarkupError::main.cpp::62 " << ex.what() << std::endl;
		return 1;
	}
	catch(const Glib::FileError& ex) {
		std::cerr << "FileError::main.cpp::62 " << ex.what() << std::endl;
		return 1;
	}
	Core::Ptr core(new Core(refBuilder));
#ifndef IS_GTK_2
	app->hold();
#endif
	SliderWindow *sliderWindow = 0;
	refBuilder->get_widget_derived("volumeFrame", sliderWindow);
	TrayIcon::Ptr trayIcon(new TrayIcon(core->getVolumeValue(),
					    core->getSoundCardName(),
					    core->getActiveMixer(),
					    core->getMuted()));
	if (trayIcon && sliderWindow) {
		sliderWindow->setVolumeValue(core->getVolumeValue());
		core->signal_value_changed().connect(sigc::mem_fun(*trayIcon, &TrayIcon::on_signal_volume_changed));
		core->signal_mixer_muted().connect(sigc::mem_fun(*trayIcon, &TrayIcon::setMuted));
		core->signal_volume_changed().connect(sigc::mem_fun(*sliderWindow, &SliderWindow::setVolumeValue));
		sliderWindow->signal_volume_changed().connect(sigc::mem_fun(*core, &Core::onVolumeSlider));
		trayIcon->signal_ask_dialog().connect(sigc::mem_fun(*core, &Core::runAboutDialog));
		trayIcon->signal_ask_settings().connect(sigc::mem_fun(*core, &Core::runSettings));
		trayIcon->signal_on_restore().connect(sigc::mem_fun(*sliderWindow, &SliderWindow::setWindowPosition));
		trayIcon->signal_save_settings().connect(sigc::mem_fun(*core, &Core::saveSettings));
		trayIcon->signal_on_mute().connect(sigc::mem_fun(*core, &Core::soundMuted));
		trayIcon->signal_value_changed().connect(sigc::mem_fun(*core, &Core::onTrayIconScroll));
		sliderWindow->set_visible(false);
#ifndef IS_GTK_2
		return app->run();
#else
		Gtk::Main::run();
#endif
	}
	delete sliderWindow;
	return 0;
}