diff options
| author | 2010-11-20 14:34:35 +0000 | |
|---|---|---|
| committer | 2010-11-20 14:34:35 +0000 | |
| commit | 5958a3b64b07290401bfa990060182d5efd41850 (patch) | |
| tree | e8982f423dcd8c649259d5e218baf4ca0bbf5829 /src | |
| parent | Fixed restore script dialog (diff) | |
| download | KVIrc-5958a3b64b07290401bfa990060182d5efd41850.tar.gz KVIrc-5958a3b64b07290401bfa990060182d5efd41850.tar.bz2 KVIrc-5958a3b64b07290401bfa990060182d5efd41850.zip | |
added $window.isDocked and window.savePropertiesAsDefault
removed hardcoded partAllChannels(), unhighlightAllWindows() and window "system popup" creation routines
binded windows "system popup"request with the OnWindowPopupRequest event
implemented all previous hardcoded functions in kvs in the (previously unused) "windowpopup" popup
implements #1021; you'll need to restore default scripts or add the popup manually
The first who opens a bug ticket because he missed to restore the scripts will win a puppy
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@5150 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src')
| -rw-r--r-- | src/kvirc/kernel/kvi_ircconnection.cpp | 9 | ||||
| -rw-r--r-- | src/kvirc/kernel/kvi_ircconnection.h | 24 | ||||
| -rw-r--r-- | src/kvirc/kernel/kvi_irccontext.cpp | 7 | ||||
| -rw-r--r-- | src/kvirc/kernel/kvi_irccontext.h | 1 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_console.cpp | 38 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_console.h | 1 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_frame.cpp | 6 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_frame.h | 4 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_mdichild.cpp | 10 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_mdichild.h | 2 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_window.cpp | 67 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_window.h | 7 | ||||
| -rw-r--r-- | src/modules/window/libkviwindow.cpp | 60 |
13 files changed, 79 insertions, 157 deletions
diff --git a/src/kvirc/kernel/kvi_ircconnection.cpp b/src/kvirc/kernel/kvi_ircconnection.cpp index 17bad0237..e72966135 100644 --- a/src/kvirc/kernel/kvi_ircconnection.cpp +++ b/src/kvirc/kernel/kvi_ircconnection.cpp @@ -579,15 +579,6 @@ void KviIrcConnection::unhighlightAllQueries() c->unhighlight(); } -void KviIrcConnection::partAllChannels() -{ - for(KviChannel * c = m_pChannelList->first(); c; c = m_pChannelList->next()) - { - c->close(); - QApplication::processEvents(QEventLoop::ExcludeSocketNotifiers & QEventLoop::ExcludeUserInputEvents); - } -} - void KviIrcConnection::closeAllChannels() { while(m_pChannelList->first()) diff --git a/src/kvirc/kernel/kvi_ircconnection.h b/src/kvirc/kernel/kvi_ircconnection.h index 1f1782472..c8850fb9a 100644 --- a/src/kvirc/kernel/kvi_ircconnection.h +++ b/src/kvirc/kernel/kvi_ircconnection.h @@ -217,7 +217,7 @@ public: * \return State */ inline State state(){ return m_eState; }; - + /** * \brief Returns a pointer to the big connection user database. * @@ -343,7 +343,7 @@ public: * \return KviRequestQueue * */ inline KviRequestQueue * requestQueue(){ return m_pRequestQueue; }; - + /** * \brief Returns the list of the channels bound to the current connection. * @@ -448,11 +448,17 @@ public: void keepChannelsOpenAfterDisconnect(); /** - * \brief Closes all the currently open channels not marked as dead). + * \brief Closes all the currently open channels not marked as dead. * \return void */ void closeAllChannels(); + /** + * \brief Closes all the currently open queries not marked as dead. + * \return void + */ + void closeAllQueries(); + // // Query management // @@ -866,12 +872,6 @@ private: void setupSrvCodec(); public slots: /** - * \brief Called when we parts from all channels - * \return void - */ - void partAllChannels(); - - /** * \brief Called when we unhighlight all channels * \return void */ @@ -888,12 +888,6 @@ public slots: * \return void */ void restartNotifyList(); - - /** - * \brief Called when we close all queries - * \return void - */ - void closeAllQueries(); private slots: /** * \brief Called when the hostname lookup is finished diff --git a/src/kvirc/kernel/kvi_irccontext.cpp b/src/kvirc/kernel/kvi_irccontext.cpp index 8cbc9be49..7ec3ca54c 100644 --- a/src/kvirc/kernel/kvi_irccontext.cpp +++ b/src/kvirc/kernel/kvi_irccontext.cpp @@ -127,11 +127,6 @@ KviIrcContext::~KviIrcContext() if(m_pSavedAsynchronousConnectionData)delete m_pSavedAsynchronousConnectionData; } -void KviIrcContext::unhighlightAllWindows() -{ - m_pFrame->unhighlightWindowsOfContext(this); -} - void KviIrcContext::registerDataStreamMonitor(KviIrcDataStreamMonitor * m) { if(!m_pMonitorList) @@ -442,7 +437,7 @@ void KviIrcContext::connectToCurrentServer() if(m_pSavedAsynchronousConnectionData->m_pReconnectInfo) m_pAsynchronousConnectionData->m_pReconnectInfo = new KviServerReconnectInfo(*(m_pSavedAsynchronousConnectionData->m_pReconnectInfo)); else m_pAsynchronousConnectionData->m_pReconnectInfo = 0; - + // and the other info, only if not overridden by the user if(m_pAsynchronousConnectionData->szBindAddress.isEmpty()) m_pAsynchronousConnectionData->szBindAddress = m_pSavedAsynchronousConnectionData->szBindAddress; diff --git a/src/kvirc/kernel/kvi_irccontext.h b/src/kvirc/kernel/kvi_irccontext.h index 1f0e36906..c2525ba93 100644 --- a/src/kvirc/kernel/kvi_irccontext.h +++ b/src/kvirc/kernel/kvi_irccontext.h @@ -183,7 +183,6 @@ signals: void stateChanged(); protected slots: void asynchronousConnect(); - void unhighlightAllWindows(); }; diff --git a/src/kvirc/ui/kvi_console.cpp b/src/kvirc/ui/kvi_console.cpp index 5401c51ea..53dcbbd4b 100644 --- a/src/kvirc/ui/kvi_console.cpp +++ b/src/kvirc/ui/kvi_console.cpp @@ -216,42 +216,6 @@ void KviConsole::triggerCreationEvents() KVS_TRIGGER_EVENT_0(KviEvent_OnIrcContextCreated,this); } -void KviConsole::fillContextPopup(KviTalPopupMenu * p) -{ - int id; - int cc = 0; - int qc = 0; - - if(connection()) - { - cc = connection()->channelList()->count(); - qc = connection()->queryList()->count(); - p->insertSeparator(); - id = p->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CHANNEL)),__tr2qs("Part All Channels"),connection(),SLOT(partAllChannels())); - if(!cc) - p->setItemEnabled(id,false); - id = p->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_QUERY)),__tr2qs("Close All Queries"),connection(),SLOT(closeAllQueries())); - if(!qc) - p->setItemEnabled(id,false); - } - - if(m_pContext->firstDeadChannel()) - p->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_DEADCHANNEL)),__tr2qs("Close All Dead Channels"),m_pContext,SLOT(closeAllDeadChannels())); - if(m_pContext->firstDeadQuery()) - p->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_DEADQUERY)),__tr2qs("Close All Dead Queries"),m_pContext,SLOT(closeAllDeadQueries())); - - p->insertSeparator(); - p->insertItem(__tr2qs("Unhighlight All Windows"),context(),SLOT(unhighlightAllWindows())); - - if(connection()) - { - id = p->insertItem(__tr2qs("Unhighlight All Channels"),connection(),SLOT(unhighlightAllChannels())); - if(!cc)p->setItemEnabled(id,false); - id = p->insertItem(__tr2qs("Unhighlight All Queries"),connection(),SLOT(unhighlightAllQueries())); - if(!qc)p->setItemEnabled(id,false); - } -} - void KviConsole::completeChannel(const QString &word,KviPointerList<QString> * matches) { // FIXME: first look in our context ? @@ -788,7 +752,7 @@ void KviConsole::outputPrivmsg(KviWindow *wnd, } pUserEntry->setSmartNickColor(sum); } - + szNick.prepend(KviNickColors::getSmartColor(sum)); } else { /* diff --git a/src/kvirc/ui/kvi_console.h b/src/kvirc/ui/kvi_console.h index f5a699b65..1e8a43be4 100644 --- a/src/kvirc/ui/kvi_console.h +++ b/src/kvirc/ui/kvi_console.h @@ -104,7 +104,6 @@ protected: virtual void closeEvent(QCloseEvent *e); virtual void getBaseLogFileName(QString &buffer); virtual void getWindowListTipText(QString &buffer); - virtual void fillContextPopup(KviTalPopupMenu * p); virtual QSize sizeHint() const; virtual void applyOptions(); virtual void triggerCreationEvents(); diff --git a/src/kvirc/ui/kvi_frame.cpp b/src/kvirc/ui/kvi_frame.cpp index 2a4b5ec97..0f351411f 100644 --- a/src/kvirc/ui/kvi_frame.cpp +++ b/src/kvirc/ui/kvi_frame.cpp @@ -639,12 +639,6 @@ void KviFrame::childWindowCloseRequest(KviWindow *wnd) closeWindow(wnd); } -void KviFrame::unhighlightWindowsOfContext(KviIrcContext * c) -{ - for(KviWindow *w = m_pWinList->first();w;w = m_pWinList->next()) - if(w->context() == c)w->unhighlight(); -} - void KviFrame::setActiveWindow(KviWindow *wnd) { // ASSERT(m_pWinList->findRef(wnd)) diff --git a/src/kvirc/ui/kvi_frame.h b/src/kvirc/ui/kvi_frame.h index d9b31147a..752017554 100644 --- a/src/kvirc/ui/kvi_frame.h +++ b/src/kvirc/ui/kvi_frame.h @@ -167,7 +167,7 @@ public: * \return void */ void setUsesBigPixmaps(bool bUse); - + public slots: void newConsole(); void executeInternalCommand(int index); @@ -179,8 +179,6 @@ protected: void registerModuleExtensionToolBar(KviMexToolBar * t); void unregisterModuleExtensionToolBar(KviMexToolBar * t); - void unhighlightWindowsOfContext(KviIrcContext * c); - void createWindowList(); void recreateWindowList(); diff --git a/src/kvirc/ui/kvi_mdichild.cpp b/src/kvirc/ui/kvi_mdichild.cpp index 286b6fea5..b93b988e9 100644 --- a/src/kvirc/ui/kvi_mdichild.cpp +++ b/src/kvirc/ui/kvi_mdichild.cpp @@ -43,6 +43,7 @@ #include "kvi_ircconnectiontarget.h" #include "kvi_irccontext.h" #include "kvi_network.h" +#include "kvi_kvs_eventtriggers.h" #ifdef COMPILE_ON_MAC #include "kvi_app.h" //Needed for g_pApp @@ -84,7 +85,7 @@ void KviMdiChild::transparencyWorkaround() { setAutoFillBackground(true); } - + void KviMdiChild::setRestoredGeometry(const QRect &r) { setGeometry(r); @@ -265,10 +266,7 @@ void KviMdiChild::updateSystemPopup() if(m_pClient->inherits("KviWindow")) { systemMenu()->clear(); - QMenu * tmp = ((KviWindow*) m_pClient)->generatePopup(); - if (tmp) - { - systemMenu()->addActions(tmp->actions()); - } + //FIXME this is an hack + KVS_TRIGGER_EVENT_0(KviEvent_OnWindowPopupRequest, ((KviWindow*) m_pClient)); } } diff --git a/src/kvirc/ui/kvi_mdichild.h b/src/kvirc/ui/kvi_mdichild.h index 65593b7f8..b152bfc05 100644 --- a/src/kvirc/ui/kvi_mdichild.h +++ b/src/kvirc/ui/kvi_mdichild.h @@ -221,7 +221,7 @@ private slots: * \return void */ void transparencyWorkaround(); - + }; #endif //_KVI_MDICHILD_H_ diff --git a/src/kvirc/ui/kvi_window.cpp b/src/kvirc/ui/kvi_window.cpp index 34eaded27..ec19c0946 100644 --- a/src/kvirc/ui/kvi_window.cpp +++ b/src/kvirc/ui/kvi_window.cpp @@ -533,7 +533,7 @@ void KviWindow::getDefaultLogFileName(QString &buffer) // FIXME: #warning "Make it configurable ?" QString szDate; QDate date(QDate::currentDate()); - + switch(KVI_OPTION_UINT(KviOption_uintOutputDatetimeFormat)) { case 0: @@ -730,64 +730,6 @@ void KviWindow::createSystemTextEncodingPopup() connect(g_pMdiWindowSystemTextEncodingPopupStandard,SIGNAL(activated(int)),this,SLOT(systemTextEncodingPopupStandardActivated(int))); } -KviTalPopupMenu * KviWindow::generatePopup() -{ - if(!g_pMdiWindowSystemMainPopup) - g_pMdiWindowSystemMainPopup = new KviTalPopupMenu(); - else - { - g_pMdiWindowSystemMainPopup->clear(); - g_pMdiWindowSystemMainPopup->disconnect(); - } - - if(mdiParent()) - g_pMdiWindowSystemMainPopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_UNDOCK)), - __tr2qs("&Undock"),this,SLOT(undock())); - else - g_pMdiWindowSystemMainPopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_DOCK)), - __tr2qs("&Dock"),this,SLOT(dock())); - - g_pMdiWindowSystemMainPopup->insertSeparator(); - - int id = g_pMdiWindowSystemMainPopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_MINIMIZE)), - __tr2qs("Mi&nimize"),this,SLOT(minimize())); - g_pMdiWindowSystemMainPopup->setItemEnabled(id,!isMinimized()); - id = g_pMdiWindowSystemMainPopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_MAXIMIZE)), - __tr2qs("Ma&ximize"),this,SLOT(maximize())); - g_pMdiWindowSystemMainPopup->setItemEnabled(id,!isMaximized()); - id = g_pMdiWindowSystemMainPopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_RESTORE)), - __tr2qs("&Restore"),this,SLOT(restore())); - g_pMdiWindowSystemMainPopup->setItemEnabled(id,isMinimized()||isMaximized()); - - g_pMdiWindowSystemMainPopup->insertSeparator(); - - g_pMdiWindowSystemMainPopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CLOSE)), - __tr2qs("Close"),this,SLOT(close())); - - g_pMdiWindowSystemMainPopup->insertSeparator(); - - if(m_pTextEncodingButton) - { - createSystemTextEncodingPopup(); - g_pMdiWindowSystemMainPopup->insertItem(__tr2qs("Text &Encoding"),g_pMdiWindowSystemTextEncodingPopup); - } // else we don't support setting private encoding anyway - - - g_pMdiWindowSystemMainPopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_XY)), - __tr2qs("Set Window Props as &default"),this,SLOT(savePropertiesAsDefault())); - - fillContextPopup(g_pMdiWindowSystemMainPopup); - - return g_pMdiWindowSystemMainPopup; -} - -void KviWindow::systemPopupRequest(const QPoint &pnt) -{ - generatePopup(); - - g_pMdiWindowSystemMainPopup->popup(pnt); -} - void KviWindow::systemTextEncodingPopupDefault() { // default @@ -837,12 +779,7 @@ void KviWindow::savePropertiesAsDefault() void KviWindow::contextPopup() { - systemPopupRequest(QCursor::pos()); -} - -void KviWindow::fillContextPopup(KviTalPopupMenu *) -{ - // nothing here + KVS_TRIGGER_EVENT_0(KviEvent_OnWindowPopupRequest,this); } void KviWindow::undock() diff --git a/src/kvirc/ui/kvi_window.h b/src/kvirc/ui/kvi_window.h index b3b22adbd..17f90f6c3 100644 --- a/src/kvirc/ui/kvi_window.h +++ b/src/kvirc/ui/kvi_window.h @@ -178,7 +178,6 @@ public: // The global ID of this window: unique in the application inline QString id(){ return QString("%1").arg(m_uId); }; inline unsigned long int numericId(){ return m_uId; }; - KviTalPopupMenu * generatePopup(); // THIS is the function that should be used inline const QString & windowName(){ return m_szName; }; @@ -266,7 +265,6 @@ public: void delayedClose(); // close that jumps out of the current event loop // Interesting overridables: - virtual void fillContextPopup(KviTalPopupMenu * p); virtual void getConfigGroupName(QString &buf); virtual void getBaseLogFileName(QString &buffer); virtual void updateCaption(); @@ -295,7 +293,7 @@ public: void listWindowTypes(); void activateSelf(); - + // call this in the constructor if your caption is fixed: // it will set m_szPlainTextCaption to szCaption and it will // automatically use it without the need of overriding fillCaptionBuffers @@ -308,13 +306,12 @@ public slots: void minimize(); void restore(); void reloadImages(); -protected slots: void savePropertiesAsDefault(); +protected slots: void toggleCryptController(); // This has to be here even if the crypt support is enabled...moc does not support conditionals void cryptControllerFinished(); // same as above void cryptSessionInfoDestroyed(); // same as above void textEncodingButtonClicked(); - void systemPopupRequest(const QPoint &pnt); void systemTextEncodingPopupSmartActivated(int id); void systemTextEncodingPopupSmartUtf8Activated(int id); void systemTextEncodingPopupStandardActivated(int id); diff --git a/src/modules/window/libkviwindow.cpp b/src/modules/window/libkviwindow.cpp index b9bcafc8c..1729c22ac 100644 --- a/src/modules/window/libkviwindow.cpp +++ b/src/modules/window/libkviwindow.cpp @@ -176,7 +176,7 @@ static bool window_kvs_cmd_close(KviKvsModuleCommandCall * c) no operation is performed. If the specified window does not exist a warning is printed unless the -q switch is used. @seealso: - [cmd]window.undock[/cmd] + [cmd]window.undock[/cmd], [fnc]$window.isDocked[/fnc] */ static bool window_kvs_cmd_dock(KviKvsModuleCommandCall * c) @@ -205,7 +205,7 @@ static bool window_kvs_cmd_dock(KviKvsModuleCommandCall * c) no operation is performed. If the specified window does not exist a warning is printed unless the -q switch is used. @seealso: - [cmd]window.dock[/cmd] + [cmd]window.dock[/cmd], [fnc]$window.isDocked[/fnc] */ static bool window_kvs_cmd_undock(KviKvsModuleCommandCall * c) @@ -480,6 +480,35 @@ static bool window_kvs_fnc_activityTemperature(KviKvsModuleFunctionCall * c) } /* + @doc: window.isDocked + @type: + function + @title: + $window.isDocked + @short: + Checks if a window is currently docked + @syntax: + $window.isDocked + $window.isDocked(<window_id>) + @description: + Returns 1 if the window specified by <window_id> is currently docked and 0 otherwise. + The form with no parameters works on the current window. If the specified window + doesn't exist then 0 is returned. + @seealso: + [cmd]window.dock[/cmd], [cmd]window.undock[/cmd] +*/ + +static bool window_kvs_fnc_isDocked(KviKvsModuleFunctionCall * c) +{ + GET_KVS_FNC_WINDOW_ID + if(pWnd) + { + c->returnValue()->setBoolean(pWnd->mdiParent() ? true : false); + } + return true; +} + +/* @doc: window.isMinimized @type: function @@ -1428,6 +1457,31 @@ static bool window_kvs_cmd_setBackground(KviKvsModuleCommandCall * c) [fnc]$asciiToHex[/fnc], [fnc]$features[/fnc] */ +/* + @doc: window.savePropertiesAsDefault + @type: + command + @title: + window.savePropertiesAsDefault + @short: + Saves the window properties as default + @syntax: + window.savePropertiesAsDefault [window_id] + @description: + Saves the window properties of the specified window as default for every window + of the same type (eg: all queries, all channels, ..). + If window_id is missing then the current window properties are used. +*/ + +static bool window_kvs_cmd_savePropertiesAsDefault(KviKvsModuleCommandCall * c) +{ + GET_KVS_WINDOW_ID + if(pWnd) + { + pWnd->savePropertiesAsDefault(); + } + return true; +} #ifdef COMPILE_CRYPT_SUPPORT static bool initializeCryptEngine(KviCryptEngine * eng,KviStr &szEncryptKey,KviStr &szDecryptKey,QString &szError) @@ -1554,6 +1608,7 @@ static bool window_module_init(KviModule *m) KVSM_REGISTER_FUNCTION(m,"console",window_kvs_fnc_console); KVSM_REGISTER_FUNCTION(m,"hasUserFocus",window_kvs_fnc_hasUserFocus); KVSM_REGISTER_FUNCTION(m,"hasOutput",window_kvs_fnc_hasOutput); + KVSM_REGISTER_FUNCTION(m,"isDocked",window_kvs_fnc_isDocked); KVSM_REGISTER_FUNCTION(m,"isMinimized",window_kvs_fnc_isMinimized); KVSM_REGISTER_FUNCTION(m,"isMaximized",window_kvs_fnc_isMaximized); KVSM_REGISTER_FUNCTION(m,"caption",window_kvs_fnc_caption); @@ -1581,6 +1636,7 @@ static bool window_module_init(KviModule *m) KVSM_REGISTER_SIMPLE_COMMAND(m,"setCryptEngine",window_kvs_cmd_setCryptEngine); KVSM_REGISTER_SIMPLE_COMMAND(m,"setInputText",window_kvs_cmd_setInputText); KVSM_REGISTER_SIMPLE_COMMAND(m,"insertInInputText",window_kvs_cmd_insertInInputText); + KVSM_REGISTER_SIMPLE_COMMAND(m,"savePropertiesAsDefault",window_kvs_cmd_savePropertiesAsDefault); // saveOutput (view()->saveBuffer()) /* |
