void ThemeManagementDialog::deleteTheme() { QList<QListWidgetItem *> itemsSelected = m_pListWidget->selectedItems(); for(int i=0; i < itemsSelected.count(); i++) { ThemeListWidgetItem * pItem = dynamic_cast<ThemeListWidgetItem *>(itemsSelected.at(i)); if(!pItem) return; KviThemeInfo * pInfo = pItem->themeInfo(); if(pInfo->isBuiltin()) continue; if(!KviMessageBox::yesNo( __tr2qs_ctx("Delete Theme - KVIrc","theme"), __tr2qs_ctx("Do you really wish to delete theme \"%Q\" (version %Q)?","theme"), &(pInfo->name()), &(pInfo->version())) ) goto jump_out; QString szThemePath = ((ThemeListWidgetItem *)itemsSelected.at(i))->themeInfo()->directory(); KviFileUtils::deleteDir(szThemePath); } jump_out: fillThemeBox(); }
void ThemeManagementDialog::contextMenuRequested(const QPoint & pos) { ThemeListWidgetItem * pItem = dynamic_cast<ThemeListWidgetItem *>(m_pListWidget->itemAt(pos)); if(pItem != 0) { m_pListWidget->setCurrentItem(pItem); m_pContextPopup->clear(); KviThemeInfo * pInfo = pItem->themeInfo(); if(!pInfo) return; if(!pInfo->isBuiltin()) m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Minus)),__tr2qs_ctx("&Remove Theme","theme"),this,SLOT(deleteTheme())); m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Accept)),__tr2qs_ctx("&Apply Theme","theme"),this,SLOT(applyCurrentTheme())); m_pContextPopup->popup(m_pListWidget->viewport()->mapToGlobal(pos)); } }
void ThemeManagementDialog::enableDisableButtons() { QList<QListWidgetItem *> itemsSelected = m_pListWidget->selectedItems(); int iCount = itemsSelected.count(); bool bHasItems = iCount ? true : false; m_pPackThemeButton->setEnabled(bHasItems); unsigned int u = 0; for(int i = 0; i < iCount; i++) { ThemeListWidgetItem * pItem = dynamic_cast<ThemeListWidgetItem *>(itemsSelected.at(i)); if(!pItem) return; KviThemeInfo * pInfo = pItem->themeInfo(); if(!pInfo->isBuiltin()) u++; } m_pDeleteThemeButton->setEnabled(u >= 1); }