aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Fabio Bas2010-08-10 15:24:11 +0000
committerGravatar Fabio Bas2010-08-10 15:24:11 +0000
commite2baf2ccce1dbff7fb16693848149c017675f9e5 (patch)
tree5bc58d41cff0dfe40cd1e15deea524a29f450405
parentfix for #879 (diff)
downloadKVIrc-e2baf2ccce1dbff7fb16693848149c017675f9e5.tar.gz
KVIrc-e2baf2ccce1dbff7fb16693848149c017675f9e5.tar.bz2
KVIrc-e2baf2ccce1dbff7fb16693848149c017675f9e5.zip
Fixed OnUserModeChange event name
Added OnWindowTitleRequest event (implements #804) Expanded window.setWindowTitle so that it can change the title of any type of window git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@4846 17fca916-40b9-46aa-a4ea-0a15b648b75c
-rw-r--r--src/kvirc/kvs/kvi_kvs_eventtable.cpp31
-rw-r--r--src/kvirc/kvs/kvi_kvs_eventtable.h9
-rw-r--r--src/kvirc/sparser/kvi_sp_literal.cpp4
-rw-r--r--src/kvirc/ui/kvi_window.cpp16
-rw-r--r--src/kvirc/ui/kvi_window.h10
-rw-r--r--src/modules/window/libkviwindow.cpp12
6 files changed, 60 insertions, 22 deletions
diff --git a/src/kvirc/kvs/kvi_kvs_eventtable.cpp b/src/kvirc/kvs/kvi_kvs_eventtable.cpp
index 9d54d4fd9..9752005b9 100644
--- a/src/kvirc/kvs/kvi_kvs_eventtable.cpp
+++ b/src/kvirc/kvs/kvi_kvs_eventtable.cpp
@@ -1754,11 +1754,11 @@ KviKvsEvent KviKvsEventManager::m_appEventTable[KVI_KVS_NUM_APP_EVENTS]=
"$4 = mode params"),
/*
- @doc: onusermode
+ @doc: onusermodechange
@type:
event
@title:
- OnUserMode
+ OnUserModeChange
@short:
The local user has changed mode
@parameters:
@@ -1771,7 +1771,7 @@ KviKvsEvent KviKvsEventManager::m_appEventTable[KVI_KVS_NUM_APP_EVENTS]=
if the mode was removed it will be something like "-x" , otherwise something like "+x".[br]
Calling 'halt' in this event will stop the "mode" message output.[br]
*/
- EVENT("OnUserModeChanged", \
+ EVENT("OnUserModeChange", \
"$0 = mode flags"),
/*
@@ -3751,5 +3751,28 @@ KviKvsEvent KviKvsEventManager::m_appEventTable[KVI_KVS_NUM_APP_EVENTS]=
EVENT("OnQueryNickDefaultActionRequest", \
"$0 = actual name\n" \
"$1 - visible name\n" \
- "$2 - command name")
+ "$2 - command name"),
+
+ /*
+ @doc: onwindowtitlerequest
+ @type:
+ event
+ @title:
+ OnWindowTitleRequest
+ @short:
+ Triggered when a window title needs to be set
+ @parameters:
+ none
+ @window:
+ Any window
+ @description:
+ This event is triggered when a KVIrc MDI or undocked window is in need of a window title change.[br]
+ You can set a customized window title and halt the default title from being set.[br]
+ @seealso:
+ [cmd]window.setWindowTitle[cmd]
+ */
+ EVENT("OnWindowTitleRequest", \
+ "$0 = window id\n" \
+ "$1 = default window title")
+
};
diff --git a/src/kvirc/kvs/kvi_kvs_eventtable.h b/src/kvirc/kvs/kvi_kvs_eventtable.h
index 30149b066..d0500fd64 100644
--- a/src/kvirc/kvs/kvi_kvs_eventtable.h
+++ b/src/kvirc/kvs/kvi_kvs_eventtable.h
@@ -39,6 +39,7 @@
* \def KviEvent_OnFrameWindowCreated Triggered when the frame window is created
* \def KviEvent_OnFrameWindowDestroyed Triggered when the frame window is destroyed
* \def KviEvent_OnURL An URL appears in one of the output windows
+* \def KviEvent_OnError Triggered when an ERROR message is received from the server
* \def KviEvent_OnAccelKeyPressed An accelerator key was pressed
* \def KviEvent_OnHighlight A channel or query message is going to be highlighted
* \def KviEvent_OnWindowActivated A window has just been activated
@@ -54,6 +55,7 @@
* \def KviEvent_OnWallops A WALLOPS message is received from the server
* \def KviEvent_OnIgnoredMessage Triggered when a message is ignored
* \def KviEvent_OnServerNotice A server NOTICE have been issued
+* \def KviEvent_OnWindowTitleRequest A window title is needed
*/
#define KviEvent_OnKVIrcStartup 0
#define KviEvent_OnKVIrcShutdown 1
@@ -78,6 +80,7 @@
#define KviEvent_OnWallops 20
#define KviEvent_OnIgnoredMessage 21
#define KviEvent_OnServerNotice 22
+#define KviEvent_OnWindowTitleRequest 145
// Connection
/**
@@ -184,7 +187,7 @@
// IRC modes
/**
* \def KviEvent_OnChannelModeChange The channel mode has been changed
-* \def KviEvent_OnUserMode The local user has changed mode
+* \def KviEvent_OnUserModeChange The local user has changed mode
* \def KviEvent_OnBan Someone has set a +b flag on the channel
* \def KviEvent_OnUnban Someone has set a -b flag on the channel
* \def KviEvent_OnMeBan Local user is being banned in a channel
@@ -234,7 +237,7 @@
* \def KviEvent_OnMeDeIrcOp Someone has given the local user the -O flag
*/
#define KviEvent_OnChannelModeChange 64
-#define KviEvent_OnUserMode 65
+#define KviEvent_OnUserModeChange 65
#define KviEvent_OnBan 66
#define KviEvent_OnUnban 67
#define KviEvent_OnMeBan 68
@@ -361,6 +364,6 @@
#define KviEvent_OnQueryNickDefaultActionRequest 144
/** \def KVI_KVS_NUM_APP_EVENTS Defines the number of events */
-#define KVI_KVS_NUM_APP_EVENTS 145
+#define KVI_KVS_NUM_APP_EVENTS 146
#endif //_KVI_KVS_EVENTTABLE_H_
diff --git a/src/kvirc/sparser/kvi_sp_literal.cpp b/src/kvirc/sparser/kvi_sp_literal.cpp
index 15ea3666b..0487db98a 100644
--- a/src/kvirc/sparser/kvi_sp_literal.cpp
+++ b/src/kvirc/sparser/kvi_sp_literal.cpp
@@ -1648,12 +1648,12 @@ void KviServerParser::parseUserMode(KviIrcMessage *msg,const char * modeflptr)
KviKvsEventManager::instance()->trigger(KviEvent_OnNickServAuth,msg->console(),&vList);
}
// There was a mode change
- if(KviKvsEventManager::instance()->hasAppHandlers(KviEvent_OnUserMode))
+ if(KviKvsEventManager::instance()->hasAppHandlers(KviEvent_OnUserModeChange))
{
QString szModeFlag(bSet ? QChar('+') : QChar('-'));
szModeFlag += QChar(*modeflptr);
KviKvsVariantList vList(new KviKvsVariant(szModeFlag));
- if(KviKvsEventManager::instance()->trigger(KviEvent_OnUserMode,msg->console(),&vList))
+ if(KviKvsEventManager::instance()->trigger(KviEvent_OnUserModeChange,msg->console(),&vList))
msg->setHaltOutput();
}
}
diff --git a/src/kvirc/ui/kvi_window.cpp b/src/kvirc/ui/kvi_window.cpp
index 5bfbcdcc4..b56641beb 100644
--- a/src/kvirc/ui/kvi_window.cpp
+++ b/src/kvirc/ui/kvi_window.cpp
@@ -57,6 +57,8 @@
#include "kvi_kvs_script.h"
#include "kvi_tal_popupmenu.h"
#include "kvi_tal_tooltip.h"
+#include "kvi_kvs_script.h"
+#include "kvi_kvs_eventtriggers.h"
#include <QPixmap>
#include <QCursor>
@@ -646,10 +648,16 @@ void KviWindow::fillSingleColorCaptionBuffers(const QString &szName)
void KviWindow::updateCaption()
{
fillCaptionBuffers();
- if(mdiParent())
- mdiParent()->setWindowTitle(m_szPlainTextCaption);
- else
- setWindowTitle(m_szPlainTextCaption);
+ bool bHaltOutput = false;
+ bHaltOutput = KVS_TRIGGER_EVENT_2_HALTED(KviEvent_OnWindowTitleRequest,this,id(),m_szPlainTextCaption);
+
+ if(!bHaltOutput)
+ {
+ if(mdiParent())
+ mdiParent()->setWindowTitle(m_szPlainTextCaption);
+ else
+ setWindowTitle(m_szPlainTextCaption);
+ }
if(m_pWindowListItem)
m_pWindowListItem->captionChanged();
}
diff --git a/src/kvirc/ui/kvi_window.h b/src/kvirc/ui/kvi_window.h
index 209565046..d3d412494 100644
--- a/src/kvirc/ui/kvi_window.h
+++ b/src/kvirc/ui/kvi_window.h
@@ -295,6 +295,11 @@ 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
+ void setFixedCaption(const QString &szCaption);
public slots:
void dock();
void undock();
@@ -331,11 +336,6 @@ protected:
// called by KviFrame
// either lost the active window status or the frame is no longer active (but we're still the active kvirc's subwindow)
virtual void lostUserFocus();
-
- // 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
- void setFixedCaption(const QString &szCaption);
// this by default calls fillSingleColorCaptionBuffer(plainTextCaption());
virtual void fillCaptionBuffers();
// protected helper
diff --git a/src/modules/window/libkviwindow.cpp b/src/modules/window/libkviwindow.cpp
index a921373ad..dd44c389c 100644
--- a/src/modules/window/libkviwindow.cpp
+++ b/src/modules/window/libkviwindow.cpp
@@ -1166,9 +1166,7 @@ static bool window_kvs_fnc_open(KviKvsModuleFunctionCall * c)
@description:
Sets the caption of the user window specified by <window_id> to <plain_text_caption>.[br]
If <window_id> is an empty string then the current window is assumed.[br]
- The window must be of type userwnd and must have been created by [fnc]$window.open[/fnc]:
- it is not possible to change the caption of other window types.[br]
- If the window does not exists or is not of the expected type then a warning is printed unless the -q switch is used.[br]
+ If the window does not exists then a warning is printed unless the -q switch is used.[br]
@seealso:
*/
@@ -1194,7 +1192,13 @@ static bool window_kvs_cmd_setWindowTitle(KviKvsModuleCommandCall * c)
{
((KviUserWindow *)pWnd)->setWindowTitleStrings(szPlain);
} else {
- if(!c->hasSwitch('q',"quiet"))c->warning(__tr2qs("The specified window is not of type \"userwnd\""));
+ //store the window title (needed for functions that search windows by their captions)
+ ((KviWindow *)pWnd)->setFixedCaption(szPlain);
+
+ if(((KviWindow *)pWnd)->mdiParent())
+ ((KviWindow *)pWnd)->mdiParent()->setWindowTitle(szPlain);
+ else
+ ((KviWindow *)pWnd)->setWindowTitle(szPlain);
}
return true;
}