From 2d250bf64eb08df60b3149e53fc839a857d47496 Mon Sep 17 00:00:00 2001 From: Alexey Uzhva Date: Wed, 6 Jun 2007 05:37:03 +0000 Subject: fixes/improvements git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@601 17fca916-40b9-46aa-a4ea-0a15b648b75c --- src/kvilib/irc/kvi_ircserver.cpp | 18 ++++++ src/kvilib/irc/kvi_ircserver.h | 2 + src/kvirc/kernel/kvi_ircconnectionserverinfo.h | 2 +- src/kvirc/kernel/kvi_main.cpp | 88 +++++++++++++++----------- src/kvirc/kernel/kvi_options.cpp | 4 +- src/kvirc/kernel/kvi_options.h | 4 +- src/kvirc/kvs/kvi_kvs_corefunctions_sz.cpp | 23 +++++-- src/kvirc/ui/kvi_input.cpp | 6 +- src/modules/actioneditor/actioneditor.cpp | 2 +- src/modules/notifier/notifiersettings.h | 2 +- src/modules/notifier/notifierwindow.cpp | 69 +++++++++++++++++++- src/modules/notifier/notifierwindow.h | 1 + 12 files changed, 173 insertions(+), 48 deletions(-) (limited to 'src') diff --git a/src/kvilib/irc/kvi_ircserver.cpp b/src/kvilib/irc/kvi_ircserver.cpp index 7fd59d86b..dbd3c12df 100644 --- a/src/kvilib/irc/kvi_ircserver.cpp +++ b/src/kvilib/irc/kvi_ircserver.cpp @@ -134,6 +134,24 @@ void KviIrcServer::generateUniqueId() KviQString::sprintf(m_szId,"myserver%d%d%d",tv.tv_usec,rand() % 1000,rand() % 1000); } +QString KviIrcServer::ircUri() +{ + QString uri("irc"); + if(useSSL())uri += "s"; + if(isIpV6())uri += "6"; + uri += "://"; + uri += m_szHostname; + + if(m_uPort!=6667) + { + uri += ":"; + QString num; + num.setNum(m_uPort); + uri += num; + } + return uri; +} + void KviIrcServer::setAutoJoinChannelList(QStringList * pNewChannelList) { if(m_pChannelList)delete m_pChannelList; diff --git a/src/kvilib/irc/kvi_ircserver.h b/src/kvilib/irc/kvi_ircserver.h index 1821b5595..0ae0f53cd 100644 --- a/src/kvilib/irc/kvi_ircserver.h +++ b/src/kvilib/irc/kvi_ircserver.h @@ -148,6 +148,8 @@ public: void generateUniqueId(); void setId(const QString &szId){ m_szId = szId; if(m_szId.isEmpty())generateUniqueId(); }; + + QString ircUri(); }; class KVILIB_API KviIrcNetwork : public KviHeapObject diff --git a/src/kvirc/kernel/kvi_ircconnectionserverinfo.h b/src/kvirc/kernel/kvi_ircconnectionserverinfo.h index b6ad505b9..60722e875 100644 --- a/src/kvirc/kernel/kvi_ircconnectionserverinfo.h +++ b/src/kvirc/kernel/kvi_ircconnectionserverinfo.h @@ -68,7 +68,7 @@ class KVIRC_API KviHyperionIrcServerInfo : public KviBasicIrcServerInfo public: KviHyperionIrcServerInfo(const QString & version = KviQString::empty) :KviBasicIrcServerInfo(version) {;}; - virtual char getRegisterModeChar() { return 'r'; }; + virtual char getRegisterModeChar() { return 'e'; }; }; class KVIRC_API KviIrcConnectionServerInfo diff --git a/src/kvirc/kernel/kvi_main.cpp b/src/kvirc/kernel/kvi_main.cpp index 08ae93574..48effd55b 100644 --- a/src/kvirc/kernel/kvi_main.cpp +++ b/src/kvirc/kernel/kvi_main.cpp @@ -30,6 +30,7 @@ #include "kvi_ircurl.h" #include "kvi_defaults.h" #include "kvi_sourcesdate.h" +#include "kvi_msgbox.h" #ifndef COMPILE_NO_IPC extern bool kvi_sendIpcMessage(const char * message); // kvi_ipc.cpp @@ -67,58 +68,71 @@ int parseArgs(ParseArgs * a) for(idx = 1;idx < a->argc;idx++) { + QString szMessage; char * p = a->argv[idx]; if((kvi_strLen(p) > 3) && (*p == '-') && (*(p+1) == '-'))p++; if(kvi_strEqualCI("-v",p) || kvi_strEqualCI("-version",p)) { - debug("KVIrc %s '%s'",KVI_VERSION,KVI_RELEASE_NAME); - debug("Sources date: %s",KVI_SOURCES_DATE); - debug("Build date: %s",KVI_BUILD_DATE); - debug("Home page: http://www.kvirc.net/"); + KviQString::appendFormatted(szMessage,"KVIrc %s '%s'\n",KVI_VERSION,KVI_RELEASE_NAME); + KviQString::appendFormatted(szMessage,"Sources date: %s\n",KVI_SOURCES_DATE); + KviQString::appendFormatted(szMessage,"Build date: %s\n",KVI_BUILD_DATE); + KviQString::appendFormatted(szMessage,"Home page: http://www.kvirc.net/\n"); + +#ifdef COMPILE_ON_WINDOWS + MessageBox(0,szMessage.local8Bit().data(),"KVIrc",0); +#else + debug(szMessage); +#endif + return KVI_ARGS_RETCODE_STOP; } if(kvi_strEqualCI("-h",p) || kvi_strEqualCI("-help",p)) { - debug("Usage:"); - debug(" %s [options] [server [port]] [ircurl [ircurl [...]]]",a->argv[0]); - debug(" "); - debug("Available options:"); - debug(" -h, --help : Print this help and exit"); - debug(" -v, --version: Print version information and exit"); - debug(" -c : Use as config file instead of ~/%s",KVI_HOME_CONFIG_FILE_NAME); - debug(" (defaults to $HOME/%s if does not exist)",KVI_HOME_CONFIG_FILE_NAME); - debug(" -n : Use as config file instead of $HOME/%s",KVI_HOME_CONFIG_FILE_NAME); - debug(" (create if it does not exist)"); + KviQString::appendFormatted(szMessage,"Usage:\n"); + KviQString::appendFormatted(szMessage," %s [options] [server [port]] [ircurl [ircurl [...]]]\n",a->argv[0]); + KviQString::appendFormatted(szMessage," \n"); + KviQString::appendFormatted(szMessage,"Available options:\n"); + KviQString::appendFormatted(szMessage," -h, --help : Print this help and exit\n"); + KviQString::appendFormatted(szMessage," -v, --version: Print version information and exit\n"); + KviQString::appendFormatted(szMessage," -c : Use as config file instead of ~/%s\n",KVI_HOME_CONFIG_FILE_NAME); + KviQString::appendFormatted(szMessage," (defaults to $HOME/%s if does not exist)\n",KVI_HOME_CONFIG_FILE_NAME); + KviQString::appendFormatted(szMessage," -n : Use as config file instead of $HOME/%s\n",KVI_HOME_CONFIG_FILE_NAME); + KviQString::appendFormatted(szMessage," (create if it does not exist)\n"); #ifdef COMPILE_NO_IPC - debug(" -f : Accepted but ignored (for compatibility)"); + KviQString::appendFormatted(szMessage," -f : Accepted but ignored (for compatibility)\n"); #else - debug(" -f : Force a new KVIrc session, even if there is already"); - debug(" a running one."); + KviQString::appendFormatted(szMessage," -f : Force a new KVIrc session, even if there is already\n"); + KviQString::appendFormatted(szMessage," a running one.\n"); #endif - debug(" -e : If a KVIrc session is already running, execute"); - debug(" the in that session, otherwise start up"); - debug(" normally and execute "); - debug(" must be a single shell token."); - debug(" You can eventually use this switch more than once"); - debug(" -x : If a KVIrc session is already running, execute"); - debug(" the in that session, otherwise exit from application without doing anything/"); - debug(" must be a single shell token."); - debug(" You can eventually use this switch more than once"); - debug(" -r : If a KVIrc session is already running, execute the "); - debug(" in that session, otherwise start up normally (do not execute)."); - debug(" must be a single shell token."); - debug(" You can eventually use this switch more than once"); - debug(" -m : If a KVIrc session is already running, show an informational"); - debug(" popup dialog instead of writing to the console"); - debug(" --nosplash : Do not show the splash screen at startup"); - debug(" [server] : Connect to this server after startup"); - debug(" [port] : Use this port for connection"); - debug(" [ircurl] : URL in the following form:"); - debug(" irc[6]://[:][/[?]]"); + KviQString::appendFormatted(szMessage," -e : If a KVIrc session is already running, execute\n"); + KviQString::appendFormatted(szMessage," the in that session, otherwise start up\n"); + KviQString::appendFormatted(szMessage," normally and execute \n"); + KviQString::appendFormatted(szMessage," must be a single shell token.\n"); + KviQString::appendFormatted(szMessage," You can eventually use this switch more than once\n"); + KviQString::appendFormatted(szMessage," -x : If a KVIrc session is already running, execute\n"); + KviQString::appendFormatted(szMessage," the in that session, otherwise exit from application without doing anything/\n"); + KviQString::appendFormatted(szMessage," must be a single shell token.\n"); + KviQString::appendFormatted(szMessage," You can eventually use this switch more than once\n"); + KviQString::appendFormatted(szMessage," -r : If a KVIrc session is already running, execute the \n"); + KviQString::appendFormatted(szMessage," in that session, otherwise start up normally (do not execute).\n"); + KviQString::appendFormatted(szMessage," must be a single shell token.\n"); + KviQString::appendFormatted(szMessage," You can eventually use this switch more than once\n"); + KviQString::appendFormatted(szMessage," -m : If a KVIrc session is already running, show an informational\n"); + KviQString::appendFormatted(szMessage," popup dialog instead of writing to the console"); + KviQString::appendFormatted(szMessage," --nosplash : Do not show the splash screen at startup\n"); + KviQString::appendFormatted(szMessage," [server] : Connect to this server after startup\n"); + KviQString::appendFormatted(szMessage," [port] : Use this port for connection\n"); + KviQString::appendFormatted(szMessage," [ircurl] : URL in the following form:\n"); + KviQString::appendFormatted(szMessage," irc[6]://[:][/[?]]\n"); +#ifdef COMPILE_ON_WINDOWS + MessageBox(0,szMessage.local8Bit().data(),"KVIrc",0); +#else + debug(szMessage); +#endif return KVI_ARGS_RETCODE_STOP; } diff --git a/src/kvirc/kernel/kvi_options.cpp b/src/kvirc/kernel/kvi_options.cpp index 7c7384f45..690d6c478 100644 --- a/src/kvirc/kernel/kvi_options.cpp +++ b/src/kvirc/kernel/kvi_options.cpp @@ -619,7 +619,9 @@ KviUIntOption g_uintOptionsTable[KVI_NUM_UINT_OPTIONS]= UINT_OPTION("MinTrayHighLevelMessage",4,KviOption_sectFlagFrame ), UINT_OPTION("IdentdOutputMode",KviIdentdOutputMode::Quiet,KviOption_sectFlagConnection ), UINT_OPTION("ScaleAvatarsOnLoadHeight",600,KviOption_sectFlagAvatar ), - UINT_OPTION("ScaleAvatarsOnLoadWidth",800,KviOption_sectFlagAvatar ) + UINT_OPTION("ScaleAvatarsOnLoadWidth",800,KviOption_sectFlagAvatar ), + UINT_OPTION("NotifierActiveTransparency",90,KviOption_sectFlagFrame ), + UINT_OPTION("NotifierInactiveTransparency",40,KviOption_sectFlagFrame ) }; #define FONT_OPTION(_name,_face,_size,_flags) \ diff --git a/src/kvirc/kernel/kvi_options.h b/src/kvirc/kernel/kvi_options.h index ff002c41d..2f9dc5dbc 100644 --- a/src/kvirc/kernel/kvi_options.h +++ b/src/kvirc/kernel/kvi_options.h @@ -557,8 +557,10 @@ DECLARE_OPTION_STRUCT(KviStringListOption,QStringList) #define KviOption_uintIdentdOutputMode 60 #define KviOption_uintScaleAvatarsOnLoadHeight 61 #define KviOption_uintScaleAvatarsOnLoadWidth 62 +#define KviOption_uintNotifierActiveTransparency 63 +#define KviOption_uintNotifierInactiveTransparency 64 -#define KVI_NUM_UINT_OPTIONS 63 +#define KVI_NUM_UINT_OPTIONS 65 namespace KviIdentdOutputMode { enum Mode { diff --git a/src/kvirc/kvs/kvi_kvs_corefunctions_sz.cpp b/src/kvirc/kvs/kvi_kvs_corefunctions_sz.cpp index b746aa1de..52275adfa 100644 --- a/src/kvirc/kvs/kvi_kvs_corefunctions_sz.cpp +++ b/src/kvirc/kvs/kvi_kvs_corefunctions_sz.cpp @@ -180,6 +180,7 @@ namespace KviKvsCoreFunctions $serialize() @description: Decodes JSON-encoded string + $serialize() returns a string containing a byte-stream representation of value that can be stored anywhere. @seealso: [fnc]$serialize[/fnc] */ @@ -387,7 +388,7 @@ namespace KviKvsCoreFunctions @short: Returns the value of a switch for an alias @syntax: - $sw() + $sw([,]) @description: This function is valid and useful only in aliases. It allows an alias to handle switches just like any other @@ -401,12 +402,13 @@ namespace KviKvsCoreFunctions @examples: [example] [cmd]alias[/cmd](test){ - if($sw(a)) [cmd]echo[/cmd] "Switch -a was passed" + if($sw(a,append)) [cmd]echo[/cmd] "Switch -a was passed" %x = $sw(x); if(%x) [cmd]echo[/cmd] "Switch -x=%x was passed" } test -a test -x + test --append -x test -a -x test -a -x=test test -a=10 -x=test @@ -416,9 +418,11 @@ namespace KviKvsCoreFunctions KVSCF(sw) { QString szSwitch; + QString szLongSwitch; KVSCF_PARAMETERS_BEGIN KVSCF_PARAMETER("switch_name",KVS_PT_STRING,0,szSwitch) + KVSCF_PARAMETER("long_name",KVS_PT_STRING | KVS_PF_OPTIONAL ,0,szLongSwitch) KVSCF_PARAMETERS_END KviKvsSwitchList * sl = KVSCF_pContext->aliasSwitchList(); @@ -429,9 +433,20 @@ namespace KviKvsCoreFunctions } KviKvsVariant * v; + - if(szSwitch.length() > 1)v = sl->find(szSwitch); - else v = sl->find(szSwitch[0]); + if(szSwitch.length() > 1) + { + if(szLongSwitch.isEmpty()) + v = sl->find(szSwitch); + else + v = sl->find(szSwitch[0].unicode(),szLongSwitch); + }else { + if(szLongSwitch.isEmpty()) + v = sl->find(szSwitch[0]); + else + v = sl->find(szSwitch[0].unicode(),szLongSwitch); + } if(v)KVSCF_pRetBuffer->copyFrom(*v); else KVSCF_pRetBuffer->setNothing(); diff --git a/src/kvirc/ui/kvi_input.cpp b/src/kvirc/ui/kvi_input.cpp index 93ebe749d..dbc843e3e 100644 --- a/src/kvirc/ui/kvi_input.cpp +++ b/src/kvirc/ui/kvi_input.cpp @@ -1372,6 +1372,7 @@ void KviInputEditor::keyPressEvent(QKeyEvent *e) return; } // completion thingies + if(!m_bReadOnly) { if((e->key() == Qt::Key_Tab) || (e->key() == Qt::Key_BackTab)) @@ -1382,6 +1383,7 @@ void KviInputEditor::keyPressEvent(QKeyEvent *e) m_bLastCompletionFinished=1; } } + if(e->key() == Qt::Key_Escape) { @@ -1560,7 +1562,9 @@ void KviInputEditor::keyPressEvent(QKeyEvent *e) } //debug("%c",e->ascii()); - if(!m_bReadOnly) insertText(e->text()); + if(!m_bReadOnly) { + insertText(e->text()); + } return; } diff --git a/src/modules/actioneditor/actioneditor.cpp b/src/modules/actioneditor/actioneditor.cpp index 022fb8725..f4f345737 100644 --- a/src/modules/actioneditor/actioneditor.cpp +++ b/src/modules/actioneditor/actioneditor.cpp @@ -401,7 +401,7 @@ void KviSingleActionEditor::chooseBigIcon() QString s = d->selectedImage(); delete d; if(ret != QDialog::Accepted)return; - QPixmap * p = g_pIconManager->getBigIcon(s.utf8().data()); + QPixmap * p = g_pIconManager->getBigIcon(s); if(!p)return; m_pBigIconEdit->setText(s); m_pBigIconButton->setPixmap(*p); diff --git a/src/modules/notifier/notifiersettings.h b/src/modules/notifier/notifiersettings.h index fe06b9b9e..50ff2aa5d 100644 --- a/src/modules/notifier/notifiersettings.h +++ b/src/modules/notifier/notifiersettings.h @@ -60,7 +60,7 @@ #define m_mac_bkgColor QColor(236,233,216) // Light-brown color of notifier background widget -enum State { Hidden, Showing, Visible, Hiding }; +enum State { Hidden, Showing, Visible, Hiding , FocusingOff, FocusingOn }; enum TabState { Normal, Highlighted, Changed }; #endif //_NOTIFIER_SETTINGS_H_ diff --git a/src/modules/notifier/notifierwindow.cpp b/src/modules/notifier/notifierwindow.cpp index 94ced105e..305053cd9 100644 --- a/src/modules/notifier/notifierwindow.cpp +++ b/src/modules/notifier/notifierwindow.cpp @@ -382,6 +382,8 @@ bool KviNotifierWindow::shouldHideIfMainWindowGotAttention() void KviNotifierWindow::heartbeat() { + bool bIncreasing; + double targetOpacity = 0; //qt4 switch(m_eState) { case Hidden: @@ -400,9 +402,18 @@ void KviNotifierWindow::heartbeat() m_eState = Hiding; } else { m_dOpacity += OPACITY_STEP; +#ifdef COMPILE_USE_QT4 + targetOpacity = isActiveWindow() ? KVI_OPTION_UINT(KviOption_uintNotifierActiveTransparency) : KVI_OPTION_UINT(KviOption_uintNotifierInactiveTransparency); + + targetOpacity/=100; + if(m_dOpacity >= targetOpacity) + { + m_dOpacity = targetOpacity; +#else if(m_dOpacity >= 1.0) { m_dOpacity = 1.0; +#endif m_eState = Visible; stopShowHideTimer(); startBlinking(); @@ -418,6 +429,42 @@ void KviNotifierWindow::heartbeat() } break; +#ifdef COMPILE_USE_QT4 + case FocusingOn: + targetOpacity = KVI_OPTION_UINT(KviOption_uintNotifierActiveTransparency); + targetOpacity/=100; + bIncreasing = targetOpacity>m_dOpacity; + m_dOpacity += bIncreasing? + OPACITY_STEP : -(OPACITY_STEP); + if( (bIncreasing && (m_dOpacity >= targetOpacity) ) || + (!bIncreasing && (m_dOpacity <= targetOpacity) ) + ) + { + m_dOpacity = targetOpacity; + m_eState = Visible; + stopShowHideTimer(); + } + + setWindowOpacity(m_dOpacity); + break; + case FocusingOff: + targetOpacity = KVI_OPTION_UINT(KviOption_uintNotifierInactiveTransparency); + targetOpacity/=100; + bIncreasing = targetOpacity>m_dOpacity; + m_dOpacity += bIncreasing ? OPACITY_STEP : -(OPACITY_STEP); + debug("%f %f %i %i",m_dOpacity,targetOpacity,bIncreasing,(m_dOpacity >= targetOpacity)); + if( (bIncreasing && (m_dOpacity >= targetOpacity) ) || + (!bIncreasing && (m_dOpacity <= targetOpacity) ) + ) + { + m_dOpacity = targetOpacity; + m_eState = Visible; + stopShowHideTimer(); + } + + setWindowOpacity(m_dOpacity); + break; +#endif case Hiding: m_dOpacity -= OPACITY_STEP; #if defined(COMPILE_USE_QT4) && (defined(COMPILE_ON_WINDOWS) || defined(Q_OS_MACX)) @@ -984,7 +1031,7 @@ void KviNotifierWindow::delayedRaiseSlot() m_pWindowToRaise->frame()->show(); m_pWindowToRaise->frame()->raise(); - ((QWidget *)(m_pWindowToRaise->frame()))->setActiveWindow(); + //((QWidget *)(m_pWindowToRaise->frame()))->setActiveWindow(); m_pWindowToRaise->frame()->setFocus(); } @@ -1153,6 +1200,18 @@ inline void KviNotifierWindow::setCursor(int cur) { if(QApplication::overrideCursor()) QApplication::restoreOverrideCursor(); } +void KviNotifierWindow::enterEvent(QEvent * e) +{ +#ifdef COMPILE_USE_QT4 + if(!m_pShowHideTimer) { + m_pShowHideTimer = new QTimer(); + connect(m_pShowHideTimer,SIGNAL(timeout()),this,SLOT(heartbeat())); + } + m_eState = FocusingOn; + m_pShowHideTimer->start(40); +#endif +} + void KviNotifierWindow::leaveEvent(QEvent * e) { // Leaving the widget area, restore default cursor @@ -1160,6 +1219,14 @@ void KviNotifierWindow::leaveEvent(QEvent * e) m_pWndTabs->resetIcons(); if (!m_bResizing) setCursor(-1); +#ifdef COMPILE_USE_QT4 + if(!m_pShowHideTimer) { + m_pShowHideTimer = new QTimer(); + connect(m_pShowHideTimer,SIGNAL(timeout()),this,SLOT(heartbeat())); + } + m_eState = FocusingOff; + m_pShowHideTimer->start(40); +#endif } void KviNotifierWindow::contextPopup(const QPoint &pos) diff --git a/src/modules/notifier/notifierwindow.h b/src/modules/notifier/notifierwindow.h index bf01081df..8966089eb 100644 --- a/src/modules/notifier/notifierwindow.h +++ b/src/modules/notifier/notifierwindow.h @@ -148,6 +148,7 @@ protected: virtual void mouseReleaseEvent(QMouseEvent * e); virtual void mouseMoveEvent(QMouseEvent * e); virtual void leaveEvent(QEvent * e); + virtual void enterEvent(QEvent * e); virtual void mouseDoubleClickEvent(QMouseEvent * e); virtual void wheelEvent(QWheelEvent * e); virtual bool eventFilter(QObject * pEdit,QEvent * e); -- cgit v1.3.1-10-gc9f91