void joydefs_config() { newmenu_item m[9]; int i1 = 3; int nitems = 9; m[0].type = NM_TYPE_CHECK; m[0].text = TXT_CONTROL_JOYSTICK; m[0].value = Config_control_joystick.intval; m[1].type = NM_TYPE_CHECK; m[1].text = TXT_CONTROL_MOUSE; m[1].value = Config_control_mouse.intval; m[2].type = NM_TYPE_TEXT; m[2].text = ""; m[3].type = NM_TYPE_MENU; m[3].text = TXT_CUST_KEYBOARD; m[4].type = NM_TYPE_MENU; m[4].text = "CUSTOMIZE ANALOG CONTROLS"; m[5].type = NM_TYPE_MENU; m[5].text = "CUSTOMIZE D2X KEYS"; m[6].type = NM_TYPE_TEXT; m[6].text = ""; m[7].type = NM_TYPE_MENU; m[7].text = TXT_JOYS_SENSITIVITY; m[8].type = NM_TYPE_MENU; m[8].text = TXT_CAL_JOYSTICK; do { i1 = newmenu_do1(NULL, TXT_CONTROLS, nitems, m, joydef_menuset_1, i1); cvar_setint(&Config_control_joystick, m[0].value); cvar_setint(&Config_control_mouse, m[1].value); switch (i1) { case 3: kconfig(0, TXT_KEYBOARD); break; case 4: kconfig(1, TXT_AXES); break; case 5: kconfig(2, "D2X KEYS"); break; case 7: joydefs_sensitivity(); break; case 8: joydefs_calibrate(); break; } } while (i1>-1); }
void KApplicationTree::parseKdelnkFile( QFileInfo *fi, KTreeList *tree, KAppTreeListItem *item ) { QPixmap pixmap; QString text_name, pixmap_name, mini_pixmap_name, big_pixmap_name, command_name, comment; QString file = fi->absFilePath(); if( fi->isDir() ) { text_name = fi->fileName(); file += "/.directory"; } else { int pos = fi->fileName().find( ".kdelnk" ); if( pos >= 0 ) text_name = fi->fileName().left( pos ); else text_name = fi->fileName(); } QFile config( file ); if( config.exists() ) { KSimpleConfig kconfig( file, true ); kconfig.setGroup("KDE Desktop Entry"); command_name = kconfig.readEntry("Exec"); mini_pixmap_name = kconfig.readEntry("MiniIcon"); big_pixmap_name = kconfig.readEntry("Icon"); comment = kconfig.readEntry("Comment"); text_name = kconfig.readEntry("Name", text_name); if( !mini_pixmap_name.isEmpty() ) pixmap = KApplication::getKApplication()->getIconLoader()->loadApplicationMiniIcon(mini_pixmap_name, 16, 16); if( pixmap.isNull() && !big_pixmap_name.isEmpty() ) pixmap = KApplication::getKApplication()->getIconLoader()->loadApplicationMiniIcon(big_pixmap_name, 16, 16); if( pixmap.isNull() ) pixmap = KApplication::getKApplication()->getIconLoader()->loadApplicationMiniIcon("mini-default.xpm", 16, 16); } else { command_name = text_name; pixmap = KApplication::getKApplication()->getIconLoader()->loadApplicationMiniIcon("mini-default.xpm", 16, 16); } it2 = new KAppTreeListItem( text_name.data(), &pixmap, false, false, fi->isDir(), fi->absFilePath(), command_name ); if( item == 0 ) tree->insertItem( it2 ); else item->appendChild( it2 ); if( fi->isDir() ) { dummy = new KAppTreeListItem( i18n("This group is empty!"), 0, true, false, false, "", "" ); it2->appendChild( dummy ); } }
void PMenuItem::writeConfig( QDir dir ) { if( read_only || entry_type == separator ) return; QString file = dir.absPath(); dir_path = file.copy(); file += ( (QString) "/" + real_name ); //+ ".kdelnk" ); QFile config(file); if( !config.open(IO_ReadWrite) ) return; config.close(); KConfig kconfig(file); kconfig.setGroup("KDE Desktop Entry"); kconfig.writeEntry("Comment", comment, TRUE, FALSE, TRUE ); kconfig.writeEntry("Icon", big_pixmap_name ); kconfig.writeEntry("MiniIcon", pixmap_name ); kconfig.writeEntry("Name", text_name, TRUE, FALSE, TRUE ); switch( (int) entry_type ) { case (int) swallow_com: kconfig.writeEntry("SwallowExec", swallow_exec ); kconfig.writeEntry("SwallowTitle", swallow_title ); //break; case (int) unix_com: if( entry_type == unix_com ) { kconfig.writeEntry("SwallowExec", "" ); kconfig.writeEntry("TerminalOptions", term_opt ); } kconfig.writeEntry("Exec", command_name ); kconfig.writeEntry("Path", exec_path ); if( use_term ) kconfig.writeEntry("Terminal", 1 ); else kconfig.writeEntry("Terminal", 0 ); kconfig.writeEntry("BinaryPattern", pattern); kconfig.writeEntry("Protocols", protocols); kconfig.writeEntry("MimeType", extensions); kconfig.writeEntry("Type", "Application"); break; case (int) url: kconfig.writeEntry("URL", url_name); kconfig.writeEntry("Type", "Link"); break; case (int) device: kconfig.writeEntry("Dev", dev_name); kconfig.writeEntry("MountPoint", mount_point); kconfig.writeEntry("FSType", fs_type); kconfig.writeEntry("UnmountIcon", umount_pixmap_name); kconfig.writeEntry("ReadOnly", dev_read_only); kconfig.writeEntry("Type", "FSDevice"); break; }; kconfig.sync(); }
void Filelight::Config::write() { KConfigGroup group = kconfig(); group.writeEntry("varyLabelFontSizes", varyLabelFontSizes); group.writeEntry("showSmallFiles", showSmallFiles); group.writeEntry("contrast", contrast); group.writeEntry("antiAliasFactor", antiAliasFactor); group.writeEntry("minFontPitch", minFontPitch); group.writeEntry("scheme", (int)scheme); }
void Filelight::Config::read() { KConfigGroup group = kconfig(); varyLabelFontSizes = group.readEntry("varyLabelFontSizes", true); showSmallFiles = group.readEntry("showSmallFiles", false); contrast = group.readEntry("contrast", 50); antiAliasFactor = group.readEntry("antiAliasFactor", 2); minFontPitch = group.readEntry("minFontPitch", QFont().pointSize() - 3); scheme = (MapScheme) group.readEntry("scheme", 0); defaultRingDepth = 4; }
PMenuItem* PFileMenu::newLinkItem(const QFileInfo* fi, bool useCurrentPath) { KSimpleConfig kconfig(this->path + "/" + fi->fileName(), true); kconfig.setGroup("KDE Desktop Entry"); if (kconfig.readEntry("Type") != "Link") return newFileItem(fi, useCurrentPath); // <<--------- QString url = kconfig.readEntry("URL"); if (url.left(5) == "file:") url = url.right(url.length() - 5); // remove "file:" struct stat urlstat; if (stat(url, &urlstat) != 0 || !S_ISDIR(urlstat.st_mode)) return newFileItem(fi, useCurrentPath); // <<--------- QString pixmap_name = kconfig.readEntry("MiniIcon", DEFAULT_FOLDER_ICON); QString comment = kconfig.readEntry("Comment"); QString name = fi->fileName().left( fi->fileName().length() - 7 ); #ifdef DISKNAV_DEBUG printf("this->path = [%s]\n", this->path.data()); printf("name = [%s]\n", name.data()); printf("url = [%s]\n", url.data()); printf("pixmap_name = [%s]\n", pixmap_name.data()); printf("comment = [%s]\n", comment.data()); #endif PMenuItem* fileb = new PMenuItem(dirbrowser, name + "/", 0, pixmap_name, new PFileMenu(url), 0, 0, new myPopupMenu(this), false, QString(), comment); CHECK_PTR(fileb); return fileb; }
static const char* getFileInfo(const char* _path, const char* file_name, char* new_file, const QFileInfo* fi = 0) { int len = strlen(file_name); strcpy(new_file, file_name); QString file(_path); file += "/"; file += file_name; if (len > 7 && new_file[len - 7] == '.' && strcmp(new_file + len - 6, "kdelnk") == 0) { new_file[len - 7] = 0; // QFileInfo fi(file); KSimpleConfig kconfig(file, true); kconfig.setGroup("KDE Desktop Entry"); QString pixmap = kconfig.readEntry("MiniIcon"); if (pixmap.isEmpty()) { QString big_pixmap_name = kconfig.readEntry("Icon"); if (big_pixmap_name.isEmpty()) return DEFAULT_EXECUTABLE_ICON; else return strdup((char*)big_pixmap_name.data()); } else return strdup((char*) pixmap.data()); } if (fi) return GET_DEFAULT_FILE_ICON(*fi); else return GET_DEFAULT_FILE_ICON(QFileInfo(file)); }
void d1x_options_menu() { newmenu_item m[14]; int i=0; int opt=0; int inputs,checks,commands; char smaxfps[4]; char shudmaxnumdisp[4]; char thogdir[64]; extern int gr_message_color_level; sprintf(thogdir,AltHogDir); sprintf(smaxfps,"%d",maxfps); sprintf(shudmaxnumdisp,"%d",HUD_max_num_disp); m[opt].type = NM_TYPE_MENU; m[opt].text = "Primary autoselect ordering..."; opt++; m[opt].type = NM_TYPE_MENU; m[opt].text = "Secondary autoselect ordering..."; opt++; //added on 2/4/99 by Victor Rachels for new key menu m[opt].type = NM_TYPE_MENU; m[opt].text = "D1X Keys"; opt++; //end this section addition - VR //enabled 3/24/99 - Owen Evans m[opt].type = NM_TYPE_MENU; m[opt].text = "Change Screen Resolution"; opt++; //end enabled stuff - OE commands=opt; //added on 2/2/99 by Victor Rachels for bans #ifdef NETWORK m[opt].type = NM_TYPE_MENU; m[opt].text = "Save bans now"; opt++; #endif //end this section addition - VR m[opt].type = NM_TYPE_TEXT; m[opt].text = "Maximum Framerate (1-80):"; opt++; inputs=opt; m[opt].type = NM_TYPE_INPUT; m[opt].text = smaxfps; m[opt].text_len=3; opt++; m[opt].type = NM_TYPE_TEXT; m[opt].text = "Mission Directory"; opt++; m[opt].type = NM_TYPE_INPUT; m[opt].text = thogdir; m[opt].text_len=64; opt++; m[opt].type = NM_TYPE_TEXT; m[opt].text = "Hud Messages lines (1-80):"; opt++; m[opt].type = NM_TYPE_INPUT; m[opt].text = shudmaxnumdisp; m[opt].text_len=3; opt++; m[opt].type = NM_TYPE_SLIDER; m[opt].text = "Message colorization level"; m[opt].value=gr_message_color_level;m[opt].min_value=0;m[opt].max_value=3; opt++; checks=opt; #ifdef __MSDOS__ m[opt].type = NM_TYPE_CHECK; m[opt].text = "Joy is sidewinder"; m[opt].value=Joy_is_Sidewinder; opt++; #endif #ifdef SUPPORTS_NICEFPS m[opt].type = NM_TYPE_CHECK; m[opt].text = "Nice FPS (free cpu cycles)"; m[opt].value = use_nice_fps; opt++; #endif for(;;) { i=newmenu_do1( NULL, "D1X options", opt, m, &d1x_options_menu_poll, i); if(i>-1) { if(i<commands) { switch(i) { case 0: reorder_primary(); break; case 1: reorder_secondary(); break; //added on 2/4/99 by Victor Rachels for new key menu case 2: kconfig(3,"D1X Keys"); break; //end this section addition - VR //enabled 3/24/99 - Owen Evans case 3: change_res(); break; //end enabled stuff - OE } } //added on 2/4/99 by Victor Rachels for bans #ifdef NETWORK if(i==commands+0) { nm_messagebox(NULL,1,TXT_OK, "%i Bans saved",writebans()); } #endif //end this section addition - VR if(i==inputs+0) { maxfps = atoi(smaxfps); if(maxfps < 1||maxfps>80) { nm_messagebox(TXT_ERROR, 1, TXT_OK, "Invalid value for maximum framerate"); maxfps=80; i=(inputs+0); } } else if(i==inputs+2) cfile_use_alternate_hogdir(thogdir); else if(i==inputs+4) { HUD_max_num_disp = atoi(shudmaxnumdisp); if(HUD_max_num_disp < 1||HUD_max_num_disp>HUD_MAX_NUM) { nm_messagebox(TXT_ERROR, 1, TXT_OK, "Invalid value for hud lines"); HUD_max_num_disp=4; // i=(inputs+4);//??? } } gr_message_color_level=m[inputs+5].value; sprintf(shudmaxnumdisp,"%d",HUD_max_num_disp); sprintf(smaxfps,"%d",maxfps); // m[inputs+0].text=smaxfps;//redundant.. its not going anywhere sprintf(thogdir,AltHogDir); // m[inputs+2].text=thogdir;//redundant } else break; } write_player_file(); #ifdef __MSDOS__ Joy_is_Sidewinder=m[(checks+0)].value; #endif #ifdef __LINUX__ Joy_is_Sidewinder=0; #endif #ifdef SUPPORTS_NICEFPS use_nice_fps=m[(checks+0)].value; #else use_nice_fps=0; #endif }
void joydefs_config() { //added/changed/killed on 10/17/98 by Hans de Goede for joystick/mouse # fix //-killed- char xtext[128]; //-killed- int i, old_masks, masks; newmenu_item m[13]; //-killed- int i1=5; //-killed- int nitems; //-killed- //-killed- do { //-killed- nitems = 6; int i, i1=5, j, nitems=7; //end this section kill/change - Hans m[0].type = NM_TYPE_RADIO; m[0].text = "KEYBOARD"; m[0].value = 0; m[0].group = 0; m[1].type = NM_TYPE_RADIO; m[1].text = "JOYSTICK"; m[1].value = 0; m[1].group = 0; m[2].type = NM_TYPE_RADIO; m[2].text = "MOUSE"; m[2].value = 0; m[2].group = 0; m[3].type = NM_TYPE_TEXT; m[3].text=""; m[4].type = NM_TYPE_MENU; m[4].text="CUSTOMIZE ABOVE"; m[5].type = NM_TYPE_MENU; m[5].text="CUSTOMIZE KEYBOARD"; //added on 2/5/99 by Victor Rachels for D1X keys menu m[6].type = NM_TYPE_MENU; m[6].text="CUSTOMIZE D1X KEYS"; //end this section addition - VR //added/changed/killed on 10/17/98 by Hans de Goede for joystick/mouse # fix //-killed- m[Config_control_type].value = 1; do { i = Config_control_type; if(i==CONTROL_MOUSE) i = 2; m[i].value=1; //end section - OE //end this section change/addition - Hans i1 = newmenu_do1( NULL, TXT_CONTROLS, nitems, m, joydef_menuset_1, i1 ); //added 6-15-99 Owen Evans for (j = 0; j <= 2; j++) if (m[j].value) Config_control_type = j; i = Config_control_type; if (Config_control_type == 2) Config_control_type = CONTROL_MOUSE; //end added - OE switch(i1) { case 4: //added/changed on 10/17/98 by Hans de Goede for joystick/mouse # fix //-killed- kconfig(Config_control_type, m[Config_control_type].text); kconfig (i, m[i].text); //end this section change - Hans break; case 5: kconfig(0, "KEYBOARD"); break; //added on 2/5/99 by Victor Rachels for D1X keys menu case 6: kconfig(3, "D1X KEYS"); break; //end this section addition - VR } } while(i1>-1); }
void PMenu::writeConfig( QDir base_dir, PMenuItem *parent_item) { if( parent_item ) if( parent_item->read_only ) return; if( !base_dir.exists() ) { return; } QString name; const QStrList *temp_list = base_dir.entryList("*", QDir::Files); QStrList file_list; file_list.setAutoDelete(TRUE); QStrListIterator temp_it( *temp_list ); while( name = temp_it.current() ) { file_list.append(name); ++temp_it; } temp_list = base_dir.entryList("*", QDir::Dirs); QStrList dir_list; dir_list.setAutoDelete(TRUE); temp_it.toFirst(); while( name = temp_it.current() ) { if(name != "." && name != "..") dir_list.append(name); ++temp_it; } QString sort_order; PMenuItem *item; for( item = list.first(); item != 0; item = list.next() ) { // if( item->read_only ) // continue; if( item->entry_type == separator ) sort_order += ((QString) "SEPARATOR" + ','); else sort_order += (item->real_name + ','); if( item->getType() == submenu ) { if( !item->read_only ) { QDir sub_dir(base_dir); if( !sub_dir.cd(item->real_name) ) { base_dir.mkdir(item->real_name); if( !sub_dir.cd(item->real_name) ) continue; } item->sub_menu->writeConfig( sub_dir, item ); } dir_list.remove(item->real_name); } else { if( item->entry_type != separator ) { if( !item->read_only ) { if( item->real_name.isEmpty() ) item->real_name = uniqueFileName(item->text_name); item->writeConfig(base_dir); } file_list.remove(item->real_name); // + ".kdelnk"); } } } // remove files not in pmenu for( name = file_list.first(); name != 0; name = file_list.next() ) { if( isKdelnkFile(base_dir.absFilePath(name)) ) { //debug("will remove file: %s", (const char *) name ); base_dir.remove(name); } } // remove dirs not in pmenu for( name = dir_list.first(); name != 0; name = dir_list.next() ) { //debug("will remove dir: %s", (const char *) name ); QDir sub_dir(base_dir); if(sub_dir.cd(name)) { PMenu *new_menu = new PMenu; new_menu->writeConfig(sub_dir); delete new_menu; sub_dir.remove(".directory"); } base_dir.rmdir(name); } sort_order.truncate(sort_order.length()-1); QString file = base_dir.absPath(); file += "/.directory"; QFile config(file); if( !config.open(IO_ReadWrite) ) return; config.close(); KConfig kconfig(file); kconfig.setGroup("KDE Desktop Entry"); kconfig.writeEntry("SortOrder", sort_order); if( parent_item ) { kconfig.writeEntry("MiniIcon", parent_item->pixmap_name ); if( parent_item->big_pixmap_name.isEmpty() ) parent_item->big_pixmap_name = "folder.xpm"; kconfig.writeEntry("Icon", parent_item->big_pixmap_name ); kconfig.writeEntry("Name", parent_item->text_name, TRUE, FALSE, TRUE ); } kconfig.sync(); }
short PMenu::parse( QDir d ) { if( !d.exists() ) return -1; PMenuItem *new_item; PMenu *new_menu; QDir new_dir; QStrList sort_order; QList<PMenuItem> item_list; item_list.setAutoDelete(FALSE); int pos; bool read_only = FALSE; sort_order.setAutoDelete(TRUE); QString file = d.path(); QFileInfo dir_info(file); if( !dir_info.isWritable() ) read_only = TRUE; file += "/.directory"; QFileInfo dir_fi(file); if( dir_fi.isReadable() ) { KConfig kconfig(file); kconfig.setGroup("KDE Desktop Entry"); QString order = kconfig.readEntry("SortOrder"); int len = order.length(); int j,i; QString temp; for( i = 0; i < len; ) { j = order.find(',', i); if( j == -1 ) j = len; temp = order.mid(i, j-i); temp.stripWhiteSpace(); sort_order.append(temp); i = j+1; } } const QFileInfoList *list = d.entryInfoList(); QFileInfoListIterator it( *list ); QFileInfo *fi; if( it.count() < 3 ) return -1; while ( (fi=it.current()) ) { if( fi->fileName() == "." || fi->fileName() == ".." ) { ++it; continue; } if( fi->isDir() ) { new_menu = new PMenu; new_item = new PMenuItem; new_dir.setPath( fi->filePath() ); new_item->read_only = read_only; if( new_menu->parse( new_dir ) < 0 || new_item->parse( fi, new_menu ) < 0 ) { delete new_menu; delete new_item; ++it; continue; } item_list.append(new_item); } else { //if( !fi->extension().contains("kdelnk") ) //if( !isKdelnkFile(fi->absFilePath())) // { ++it; continue; } new_item = new PMenuItem; new_item->read_only = read_only; if( new_item->parse(fi) < 0 ) delete new_item; else item_list.append(new_item); } ++it; } // sort items QString item_name; PMenuItem *item; for( item_name = sort_order.first(); !item_name.isEmpty(); item_name = sort_order.next() ) { for( item = item_list.first(); item != NULL; item = item_list.next() ) { if( item->real_name == item_name ) { add(item); item_list.removeRef(item); break; } } } if( item_list.count() != 0 ) { for( item = item_list.first(); item != NULL; item = item_list.next() ) { add(item); } } item_list.clear(); // insert separators sort_order.first(); while( (pos = sort_order.findNext((QString) "SEPARATOR")) >= 0 ) { sort_order.next(); new_item = new PMenuItem; new_item->entry_type = separator; new_item->read_only = read_only; insert(new_item, pos); } return 0; }
short PMenuItem::parse( QFileInfo *fi, PMenu *menu ) { QString lang = KApplication::getKApplication()->getLocale()->language(); real_name = fi->fileName().copy(); old_name = real_name; QString type_string = ""; int pos = fi->fileName().find(".kdelnk"); if( pos >= 0 ) text_name = fi->fileName().left(pos); else text_name = fi->fileName(); if( !(fi->isWritable()) ) read_only = TRUE; if( menu != NULL ) { QString file_name = fi->absFilePath(); file_name += "/.directory"; QFileInfo fi_config(file_name); if( fi_config.isReadable() ) { KConfig kconfig(file_name); kconfig.setGroup("KDE Desktop Entry"); comment = kconfig.readEntry("Comment"); text_name = kconfig.readEntry("Name", text_name); pixmap_name = kconfig.readEntry("MiniIcon"); big_pixmap_name = kconfig.readEntry("Icon"); dir_path = fi->dirPath(TRUE); } entry_type = submenu; sub_menu = menu; cmenu = new CPopupMenu; } else { // test if file is a kdelnk file QFile file(fi->absFilePath()); if( file.open(IO_ReadOnly) ) { char s[19]; int r = file.readLine(s, 18); if(r > -1) { s[r] = '\0'; if(QString(s).left(17) != "# KDE Config File") { file.close(); return -1; } } } else { file.close(); return -1; } // parse file file.at(0); QTextStream stream(&file); QString current_line, key, value; QString temp_swallow_title, temp_term_opt, temp_exec_path, temp_text_name; QString temp_use_term, temp_pattern, temp_protocols, temp_extensions, temp_url_name; QString temp_dev_name, temp_mount_point, temp_fs_type, temp_umount_pixmap_name; QString temp_dev_read_only = "0"; temp_use_term = "0"; bool inside_group = FALSE; int equal_pos; comment = ""; while(!stream.eof()) { current_line = stream.readLine(); if( current_line[0] == '#' ) continue; if( !inside_group ) { if( current_line != "[KDE Desktop Entry]" ) { continue; } else { inside_group = TRUE; continue; } } equal_pos = current_line.find('='); if( equal_pos == -1 ) continue; key = current_line.left(equal_pos).stripWhiteSpace(); value = current_line.right(current_line.length() - equal_pos - 1).stripWhiteSpace(); if( key == "Exec" ) { command_name = value; continue; } else if( key == "SwallowExec" ) { swallow_exec = value; continue; } else if( key.left(7) == "Comment" ) { if( key == "Comment" ) { if( comment.isEmpty() ) comment = value; } else { if( key == "Comment[" + lang + "]" ) comment = value; } continue; } else if( key.left(4) == "Name" ) { if( key == "Name" ) { if( temp_text_name.isEmpty() ) temp_text_name = value; } else { if( key == "Name[" + lang + "]" ) temp_text_name = value; } continue; } else if( key == "MiniIcon" ) { pixmap_name = value; continue; } else if( key == "Icon" ) { big_pixmap_name = value; continue; } else if( key == "Type" ) { type_string = value; continue; } else if( key == "SwallowTitle" ) { temp_swallow_title = value; continue; } else if( key == "TerminalOptions" ) { temp_term_opt = value; continue; } else if( key == "Path" ) { temp_exec_path = value; continue; } else if( key == "Terminal" ) { temp_use_term = value; continue; } else if( key == "BinaryPattern" ) { temp_pattern = value; continue; } else if( key == "Protocols" ) { temp_protocols = value; continue; } else if( key == "MimeType" ) { temp_extensions = value; continue; } else if( key == "URL" ) { temp_url_name = value; continue; } else if( key == "Dev" ) { temp_dev_name = value; continue; } else if( key == "MountPoint" ) { temp_mount_point = value; continue; } else if( key == "FSType" ) { temp_fs_type = value; continue; } else if( key == "UnmountIcon" ) { temp_umount_pixmap_name = value; continue; } else if( key == "ReadOnly" ) { temp_dev_read_only = value; continue; } } file.close(); if( type_string.isEmpty() ) return -1; if( !temp_text_name.isEmpty() ) text_name = temp_text_name; if( type_string == "Application" ) { if( !swallow_exec.isEmpty() ) { entry_type = swallow_com; swallow_title = temp_swallow_title; } else { entry_type = unix_com; term_opt = temp_term_opt; } exec_path = temp_exec_path; dir_path = fi->dirPath(TRUE); if( temp_use_term == "0" ) use_term = 0; else use_term = 1; pattern = temp_pattern; protocols = temp_protocols; extensions = temp_extensions; } else if( type_string == "Link" ) { entry_type = url; url_name = temp_url_name; } else if( type_string == "FSDevice" ) { entry_type = device; dev_name = temp_dev_name; mount_point = temp_mount_point; fs_type = temp_fs_type; umount_pixmap_name = temp_umount_pixmap_name; if( temp_dev_read_only == "0" ) dev_read_only = 0; else dev_read_only = 1; } // if( !fi->isReadable() ) // return -1; // KConfig kconfig(fi->absFilePath()); // kconfig.setGroup("KDE Desktop Entry"); // command_name = kconfig.readEntry("Exec"); // swallow_exec = kconfig.readEntry("SwallowExec"); // comment = kconfig.readEntry("Comment"); // text_name = kconfig.readEntry("Name", text_name); // pixmap_name = kconfig.readEntry("MiniIcon"); // big_pixmap_name = kconfig.readEntry("Icon"); // type_string = kconfig.readEntry("Type"); // if( type_string == "Application" ) // { // if( !swallow_exec.isEmpty() ) // { // entry_type = swallow_com; // swallow_title = kconfig.readEntry("SwallowTitle"); // } // else // { // entry_type = unix_com; // term_opt = kconfig.readEntry("TerminalOptions"); // } // exec_path = kconfig.readEntry("Path"); // dir_path = fi->dirPath(TRUE); // use_term = kconfig.readNumEntry("Terminal"); // pattern = kconfig.readEntry("BinaryPattern"); // protocols = kconfig.readEntry("Protocols"); // extensions = kconfig.readEntry("MimeType"); // } // else if( type_string == "Link" ) // { // entry_type = url; // url_name = kconfig.readEntry("URL"); // } // else if( type_string == "FSDevice" ) // { // entry_type = device; // dev_name = kconfig.readEntry("Dev"); // mount_point = kconfig.readEntry("MountPoint"); // fs_type = kconfig.readEntry("FSType"); // umount_pixmap_name = kconfig.readEntry("UnmountIcon"); // dev_read_only = kconfig.readNumEntry("ReadOnly"); // } } // some code from kpanel QPixmap tmppix; pixmap = tmppix; if( !pixmap_name.isEmpty() ){ pixmap = global_pix_loader->loadApplicationMiniIcon(pixmap_name, 16, 16); } if (pixmap.isNull() && !big_pixmap_name.isEmpty()){ pixmap = global_pix_loader->loadApplicationMiniIcon(big_pixmap_name, 16, 16); } if (pixmap.isNull() && getType() == unix_com){ QString tmp = real_name.copy(); int pos = tmp.find(".kdelnk"); if( pos >= 0 ) tmp = tmp.left(pos); tmp.append(".xpm"); pixmap = global_pix_loader->loadApplicationMiniIcon(tmp, 16, 16); } if (pixmap.isNull()) pixmap = global_pix_loader->loadApplicationMiniIcon("mini-default.xpm", 16, 16); if (comment.isEmpty()) comment = text_name; if (big_pixmap_name.isEmpty()){ QString tmp = real_name.copy(); int pos = tmp.find(".kdelnk"); if( pos >= 0 ) tmp = tmp.left(pos); tmp.append(".xpm"); big_pixmap_name = tmp.copy(); } // end kpanel return 0; }
void KCMStyle::save() { // Don't do anything if we don't need to. if ( !(m_bToolbarsDirty | m_bEffectsDirty | m_bStyleDirty ) ) return; bool allowMenuTransparency = false; bool allowMenuDropShadow = false; // Read the KStyle flags to see if the style writer // has enabled menu translucency in the style. if (appliedStyle && appliedStyle->inherits("KStyle")) { allowMenuDropShadow = true; KStyle* style = dynamic_cast<KStyle*>(appliedStyle); if (style) { KStyle::KStyleFlags flags = style->styleFlags(); if (flags & KStyle::AllowMenuTransparency) allowMenuTransparency = true; } } QString warn_string( i18n("<qt>Selected style: <b>%1</b><br><br>" "One or more effects that you have chosen could not be applied because the selected " "style does not support them; they have therefore been disabled.<br>" "<br>" ).arg( cbStyle->currentText()) ); bool show_warning = false; // Warn the user if they're applying a style that doesn't support // menu translucency and they enabled it. if ( (!allowMenuTransparency) && (cbEnableEffects->isChecked()) && (comboMenuEffect->currentItem() == 3) ) // Make Translucent { warn_string += i18n("Menu translucency is not available.<br>"); comboMenuEffect->setCurrentItem(0); // Disable menu effect. show_warning = true; } if (!allowMenuDropShadow && cbMenuShadow->isChecked()) { warn_string += i18n("Menu drop-shadows are not available."); cbMenuShadow->setChecked(false); show_warning = true; } // Tell the user what features we could not apply on their behalf. if (show_warning) KMessageBox::information(this, warn_string); // Save effects. KConfig config( "kdeglobals" ); config.setGroup("KDE"); config.writeEntry( "EffectsEnabled", cbEnableEffects->isChecked()); int item = comboComboEffect->currentItem(); config.writeEntry( "EffectAnimateCombo", item == 1 ); item = comboTooltipEffect->currentItem(); config.writeEntry( "EffectAnimateTooltip", item == 1); config.writeEntry( "EffectFadeTooltip", item == 2 ); item = comboMenuHandle->currentItem(); config.writeEntry( "InsertTearOffHandle", item ); item = comboMenuEffect->currentItem(); config.writeEntry( "EffectAnimateMenu", item == 1 ); config.writeEntry( "EffectFadeMenu", item == 2 ); // Handle KStyle's menu effects QString engine("Disabled"); if (item == 3 && cbEnableEffects->isChecked()) // Make Translucent switch( comboMenuEffectType->currentItem()) { case 1: engine = "SoftwareBlend"; break; case 2: engine = "XRender"; break; default: case 0: engine = "SoftwareTint"; break; } { // Braces force a QSettings::sync() QSettings settings; // Only for KStyle stuff settings.writeEntry("/KStyle/Settings/MenuTransparencyEngine", engine); settings.writeEntry("/KStyle/Settings/MenuOpacity", slOpacity->value()/100.0); settings.writeEntry("/KStyle/Settings/MenuDropShadow", cbEnableEffects->isChecked() && cbMenuShadow->isChecked() ); } // Misc page config.writeEntry( "ShowIconsOnPushButtons", cbIconsOnButtons->isChecked(), true, true ); config.writeEntry( "EffectNoTooltip", !cbEnableTooltips->isChecked(), true, true ); config.setGroup("General"); config.writeEntry( "widgetStyle", currentStyle() ); config.setGroup("Toolbar style"); config.writeEntry( "Highlighting", cbHoverButtons->isChecked(), true, true ); config.writeEntry( "TransparentMoving", cbTransparentToolbars->isChecked(), true, true ); QString tbIcon; switch( comboToolbarIcons->currentItem() ) { case 1: tbIcon = "TextOnly"; break; case 2: tbIcon = "IconTextRight"; break; case 3: tbIcon = "IconTextBottom"; break; case 0: default: tbIcon = "IconOnly"; break; } config.writeEntry( "IconText", tbIcon, true, true ); config.sync(); // Export the changes we made to qtrc, and update all qt-only // applications on the fly, ensuring that we still follow the user's // export fonts/colors settings. if (m_bStyleDirty | m_bEffectsDirty) // Export only if necessary { uint flags = KRdbExportQtSettings; KConfig kconfig("kcmdisplayrc", true /*readonly*/, false /*no globals*/); kconfig.setGroup("X11"); bool exportKDEColors = kconfig.readBoolEntry("exportKDEColors", true); if (exportKDEColors) flags |= KRdbExportColors; runRdb( flags ); } // Now allow KDE apps to reconfigure themselves. if ( m_bStyleDirty ) KIPC::sendMessageAll(KIPC::StyleChanged); if ( m_bToolbarsDirty ) // ##### FIXME - Doesn't apply all settings correctly due to bugs in // KApplication/KToolbar KIPC::sendMessageAll(KIPC::ToolbarStyleChanged); if (m_bEffectsDirty) { KIPC::sendMessageAll(KIPC::SettingsChanged); kapp->dcopClient()->send("kwin*", "", "reconfigure()", ""); } //update kicker to re-used tooltips kicker parameter otherwise, it overwritted //by style tooltips parameters. QByteArray data; kapp->dcopClient()->send( "kicker", "kicker", "configure()", data ); // Clean up m_bEffectsDirty = false; m_bToolbarsDirty = false; m_bStyleDirty = false; emit changed( false ); }