void CreateSmileyWindow::slotOKClicked( ) { bool ok = false; TQString destDir = EvaMain::user->getSetting()->getCustomSmileyDir(); if(cbbGroup->currentItem()>0) destDir += ( "/" + cbbGroup->currentText() ); if(!m_FileName.isEmpty()){ TQString destFile = EvaHelper::generateCustomSmiley(m_FileName, destDir, true); if(!destFile.isEmpty()) { TQString name = destFile.right( destFile.length() - destFile.findRev("/") - 1); CustomFace face(name, leShortcut->text(), leTip->text(), 0, cbbGroup->currentItem()); ok = m_Config->addFace(face); } } else { ///TODO: add multiple files for(TQStringList::Iterator it = m_FileNames.begin(); it != m_FileNames.end(); ++it){ TQString destFile = EvaHelper::generateCustomSmiley((*it), destDir, true); if(!destFile.isEmpty()) { TQString name = destFile.right( destFile.length() - destFile.findRev("/") - 1); CustomFace face( name, name.left(6), name.left(name.findRev(".")), 0, cbbGroup->currentItem()); ok = m_Config->addFace(face); } } } if(ok) m_Config->saveXML(); emit addCustomSmileyReady(ok); close(); }
void MntConfigWidget::iconChanged(const TQString &iconName) { if( iconName.findRev('_') == 0 || (iconName.right(iconName.length()-iconName.findRev('_'))!="_mount" && iconName.right(iconName.length()-iconName.findRev('_'))!="_unmount")) { TQString msg = i18n("" "This filename is not valid: %1\n" "It must end with " "\"_mount\" or \"_unmount\".").arg(iconName); KMessageBox::sorry( this, msg ); return; } TQListViewItem *item = mList->selectedItem(); for(unsigned i=0 ; i < mDiskList.count() ; ++i) { if (mDiskLookup[i] == item) { DiskEntry *disk = mDiskList.at(i); if( disk != 0 ) { disk->setIconName(iconName); mIconLineEdit->setText(iconName); TDEIconLoader &loader = *TDEGlobal::iconLoader(); item->setPixmap( ICONCOL, loader.loadIcon( iconName, TDEIcon::Small)); } break; } } }
bool KLpdUnixPrinterImpl::setupCommand(TQString& cmd, KPrinter *printer) { TQString exe = printer->option( "kde-printcommand" ); if ( exe.isEmpty() || exe == "<automatic>" ) { exe = executable(); if (!exe.isEmpty()) { cmd = exe; if (exe.right(3) == "lpr") initLprPrint(cmd,printer); else initLpPrint(cmd,printer); return true; } else printer->setErrorMessage(i18n("No valid print executable was found in your path. Check your installation.")); return false; } else { TQMap<TQString,TQString> map; map.insert( "printer", printer->printerName() ); map.insert( "copies", TQString::number( printer->numCopies() ) ); cmd = KMacroExpander::expandMacrosShellQuote( exe, map ); return true; } }
TQString KStringHandler::csqueeze( const TQString & str, uint maxlen ) { if (str.length() > maxlen && maxlen > 3) { int part = (maxlen-3)/2; return TQString(str.left(part) + "..." + str.right(part)); } else return str; }
TQString KStringHandler::lsqueeze( const TQString & str, uint maxlen ) { if (str.length() > maxlen) { int part = maxlen-3; return TQString("..." + str.right(part)); } else return str; }
int getServerPid() { TQDir dir("/proc",TQString::null,TQDir::Name,TQDir::Dirs); for (uint i=0;i<dir.count();i++) { if (dir[i] == "." || dir[i] == ".." || dir[i] == "self") continue; TQFile f("/proc/" + dir[i] + "/cmdline"); if (f.exists() && f.open(IO_ReadOnly)) { TQTextStream t(&f); TQString line; t >> line; f.close(); if (line.right(5) == "cupsd" || line.right(6).left(5) == "cupsd") // second condition for 2.4.x kernels // which add a null byte at the end return dir[i].toInt(); } }
double coordinate(TQString c) { int neg; int d=0, m=0, s=0; neg = c.left(1) == "-"; c.remove(0,1); switch (c.length()) { case 4: d = c.left(2).toInt(); m = c.mid(2).toInt(); break; case 5: d = c.left(3).toInt(); m = c.mid(3).toInt(); break; case 6: d = c.left(2).toInt(); m = c.mid(2,2).toInt(); s = c.right(2).toInt(); break; case 7: d = c.left(3).toInt(); m = c.mid(3,2).toInt(); s = c.right(2).toInt(); break; default: break; } if (neg) return - (d + m/60.0 + s/3600.0); else return d + m/60.0 + s/3600.0; }
TDEIO::filesize_t ArkUtils::getSizes(TQStringList *list) { TDEIO::filesize_t sum = 0; TQString str; KDE_struct_stat st; for ( TQStringList::Iterator it = list->begin(); it != list->end(); ++it) { str = *it; str = str.right(str.length()-5); if (KDE_stat(TQFile::encodeName(str), &st ) < 0) continue; sum += st.st_size; } return sum; }
TQString KStringHandler::cPixelSqueeze(const TQString& s, const TQFontMetrics& fm, uint width) { if ( s.isEmpty() || uint( fm.width( s ) ) <= width ) { return s; } const unsigned int length = s.length(); if ( length == 2 ) { return s; } const int maxWidth = width - fm.width( '.' ) * 3; if ( maxWidth <= 0 ) { return "..."; } unsigned int leftIdx = 0, rightIdx = length; unsigned int leftWidth = fm.charWidth( s, leftIdx++ ); unsigned int rightWidth = fm.charWidth( s, --rightIdx ); while ( leftWidth + rightWidth < uint( maxWidth ) ) { while ( leftWidth <= rightWidth && leftWidth + rightWidth < uint( maxWidth ) ) { leftWidth += fm.charWidth( s, leftIdx++ ); } while ( rightWidth <= leftWidth && leftWidth + rightWidth < uint( maxWidth ) ) { rightWidth += fm.charWidth( s, --rightIdx ); } } if ( leftWidth > rightWidth ) { --leftIdx; } else { ++rightIdx; } rightIdx = length - rightIdx; if ( leftIdx == 0 && rightIdx == 1 || leftIdx == 1 && rightIdx == 0 ) { return "..."; } return s.left( leftIdx ) + "..." + s.right( rightIdx ); }
void ConfFilters::load() { TQFile f(locate("data","tdeprintfax/faxfilters")); if (f.exists() && f.open(IO_ReadOnly)) { TQTextStream t(&f); TQString line; int p(-1); TQListViewItem *item(0); while (!t.eof()) { line = t.readLine().stripWhiteSpace(); if ((p=line.find(TQRegExp("\\s"))) != -1) { TQString mime(line.left(p)), cmd(line.right(line.length()-p-1).stripWhiteSpace()); if (!mime.isEmpty() && !cmd.isEmpty()) item = new TQListViewItem(m_filters, item, mime, cmd); } } } }
// RETURN: <0 => error // =0 => no error, no update // >0 => no error, update happened // int KPCMCIACard::refresh() { ////////////////////////////////////////////// ///////////// LINUX ONLY /////////////////////////////////////////////// #ifdef __linux__ struct timeval tv; cs_status_t status; fd_set rfds; int rc; event_t event; struct stat sb; config_info_t cfg; KPCMCIACard oldValues(*this); int updated = 0; oldValues._fd = -1; #define CHECK_CHANGED(x, y) do { if (x.y != y) updated = 1; } while(0) /** * Get any events on the pcmcia device */ tv.tv_sec = 0; tv.tv_usec = 0; FD_ZERO(&rfds); FD_SET(_fd, &rfds); rc = select(_fd+1, &rfds, NULL, NULL, &tv); if (rc > 0) { rc = read(_fd, (void *)&event, 4); if (rc == 4) { int thisEvent = -1; // thisEvent is the index of event in event_tag for (unsigned int j = 0; j < NTAGS; j++) { if (event_tag[j].event == event) { thisEvent = j; break; } if (thisEvent < 0) return -1; } } else { return -1; } } else return updated; if (event == CS_EVENT_EJECTION_REQUEST) { _interrupt = -1; _ports = ""; _device = ""; _module = ""; _type = ""; _iotype = 0; _inttype = 0; _cfgbase = 0; _cardname = i18n("Empty slot."); _vcc = _vpp = _vpp2 = 0; return updated; } /** * Read in the stab file. */ if (!stat(_stabPath.latin1(), &sb) && sb.st_mtime >= _last) { TQFile f(_stabPath.latin1()); if (f.open(IO_ReadOnly)) { TQTextStream ts(&f); bool foundit = false; TQString _thisreg = "^Socket %1: "; TQRegExp thisreg ( _thisreg.arg(_num) ); if (flock(f.handle(), LOCK_SH)) return updated; _last = sb.st_mtime; // find the card while(!foundit) { TQString s; if (ts.eof()) break; s = ts.readLine(); if (s.contains(thisreg)) { _cardname = s.right(s.length() - s.find(':') - 1); _cardname = _cardname.stripWhiteSpace(); foundit = true; CHECK_CHANGED(oldValues, _cardname); } } // read it in if (foundit && !ts.eof()) { // FIXME: ts.eof() is a bad error!! TQString s = ts.readLine(); int end; s.simplifyWhiteSpace(); end = s.find(TQRegExp("[ \r\t\n]")); s = s.remove(0, end+1); end = s.find(TQRegExp("[ \r\t\n]")); _type = s; _type.truncate(end); s = s.remove(0, end+1); end = s.find(TQRegExp("[ \r\t\n]")); _module = s; _module.truncate(end); s = s.remove(0, end+1); end = s.find(TQRegExp("[ \r\t\n]")); s = s.remove(0, end+1); end = s.find(TQRegExp("[ \r\t\n]")); _device = s; _device.truncate(end); s = s.remove(0, end+1); CHECK_CHANGED(oldValues, _type); CHECK_CHANGED(oldValues, _module); CHECK_CHANGED(oldValues, _device); } flock(f.handle(), LOCK_UN); f.close(); } else return -1; } else return updated; /** * Get the card's status and configuration information */ status.Function = 0; ioctl(_fd, DS_GET_STATUS, &status); memset(&cfg, 0, sizeof(cfg)); ioctl(_fd, DS_GET_CONFIGURATION_INFO, &cfg); // status is looked up in the table at the top if (cfg.Attributes & CONF_VALID_CLIENT) { if (cfg.AssignedIRQ == 0) _interrupt = -1; else _interrupt = cfg.AssignedIRQ; if (cfg.NumPorts1 > 0) { int stop = cfg.BasePort1 + cfg.NumPorts1; if (cfg.NumPorts2 > 0) { if (stop == cfg.BasePort2) { _ports.sprintf("%#x-%#x", cfg.BasePort1, stop+cfg.NumPorts2-1); } else { _ports.sprintf("%#x-%#x, %#x-%#x", cfg.BasePort1, stop-1, cfg.BasePort2, cfg.BasePort2+cfg.NumPorts2-1); } } else { _ports.sprintf("%#x-%#x", cfg.BasePort1, stop-1); } } CHECK_CHANGED(oldValues, _ports); CHECK_CHANGED(oldValues, _interrupt); } _vcc = cfg.Vcc; _vpp = cfg.Vpp1; _vpp2 = cfg.Vpp2; CHECK_CHANGED(oldValues, _vcc); CHECK_CHANGED(oldValues, _vpp); CHECK_CHANGED(oldValues, _vpp2); _inttype = cfg.IntType; CHECK_CHANGED(oldValues, _inttype); _iotype = cfg.IOAddrLines; CHECK_CHANGED(oldValues, _iotype); _cfgbase = cfg.ConfigBase; CHECK_CHANGED(oldValues, _cfgbase); if (status.CardState & CS_EVENT_CARD_DETECT) _status |= CARD_STATUS_PRESENT; if (status.CardState & CS_EVENT_CARD_REMOVAL) _status &= ~CARD_STATUS_PRESENT; if (event & CS_EVENT_CARD_REMOVAL) _status &= ~CARD_STATUS_PRESENT; if (!(status.CardState & CS_EVENT_PM_SUSPEND)) { if (status.CardState & CS_EVENT_READY_CHANGE) { _status |= CARD_STATUS_READY; _status &= ~(CARD_STATUS_BUSY|CARD_STATUS_SUSPEND); } else { _status |= CARD_STATUS_BUSY; _status &= ~(CARD_STATUS_READY|CARD_STATUS_SUSPEND); } } else if (status.CardState & CS_EVENT_PM_SUSPEND) { _status |= CARD_STATUS_SUSPEND; _status &= ~(CARD_STATUS_READY|CARD_STATUS_BUSY); } CHECK_CHANGED(oldValues, _status); return updated; #else return 0; #endif }
int main( int argc, char *argv[] ) { TDEAboutData aboutData( "ksystraycmd", I18N_NOOP( "KSysTrayCmd" ), "KSysTrayCmd 0.1", I18N_NOOP( "Allows any application to be kept in the system tray" ), TDEAboutData::License_GPL, "(C) 2001-2002 Richard Moore ([email protected])" ); aboutData.addAuthor( "Richard Moore", 0, "*****@*****.**" ); TDECmdLineArgs::init( argc, argv, &aboutData ); TDECmdLineArgs::addCmdLineOptions( options ); // Add our own options. TDEApplication app; // // Setup the tray icon from the arguments. // TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); KSysTrayCmd cmd; // Read the window id TQString wid = args->getOption( "wid" ); if ( !wid.isEmpty() ) { int base = 10; if ( wid.startsWith( "0x" ) ) { base = 16; wid = wid.right( wid.length() - 2 ); } bool ok=true; ulong w = wid.toULong( &ok, base ); if ( ok ) cmd.setTargetWindow( w ); else { kdWarning() << "KSysTrayCmd: Got bad win id" << endl; } } // Read window title regexp TQString title = args->getOption( "window" ); if ( !title.isEmpty() ) cmd.setPattern( title ); if ( !title && !wid && (args->count() == 0) ) TDECmdLineArgs::usage(i18n("No command or window specified")); // Read the command TQString command; for ( int i = 0; i < args->count(); i++ ) command += TDEProcess::quote(TQString::fromLocal8Bit( args->arg(i) )) + " "; if ( !command.isEmpty() ) cmd.setCommand( command ); // Tooltip TQString tip = args->getOption( "tooltip" ); if ( !tip.isEmpty() ) cmd.setDefaultTip( tip ); // Keep running flag if ( args->isSet( "keeprunning" ) ) cmd.setNoQuit( true ); if ( args->isSet( "quitonhide" ) ) { cmd.setNoQuit( true ); cmd.setQuitOnHide( true ); } // Start hidden if ( args->isSet( "hidden" ) ) cmd.hideWindow(); // On top if ( args->isSet( "ontop" ) ) cmd.setOnTop(true); // Use ksystraycmd icon if ( args->isSet( "ownicon" ) ) cmd.setOwnIcon(true); // Lazy invocation flag if ( args->isSet( "startonshow" ) ) { cmd.setStartOnShow( true ); cmd.show(); } else { if ( !cmd.start() ) return 1; } fcntl(ConnectionNumber(tqt_xdisplay()), F_SETFD, 1); args->clear(); return app.exec(); }
/* we just simplify the process. if we use KParts::BrowserExtension, we have to do lots extra work, adding so much classes. so just hack like following. grab useful code from TDEHTMLPopupGUIClient(tdehtml_ext.cpp), and change a little bit to fit our needs */ void EvaChatView::slotPopupMenu( const TQString & _url, const TQPoint & point ) { menu->clear(); bool isImage = false; bool hasSelection = TDEHTMLPart::hasSelection(); KURL url = KURL(_url); if(d) delete d; d = new MenuPrivateData; d->m_url = url; DOM::Element e = nodeUnderMouse(); if ( !e.isNull() && (e.elementId() == ID_IMG) ) { DOM::HTMLImageElement ie = static_cast<DOM::HTMLImageElement>(e); TQString src = ie.src().string(); d->m_imageURL = KURL(src); d->m_suggestedFilename = src.right(src.length() - src.findRev("/") -1); isImage=true; } TDEAction *action = 0L; if(hasSelection) { //action = new TDEAction( i18n( "&Copy Text" ), TDEShortcut("Ctrl+C"), this, SLOT( copy() ), // actionCollection(), "copy" ); //action = KStdAction::copy( browserExtension(), SLOT(copy()), actionCollection(), "copy"); //action->setText(i18n("&Copy Text")); //action->setEnabled(true); copyAction->plug(menu); // search text TQString selectedText = TDEHTMLPart::selectedText(); if ( selectedText.length()>18 ) { selectedText.truncate(15); selectedText+="..."; } #ifdef HAS_KONTQUEROR // Fill search provider entries TDEConfig config("kuriikwsfilterrc"); config.setGroup("General"); const TQString defaultEngine = config.readEntry("DefaultSearchEngine", "google"); const char keywordDelimiter = config.readNumEntry("KeywordDelimiter", ':'); // default search provider KService::Ptr service = KService::serviceByDesktopPath(TQString("searchproviders/%1.desktop").arg(defaultEngine)); // search provider icon TQPixmap icon; KURIFilterData data; TQStringList list; const TQString defaultSearchProviderPrefix = *(service->property("Keys").toStringList().begin()) + keywordDelimiter; data.setData( defaultSearchProviderPrefix + TQString("some keyword") ); list << "kurisearchfilter" << "kuriikwsfilter"; TQString name; if ( KURIFilter::self()->filterURI(data, list) ) { TQString iconPath = locate("cache", KMimeType::favIconForURL(data.uri()) + ".png"); if ( iconPath.isEmpty() ) icon = SmallIcon("edit-find"); else icon = TQPixmap( iconPath ); name = service->name(); } else { icon = SmallIcon("google"); name = "Google"; } action = new TDEAction( i18n( "Search '%1' at %2" ).arg( selectedText ).arg( name ), icon, 0, this, SLOT( searchProvider() ), actionCollection(), "searchProvider" ); action->plug(menu); // favorite search providers TQStringList favoriteEngines; favoriteEngines = config.readListEntry("FavoriteSearchEngines"); // for KDE 3.2 API compatibility if(favoriteEngines.isEmpty()) favoriteEngines << "google" << "google_groups" << "google_news" << "webster" << "dmoz" << "wikipedia"; if ( !favoriteEngines.isEmpty()) { TDEActionMenu* providerList = new TDEActionMenu( i18n( "Search '%1' At" ).arg( selectedText ), actionCollection(), "searchProviderList" ); bool hasSubMenus = false; TQStringList::ConstIterator it = favoriteEngines.begin(); for ( ; it != favoriteEngines.end(); ++it ) { if (*it==defaultEngine) continue; service = KService::serviceByDesktopPath(TQString("searchproviders/%1.desktop").arg(*it)); if (!service) continue; const TQString searchProviderPrefix = *(service->property("Keys").toStringList().begin()) + keywordDelimiter; data.setData( searchProviderPrefix + "some keyword" ); if ( KURIFilter::self()->filterURI(data, list) ) { TQString iconPath = locate("cache", KMimeType::favIconForURL(data.uri()) + ".png"); if ( iconPath.isEmpty() ) icon = SmallIcon("edit-find"); else icon = TQPixmap( iconPath ); name = service->name(); providerList->insert( new TDEAction( name, icon, 0, this, SLOT( searchProvider() ), actionCollection(), TQString( "searchProvider" + searchProviderPrefix ).latin1() ) ); hasSubMenus = true; } } if(hasSubMenus) providerList->plug(menu); } #endif // HAS_KONTQUEROR if ( selectedText.contains("://") && KURL(selectedText).isValid() ) { action = new TDEAction( i18n( "Open '%1'" ).arg( selectedText ), "window_new", 0, this, SLOT( openSelection() ), actionCollection(), "openSelection" ); action->plug(menu); } } if ( !url.isEmpty() ) { if (url.protocol() == "mailto") { action = new TDEAction( i18n( "Copy Email Address" ), 0, this, SLOT( slotCopyLinkLocation() ), actionCollection(), "copylinklocation" ); action->plug(menu); } else { action = new TDEAction( i18n( "Copy &Link Address" ), 0, this, SLOT( slotCopyLinkLocation() ), actionCollection(), "copylinklocation" ); action->plug(menu); } } if (isImage) { #ifndef QT_NO_MIMECLIPBOARD action = (new TDEAction( i18n( "Copy Image" ), 0, this, SLOT( slotCopyImage() ), actionCollection(), "copyimage" )); action->plug(menu); #endif action = new TDEAction( i18n( "Save Image As..." ), 0, this, SLOT( slotSaveImageAs() ), actionCollection(), "saveimageas" ); action->plug(menu); action = new TDEAction( i18n( "Save As Custom Smiley"), 0, this, SLOT( slotSaveAsCustomSmiley() ), actionCollection(), "saveascustomsmiley" ); action->plug(menu); } if(menu->count()) menu->popup(point); }
void BasicTab::setEntryInfo(MenuEntryInfo *entryInfo) { blockSignals(true); _menuFolderInfo = 0; _menuEntryInfo = entryInfo; if (!entryInfo) { _nameEdit->setText(TQString::null); _descriptionEdit->setText(TQString::null); _commentEdit->setText(TQString::null); _iconButton->setIcon(TQString::null); // key binding part _keyEdit->setShortcut( TDEShortcut(), false ); _execEdit->lineEdit()->setText(TQString::null); _systrayCB->setChecked(false); _pathEdit->lineEdit()->setText(TQString::null); _termOptEdit->setText(TQString::null); _uidEdit->setText(TQString::null); _launchCB->setChecked(false); _terminalCB->setChecked(false); _uidCB->setChecked(false); enableWidgets(true, true); blockSignals(false); return; } KDesktopFile *df = entryInfo->desktopFile(); _nameEdit->setText(df->readName()); _descriptionEdit->setText(df->readGenericName()); _descriptionEdit->setCursorPosition(0); _commentEdit->setText(df->readComment()); _commentEdit->setCursorPosition(0); _iconButton->setIcon(df->readIcon()); // key binding part if( KHotKeys::present()) { _keyEdit->setShortcut( entryInfo->shortcut(), false ); } TQString temp = df->readPathEntry("Exec"); if (temp.left(12) == "ksystraycmd ") { _execEdit->lineEdit()->setText(temp.right(temp.length()-12)); _systrayCB->setChecked(true); } else { _execEdit->lineEdit()->setText(temp); _systrayCB->setChecked(false); } _pathEdit->lineEdit()->setText(df->readPath()); _termOptEdit->setText(df->readEntry("TerminalOptions")); if( df->hasKey( "X-TDE-Username" )) { _uidEdit->setText(df->readEntry("X-TDE-Username")); } else { _uidEdit->setText(df->readEntry("X-KDE-Username")); } if( df->hasKey( "StartupNotify" )) _launchCB->setChecked(df->readBoolEntry("StartupNotify", true)); else // backwards comp. _launchCB->setChecked(df->readBoolEntry("X-TDE-StartupNotify", true)); if(df->readNumEntry("Terminal", 0) == 1) _terminalCB->setChecked(true); else _terminalCB->setChecked(false); _uidCB->setChecked(df->readBoolEntry("X-TDE-SubstituteUID", false) || df->readBoolEntry("X-KDE-SubstituteUID", false)); enableWidgets(true, entryInfo->hidden); blockSignals(false); }
/* --| main |------------------------------------------------------ */ extern "C" int KDE_EXPORT kdemain(int argc, char* argv[]) { setgid(getgid()); setuid(getuid()); // drop privileges // deal with shell/command //////////////////////////// bool histon = true; bool menubaron = true; bool tabbaron = true; bool frameon = true; bool scrollbaron = true; bool showtip = true; TDEAboutData aboutData( "konsole", I18N_NOOP("Konsole"), KONSOLE_VERSION, description, TDEAboutData::License_GPL_V2, "Copyright (c) 2011-2014, The Trinity Desktop project\nCopyright (c) 1997-2006, Lars Doelle"); aboutData.addAuthor( "Timothy Pearson", I18N_NOOP("Maintainer, Trinity bugfixes"), "*****@*****.**" ); aboutData.addAuthor("Robert Knight",I18N_NOOP("Previous Maintainer"), "*****@*****.**"); aboutData.addAuthor("Lars Doelle",I18N_NOOP("Author"), "*****@*****.**"); aboutData.addCredit("Kurt V. Hindenburg", I18N_NOOP("bug fixing and improvements"), "*****@*****.**"); aboutData.addCredit("Waldo Bastian", I18N_NOOP("bug fixing and improvements"), "*****@*****.**"); aboutData.addCredit("Stephan Binner", I18N_NOOP("bug fixing and improvements"), "*****@*****.**"); aboutData.addCredit("Chris Machemer", I18N_NOOP("bug fixing"), "*****@*****.**"); aboutData.addCredit("Stephan Kulow", I18N_NOOP("Solaris support and work on history"), "*****@*****.**"); aboutData.addCredit("Alexander Neundorf", I18N_NOOP("faster startup, bug fixing"), "*****@*****.**"); aboutData.addCredit("Peter Silva", I18N_NOOP("decent marking"), "*****@*****.**"); aboutData.addCredit("Lotzi Boloni", I18N_NOOP("partification\n" "Toolbar and session names"), "*****@*****.**"); aboutData.addCredit("David Faure", I18N_NOOP("partification\n" "overall improvements"), "*****@*****.**"); aboutData.addCredit("Antonio Larrosa", I18N_NOOP("transparency"), "*****@*****.**"); aboutData.addCredit("Matthias Ettrich", I18N_NOOP("most of main.C donated via kvt\n" "overall improvements"), "*****@*****.**"); aboutData.addCredit("Warwick Allison", I18N_NOOP("schema and selection improvements"), "*****@*****.**"); aboutData.addCredit("Dan Pilone", I18N_NOOP("SGI Port"), "*****@*****.**"); aboutData.addCredit("Kevin Street", I18N_NOOP("FreeBSD port"), "*****@*****.**"); aboutData.addCredit("Sven Fischer", I18N_NOOP("bug fixing"), "*****@*****.**"); aboutData.addCredit("Dale M. Flaven", I18N_NOOP("bug fixing"), "*****@*****.**"); aboutData.addCredit("Martin Jones", I18N_NOOP("bug fixing"), "*****@*****.**"); aboutData.addCredit("Lars Knoll", I18N_NOOP("bug fixing"), "*****@*****.**"); aboutData.addCredit("",I18N_NOOP("Thanks to many others.\n" "The above list only reflects the contributors\n" "I managed to keep track of.")); TDECmdLineArgs::init( argc, argv, &aboutData ); TDECmdLineArgs::addCmdLineOptions( options ); // Add our own options. //1.53 sec TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); TDECmdLineArgs *qtargs = TDECmdLineArgs::parsedArgs("qt"); has_noxft = !args->isSet("xft"); TEWidget::setAntialias( !has_noxft ); TEWidget::setStandalone( true ); // The following Qt options have no effect; warn users. if( qtargs->isSet("background") ) kdWarning() << "The Qt option -bg, --background has no effect." << endl; if( qtargs->isSet("foreground") ) kdWarning() << "The Qt option -fg, --foreground has no effect." << endl; if( qtargs->isSet("button") ) kdWarning() << "The Qt option -btn, --button has no effect." << endl; if( qtargs->isSet("font") ) kdWarning() << "The Qt option -fn, --font has no effect." << endl; TDEApplication* a = NULL; #ifdef COMPOSITE a = new TDEApplication(TDEApplication::openX11RGBADisplay()); argb_visual = a->isX11CompositionAvailable(); #else a = new TDEApplication; #endif TQString dataPathBase = TDEStandardDirs::kde_default("data").append("konsole/"); TDEGlobal::dirs()->addResourceType("wallpaper", dataPathBase + "wallpapers"); KImageIO::registerFormats(); // add io for additional image formats //2.1 secs TQString title; if(args->isSet("T")) { title = TQFile::decodeName(args->getOption("T")); } if(qtargs->isSet("title")) { title = TQFile::decodeName(qtargs->getOption("title")); } TQString term = ""; if(args->isSet("tn")) { term=TQString::fromLatin1(args->getOption("tn")); } login_shell = args->isSet("ls"); TQStrList eargs; const char* shell = 0; if (!args->getOption("e").isEmpty()) { if (args->isSet("ls")) TDECmdLineArgs::usage(i18n("You can't use BOTH -ls and -e.\n")); shell = strdup(args->getOption("e")); eargs.append(shell); for(int i=0; i < args->count(); i++) eargs.append( args->arg(i) ); if (title.isEmpty() && (kapp->caption() == kapp->aboutData()->programName())) { title = TQFile::decodeName(shell); // program executed in the title bar } showtip = false; } TQCString sz = ""; sz = args->getOption("vt_sz"); histon = args->isSet("hist"); menubaron = args->isSet("menubar"); tabbaron = args->isSet("tabbar") && args->isSet("toolbar"); frameon = args->isSet("frame"); scrollbaron = args->isSet("scrollbar"); TQCString wname = qtargs->getOption("name"); full_script = args->isSet("script"); auto_close = args->isSet("close"); fixed_size = !args->isSet("resize"); if (!full_script) a->dcopClient()->setQtBridgeEnabled(false); TQCString type = ""; if(args->isSet("type")) { type = args->getOption("type"); } if(args->isSet("types")) { TQStringList types = TDEGlobal::dirs()->findAllResources("appdata", "*.desktop", false, true); types.sort(); for(TQStringList::ConstIterator it = types.begin(); it != types.end(); ++it) { TQString file = *it; file = file.mid(file.findRev('/')+1); if (file.endsWith(".desktop")) file = file.left(file.length()-8); printf("%s\n", TQFile::encodeName(file).data()); } return 0; } if(args->isSet("schemas") || args->isSet("schemata")) { ColorSchemaList colors; colors.checkSchemas(); for(int i = 0; i < (int) colors.count(); i++) { ColorSchema *schema = colors.find(i); TQString relPath = schema->relPath(); if (!relPath.isEmpty()) printf("%s\n", TQFile::encodeName(relPath).data()); } return 0; } if(args->isSet("keytabs")) { TQStringList lst = TDEGlobal::dirs()->findAllResources("data", "konsole/*.keytab"); printf("default\n"); // 'buildin' keytab lst.sort(); for(TQStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { TQFileInfo fi(*it); TQString file = fi.baseName(); printf("%s\n", TQFile::encodeName(file).data()); } return 0; } TQString workDir = TQFile::decodeName( args->getOption("workdir") ); TQString keytab = ""; if (args->isSet("keytab")) keytab = TQFile::decodeName(args->getOption("keytab")); TQString schema = ""; if (args->isSet("schema")) schema = args->getOption("schema"); TDEConfig * sessionconfig = 0; TQString profile = ""; if (args->isSet("profile")) { profile = args->getOption("profile"); TQString path = locate( "data", "konsole/profiles/" + profile ); if ( TQFile::exists( path ) ) sessionconfig=new TDEConfig( path, true ); else profile = ""; } if (args->isSet("profiles")) { TQStringList profiles = TDEGlobal::dirs()->findAllResources("data", "konsole/profiles/*", false, true); profiles.sort(); for(TQStringList::ConstIterator it = profiles.begin(); it != profiles.end(); ++it) { TQString file = *it; file = file.mid(file.findRev('/')+1); printf("%s\n", TQFile::encodeName(file).data()); } return 0; } //FIXME: more: font args->clear(); int c = 0, l = 0; if ( !sz.isEmpty() ) { char *ls = strchr( sz.data(), 'x' ); if ( ls != NULL ) { *ls='\0'; ls++; c=atoi(sz.data()); l=atoi(ls); } else { TDECmdLineArgs::usage(i18n("expected --vt_sz <#columns>x<#lines> e.g. 80x40\n")); } } if (!kapp->authorizeTDEAction("size")) fixed_size = true; // /////////////////////////////////////////////// // Ignore SIGHUP so that we don't get killed when // our parent-shell gets closed. signal(SIGHUP, SIG_IGN); putenv((char*)"COLORTERM="); // to trigger mc's color detection KonsoleSessionManaged ksm; if (a->isRestored() || !profile.isEmpty()) { if (!shell) shell = konsole_shell(eargs); if (profile.isEmpty()) sessionconfig = a->sessionConfig(); sessionconfig->setDesktopGroup(); int n = 1; TQString key; TQString sTitle; TQString sPgm; TQString sTerm; TQString sIcon; TQString sCwd; int n_tabbar; // TODO: Session management stores everything in same group, // should use one group / mainwindow while (TDEMainWindow::canBeRestored(n) || !profile.isEmpty()) { sessionconfig->setGroup(TQString("%1").arg(n)); if (!sessionconfig->hasKey("Pgm0")) sessionconfig->setDesktopGroup(); // Backwards compatible int session_count = sessionconfig->readNumEntry("numSes"); int counter = 0; wname = sessionconfig->readEntry("class",wname).latin1(); sPgm = sessionconfig->readEntry("Pgm0", shell); sessionconfig->readListEntry("Args0", eargs); sTitle = sessionconfig->readEntry("Title0", title); sTerm = sessionconfig->readEntry("Term0"); sIcon = sessionconfig->readEntry("Icon0","konsole"); sCwd = sessionconfig->readPathEntry("Cwd0"); workDir = sessionconfig->readPathEntry("workdir"); n_tabbar = TQMIN(sessionconfig->readUnsignedNumEntry("tabbar",Konsole::TabBottom),2); Konsole *m = new Konsole(wname,histon,menubaron,tabbaron,frameon,scrollbaron,0/*type*/,true,n_tabbar, workDir); m->newSession(sPgm, eargs, sTerm, sIcon, sTitle, sCwd); m->enableFullScripting(full_script); m->enableFixedSize(fixed_size); m->restore(n); sessionconfig->setGroup(TQString("%1").arg(n)); if (!sessionconfig->hasKey("Pgm0")) sessionconfig->setDesktopGroup(); // Backwards compatible m->makeGUI(); m->setEncoding(sessionconfig->readNumEntry("Encoding0")); m->setSchema(sessionconfig->readEntry("Schema0")); // Use konsolerc default as tmpFont instead? TQFont tmpFont = TDEGlobalSettings::fixedFont(); m->initSessionFont(sessionconfig->readFontEntry("SessionFont0", &tmpFont)); m->initSessionKeyTab(sessionconfig->readEntry("KeyTab0")); m->initMonitorActivity(sessionconfig->readBoolEntry("MonitorActivity0",false)); m->initMonitorSilence(sessionconfig->readBoolEntry("MonitorSilence0",false)); m->initMasterMode(sessionconfig->readBoolEntry("MasterMode0",false)); m->initTabColor(sessionconfig->readColorEntry("TabColor0")); // -1 will be changed to the default history in konsolerc m->initHistory(sessionconfig->readNumEntry("History0", -1), sessionconfig->readBoolEntry("HistoryEnabled0", true)); counter++; // show() before 2nd+ sessions are created allows --profile to // initialize the TE size correctly. m->show(); while (counter < session_count) { key = TQString("Title%1").arg(counter); sTitle = sessionconfig->readEntry(key, title); key = TQString("Args%1").arg(counter); sessionconfig->readListEntry(key, eargs); key = TQString("Pgm%1").arg(counter); // if the -e option is passed on the command line, this overrides the program specified // in the profile file if ( args->isSet("e") ) sPgm = (shell ? TQFile::decodeName(shell) : TQString()); else sPgm = sessionconfig->readEntry(key, shell); key = TQString("Term%1").arg(counter); sTerm = sessionconfig->readEntry(key); key = TQString("Icon%1").arg(counter); sIcon = sessionconfig->readEntry(key,"konsole"); key = TQString("Cwd%1").arg(counter); sCwd = sessionconfig->readPathEntry(key); m->newSession(sPgm, eargs, sTerm, sIcon, sTitle, sCwd); m->setSessionTitle(sTitle); // Use title as is key = TQString("Schema%1").arg(counter); m->setSchema(sessionconfig->readEntry(key)); key = TQString("Encoding%1").arg(counter); m->setEncoding(sessionconfig->readNumEntry(key)); key = TQString("SessionFont%1").arg(counter); TQFont tmpFont = TDEGlobalSettings::fixedFont(); m->initSessionFont(sessionconfig->readFontEntry(key, &tmpFont)); key = TQString("KeyTab%1").arg(counter); m->initSessionKeyTab(sessionconfig->readEntry(key)); key = TQString("MonitorActivity%1").arg(counter); m->initMonitorActivity(sessionconfig->readBoolEntry(key,false)); key = TQString("MonitorSilence%1").arg(counter); m->initMonitorSilence(sessionconfig->readBoolEntry(key,false)); key = TQString("MasterMode%1").arg(counter); m->initMasterMode(sessionconfig->readBoolEntry(key,false)); key = TQString("TabColor%1").arg(counter); m->initTabColor(sessionconfig->readColorEntry(key)); // -1 will be changed to the default history in konsolerc key = TQString("History%1").arg(counter); TQString key2 = TQString("HistoryEnabled%1").arg(counter); m->initHistory(sessionconfig->readNumEntry(key, -1), sessionconfig->readBoolEntry(key2, true)); counter++; } m->setDefaultSession( sessionconfig->readEntry("DefaultSession","shell.desktop") ); m->initFullScreen(); if ( !profile.isEmpty() ) { m->callReadPropertiesInternal(sessionconfig,1); profile = ""; // Hack to work-around sessions initialized with minimum size for (int i=0;i<counter;i++) m->activateSession( i ); m->setColLin(c,l); // will use default height and width if called with (0,0) } // works only for the first one, but there won't be more. n++; m->activateSession( sessionconfig->readNumEntry("ActiveSession",0) ); m->setAutoClose(auto_close); } } else { Konsole* m = new Konsole(wname,histon,menubaron,tabbaron,frameon,scrollbaron,type, false, 0, workDir); m->newSession((shell ? TQFile::decodeName(shell) : TQString()), eargs, term, TQString(), title, workDir); m->enableFullScripting(full_script); m->enableFixedSize(fixed_size); //3.8 :-( //exit(0); if (!keytab.isEmpty()) m->initSessionKeyTab(keytab); if (!schema.isEmpty()) { if (schema.right(7)!=".schema") schema+=".schema"; m->setSchema(schema); m->activateSession(0); // Fixes BR83162, transp. schema + notabbar } m->setColLin(c,l); // will use default height and width if called with (0,0) m->initFullScreen(); m->show(); if (showtip) m->showTipOnStart(); m->setAutoClose(auto_close); } int ret = a->exec(); //// Temporary code, waiting for Qt to do this properly // Delete all toplevel widgets that have WDestructiveClose TQWidgetList *list = TQApplication::topLevelWidgets(); // remove all toplevel widgets that have a parent (i.e. they // got WTopLevel explicitly), they'll be deleted by the parent list->first(); while( list->current()) { if( list->current()->parentWidget() != NULL || !list->current()->testWFlags( TQt::WDestructiveClose ) ) { list->remove(); continue; } list->next(); } TQWidgetListIt it(*list); TQWidget * w; while( (w=it.current()) != 0 ) { ++it; delete w; } delete list; delete a; return ret; }
bool SevenZipArch::processLine( const TQCString& _line ) { TQString line; TQString columns[ 11 ]; unsigned int pos = 0; int strpos, len; TQTextCodec *codec = TQTextCodec::codecForLocale(); line = codec->toUnicode( _line ); columns[ 0 ] = line.right( line.length() - m_nameColumnPos); line.truncate( m_nameColumnPos ); // Go through our columns, try to pick out data, return silently on failure for ( TQPtrListIterator <ArchColumns>col( m_archCols ); col.current(); ++col ) { ArchColumns *curCol = *col; strpos = curCol->pattern.search( line, pos ); len = curCol->pattern.matchedLength(); if ( ( strpos == -1 ) || ( len > curCol->maxLength ) ) { if ( curCol->optional ) continue; // More? else { kdDebug(1601) << "processLine failed to match critical column" << endl; return false; } } pos = strpos + len; columns[ curCol->colRef ] = line.mid( strpos, len ); } // Separated directories pass if(columns[4].length() && columns[4][0] == 'D') return true; if ( m_dateCol >= 0 ) { TQString year = ( m_repairYear >= 0 ) ? ArkUtils::fixYear( columns[ m_repairYear ].ascii()) : columns[ m_fixYear ]; TQString month = ( m_repairMonth >= 0 ) ? TQString( "%1" ) .arg( ArkUtils::getMonth( columns[ m_repairMonth ].ascii() ) ) : columns[ m_fixMonth ]; TQString timestamp = TQString::fromLatin1( "%1-%2-%3 %4" ) .arg( year ) .arg( month ) .arg( columns[ m_fixDay ] ) .arg( columns[ m_fixTime ] ); columns[ m_dateCol ] = timestamp; } TQStringList list; for ( int i = 0; i < m_numCols; ++i ) { list.append( columns[ i ] ); } m_gui->fileList()->addItem( list ); // send the entry to the GUI return true; }