Implemented slots in Tabs menu and reworked tab mechanism.

The idea is to make some tabs closeable by the user (e.g. one may not
need the Virus Browser tab all the time!). The state is stored in
the program's configuration file.
Some tabs are supposed to be always open (Scan and Update), that is
why a way to close them is not programmatically implemented.

Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
pull/24/head
Mavridis Philippe 4 years ago
parent ea73c1340c
commit c30d5e78ea
No known key found for this signature in database
GPG Key ID: F8D2D7E2F989A494

@ -85,12 +85,12 @@ Klamav::Klamav()
scanner_menu->insertItem( i18n("&Schedule scan..."), this, SLOT(slotScheduleScan()) ); scanner_menu->insertItem( i18n("&Schedule scan..."), this, SLOT(slotScheduleScan()) );
scanner_menu->insertItem( i18n("&Options..."), this, SLOT(slotOptions()) ); scanner_menu->insertItem( i18n("&Options..."), this, SLOT(slotOptions()) );
TDEPopupMenu *tabs_menu = new TDEPopupMenu(this); tabs_menu = new TDEPopupMenu(this);
tabs_menu->setCheckable(true); tabs_menu->setCheckable(true);
tabs_menu->insertItem( i18n("Show &Welcome tab"), this, SLOT(slotToggleWelcome()) ); showWelcomeTab = tabs_menu->insertItem( i18n("Show &Welcome tab"), this, SLOT(slotToggleWelcome()) );
tabs_menu->insertItem( i18n("Show &Quarantine tab"), this, SLOT(slotToggleWelcome()) ); showQuarantineTab = tabs_menu->insertItem( i18n("Show &Quarantine tab"), this, SLOT(slotToggleQuarantine()) );
tabs_menu->insertItem( i18n("Show &Virus Browser tab"), this, SLOT(slotToggleDBViewer()) ); showDBViewerTab = tabs_menu->insertItem( i18n("Show &Virus Browser tab"), this, SLOT(slotToggleDBViewer()) );
tabs_menu->insertItem( i18n("Show &Events tab"), this, SLOT(slotToggleEvents()) ); showEventsTab = tabs_menu->insertItem( i18n("Show &Events tab"), this, SLOT(slotToggleEvents()) );
// Menu bar // Menu bar
@ -104,7 +104,7 @@ Klamav::Klamav()
activityviewer = new Activityviewer(this); activityviewer = new Activityviewer(this);
aboutklamav = new Aboutklamav(this); aboutklamav = new Aboutklamav(this);
tab->addTab(aboutklamav, i18n("Welcome")); updateTabState(0, true); // Welcome tab
klamscan = new Klamscan(this); klamscan = new Klamscan(this);
tab->addTab(klamscan, i18n("&Scan")); tab->addTab(klamscan, i18n("&Scan"));
@ -120,14 +120,12 @@ Klamav::Klamav()
kuarantine = new Kuarantine(this); kuarantine = new Kuarantine(this);
tab->addTab(kuarantine, i18n("&Quarantine")); updateTabState(1, true); // Quarantine tab
klamdb = new KlamDB(this); klamdb = new KlamDB(this);
tab->addTab(klamdb, i18n("Virus Browser")); updateTabState(2, true); // Virus Browser tab
tab->addTab(activityviewer, i18n("Events"));
updateTabState(3, true); // Events tab
top->addWidget(tab); top->addWidget(tab);
@ -189,6 +187,62 @@ void Klamav::clamdStopped() {
_tray->setPixmap(KSystemTray::loadIcon("klamav_on_acc_disabled")); _tray->setPixmap(KSystemTray::loadIcon("klamav_on_acc_disabled"));
} }
void Klamav::updateTabState( int tabId, bool init ) {
if( config->group() != "Tabs" )
config->setGroup("Tabs");
TQString optionName, tabName;
TQWidget* tabWidget;
int itemId;
switch(tabId) {
case 0: // Welcome tab
optionName="ShowWelcomeTab";
tabName="Welcome";
tabWidget=aboutklamav;
itemId=showWelcomeTab;
break;
case 1: // Quarantine tab
optionName="ShowQuarantineTab";
tabName="Quarantine";
tabWidget=kuarantine;
itemId=showQuarantineTab;
break;
case 2: // DBViewer tab
optionName="ShowDBViewerTab";
tabName="Virus Browser";
tabWidget=klamdb;
itemId=showDBViewerTab;
break;
case 3: // Events tab
optionName="ShowEventsTab";
tabName="Events";
tabWidget=activityviewer;
itemId=showEventsTab;
break;
}
if( config->readBoolEntry(optionName, true) ) {
tab->insertTab(tabWidget, i18n(tabName));
tabWidget->show();
if(!init) tab->setCurrentPage( tab->indexOf(tabWidget) );
} else {
if( tab->currentPageIndex() == tabId )
tab->setCurrentPage(0);
if( tab->indexOf( tabWidget ) != -1 ) {
tab->removePage( tabWidget );
}
tabWidget->hide();
}
tabs_menu->setItemChecked(itemId, config->readBoolEntry(optionName, true) );
}
// Menu slots // Menu slots
void Klamav::slotScanFile() {} void Klamav::slotScanFile() {}
void Klamav::slotScanDir() {} void Klamav::slotScanDir() {}
@ -197,10 +251,34 @@ void Klamav::slotOptions() {
slotConfigKlamav("Archive Limits"); slotConfigKlamav("Archive Limits");
} }
void Klamav::slotToggleWelcome() {} void Klamav::slotToggleWelcome() {
void Klamav::slotToggleQuarantine() {} bool newState = ! config->readBoolEntry("ShowWelcomeTab", true);
void Klamav::slotToggleDBViewer() {} config->writeEntry("ShowWelcomeTab", newState);
void Klamav::slotToggleEvents() {} config->sync();
updateTabState(0, false);
}
void Klamav::slotToggleQuarantine() {
bool newState = ! config->readBoolEntry("ShowQuarantineTab", true);
config->writeEntry("ShowQuarantineTab", newState);
config->sync();
updateTabState(1, false);
}
void Klamav::slotToggleDBViewer() {
bool newState = ! config->readBoolEntry("ShowDBViewerTab", true);
config->writeEntry("ShowDBViewerTab", newState);
config->sync();
updateTabState(2, false);
}
void Klamav::slotToggleEvents() {
bool newState = ! config->readBoolEntry("ShowEventsTab", true);
config->writeEntry("ShowEventsTab", newState);
config->sync();
updateTabState(3, false);
}
void Klamav::contextUpdateFK() { void Klamav::contextUpdateFK() {

@ -17,6 +17,7 @@
class KPrinter; class KPrinter;
class TDEToggleAction; class TDEToggleAction;
class TDEPopupMenu;
class KURL; class KURL;
class TQLineEdit; class TQLineEdit;
class TQComboBox; class TQComboBox;
@ -124,6 +125,7 @@ private:
void firstRunWizard(); void firstRunWizard();
void createDefaultKlamAVDir(TQString type); void createDefaultKlamAVDir(TQString type);
void checkDir(TQString path); void checkDir(TQString path);
void updateTabState(int tabId, bool init);
private: private:
//KlamavView *m_view; //KlamavView *m_view;
@ -156,6 +158,11 @@ private:
Sigtool *sigtool; Sigtool *sigtool;
Aboutklamav *aboutklamav; Aboutklamav *aboutklamav;
TDEPopupMenu *tabs_menu;
int showWelcomeTab;
int showQuarantineTab;
int showDBViewerTab;
int showEventsTab;
}; };
extern Klamav *tdemain; extern Klamav *tdemain;

Loading…
Cancel
Save