diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/kvirc/kernel/KviIconManager.cpp | 59 | ||||
| -rw-r--r-- | src/kvirc/kvs/KviKvsAliasManager.cpp | 2 | ||||
| -rw-r--r-- | src/kvirc/kvs/KviKvsScriptAddonManager.cpp | 1 | ||||
| -rw-r--r-- | src/modules/addon/PackAddonDialog.cpp | 128 |
4 files changed, 30 insertions, 160 deletions
diff --git a/src/kvirc/kernel/KviIconManager.cpp b/src/kvirc/kernel/KviIconManager.cpp index 3b404ae93..d8c72ee36 100644 --- a/src/kvirc/kernel/KviIconManager.cpp +++ b/src/kvirc/kernel/KviIconManager.cpp @@ -1004,16 +1004,14 @@ KviCachedPixmap * KviIconManager::getPixmapWithCache(const QString & szName) QString szRetPath; - if(g_pApp->findImage(szRetPath,szName)) + if(!g_pApp->findImage(szRetPath,szName)) + return 0; + + pPix = new QPixmap(szRetPath); + if(pPix->isNull()) { - pPix = new QPixmap(szRetPath); - if(pPix->isNull()) - { - delete pPix; // it is not an valid image!!! (really bad situation...) - pPix = 0; - return 0; - } - } else { + delete pPix; // it is not an valid image!!! (really bad situation...) + pPix = 0; return 0; } @@ -1040,32 +1038,31 @@ KviCachedPixmap * KviIconManager::getPixmapWithCacheScaleOnLoad(const QString & QString szRetPath; - if(g_pApp->findImage(szRetPath,szName)) + + if(!g_pApp->findImage(szRetPath,szName)) + return 0; + + pPix = new QPixmap(szRetPath); + if(pPix->isNull()) { - pPix = new QPixmap(szRetPath); - if(pPix->isNull()) + delete pPix; // it is not an valid image!!! (really bad situation...) + pPix = 0; + return 0; + } + if((pPix->width() > iMaxWidth) || (pPix->height() > iMaxHeight)) + { + // scale to fit + int scaleW = iMaxWidth; + int scaleH; + scaleH = (pPix->height() * iMaxWidth) / pPix->width(); + if(scaleH > iMaxHeight) { - delete pPix; // it is not an valid image!!! (really bad situation...) - pPix = 0; - return 0; + scaleH = iMaxHeight; + scaleW = (scaleH * pPix->width()) / pPix->height(); } - if((pPix->width() > iMaxWidth) || (pPix->height() > iMaxHeight)) - { - // scale to fit - int scaleW = iMaxWidth; - int scaleH; - scaleH = (pPix->height() * iMaxWidth) / pPix->width(); - if(scaleH > iMaxHeight) - { - scaleH = iMaxHeight; - scaleW = (scaleH * pPix->width()) / pPix->height(); - } - QImage img = pPix->toImage(); - *pPix = QPixmap::fromImage(img.scaled(scaleW,scaleH,Qt::IgnoreAspectRatio,Qt::SmoothTransformation)); - } - } else { - return 0; + QImage img = pPix->toImage(); + *pPix = QPixmap::fromImage(img.scaled(scaleW,scaleH,Qt::IgnoreAspectRatio,Qt::SmoothTransformation)); } pCache = new KviCachedPixmap(pPix,QString(szRetPath)); diff --git a/src/kvirc/kvs/KviKvsAliasManager.cpp b/src/kvirc/kvs/KviKvsAliasManager.cpp index 54bdfd2b6..01f096ed2 100644 --- a/src/kvirc/kvs/KviKvsAliasManager.cpp +++ b/src/kvirc/kvs/KviKvsAliasManager.cpp @@ -68,7 +68,7 @@ bool KviKvsAliasManager::removeNamespace(const QString & szName) QList<QString> lKill; while(it.current()) { - if(szName.compare(it.current()->name()) == 0) + if(it.current()->name().startsWith(szName,Qt::CaseInsensitive)) lKill.append(it.current()->name()); it.moveNext(); } diff --git a/src/kvirc/kvs/KviKvsScriptAddonManager.cpp b/src/kvirc/kvs/KviKvsScriptAddonManager.cpp index 6d34ac4c0..fb366502f 100644 --- a/src/kvirc/kvs/KviKvsScriptAddonManager.cpp +++ b/src/kvirc/kvs/KviKvsScriptAddonManager.cpp @@ -85,6 +85,7 @@ KviKvsScriptAddon::~KviKvsScriptAddon() QPixmap * KviKvsScriptAddon::icon() { + qDebug("Addon requests icon %s",m_szIconId.toUtf8().data()); return g_pIconManager->getBigIcon(m_szIconId.isEmpty() ? QString(KVI_BIGICON_KVS) : m_szIconId); } diff --git a/src/modules/addon/PackAddonDialog.cpp b/src/modules/addon/PackAddonDialog.cpp index 0abec8bc2..6f5a79b04 100644 --- a/src/modules/addon/PackAddonDialog.cpp +++ b/src/modules/addon/PackAddonDialog.cpp @@ -130,134 +130,6 @@ void PackAddonDialog::accept() QWizard::accept(); } - -#if 0 -bool PackAddonDialog::checkDirTree(QString * pszError) -{ - if(pszError) - *pszError = ""; - - QDir addon(m_szDirPath); - if(!addon.exists()) - { - *pszError = __tr2qs_ctx("The selected directory does not exist.","addon"); - return false; - } - - QFileInfo init(m_szDirPath + "/install.kvs"); - if(!init.exists()) - { - *pszError = __tr2qs_ctx("The initialization script (install.kvs) does not exist.","addon"); - return false; - } - - return true; -} -bool PackAddonDialog::createInstaller(QString * pszError) -{ - if(pszError) - *pszError = ""; - - // Start creating install.kvs: header - QString szTmp; - szTmp += QString("# This file is generated automatically. Do NOT touch unless you know what are you doing\n#\n"); - szTmp += QString("# %1 %2\n# Written by %3\n# %4\n\n").arg(m_szName, m_szVersion, m_szAuthor, m_szDescription); - szTmp += "# Register the script: this must be the first instruction executed\n# since it will abort with an error when a greater version is already installed\n"; - - // install.kvs: addon registration - /* FIXME: re-add in KVIrc 4.1! - * implement a backend with full automatic cleaning for aliases, classes, popups, - * actions, ... via snapshot/diff of kvirc state before/after installing a package - - szTmp += QString("addon.register(\"%1\",\"%2\",\"%1\",\"%3\",\"%4\",\"%5\")\n").arg(m_szName, m_szVersion, m_szDescription, m_szMinVersion, m_szIcon); - szTmp += "{\n"; - szTmp += "\t# This is our uninstall callback: it will be called by KVIrc when addon.uninstall is invoked\n"; - szTmp += QString("\t%1::uninstall::uninstall\n").arg(m_szName); - szTmp += QString("\t%1::uninstall::uninstallfiles\n").arg(m_szName); - szTmp += QString("\t%1::uninstall::uninstallaliases\n").arg(m_szName); - szTmp += "}\n\n"; - szTmp += "# Ok, addon.register succeeded. We can go on with the installation.\n\n"; - */ - - // install.kvs: run path - szTmp += "# Get the path that this script was launched from\n"; - szTmp += "%mypath = $file.extractPath($0)\n\n"; - - // install.kvs: create an instance of the installer class - szTmp += "# The installer will copy our files and generate automatically an uninstallation\n# alias for them\n"; - szTmp += "%installer = $new(installer,0,myaddon)\n\n"; - - // install.kvs: copy files - szTmp += "# Copy files in each subdirectory\n# the pics\n"; - - szTmp += QString("%installer->$copyFiles(\"%mypath/pics\",\"*.png\",$file.localdir(\"pics\"))\n\n"); - szTmp += "# the translations\n"; - szTmp += "%installer->$copyFiles(\"%mypath/locale\",\"*.mo\",$file.localdir(\"locale\"))\n\n"; - - szTmp += "# the documentation\n"; - szTmp += QString("%installer->$copyFiles(\"%mypath/help/\",\"*.html\",$file.localdir(\"help/\"))\n\n"); - - // install.kvs: generate uninstall alias - szTmp += "# Generate the uninstall alias\n"; - szTmp += QString("%installer->$generateUninstallAlias(\"%1::uninstallfiles\")\n\n") \ - .arg(m_szName); - - // kviinstall.kvs: kill the installer class - szTmp += "# Kill the installer helper\n"; - szTmp += "delete %installer\n\n"; - -#if 0 - // install.kvs: fetch the complete script - szTmp += "# Fetch the complete script\n"; - szTmp += "%files[] = $file.ls($file.extractpath($0)/src,f)\n"; - szTmp += QString("%alias = \"alias(%1::uninstall::uninstallaliases){$lf\"\n") \ - .arg(m_szName); - szTmp += "for(%i=0; %i<$length(%files[]); %i++)\n{\n"; - szTmp += "\tinclude $file.extractpath($0)/src/%files[%i]\n"; - szTmp += "\t%flt = $str.left(%files[%i],$($str.len(%files[%i])-4))\n"; - szTmp += "\t%file = $str.replace(%flt,\"_\",\"::\")\n"; - szTmp += "\t%alias .= \"alias(%file){};$lf\"\n}\n"; - szTmp += QString("\t%alias .= \"alias(%1::uninstall::uninstallfiles){};$lf\"\n") \ - .arg(m_szName); - szTmp += QString("\t%alias .= \"alias(%1::uninstall::uninstallaliases){};$lf\"\n") \ - .arg(m_szName); - szTmp += "%alias .= \"}\"\n"; - szTmp += "eval %alias\n\n"; -#endif - - // install.kvs: include initialization file - szTmp += "# Include initialization file\n"; - szTmp += "include \"init.kvs\" %mypath\n\n"; - - // Put the install.kvs in the buffer - QByteArray buffer; - buffer.append(szTmp.toUtf8()); - - // We don't need to check dir existance since it was checked just before - QDir addon(m_szDirPath); - - // Open file for writing - QFile installer(addon.filePath("install.kvs")); - if(!installer.open(QIODevice::WriteOnly)) - { - *pszError = __tr2qs_ctx("Cannot open file for writing.","addon"); - return false; - } - - // Write the buffer to the file descriptor - if(installer.write(buffer) == -1) - { - *pszError = __tr2qs_ctx("Cannot write to the file descriptor.","addon"); - return false; - } - - return true; -} -#endif - - - - bool PackAddonDialog::packAddon() { // Get data from registered fields |
