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("&Options..."), this, SLOT(slotOptions()) );
TDEPopupMenu *tabs_menu = new TDEPopupMenu(this);
tabs_menu = new TDEPopupMenu(this);
tabs_menu->setCheckable(true);
tabs_menu->insertItem( i18n("Show &Welcome tab"), this, SLOT(slotToggleWelcome()) );
tabs_menu->insertItem( i18n("Show &Quarantine tab"), this, SLOT(slotToggleWelcome()) );
tabs_menu->insertItem( i18n("Show &Virus Browser tab"), this, SLOT(slotToggleDBViewer()) );
tabs_menu->insertItem( i18n("Show &Events tab"), this, SLOT(slotToggleEvents()) );
showWelcomeTab = tabs_menu->insertItem( i18n("Show &Welcome tab"), this, SLOT(slotToggleWelcome()) );
showQuarantineTab = tabs_menu->insertItem( i18n("Show &Quarantine tab"), this, SLOT(slotToggleQuarantine()) );
showDBViewerTab = tabs_menu->insertItem( i18n("Show &Virus Browser tab"), this, SLOT(slotToggleDBViewer()) );
showEventsTab = tabs_menu->insertItem( i18n("Show &Events tab"), this, SLOT(slotToggleEvents()) );
// Menu bar
@ -104,7 +104,7 @@ Klamav::Klamav()
activityviewer = new Activityviewer(this);
aboutklamav = new Aboutklamav(this);
tab->addTab(aboutklamav, i18n("Welcome"));
updateTabState(0, true); // Welcome tab
klamscan = new Klamscan(this);
tab->addTab(klamscan, i18n("&Scan"));
@ -120,14 +120,12 @@ Klamav::Klamav()
kuarantine = new Kuarantine(this);
tab->addTab(kuarantine, i18n("&Quarantine"));
updateTabState(1, true); // Quarantine tab
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);
@ -189,6 +187,62 @@ void Klamav::clamdStopped() {
_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
void Klamav::slotScanFile() {}
void Klamav::slotScanDir() {}
@ -197,10 +251,34 @@ void Klamav::slotOptions() {
slotConfigKlamav("Archive Limits");
}
void Klamav::slotToggleWelcome() {}
void Klamav::slotToggleQuarantine() {}
void Klamav::slotToggleDBViewer() {}
void Klamav::slotToggleEvents() {}
void Klamav::slotToggleWelcome() {
bool newState = ! config->readBoolEntry("ShowWelcomeTab", true);
config->writeEntry("ShowWelcomeTab", newState);
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() {

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

Loading…
Cancel
Save