From f4da8086b4ab698510290f92aa679a305a537a27 Mon Sep 17 00:00:00 2001 From: Robert Förster Date: Tue, 16 Sep 2008 11:43:31 +0000 Subject: pop in some EOL and svn properties fixes. - all textfiles were converted to unix line endings - svn:eol-style native has been set on that files so noone has to care about it again, now the svn client does take care of that, a checkout on unix will get unix lineendings, a checkout on windows will get windows lineendings - svn:executable fixup (some file had the executable bit set were they shouldn't) - svn:mime-type fixes for most of the files, which will probaly only affect trac in viewing that files - some typo fixup, the manpage seems to need some love, though. this will be pushed to the branches once i get to it today. git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@2469 17fca916-40b9-46aa-a4ea-0a15b648b75c --- src/modules/addon/addon_QT4_vc05.vcproj | 596 +++++++++++++-------------- src/modules/addon/managementdialog.cpp | 706 ++++++++++++++++---------------- 2 files changed, 651 insertions(+), 651 deletions(-) (limited to 'src/modules/addon') diff --git a/src/modules/addon/addon_QT4_vc05.vcproj b/src/modules/addon/addon_QT4_vc05.vcproj index 52f055e76..941124ebc 100644 --- a/src/modules/addon/addon_QT4_vc05.vcproj +++ b/src/modules/addon/addon_QT4_vc05.vcproj @@ -1,298 +1,298 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/modules/addon/managementdialog.cpp b/src/modules/addon/managementdialog.cpp index 745825d7a..d7a8da2b4 100644 --- a/src/modules/addon/managementdialog.cpp +++ b/src/modules/addon/managementdialog.cpp @@ -1,353 +1,353 @@ -//============================================================================= -// -// File : managementdialog.cpp -// Created on Fri 08 Apr 2005 14:54:56 by Szymon Stefanek -// -// This file is part of the KVIrc IRC Client distribution -// Copyright (C) 2005 Szymon Stefanek -// -// This program is FREE software. You can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your opinion) any later version. -// -// This program is distributed in the HOPE that it will be USEFUL, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, write to the Free Software Foundation, -// Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -//============================================================================= - -#include "managementdialog.h" -#include "packaddondialog.h" -#include "addonfunctions.h" - -#include "kvi_app.h" -#include "kvi_locale.h" -#include "kvi_frame.h" -#include "kvi_iconmanager.h" -#include "kvi_kvs_scriptaddonmanager.h" -#include "kvi_window.h" -#include "kvi_filedialog.h" -#include "kvi_fileutils.h" -#include "kvi_fileextensions.h" -#include "kvi_kvs_script.h" -#include "kvi_sourcesdate.h" -#include "kvi_tal_listwidget.h" -#include "kvi_tal_tooltip.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - - -KviScriptManagementDialog * KviScriptManagementDialog::m_pInstance = 0; -extern QRect g_rectManagementDialogGeometry; - -KviScriptAddonListViewItem::KviScriptAddonListViewItem(KviTalListWidget *v,KviKvsScriptAddon * a) -: KviTalListWidgetItem(v) -{ - m_pAddon = new KviKvsScriptAddon(*a); - m_pListWidget = v; - QString t = ""; - t += a->visibleName(); - t += " ["; - t += a->version(); - t += "]"; - t += " ["; - t += a->name(); - t += "]"; - t += "
"; - t += a->description(); - t += ""; - - setText(t); - QPixmap * p = a->icon(); - if (p) setIcon(*p); -} - -KviScriptAddonListViewItem::~KviScriptAddonListViewItem() -{ - delete m_pAddon; -} - -KviScriptManagementDialog::KviScriptManagementDialog(QWidget * p) -: QDialog(p) -{ - setWindowTitle(__tr2qs("Manage Script-Based Addons")); - setObjectName("Addon manager"); - setWindowIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_ADDONS))); - setModal(true); - m_pInstance = this; - QGridLayout * g = new QGridLayout(this); - - KviTalHBox *hb = new KviTalHBox(this); - hb->setMargin(1); - hb->setSpacing(1); - g->addWidget(hb,0,0); - - QToolButton * tb; - QFrame * sep; - - m_pConfigureButton = new QToolButton(hb); - m_pConfigureButton->setIcon(*(g_pIconManager->getBigIcon(KVI_BIGICON_ADDONS))); - m_pConfigureButton->setIconSize(QSize(32,32)); - KviTalToolTip::add(m_pConfigureButton,__tr2qs_ctx("Configure Addon...","addon")); - connect(m_pConfigureButton,SIGNAL(clicked()),this,SLOT(configureScript())); - - m_pHelpButton = new QToolButton(hb); - m_pHelpButton->setIcon(*(g_pIconManager->getBigIcon(KVI_BIGICON_HELP))); - m_pHelpButton->setIconSize(QSize(32,32)); - KviTalToolTip::add(m_pHelpButton,__tr2qs_ctx("Show Help","addon")); - connect(m_pHelpButton,SIGNAL(clicked()),this,SLOT(showScriptHelp())); - - m_pUninstallButton = new QToolButton(hb); - m_pUninstallButton->setIcon(*(g_pIconManager->getBigIcon(KVI_BIGICON_REMOVE))); - m_pUninstallButton->setIconSize(QSize(32,32)); - KviTalToolTip::add(m_pUninstallButton,__tr2qs_ctx("Delete Selected Addons","addon")); - connect(m_pUninstallButton,SIGNAL(clicked()),this,SLOT(uninstallScript())); - - sep = new QFrame(hb); - sep->setFrameStyle(QFrame::VLine | QFrame::Sunken); - sep->setMinimumWidth(12); - - m_pPackButton = new QToolButton(hb); - m_pPackButton->setIcon(*(g_pIconManager->getBigIcon(KVI_BIGICON_PACK))); - m_pPackButton->setIconSize(QSize(32,32)); - KviTalToolTip::add(m_pPackButton,__tr2qs_ctx("Create an Addon as a Distributable Package","addon")); - connect(m_pPackButton,SIGNAL(clicked()),this,SLOT(packScript())); - - sep = new QFrame(hb); - sep->setFrameStyle(QFrame::VLine | QFrame::Sunken); - sep->setMinimumWidth(12); - - tb = new QToolButton(hb); - tb->setIcon(*(g_pIconManager->getBigIcon(KVI_BIGICON_OPEN))); - tb->setIconSize(QSize(32,32)); - KviTalToolTip::add(tb,__tr2qs_ctx("Install Addon Package From Disk","addon")); - connect(tb,SIGNAL(clicked()),this,SLOT(installScript())); - - tb = new QToolButton(hb); - tb->setIcon(*(g_pIconManager->getBigIcon(KVI_BIGICON_WWW))); - tb->setIconSize(QSize(32,32)); - KviTalToolTip::add(tb,__tr2qs_ctx("Get More Addons...","addon")); - connect(tb,SIGNAL(clicked()),this,SLOT(getMoreScripts())); - - QWidget *w= new QWidget(hb); - w->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum); - - m_pListWidget = new KviTalListWidget(this); - KviTalIconAndRichTextItemDelegate *itemDelegate=new KviTalIconAndRichTextItemDelegate(m_pListWidget); - - m_pListWidget->setItemDelegate(itemDelegate); - m_pListWidget->setSelectionMode(QAbstractItemView::SingleSelection); - m_pListWidget->setSortingEnabled(true); - m_pListWidget->setMinimumHeight(400); - m_pListWidget->setMinimumWidth(380); - - QString szPic; - g_pApp->getGlobalKvircDirectory(szPic,KviApp::Pics); - // we need mandatory unix like path separator - szPic.replace('\\',"/"); - - szPic += "/kvi_dialog_addons.png"; - QString szStyle("QListWidget {background-image: url(" + szPic + ");background-repeat: no-repeat;background-position: bottom right;}"); - m_pListWidget->setStyleSheet(szStyle); - g->addWidget(m_pListWidget,1,0); - - fillListView(); - - currentChanged(0,0); - connect(m_pListWidget,SIGNAL(currentItemChanged(QListWidgetItem *,QListWidgetItem *)),this,SLOT(currentChanged(QListWidgetItem *,QListWidgetItem *))); - m_pListWidget->setCurrentItem(m_pListWidget->item(0)); - - QPushButton * pCloseBtn = new QPushButton(__tr2qs("Close"),this); - pCloseBtn->setMaximumSize(pCloseBtn->sizeHint().width(),pCloseBtn->sizeHint().height()); - connect(pCloseBtn,SIGNAL(clicked()),this,SLOT(closeClicked())); - g->addWidget(pCloseBtn,2,0); - - g->setMargin(5); - g->setSpacing(5); - g->setAlignment(pCloseBtn,Qt::AlignRight); - - if(g_rectManagementDialogGeometry.y() < 5) - { - g_rectManagementDialogGeometry.setY(5); - } - resize(g_rectManagementDialogGeometry.width(), - g_rectManagementDialogGeometry.height()); - move(g_rectManagementDialogGeometry.x(), - g_rectManagementDialogGeometry.y()); -} - -KviScriptManagementDialog::~KviScriptManagementDialog() -{ - g_rectManagementDialogGeometry = QRect(pos().x(),pos().y(),size().width(),size().height()); - m_pInstance = 0; -} - -void KviScriptManagementDialog::fillListView() -{ - m_pListWidget->clear(); - KviPointerHashTable * d = KviKvsScriptAddonManager::instance()->addonDict(); - if(!d)return; - KviPointerHashTableIterator it(*d); - KviScriptAddonListViewItem * item; - while(KviKvsScriptAddon * a = it.current()) - { - item = new KviScriptAddonListViewItem(m_pListWidget,a); - ++it; - } -} - -void KviScriptManagementDialog::currentChanged(QListWidgetItem *item,QListWidgetItem *) -{ - KviScriptAddonListViewItem * it = (KviScriptAddonListViewItem *)item; - if(!it) - { - m_pConfigureButton->setEnabled(false); - m_pUninstallButton->setEnabled(false); - m_pHelpButton->setEnabled(false); - } else { - m_pConfigureButton->setEnabled(!(it->addon()->configureCallbackCode().isEmpty())); - m_pHelpButton->setEnabled(!(it->addon()->helpCallbackCode().isEmpty())); - m_pUninstallButton->setEnabled(true); - } -} - -void KviScriptManagementDialog::showScriptHelp() -{ - KviScriptAddonListViewItem * it = (KviScriptAddonListViewItem *)m_pListWidget->currentItem(); - if(!it)return; - if(it->addon()->helpCallbackCode().isEmpty())return; - it->addon()->executeHelpCallback(g_pActiveWindow); -} - -void KviScriptManagementDialog::configureScript() -{ - KviScriptAddonListViewItem * it = (KviScriptAddonListViewItem *)m_pListWidget->currentItem(); - if(!it)return; - if(it->addon()->configureCallbackCode().isEmpty())return; - it->addon()->executeConfigureCallback(g_pActiveWindow); -} - -void KviScriptManagementDialog::packScript() -{ - KviPackAddonDialog * pDialog = new KviPackAddonDialog(this); - pDialog->exec(); - delete pDialog; -} - -void KviScriptManagementDialog::uninstallScript() -{ - KviScriptAddonListViewItem * it = (KviScriptAddonListViewItem *)m_pListWidget->currentItem(); - if(!it)return; - - QString txt = "

"; - txt += __tr2qs("Do you really want to uninstall the addon \"%1\" ?").arg(it->addon()->visibleName()); - txt += "

"; - - if(QMessageBox::question(this, - __tr2qs("Confirm addon uninstallation"),txt,__tr2qs("&Yes"),__tr2qs("&No"),0,1) != 0)return; - - KviKvsScriptAddonManager::instance()->unregisterAddon(it->addon()->name(),g_pActiveWindow); - - fillListView(); - currentChanged(0,0); -} - -void KviScriptManagementDialog::getMoreScripts() -{ - KviKvsScript::run("openurl http://www.kvirc.net/?id=addons&version=" KVI_VERSION "." KVI_SOURCES_DATE,g_pActiveWindow); -} - -void KviScriptManagementDialog::installScript() -{ - QString szFileName, szError; - - if(!KviFileDialog::askForOpenFileName(szFileName,__tr2qs("Please select the addon installation file"),QString::null,KVI_FILTER_SCRIPTS,false,true))return; - - szFileName.replace("\\","\\\\"); - - // Switch between script and addon - if(szFileName.endsWith(".kvs")) - { - qDebug("Script file .kvs"); - QString szCmd = "parse \""; - szCmd += szFileName; - szCmd += "\""; - - KviKvsScript::run(szCmd,g_pActiveWindow); - } else if(szFileName.endsWith(".kva")){ - qDebug("Addon file .kva"); - if(!KviAddonFunctions::installAddonPackage(szFileName,szError,this)) - { - QMessageBox::critical(this,__tr2qs_ctx("Install Addon - KVIrc","addon"),szError,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); - return; - } - } else { - // Just for sanity check. We should NEVER enter here - qDebug("Entered sanity check"); - KviAddonFunctions::notAValidAddonPackage(szError); - QMessageBox::critical(this,__tr2qs_ctx("Install Addon - KVIrc","addon"),szError,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); - } - - fillListView(); - currentChanged(0,0); - - //m_pListWidget->publicUpdateContents(); - //m_pListWidget->triggerUpdate(); -} - -void KviScriptManagementDialog::showEvent(QShowEvent * e) -{ -// QRect r = parentWidget() ? parentWidget()->rect() : QApplication::desktop()->rect(); -// int x = (r.width() - width()) / 2; -// int y = (r.height() - height()) / 2; -// move(x,y); -} - -void KviScriptManagementDialog::closeClicked() -{ - delete this; -} - -void KviScriptManagementDialog::cleanup() -{ - if(!m_pInstance)return; - delete m_pInstance; - m_pInstance = 0; -} - -void KviScriptManagementDialog::display() -{ - if(m_pInstance)return; - m_pInstance = new KviScriptManagementDialog(g_pFrame); - m_pInstance->show(); -} - -void KviScriptManagementDialog::closeEvent(QCloseEvent * e) -{ - e->ignore(); - delete this; -} - -void KviScriptManagementDialog::reject() -{ - cleanup(); -} +//============================================================================= +// +// File : managementdialog.cpp +// Created on Fri 08 Apr 2005 14:54:56 by Szymon Stefanek +// +// This file is part of the KVIrc IRC Client distribution +// Copyright (C) 2005 Szymon Stefanek +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +//============================================================================= + +#include "managementdialog.h" +#include "packaddondialog.h" +#include "addonfunctions.h" + +#include "kvi_app.h" +#include "kvi_locale.h" +#include "kvi_frame.h" +#include "kvi_iconmanager.h" +#include "kvi_kvs_scriptaddonmanager.h" +#include "kvi_window.h" +#include "kvi_filedialog.h" +#include "kvi_fileutils.h" +#include "kvi_fileextensions.h" +#include "kvi_kvs_script.h" +#include "kvi_sourcesdate.h" +#include "kvi_tal_listwidget.h" +#include "kvi_tal_tooltip.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + + +KviScriptManagementDialog * KviScriptManagementDialog::m_pInstance = 0; +extern QRect g_rectManagementDialogGeometry; + +KviScriptAddonListViewItem::KviScriptAddonListViewItem(KviTalListWidget *v,KviKvsScriptAddon * a) +: KviTalListWidgetItem(v) +{ + m_pAddon = new KviKvsScriptAddon(*a); + m_pListWidget = v; + QString t = ""; + t += a->visibleName(); + t += " ["; + t += a->version(); + t += "]"; + t += " ["; + t += a->name(); + t += "]"; + t += "
"; + t += a->description(); + t += ""; + + setText(t); + QPixmap * p = a->icon(); + if (p) setIcon(*p); +} + +KviScriptAddonListViewItem::~KviScriptAddonListViewItem() +{ + delete m_pAddon; +} + +KviScriptManagementDialog::KviScriptManagementDialog(QWidget * p) +: QDialog(p) +{ + setWindowTitle(__tr2qs("Manage Script-Based Addons")); + setObjectName("Addon manager"); + setWindowIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_ADDONS))); + setModal(true); + m_pInstance = this; + QGridLayout * g = new QGridLayout(this); + + KviTalHBox *hb = new KviTalHBox(this); + hb->setMargin(1); + hb->setSpacing(1); + g->addWidget(hb,0,0); + + QToolButton * tb; + QFrame * sep; + + m_pConfigureButton = new QToolButton(hb); + m_pConfigureButton->setIcon(*(g_pIconManager->getBigIcon(KVI_BIGICON_ADDONS))); + m_pConfigureButton->setIconSize(QSize(32,32)); + KviTalToolTip::add(m_pConfigureButton,__tr2qs_ctx("Configure Addon...","addon")); + connect(m_pConfigureButton,SIGNAL(clicked()),this,SLOT(configureScript())); + + m_pHelpButton = new QToolButton(hb); + m_pHelpButton->setIcon(*(g_pIconManager->getBigIcon(KVI_BIGICON_HELP))); + m_pHelpButton->setIconSize(QSize(32,32)); + KviTalToolTip::add(m_pHelpButton,__tr2qs_ctx("Show Help","addon")); + connect(m_pHelpButton,SIGNAL(clicked()),this,SLOT(showScriptHelp())); + + m_pUninstallButton = new QToolButton(hb); + m_pUninstallButton->setIcon(*(g_pIconManager->getBigIcon(KVI_BIGICON_REMOVE))); + m_pUninstallButton->setIconSize(QSize(32,32)); + KviTalToolTip::add(m_pUninstallButton,__tr2qs_ctx("Delete Selected Addons","addon")); + connect(m_pUninstallButton,SIGNAL(clicked()),this,SLOT(uninstallScript())); + + sep = new QFrame(hb); + sep->setFrameStyle(QFrame::VLine | QFrame::Sunken); + sep->setMinimumWidth(12); + + m_pPackButton = new QToolButton(hb); + m_pPackButton->setIcon(*(g_pIconManager->getBigIcon(KVI_BIGICON_PACK))); + m_pPackButton->setIconSize(QSize(32,32)); + KviTalToolTip::add(m_pPackButton,__tr2qs_ctx("Create an Addon as a Distributable Package","addon")); + connect(m_pPackButton,SIGNAL(clicked()),this,SLOT(packScript())); + + sep = new QFrame(hb); + sep->setFrameStyle(QFrame::VLine | QFrame::Sunken); + sep->setMinimumWidth(12); + + tb = new QToolButton(hb); + tb->setIcon(*(g_pIconManager->getBigIcon(KVI_BIGICON_OPEN))); + tb->setIconSize(QSize(32,32)); + KviTalToolTip::add(tb,__tr2qs_ctx("Install Addon Package From Disk","addon")); + connect(tb,SIGNAL(clicked()),this,SLOT(installScript())); + + tb = new QToolButton(hb); + tb->setIcon(*(g_pIconManager->getBigIcon(KVI_BIGICON_WWW))); + tb->setIconSize(QSize(32,32)); + KviTalToolTip::add(tb,__tr2qs_ctx("Get More Addons...","addon")); + connect(tb,SIGNAL(clicked()),this,SLOT(getMoreScripts())); + + QWidget *w= new QWidget(hb); + w->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum); + + m_pListWidget = new KviTalListWidget(this); + KviTalIconAndRichTextItemDelegate *itemDelegate=new KviTalIconAndRichTextItemDelegate(m_pListWidget); + + m_pListWidget->setItemDelegate(itemDelegate); + m_pListWidget->setSelectionMode(QAbstractItemView::SingleSelection); + m_pListWidget->setSortingEnabled(true); + m_pListWidget->setMinimumHeight(400); + m_pListWidget->setMinimumWidth(380); + + QString szPic; + g_pApp->getGlobalKvircDirectory(szPic,KviApp::Pics); + // we need mandatory unix like path separator + szPic.replace('\\',"/"); + + szPic += "/kvi_dialog_addons.png"; + QString szStyle("QListWidget {background-image: url(" + szPic + ");background-repeat: no-repeat;background-position: bottom right;}"); + m_pListWidget->setStyleSheet(szStyle); + g->addWidget(m_pListWidget,1,0); + + fillListView(); + + currentChanged(0,0); + connect(m_pListWidget,SIGNAL(currentItemChanged(QListWidgetItem *,QListWidgetItem *)),this,SLOT(currentChanged(QListWidgetItem *,QListWidgetItem *))); + m_pListWidget->setCurrentItem(m_pListWidget->item(0)); + + QPushButton * pCloseBtn = new QPushButton(__tr2qs("Close"),this); + pCloseBtn->setMaximumSize(pCloseBtn->sizeHint().width(),pCloseBtn->sizeHint().height()); + connect(pCloseBtn,SIGNAL(clicked()),this,SLOT(closeClicked())); + g->addWidget(pCloseBtn,2,0); + + g->setMargin(5); + g->setSpacing(5); + g->setAlignment(pCloseBtn,Qt::AlignRight); + + if(g_rectManagementDialogGeometry.y() < 5) + { + g_rectManagementDialogGeometry.setY(5); + } + resize(g_rectManagementDialogGeometry.width(), + g_rectManagementDialogGeometry.height()); + move(g_rectManagementDialogGeometry.x(), + g_rectManagementDialogGeometry.y()); +} + +KviScriptManagementDialog::~KviScriptManagementDialog() +{ + g_rectManagementDialogGeometry = QRect(pos().x(),pos().y(),size().width(),size().height()); + m_pInstance = 0; +} + +void KviScriptManagementDialog::fillListView() +{ + m_pListWidget->clear(); + KviPointerHashTable * d = KviKvsScriptAddonManager::instance()->addonDict(); + if(!d)return; + KviPointerHashTableIterator it(*d); + KviScriptAddonListViewItem * item; + while(KviKvsScriptAddon * a = it.current()) + { + item = new KviScriptAddonListViewItem(m_pListWidget,a); + ++it; + } +} + +void KviScriptManagementDialog::currentChanged(QListWidgetItem *item,QListWidgetItem *) +{ + KviScriptAddonListViewItem * it = (KviScriptAddonListViewItem *)item; + if(!it) + { + m_pConfigureButton->setEnabled(false); + m_pUninstallButton->setEnabled(false); + m_pHelpButton->setEnabled(false); + } else { + m_pConfigureButton->setEnabled(!(it->addon()->configureCallbackCode().isEmpty())); + m_pHelpButton->setEnabled(!(it->addon()->helpCallbackCode().isEmpty())); + m_pUninstallButton->setEnabled(true); + } +} + +void KviScriptManagementDialog::showScriptHelp() +{ + KviScriptAddonListViewItem * it = (KviScriptAddonListViewItem *)m_pListWidget->currentItem(); + if(!it)return; + if(it->addon()->helpCallbackCode().isEmpty())return; + it->addon()->executeHelpCallback(g_pActiveWindow); +} + +void KviScriptManagementDialog::configureScript() +{ + KviScriptAddonListViewItem * it = (KviScriptAddonListViewItem *)m_pListWidget->currentItem(); + if(!it)return; + if(it->addon()->configureCallbackCode().isEmpty())return; + it->addon()->executeConfigureCallback(g_pActiveWindow); +} + +void KviScriptManagementDialog::packScript() +{ + KviPackAddonDialog * pDialog = new KviPackAddonDialog(this); + pDialog->exec(); + delete pDialog; +} + +void KviScriptManagementDialog::uninstallScript() +{ + KviScriptAddonListViewItem * it = (KviScriptAddonListViewItem *)m_pListWidget->currentItem(); + if(!it)return; + + QString txt = "

"; + txt += __tr2qs("Do you really want to uninstall the addon \"%1\" ?").arg(it->addon()->visibleName()); + txt += "

"; + + if(QMessageBox::question(this, + __tr2qs("Confirm addon uninstallation"),txt,__tr2qs("&Yes"),__tr2qs("&No"),0,1) != 0)return; + + KviKvsScriptAddonManager::instance()->unregisterAddon(it->addon()->name(),g_pActiveWindow); + + fillListView(); + currentChanged(0,0); +} + +void KviScriptManagementDialog::getMoreScripts() +{ + KviKvsScript::run("openurl http://www.kvirc.net/?id=addons&version=" KVI_VERSION "." KVI_SOURCES_DATE,g_pActiveWindow); +} + +void KviScriptManagementDialog::installScript() +{ + QString szFileName, szError; + + if(!KviFileDialog::askForOpenFileName(szFileName,__tr2qs("Please select the addon installation file"),QString::null,KVI_FILTER_SCRIPTS,false,true))return; + + szFileName.replace("\\","\\\\"); + + // Switch between script and addon + if(szFileName.endsWith(".kvs")) + { + qDebug("Script file .kvs"); + QString szCmd = "parse \""; + szCmd += szFileName; + szCmd += "\""; + + KviKvsScript::run(szCmd,g_pActiveWindow); + } else if(szFileName.endsWith(".kva")){ + qDebug("Addon file .kva"); + if(!KviAddonFunctions::installAddonPackage(szFileName,szError,this)) + { + QMessageBox::critical(this,__tr2qs_ctx("Install Addon - KVIrc","addon"),szError,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); + return; + } + } else { + // Just for sanity check. We should NEVER enter here + qDebug("Entered sanity check"); + KviAddonFunctions::notAValidAddonPackage(szError); + QMessageBox::critical(this,__tr2qs_ctx("Install Addon - KVIrc","addon"),szError,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); + } + + fillListView(); + currentChanged(0,0); + + //m_pListWidget->publicUpdateContents(); + //m_pListWidget->triggerUpdate(); +} + +void KviScriptManagementDialog::showEvent(QShowEvent * e) +{ +// QRect r = parentWidget() ? parentWidget()->rect() : QApplication::desktop()->rect(); +// int x = (r.width() - width()) / 2; +// int y = (r.height() - height()) / 2; +// move(x,y); +} + +void KviScriptManagementDialog::closeClicked() +{ + delete this; +} + +void KviScriptManagementDialog::cleanup() +{ + if(!m_pInstance)return; + delete m_pInstance; + m_pInstance = 0; +} + +void KviScriptManagementDialog::display() +{ + if(m_pInstance)return; + m_pInstance = new KviScriptManagementDialog(g_pFrame); + m_pInstance->show(); +} + +void KviScriptManagementDialog::closeEvent(QCloseEvent * e) +{ + e->ignore(); + delete this; +} + +void KviScriptManagementDialog::reject() +{ + cleanup(); +} -- cgit v1.3.1-10-gc9f91