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; }
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; }
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); }
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; }
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; }
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(); } }