From bcb704366cb5e333a626c18c308c7e0448a8e69f Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- ksirc/usercontrolmenu.cpp | 167 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 ksirc/usercontrolmenu.cpp (limited to 'ksirc/usercontrolmenu.cpp') diff --git a/ksirc/usercontrolmenu.cpp b/ksirc/usercontrolmenu.cpp new file mode 100644 index 00000000..ca35e094 --- /dev/null +++ b/ksirc/usercontrolmenu.cpp @@ -0,0 +1,167 @@ +#include "usercontrolmenu.h" + +#include +#include +#include + +QPtrList UserControlMenu::UserMenu; + +UserControlMenu::UserControlMenu(const QString& _title, + const QString& _action, + int _accel, + int _type, + bool _op_only) +{ + title = _title; + action = _action; + accel = _accel; + type = (itype) _type; + op_only = _op_only; +} + +UserControlMenu::~UserControlMenu() +{ +} + +QPtrList *UserControlMenu::parseKConfig() +{ + + // Reset the UserMenu to nothing before we start. + + UserMenu.clear(); + + KConfig *kConfig = kapp->config(); + kConfig->setGroup("UserMenu"); + int items = kConfig->readNumEntry("Number"); + if(items == 0){ + + // We found nothing, so let's use some defaults. + + UserMenu.setAutoDelete(TRUE); + UserMenu.append(new UserControlMenu(i18n("&Refresh Nicks"), + "refresh", + 0, UserControlMenu::Text)); + UserMenu.append(new UserControlMenu); + UserMenu.append(new UserControlMenu(i18n("&Follow"), + "follow $$dest_nick", + 0, UserControlMenu::Text)); + UserMenu.append(new UserControlMenu(i18n("&UnFollow"), + "unfollow $$dest_nick", + 0, UserControlMenu::Text)); + UserMenu.append(new UserControlMenu); // Defaults to a separator + UserMenu.append(new UserControlMenu(i18n("&Whois"), + "/whois $$dest_nick", + 0, UserControlMenu::Text)); + UserMenu.append(new UserControlMenu(i18n("&Ping"), + "/ping $$dest_nick", + 0, UserControlMenu::Text)); + UserMenu.append(new UserControlMenu(i18n("V&ersion"), + "/ctcp $$dest_nick VERSION", + 0, UserControlMenu::Text)); + UserMenu.append(new UserControlMenu); // Defaults to a separator + UserMenu.append(new UserControlMenu(i18n("&Abuse"), + "/me slaps $$dest_nick around with a small 50lb Unix Manual", + 0, UserControlMenu::Text)); + UserMenu.append(new UserControlMenu); // Defaults to a separator + UserMenu.append(new UserControlMenu(i18n("&Kick"), + "/kick $$dest_nick", + 0, + UserControlMenu::Text, + TRUE)); + UserMenu.append(new UserControlMenu(i18n("&Ban"), + "/ban $$dest_nick", + 0, + UserControlMenu::Text, + TRUE)); + UserMenu.append(new UserControlMenu(i18n("U&nBan"), + "/unban $$dest_nick", + 0, + UserControlMenu::Text, + TRUE)); + UserMenu.append(new UserControlMenu()); + UserMenu.append(new UserControlMenu(i18n("&Op"), + "/op $$dest_nick", + 0, + UserControlMenu::Text, + TRUE)); + UserMenu.append(new UserControlMenu(i18n("&Deop"), + "/deop $$dest_nick", + 0, + UserControlMenu::Text, + TRUE)); + UserMenu.append(new UserControlMenu()); + UserMenu.append(new UserControlMenu(i18n("&Voice"), + "/mode $$dest_chan +v $$dest_nick", + 0, + UserControlMenu::Text, + TRUE)); + UserMenu.append(new UserControlMenu(i18n("Devo&ice"), + "/mode $$dest_chan -v $$dest_nick", + 0, + UserControlMenu::Text, + TRUE)); + } + else{ + QString key, cindex, title, action; + int accel, type, oponly; + for(int i = 0; i < items; i++){ + cindex.sprintf("%d", i); + key = "MenuType-" + cindex; + type = kConfig->readNumEntry(key); + if(type == UserControlMenu::Seperator) + UserMenu.append(new UserControlMenu()); + else if(type == UserControlMenu::Text){ + key = "MenuTitle-" + cindex; + title = kConfig->readEntry(key); + key = "MenuAction-" + cindex; + action = kConfig->readEntry(key); + key = "MenuAccel-" + cindex; + accel = kConfig->readNumEntry(key); + key = "MenuOpOnly-" + cindex; + oponly = kConfig->readNumEntry(key); + + UserMenu.append(new UserControlMenu(title, action, accel, type, (bool) oponly)); + } + } + } + + return &UserMenu; + +} + +void UserControlMenu::writeKConfig() +{ + KConfig *kConfig = kapp->config(); + kConfig->setGroup("UserMenu"); + + int items = (int) UserMenu.count(); + + kConfig->writeEntry("Number", items); + + QString key; + QString cindex; + UserControlMenu *ucm; + int type; + + for(int i = 0; i < items; i++){ + ucm = UserMenu.at(i); + cindex.sprintf("%d", i); + key = "MenuType-" + cindex; + type = ucm->type; + kConfig->writeEntry(key, (int) type); + // Do nothing for a seperator since it defaults across + if(type == UserControlMenu::Text){ + key = "MenuTitle-" + cindex; + kConfig->writeEntry(key, ucm->title); + key = "MenuAction-" + cindex; + kConfig->writeEntry(key, ucm->action); + key = "MenuAccel-" + cindex; + kConfig->writeEntry(key, (int) ucm->accel); + key = "MenuOpOnly-" + cindex; + kConfig->writeEntry(key, (int) ucm->op_only); + } + } + kConfig->sync(); + +} + -- cgit v1.2.1