Пример #1
0
void KviMainWindow::updatePseudoTransparency()
{
#ifdef COMPILE_PSEUDO_TRANSPARENCY
	uint uOpacity = KVI_OPTION_UINT(KviOption_uintGlobalWindowOpacityPercent) < 50 ? 50 : KVI_OPTION_UINT(KviOption_uintGlobalWindowOpacityPercent);
	setWindowOpacity((float)uOpacity / 100);
#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)
#ifndef Q_WS_EX_LAYERED
#define Q_WS_EX_LAYERED WS_EX_LAYERED
#endif
	if(uOpacity < 100)
	{
		SetWindowLong(reinterpret_cast<HWND>(effectiveWinId()), GWL_EXSTYLE,
		    GetWindowLong(reinterpret_cast<HWND>(effectiveWinId()), GWL_EXSTYLE) | Q_WS_EX_LAYERED);
	}
	else
	{
		SetWindowLong(reinterpret_cast<HWND>(effectiveWinId()), GWL_EXSTYLE,
		    GetWindowLong(reinterpret_cast<HWND>(effectiveWinId()), GWL_EXSTYLE) & ~Q_WS_EX_LAYERED);
	}
#endif
	if(g_pShadedParentGlobalDesktopBackground)
		m_pWindowStack->update();

	if(g_pShadedChildGlobalDesktopBackground)
	{
		for(KviWindow * wnd = m_pWinList->first(); wnd; wnd = m_pWinList->next())
			wnd->updateBackgrounds();
		m_pWindowList->updatePseudoTransparency();
	}
#endif
}
Пример #2
0
void KviKvsAsyncDnsOperation::lookupTerminated(KviDnsResolver *)
{
	KviWindow * pWnd = window();
	if(!g_pApp->windowExists(pWnd))
		pWnd = g_pActiveWindow;

	if(m_pCallback)
	{
		KviKvsVariantList params;
		params.setAutoDelete(true);
		if(m_pDns->state() == KviDnsResolver::Failure)
		{
			params.append(new KviKvsVariant(m_szQuery));
			params.append(new KviKvsVariant((kvs_int_t)0));
			params.append(new KviKvsVariant(m_pDns->errorString()));
			params.append(new KviKvsVariant());
			params.append(new KviKvsVariant(*m_pMagic));
		}
		else
		{
			QString szHostName = m_pDns->hostName();
			const auto & strL = m_pDns->ipAddressList();
			const QString & fi = strL.empty() ? QString("?.?.?.?") : strL.front();

			params.append(new KviKvsVariant(m_szQuery));
			params.append(new KviKvsVariant((kvs_int_t)1));
			params.append(new KviKvsVariant(fi));
			params.append(new KviKvsVariant(szHostName.isEmpty() ? QString("?.?") : szHostName));
			params.append(new KviKvsVariant(*m_pMagic));
		}

		m_pCallback->run(pWnd, &params, nullptr, KviKvsScript::PreserveParams);

		delete this;
		return;
	}

	// we have no callback : output the results
	QString szQuery = m_pDns->query();
	pWnd->output(KVI_OUT_HOSTLOOKUP, __tr2qs_ctx("DNS lookup result for query \"%Q\"", "kvs"), &szQuery);

	if(m_pDns->state() == KviDnsResolver::Failure)
	{
		QString strDescription(m_pDns->errorString());
		pWnd->output(KVI_OUT_HOSTLOOKUP, __tr2qs_ctx("Error: %Q", "kvs"), &strDescription);
	}
	else
	{
		QString szHostName = m_pDns->hostName();
		pWnd->output(KVI_OUT_HOSTLOOKUP, __tr2qs_ctx("Hostname: %Q", "kvs"), &szHostName);
		int idx = 1;
		for(const auto & a : m_pDns->ipAddressList())
		{
			pWnd->output(KVI_OUT_HOSTLOOKUP, __tr2qs_ctx("IP address %d: %Q", "kvs"), idx, &a);
			idx++;
		}
	}

	delete this;
}
Пример #3
0
void ChannelsJoinDialog::regClicked()
{
	QString szTmp = m_pChannelEdit->text();

	if(szTmp.isEmpty())
		return;

	KviQString::escapeKvs(&szTmp);
	QString szCmd = "regchan.add ";
	szCmd += szTmp;

	KviConsoleWindow * c = g_pApp->topmostConnectedConsole();
	if(!c)
		return; // no connection

	KviWindow * w = g_pActiveWindow;
	if(w->console() != c)
		w = c;

	KviKvsScript::run(szCmd,w);
	fillListView();

	//focus the new item (in reality, the first matching one)
	QList<QTreeWidgetItem*> items = m_pTreeWidget->findItems(szTmp, Qt::MatchRecursive | Qt::MatchExactly);
	if(!items.empty())
	{
		m_pTreeWidget->setCurrentItem(items.first());
		m_pTreeWidget->scrollToItem(items.first());
	}
}
Пример #4
0
void ChannelsJoinDialog::joinClicked()
{
	QString szPass = m_pPass->text();
	QString szTmp = m_pChannelEdit->text();

	if(szTmp.isEmpty())
		return;

	KviQString::escapeKvs(&szTmp);
	KviQString::escapeKvs(&szPass);

	QString szCmd = "join ";
	szCmd += szTmp;
	szCmd += " ";
	szCmd += szPass;

	KviConsoleWindow * c = g_pApp->topmostConnectedConsole();
	if(!c)
		return; // no connection

	KviWindow * w = g_pActiveWindow;
	if(w->console() != c)
		w = c;

	KviKvsScript::run(szCmd,w);

	m_pChannelEdit->setText("");
	m_pPass->setText("");
}
Пример #5
0
void HttpFileTransfer::transferTerminated(bool bSuccess)
{
	KviWindow * out = transferWindow();

	m_tTransferEndTime = kvi_unixTime();

	KviKvsVariantList vParams;
	vParams.append(bSuccess);
	vParams.append(new KviKvsVariant(m_pHttpRequest->url().url(), true));
	vParams.append(new KviKvsVariant(m_pHttpRequest->fileName(), true));
	vParams.append(new KviKvsVariant(m_vMagicIdentifier));

	if(m_szCompletionCallback.isNull())
	{
		KVS_TRIGGER_EVENT(KviEvent_OnHTTPGetTerminated,out ? out : (KviWindow *)(g_pApp->activeConsole()),&vParams)
	} else {
		KviKvsScript::run(m_szCompletionCallback,out ? out : (KviWindow *)(g_pApp->activeConsole()),&vParams);
	}

	if(bSuccess)
	{
		m_szStatusString = __tr2qs_ctx("Transfer completed","http");
		m_eGeneralStatus = Success;
		displayUpdate();
		if(out && (!m_bNoOutput))out->output(KVI_OUT_GENERICSUCCESS,__tr2qs_ctx("[HTTP %d]: Transfer completed","http"),id());
		g_pApp->fileDownloadTerminated(
				true,
				m_pHttpRequest->url().url(),
				m_pHttpRequest->fileName(),
				QString(),
				QString(),
				!m_bNotifyCompletion
			);
	} else {
		m_szStatusString = __tr2qs_ctx("Transfer failed","http");
		m_szStatusString += ": ";
		m_szStatusString += m_pHttpRequest->lastError();
		m_eGeneralStatus = Failure;
		displayUpdate();
		if(out && (!m_bNoOutput))out->output(KVI_OUT_GENERICERROR,__tr2qs_ctx("[HTTP %d]: Transfer failed: %Q","http"),id(),&(m_pHttpRequest->lastError()));
		g_pApp->fileDownloadTerminated(
				false,
				m_pHttpRequest->url().url(),
				m_pHttpRequest->fileName(),
				QString(),
				m_pHttpRequest->lastError(),
				!m_bNotifyCompletion
			);
	}

	if(m_bAutoClean)
	{
		if(m_pAutoCleanTimer)delete m_pAutoCleanTimer;
		m_pAutoCleanTimer = new QTimer();
		connect(m_pAutoCleanTimer,SIGNAL(timeout()),this,SLOT(autoClean()));
		m_pAutoCleanTimer->start(100);
		m_TimerId=m_pAutoCleanTimer->timerId();
	}
}
Пример #6
0
KviMainWindow::~KviMainWindow()
{
	KVI_OPTION_BOOL(KviOption_boolFrameIsMaximized) = isMaximized();
	KVI_OPTION_RECT(KviOption_rectFrameGeometry) = QRect(pos().x(), pos().y(),
	    size().width(), size().height());

	KVI_OPTION_BOOL(KviOption_boolStatusBarVisible) = m_pStatusBar ? true : false;

	KviCustomToolBarManager::instance()->storeVisibilityState();

	saveToolBarPositions();
	saveModuleExtensionToolBars();

	// Call the frame destructor callback AFTER saving the toolbar positions
	// This is because the destructor callback kills alls the KVS objects
	// and thus the eventual user toolbar objects too and their position
	// wouldn't be saved if they are shown at startup.

	g_pApp->frameDestructorCallback();

	// Now start killing stuff

	// Explicitly kill all the module extension toolbars: qt has NOT to delete them: we must call their "die" method
	while(KviMexToolBar * t = m_pModuleExtensionToolBarList->first())
		t->die();
	delete m_pModuleExtensionToolBarList;

	KVI_OPTION_BOOL(KviOption_boolShowDockExtension) = m_pTrayIcon != nullptr;

	if(m_pTrayIcon)
	{
		m_pTrayIcon->die();
		m_pTrayIcon = nullptr;
	}

	if(m_pStatusBar)
	{
		delete m_pStatusBar;
		m_pStatusBar = nullptr;
	}

	//close all not console windows
	for(int i = m_pWinList->count() - 1; i >= 0; --i)
	{
		KviWindow * wnd = m_pWinList->at(i);
		if(wnd->type() != KviWindow::Console)
			closeWindow(wnd);
	}

	// close all the remaining windows (consoles)
	while(m_pWinList->first())
		closeWindow(m_pWinList->first());

	delete m_pWinList;
	delete m_pAccellerators;

	g_pMainWindow = nullptr;
}
Пример #7
0
unsigned int KviMainWindow::consoleCount()
{
	unsigned int count = 0;
	for(KviWindow * wnd = m_pWinList->first();wnd;wnd = m_pWinList->next())
	{
		if (wnd) if(wnd->type() == KviWindow::Console) count++;
	}
	return count;
}
Пример #8
0
void KviWindowStack::fillWindowPopup()
{
	m_pWindowPopup->clear();

	int i = 100;
	QString szItem;
	QString szCaption;

	KviWindow * pWnd;

	QAction * pAction;

	int idx = 0;
	int cnt = count();

	while(idx < cnt)
	{
		QWidget * w = widget(idx);
		if(!w->inherits("KviWindow"))
		{
			idx++;
			continue;
		}

		pWnd = (KviWindow *)w;

		szItem.setNum(((uint)idx)+1);
		szItem+=". ";

		szCaption = pWnd->windowTitle();
		if(szCaption.length() > 30)
		{
			QString trail = szCaption.right(12);
			szCaption.truncate(12);
			szCaption+="...";
			szCaption+=trail;
		}

		szItem+=szCaption;

		const QPixmap * pix = pWnd->myIconPtr();

		if (pix && !(pix->isNull()))
			pAction = m_pWindowPopup->addAction(*pix, szItem);
		else
			pAction = m_pWindowPopup->addAction(szItem);

		pAction->setData(idx);

		if(w == currentWidget())
			pAction->setChecked(true);

		idx++;
	}

}
Пример #9
0
void KviWindow::internalOutput(KviIrcView * pView, int iMsgType, const kvi_wchar_t * pwText, int iFlags)
{
    // all roads lead to Rome :)

    if(pView)
    {
        if(!hasAttention())
        {
            iFlags |= KviIrcView::TriggersNotification;
            if(!pView->hasLineMark())
            {
                iFlags |= KviIrcView::SetLineMark;
            }
        }
        pView->appendText(iMsgType,pwText,iFlags);
    } else {
        // Redirect to the output proxy
        KviWindow * pWnd = outputProxy();
        if(pWnd)
            pWnd->outputNoFmt(iMsgType,pwText,iFlags);
    }

    if(!m_pWindowListItem)
        return;

    // if this option is checked we don't highlight other than channel msg
    if(KVI_OPTION_BOOL(KviOption_boolHighlightOnlyNormalMsg))
    {
        if((iMsgType != KVI_OUT_CHANPRIVMSG) && (iMsgType != KVI_OUT_CHANPRIVMSGCRYPTED))
        {
            if(!(
                        (
                            KVI_OPTION_BOOL(KviOption_boolHighlightOnlyNormalMsgQueryToo) &&
                            (
                                (iMsgType == KVI_OUT_QUERYPRIVMSG) || (iMsgType == KVI_OUT_QUERYTRACE) ||
                                (iMsgType == KVI_OUT_QUERYPRIVMSGCRYPTED) || (iMsgType == KVI_OUT_QUERYNOTICE) || (iMsgType == KVI_OUT_QUERYNOTICECRYPTED)
                            )
                        )
                        ||
                        (
                            KVI_OPTION_BOOL(KviOption_boolHighlightOnlyNormalMsgHighlightInChanToo) && (iMsgType == KVI_OUT_HIGHLIGHT)
                        )
                    )
              )
                return;
        }
    }

    if(KVI_OPTION_BOOL(KviOption_boolHighlightOnlyAtCostumHighlightLevel) &&
            (KVI_OPTION_MSGTYPE(iMsgType).level() < ((int)(KVI_OPTION_UINT(KviOption_uintMinHighlightLevel)))))
    {
        return;
    }

    m_pWindowListItem->highlight(KVI_OPTION_MSGTYPE(iMsgType).level());
}
Пример #10
0
void KviMdiChild::closeEvent(QCloseEvent * e)
{
	//we let kviwindow handle the process
	KviWindow * pClient = (KviWindow*) widget();
	if(pClient)
	{
		e->ignore();
		pClient->delayedClose();
	}
}
Пример #11
0
void KviMainWindow::applyOptions()
{
	m_pMdi->update();

	for(KviWindow * wnd = m_pWinList->first();wnd;wnd = m_pWinList->next())
		wnd->applyOptions();

	m_pWindowList->applyOptions();
	g_pTextIconManager->applyOptions();
}
Пример #12
0
KviConsoleWindow * KviMainWindow::firstConsole()
{
	for(KviWindow * wnd = m_pWinList->first(); wnd; wnd = m_pWinList->next())
	{
		if(wnd->type() == KviWindow::Console)
			return (KviConsoleWindow *)wnd;
	}

	// We end up here when we have not console windows.
	// This may happen at early startup or late before shutdown.
	return nullptr;
}
Пример #13
0
KviConsoleWindow * KviMainWindow::firstNotConnectedConsole()
{
	for(KviWindow * wnd = m_pWinList->first(); wnd; wnd = m_pWinList->next())
	{
		if(wnd->type() == KviWindow::Console)
		{
			if(!((KviConsoleWindow *)wnd)->connectionInProgress())
				return (KviConsoleWindow *)wnd;
		}
	}
	return nullptr;
}
Пример #14
0
void KviNotifyListManager::notifyOffLine(const QString & szNick, const QString & szUser, const QString & szHost, const QString & szReason)
{
	KviWindow * pOut = KVI_OPTION_BOOL(KviOption_boolNotifyListChangesToActiveWindow) ? m_pConsole->activeWindow() : m_pConsole;
	if(!KVS_TRIGGER_EVENT_1_HALTED(KviEvent_OnNotifyOffLine, pOut, szNick))
	{
		QString szWho;

		if(!(szUser.isEmpty() || szHost.isEmpty()))
			szWho = QString("\r!n\r%1\r [%2@\r!h\r%3\r]").arg(szNick, szUser, szHost);
		else
			szWho = QString("\r!n\r%1\r").arg(szNick);

		QString szMsg;

		KviPointerHashTable<QString, KviRegisteredUser> * d = g_pRegisteredUserDataBase->userDict();
		KviPointerHashTableIterator<QString, KviRegisteredUser> it(*d);

		while(KviRegisteredUser * pUser = it.current())
		{
			QString szProp = pUser->getProperty("notify");
			if(!szProp.isEmpty())
			{
				if(szProp.split(",", QString::SkipEmptyParts).indexOf(szNick) != -1)
				{
					QString szComment = pUser->getProperty("comment");
					if(!szComment.isEmpty())
						szMsg = QString("%1 (%2), Group \"%3\" has left IRC as (%4)").arg(pUser->name(), szComment, pUser->group(), szWho);
					else
						szMsg = QString("%1, Group \"%2\" has left IRC as (%3)").arg(pUser->name(), pUser->group(), szWho);
					break;
				}
			}
			++it;
		}

		if(szMsg.isEmpty())
			szMsg = QString(__tr2qs("%1 has left IRC")).arg(szWho);

		if((!szReason.isEmpty()) && (_OUTPUT_VERBOSE))
		{
			szMsg += "(";
			szMsg += szReason;
			szMsg += ")";
		}

		pOut->outputNoFmt(KVI_OUT_NOTIFYOFFLINE, szMsg);
	}

	m_pConsole->notifyListView()->part(szNick);
}
Пример #15
0
void KviMainWindow::applyOptions()
{
	m_pWindowStack->update();

	for(KviWindow * wnd = m_pWinList->first(); wnd; wnd = m_pWinList->next())
		wnd->applyOptions();

	m_pWindowList->applyOptions();
	g_pTextIconManager->applyOptions();

#ifndef COMPILE_ON_MAC
	m_pMenuBar->setVisible(KVI_OPTION_BOOL(KviOption_boolMenuBarVisible));
#endif
}
Пример #16
0
void ChannelsJoinDialog::clearClicked()
{
	QString szCmd = "option stringlistRecentChannels";

	KviConsoleWindow * c = g_pApp->topmostConnectedConsole();
	if(!c)
		return; // no connection

	KviWindow * w = g_pActiveWindow;
	if(w->console() != c)
		w = c;

	KviKvsScript::run(szCmd,w);
	fillListView();
}
Пример #17
0
void UrlDialog::sayToWin(QAction * act)
{
	KviWindow *wnd = g_pApp->findWindowByCaption(act->text());
	if(wnd)
	{
		QString szUrl = m_szUrl;
		QString szWindow = wnd->windowName();
		KviQString::escapeKvs(&szUrl);
		KviQString::escapeKvs(&szWindow);
		QString say=QString("PRIVMSG %1 %2").arg(szWindow, szUrl);
		KviKvsScript::run(say,wnd);
		g_pMainWindow->setActiveWindow(wnd);
	} else {
		QMessageBox::warning(0,__tr2qs("Warning - KVIrc"),__tr2qs("Window not found."),QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
	}
}
Пример #18
0
void HttpFileTransfer::headersReceived(KviPointerHashTable<const char *,KviCString> *h)
{
	if(!h)return;
	KviWindow * out = transferWindow();

	if(out && (!m_bNoOutput))out->output(KVI_OUT_GENERICSTATUS,__tr2qs_ctx("[HTTP %d]: response headers:","http"),id());
	KviPointerHashTableIterator<const char *,KviCString> it(*h);
	while(KviCString * s = it.current())
	{
		QString szHeader = it.currentKey();
		szHeader += ": ";
		szHeader += s->ptr();
		m_lHeaders.append(szHeader);
		if(out && (!m_bNoOutput))out->output(KVI_OUT_GENERICSTATUS,"[HTTP %d]:   %s: %s",id(),it.currentKey(),s->ptr());
		++it;
	}
}
Пример #19
0
void KviMainWindow::recreateWindowList()
{
	KviWindow * w;
	for(w = m_pWinList->first(); w; w = m_pWinList->next())
	{
		w->destroyWindowListItem();
	}

	createWindowList();

	for(w = m_pWinList->first(); w; w = m_pWinList->next())
	{
		w->createWindowListItem();
	}

	if(g_pActiveWindow)
		m_pWindowList->setActiveItem(g_pActiveWindow->windowListItem());
}
Пример #20
0
void HttpFileTransfer::requestSent(const QStringList &requestHeaders)
{
	m_szStatusString = __tr2qs_ctx("Request sent: waiting for reply...","http");
	displayUpdate();

	KviWindow * out = transferWindow();
	if(!out)return;

	if(!m_bNoOutput)
		out->output(KVI_OUT_GENERICSTATUS,__tr2qs_ctx("[HTTP %d]: Request data sent:","http"),id());

	for(QStringList::ConstIterator it = requestHeaders.begin();it != requestHeaders.end();++it)
	{
		if(!m_bNoOutput)
			out->output(KVI_OUT_GENERICSTATUS,"[HTTP %d]:   %s",id(),(*it).toUtf8().data());
	}

	m_lRequest = requestHeaders;
}
Пример #21
0
void UrlDialog::popup(QTreeWidgetItem * item, const QPoint & point)
{
    m_szUrl = item->text(0);
    QMenu p("menu", nullptr);
    p.addAction(__tr2qs("&Remove"), this, SLOT(remove()));

    p.addSeparator();
    m_pListPopup = new QMenu("list", nullptr);

    for(KviWindow * w = g_pMainWindow->windowList()->first(); w; w = g_pMainWindow->windowList()->next())
    {
        if((w->type() == KviWindow::Channel) || (w->type() == KviWindow::Query) || (w->type() == KviWindow::DccChat))
        {
            m_pListPopup->addAction(w->plainTextCaption());
        }
    }
    p.addAction(__tr2qs("&Say to Window"))->setMenu(m_pListPopup);
    connect(m_pListPopup, SIGNAL(triggered(QAction *)), this, SLOT(sayToWin(QAction *)));
    p.exec(point);
}
Пример #22
0
void KviNotifyListManager::notifyOnLine(const QString & szNick, const QString & szUser, const QString & szHost, const QString & szReason, bool bJoin)
{
	if(bJoin)
		m_pConsole->notifyListView()->join(szNick, szUser, szHost);

	KviWindow * pOut = KVI_OPTION_BOOL(KviOption_boolNotifyListChangesToActiveWindow) ? m_pConsole->activeWindow() : m_pConsole;
	if(KVS_TRIGGER_EVENT_1_HALTED(KviEvent_OnNotifyOnLine, pOut, szNick))
		return;

	QString szWho;
	QString szMsg;

	if(!(szUser.isEmpty() || szHost.isEmpty()))
		szWho = QString("\r!n\r%1\r [%2@\r!h\r%3\r]").arg(szNick, szUser, szHost);
	else
		szWho = QString("\r!n\r%1\r").arg(szNick);

	KviPointerHashTable<QString, KviRegisteredUser> * d = g_pRegisteredUserDataBase->userDict();
	KviPointerHashTableIterator<QString, KviRegisteredUser> it(*d);

	while(KviRegisteredUser * pUser = it.current())
	{
		QString szProp = pUser->getProperty("notify");
		if(!szProp.isEmpty())
		{
			if(szProp.split(",", QString::SkipEmptyParts).indexOf(szNick) != -1)
			{
				QString szComment = pUser->getProperty("comment");
				if(!szComment.isEmpty())
					szMsg = QString("%1 (%2), Group \"%3\" is on IRC as (%4)").arg(pUser->name(), szComment, pUser->group(), szWho);
				else
					szMsg = QString("%1, Group \"%2\" is on IRC as (%3)").arg(pUser->name(), pUser->group(), szWho);
				break;
			}
		}
		++it;
	}

	QString szFmt = __tr2qs("%1 is on IRC");

	if(szMsg.isEmpty())
		szMsg = QString(szFmt).arg(szWho);

	if((!szReason.isEmpty()) && (_OUTPUT_VERBOSE))
	{
		szMsg += "(";
		szMsg += szReason;
		szMsg += ")";
	}

	pOut->outputNoFmt(KVI_OUT_NOTIFYONLINE, szMsg);

	if(!(pOut->hasAttention(KviWindow::MainWindowIsVisible)))
	{
		if(KVI_OPTION_BOOL(KviOption_boolFlashWindowOnNotifyOnLine))
			pOut->demandAttention();
		if(KVI_OPTION_BOOL(KviOption_boolPopupNotifierOnNotifyOnLine))
		{
			szWho = "<b>";
			szWho += szNick;
			szWho += "</b>";
			szMsg = QString(szFmt).arg(szWho);
			g_pApp->notifierMessage(pOut, KVI_OPTION_MSGTYPE(KVI_OUT_NOTIFYONLINE).pixId(), szMsg, KVI_OPTION_UINT(KviOption_uintNotifierAutoHideTime));
		}
	}
}
Пример #23
0
void HttpFileTransfer::statusMessage(const QString &txt)
{
	KviWindow * out = transferWindow();
	if(out && (!m_bNoOutput))
		out->output(KVI_OUT_GENERICSTATUS,"[HTTP %d]: %Q",id(),&txt);
}
Пример #24
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();
	}
}