TQString TDEStorageDevice::friendlyName() { // Return the actual storage device name TQString devicevendorid = vendorEncoded(); TQString devicemodelid = modelEncoded(); devicevendorid.replace("\\x20", " "); devicemodelid.replace("\\x20", " "); devicevendorid = devicevendorid.stripWhiteSpace(); devicemodelid = devicemodelid.stripWhiteSpace(); devicevendorid = devicevendorid.simplifyWhiteSpace(); devicemodelid = devicemodelid.simplifyWhiteSpace(); TQString devicename = devicevendorid + " " + devicemodelid; devicename = devicename.stripWhiteSpace(); devicename = devicename.simplifyWhiteSpace(); if (devicename != "") { return devicename; } if (isDiskOfType(TDEDiskDeviceType::Camera)) { return TDEGenericDevice::friendlyName(); } if (isDiskOfType(TDEDiskDeviceType::Floppy)) { return friendlyDeviceType(); } TQString label = diskLabel(); if (label.isNull()) { if (deviceSize() > 0) { if (checkDiskStatus(TDEDiskDeviceStatus::Hotpluggable)) { label = i18n("%1 Removable Device").arg(deviceFriendlySize()); } else { label = i18n("%1 Fixed Storage Device").arg(deviceFriendlySize()); } } } if (!label.isNull()) { return label; } return friendlyDeviceType(); }
TQVariant KJSProxyImpl::evaluate(TQString filename, int baseLine, const TQString&str, const DOM::Node &n, Completion *completion) { // evaluate code. Returns the JS return value or an invalid QVariant // if there was none, an error occurred or the type couldn't be converted. initScript(); // inlineCode is true for <a href="javascript:doSomething()"> // and false for <script>doSomething()</script>. Check if it has the // expected value in all cases. // See smart window.open policy for where this is used. bool inlineCode = filename.isNull(); //kdDebug(6070) << "KJSProxyImpl::evaluate inlineCode=" << inlineCode << endl; #ifdef KJS_DEBUGGER if (inlineCode) filename = "(unknown file)"; if (KJSDebugWin::debugWindow()) { KJSDebugWin::debugWindow()->attach(m_script); KJSDebugWin::debugWindow()->setNextSourceInfo(filename,baseLine); // KJSDebugWin::debugWindow()->setMode(KJSDebugWin::Step); } #else Q_UNUSED(baseLine); #endif m_script->setInlineCode(inlineCode); Window* window = Window::retrieveWindow( m_frame->m_part ); KJS::Value thisNode = n.isNull() ? Window::retrieve( m_frame->m_part ) : getDOMNode(m_script->globalExec(),n); UString code( str ); KJSCPUGuard guard; guard.start(); Completion comp = m_script->evaluate(code, thisNode); guard.stop(); bool success = ( comp.complType() == Normal ) || ( comp.complType() == ReturnValue ); if (completion) *completion = comp; #ifdef KJS_DEBUGGER // KJSDebugWin::debugWindow()->setCode(TQString::null); #endif window->afterScriptExecution(); // let's try to convert the return value if (success && comp.value().isValid()) return ValueToVariant( m_script->globalExec(), comp.value()); else { if ( comp.complType() == Throw ) { UString msg = comp.value().toString(m_script->globalExec()); kdDebug(6070) << "WARNING: Script threw exception: " << msg.qstring() << endl; } return TQVariant(); } }
TQString TDECompletion::makeCompletion( const TQString& string ) { if ( myCompletionMode == TDEGlobalSettings::CompletionNone ) return TQString::null; //kdDebug(0) << "TDECompletion: completing: " << string << endl; d->matches.clear(); myRotationIndex = 0; myHasMultipleMatches = false; myLastMatch = myCurrentMatch; // in Shell-completion-mode, emit all matches when we get the same // complete-string twice if ( myCompletionMode == TDEGlobalSettings::CompletionShell && string == myLastString ) { // Don't use d->matches since calling postProcessMatches() // on d->matches here would interfere with call to // postProcessMatch() during rotation findAllCompletions( string, &d->matches, myHasMultipleMatches ); TQStringList l = d->matches.list(); postProcessMatches( &l ); emit matches( l ); if ( l.isEmpty() ) doBeep( NoMatch ); return TQString::null; } TQString completion; // in case-insensitive popup mode, we search all completions at once if ( myCompletionMode == TDEGlobalSettings::CompletionPopup || myCompletionMode == TDEGlobalSettings::CompletionPopupAuto ) { findAllCompletions( string, &d->matches, myHasMultipleMatches ); if ( !d->matches.isEmpty() ) completion = d->matches.first(); } else completion = findCompletion( string ); if ( myHasMultipleMatches ) emit multipleMatches(); myLastString = string; myCurrentMatch = completion; postProcessMatch( &completion ); if ( !string.isEmpty() ) { // only emit match when string is not empty //kdDebug(0) << "TDECompletion: Match: " << completion << endl; emit match( completion ); } if ( completion.isNull() ) doBeep( NoMatch ); return completion; }
void KonqSidebarHistoryItem::update( const KonqHistoryEntry *entry ) { m_entry = entry; if (!entry) return; TQString title( entry->title ); if ( !title.stripWhiteSpace().isEmpty() && title != entry->url.url() ) setText( 0, title ); else { TQString path( entry->url.path() ); if ( path.isEmpty() ) path += '/'; setText( 0, path ); } KonqSidebarHistoryGroupItem *group = MYGROUP; assert(group); TQString path = entry->url.path(); if ( group->hasFavIcon() && (path.isNull() || path == "/") ) { const TQPixmap *pm = group->pixmap(0); if (pm) setPixmap( 0, *pm ); } else { setPixmap( 0, SmallIcon(KProtocolInfo::icon( entry->url.protocol() ))); } group->itemUpdated( this ); // update for sorting }
void KTextBrowser::setSource( const TQString& name ) { if( name.isNull() ) { return; } if( name.find('@') > -1 ) { if( !mNotifyClick ) { kapp->invokeMailer( KURL( name ) ); } else { emit mailClick( TQString::null, name ); } } else { if( !mNotifyClick ) { kapp->invokeBrowser( name ); } else { emit urlClick( name ); } } }
/* Checks if dates are correct and popups a error box if they are not. */ bool KfindTabWidget::isDateValid() { // All files if ( !findCreated->isChecked() ) return TRUE; if (rb[1]->isChecked()) { if (timeBox->value() > 0 ) return TRUE; KMessageBox::sorry(this, i18n("Unable to search within a period that is less than a minute.")); return FALSE; } // If we can not parse either of the dates or // "from" date is bigger than "to" date return FALSE. TQDate hi1, hi2; TQString str; if ( ! fromDate->getDate(&hi1).isValid() || ! toDate->getDate(&hi2).isValid() ) str = i18n("The date is not valid."); else if ( hi1 > hi2 ) str = i18n("Invalid date range."); else if ( TQDate::currentDate() < hi1 ) str = i18n("Unable to search dates in the future."); if (!str.isNull()) { KMessageBox::sorry(0, str); return FALSE; } return TRUE; }
TQString TDEStorageDevice::mountPath() { // See if this device node is mounted // This requires parsing /proc/mounts, looking for deviceNode() // The Device Mapper throws a monkey wrench into this // It likes to advertise mounts as /dev/mapper/<something>, // where <something> is listed in <system path>/dm/name // First, ensure that all device information (mainly holders/slaves) is accurate TDEGlobal::hardwareDevices()->rescanDeviceInformation(this); TQString dmnodename = systemPath(); dmnodename.append("/dm/name"); TQFile namefile( dmnodename ); TQString dmaltname; if ( namefile.open( IO_ReadOnly ) ) { TQTextStream stream( &namefile ); dmaltname = stream.readLine(); namefile.close(); } if (!dmaltname.isNull()) { dmaltname.prepend("/dev/mapper/"); } TQStringList lines; TQFile file( "/proc/mounts" ); if ( file.open( IO_ReadOnly ) ) { TQTextStream stream( &file ); TQString line; while ( !stream.atEnd() ) { line = stream.readLine(); TQStringList mountInfo = TQStringList::split(" ", line, true); TQString testNode = *mountInfo.at(0); // Check for match if ((testNode == deviceNode()) || (testNode == dmaltname) || (testNode == ("/dev/disk/by-uuid/" + diskUUID()))) { TQString ret = *mountInfo.at(1); ret.replace("\\040", " "); return ret; } lines += line; } file.close(); } // While this device is not directly mounted, it could concievably be mounted via the Device Mapper // If so, try to retrieve the mount path... TQStringList slaveDeviceList = holdingDevices(); for ( TQStringList::Iterator slavedevit = slaveDeviceList.begin(); slavedevit != slaveDeviceList.end(); ++slavedevit ) { // Try to locate this device path in the TDE device tree TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices(); TDEGenericDevice *hwdevice = hwdevices->findBySystemPath(*slavedevit); if ((hwdevice) && (hwdevice->type() == TDEGenericDeviceType::Disk)) { TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(hwdevice); return sdevice->mountPath(); } } return TQString::null; }
static TQString beatifyValue( const TQString& value ) { if ( value.isNull() ) return TQString("(no value for key available)"); else if ( value.isEmpty() ) return TQString("(empty)"); return value; }
void TDEAboutContainerBase::setProgramLogo( const TQString &fileName ) { if( fileName.isNull() ) { return; } const TQPixmap logo( fileName ); setProgramLogo( logo ); }
/* * ObjKsTheme::loadCmdLineArgs(): Handle any overrides which the user might have * specified. */ void ObjKsTheme::loadCmdLineArgs( TDECmdLineArgs *args ) { mManagedMode = args->isSet( "managed" ); mTesting = args->isSet("test"); mLoColor = ( TQPixmap::defaultDepth() <= 8 ); TQString theme = args->getOption( "theme" ); if( theme != mActiveTheme && !theme.isNull() ) if( loadThemeRc( theme, false ) ) mActiveTheme = theme; //args->clear(); }
void TarListingThread::processDir( const KTarDirectory *tardir, const TQString & root ) { TQStringList list = tardir->entries(); TQStringList::const_iterator itEnd = list.constEnd(); for ( TQStringList::const_iterator it = list.constBegin(); it != itEnd; ++it ) { const KTarEntry* tarEntry = tardir->entry((*it)); if (!tarEntry) continue; TQStringList col_list; TQString name; if (root.isEmpty() || root.isNull()) name = tarEntry->name(); else name = root + tarEntry->name(); if ( !tarEntry->isFile() ) name += '/'; col_list.append( name ); TQString perms = makeAccessString(tarEntry->permissions()); if (!tarEntry->isFile()) perms = "d" + perms; else if (!tarEntry->symlink().isEmpty()) perms = "l" + perms; else perms = "-" + perms; col_list.append(perms); col_list.append( tarEntry->user() ); col_list.append( tarEntry->group() ); TQString strSize = "0"; if (tarEntry->isFile()) { strSize.sprintf("%d", ((KTarFile *)tarEntry)->size()); } col_list.append(strSize); TQString timestamp = tarEntry->datetime().toString(Qt::ISODate); col_list.append(timestamp); col_list.append(tarEntry->symlink()); ListingEvent *ev = new ListingEvent( col_list ); tqApp->postEvent( m_parent, ev ); // if it's a directory, process it. // remember that name is root + / + the name of the directory if ( tarEntry->isDirectory() ) { processDir( static_cast<const KTarDirectory *>( tarEntry ), name ); } } }
KURL KURLRequesterDlg::getURL(const TQString& dir, TQWidget *parent, const TQString& caption) { KURLRequesterDlg dlg(dir, parent, "filedialog", true); dlg.setCaption(caption.isNull() ? i18n("Open") : caption); dlg.exec(); const KURL& url = dlg.selectedURL(); if (url.isValid()) TDERecentDocument::add(url); return url; }
void QuickLauncher::addAppBeforeManually(TQString url, TQString sender) { if (sender.isNull()) { addApp(url, Append, true); } int pos = findApp(sender); if (pos < 0) { pos = Append; } DEBUGSTR << "QuickLauncher::addAppBefore(" << url << "," << sender << "): pos=" << pos << endl << flush; addApp(url, pos, true); }
void kSpaceSaver::readSettings() { KConfig *config = klock_config(); config->setGroup( "Settings" ); TQString str; str = config->readEntry( "Speed" ); if ( !str.isNull() ) speed = MAXSPEED - str.toInt(); else speed = DEFSPEED; warpinterval = config->readNumEntry( "WarpInterval", 15 ); delete config; }
void TDEAboutContainer::addImage( const TQString &fileName, int alignment ) { if( fileName.isNull() ) { return; } KImageTrackLabel* const label = new KImageTrackLabel( this, "image" ); const TQImage logo( fileName ); if( !logo.isNull() ) { TQPixmap pix; pix = logo; label->setPixmap( pix ); } label->setAlignment( alignment ); }
void Medium::setUserLabel(const TQString &label) { TDEConfig cfg("mediamanagerrc"); cfg.setGroup("UserLabels"); TQString entry_name = m_properties[UUID]; if ( label.isNull() ) { cfg.deleteEntry(entry_name); } else { cfg.writeEntry(entry_name, label); } m_properties[USER_LABEL] = label; }
void TDEAboutContainerBase::setImage( const TQString &fileName ) { if( !mImageLabel ) { kdDebug(291) << "setImage: " << "Invalid layout" << endl; return; } if( fileName.isNull() ) { return; } const TQPixmap logo( fileName ); if( !logo.isNull() ) mImageLabel->setPixmap( logo ); mImageFrame->layout()->activate(); }
void ExtensionProxy::loadExtension(const TQCString& desktopFile, const TQCString& configFile) { TQString df; // try simple path first TQFileInfo finfo( desktopFile ); if ( finfo.exists() ) { df = finfo.absFilePath(); } else { // locate desktop file df = TDEGlobal::dirs()->findResource("extensions", TQString(desktopFile)); } TQFile file(df); // does the config file exist? if (df.isNull() || !file.exists()) { kdError() << "Failed to locate extension desktop file: " << desktopFile << endl; exit(0); } // create AppletInfo instance _info = new AppletInfo(df); // set the config file if (!configFile.isNull()) _info->setConfigFile(configFile); // load extension DSO _extension = loadExtension(*_info); // sanity check if (!_extension) { kdError() << "Failed to load extension: " << _info->library() << endl; exit(0); } // connect updateLayout signal connect(_extension, TQT_SIGNAL(updateLayout()), TQT_SLOT(slotUpdateLayout())); }
bool TDEStorageDevice::unmountDevice(TQString* errRet, int* retcode) { int internal_retcode; if (!retcode) { retcode = &internal_retcode; } TQString mountpoint = mountPath(); TQString devNode = deviceNode(); if (mountpoint.isNull()) { return true; } mountpoint.replace("'", "'\\''"); TQString command; #ifdef WITH_UDISKS2 if(command.isEmpty()) { // Try to use UDISKS v2 via DBUS, if available TQString errorString; int unMountUDisks2Ret = unMountDriveUDisks2(devNode, TQString::null, &errorString); if (unMountUDisks2Ret == 0) { // Update internal mount data TDEGlobal::hardwareDevices()->processModifiedMounts(); return true; } else if (unMountUDisks2Ret == -1) { if (errRet) { *errRet = errorString; } // Update internal mount data TDEGlobal::hardwareDevices()->processModifiedMounts(); return false; } else { // The UDISKS v2 DBUS service was either not available or was unusable; try another method... command = TQString::null; } } #endif // WITH_UDISKS2 #ifdef WITH_UDISKS if(command.isEmpty()) { // Try to use UDISKS v1 via DBUS, if available TQString errorString; int unMountUDisksRet = unMountDriveUDisks(devNode, TQStringList(), &errorString); if (unMountUDisksRet == 0) { // Update internal mount data TDEGlobal::hardwareDevices()->processModifiedMounts(); return true; } else if (unMountUDisksRet == -1) { if (errRet) { *errRet = errorString; } // Update internal mount data TDEGlobal::hardwareDevices()->processModifiedMounts(); return false; } else { // The UDISKS v1 DBUS service was either not available or was unusable; try another method... command = TQString::null; } } #endif // WITH_UDISKS if(command.isEmpty() && !(TDEGlobal::dirs()->findExe("pumount").isEmpty())) { command = TQString("pumount '%1' 2>&1").arg(mountpoint); } if(command.isEmpty()) { if (errRet) { *errRet = i18n("No supported unmounting methods were detected on your system"); } return true; } FILE *exepipe = popen(command.local8Bit(), "r"); if (exepipe) { TQString umount_output; TQTextStream ts(exepipe, IO_ReadOnly); umount_output = ts.read(); *retcode = pclose(exepipe); if (*retcode == 0) { // Update internal mount data TDEGlobal::hardwareDevices()->processModifiedMounts(); return true; } else { if (errRet) { *errRet = umount_output; } } } // Update internal mount data TDEGlobal::hardwareDevices()->processModifiedMounts(); return false; }
void KJanusWidget::addPageWidget( TQFrame *page, const TQStringList &items, const TQString &header,const TQPixmap &pixmap ) { connect(page, TQT_SIGNAL(destroyed(TQObject*)), TQT_SLOT(pageGone(TQObject*))); if( mFace == Tabbed ) { mTabControl->addTab (page, items.last()); d->mIntToPage[d->mNextPageIndex] = static_cast<TQWidget*>(page); d->mPageToInt[static_cast<TQWidget*>(page)] = d->mNextPageIndex; d->mNextPageIndex++; } else if( mFace == TreeList || mFace == IconList ) { d->mIntToPage[d->mNextPageIndex] = static_cast<TQWidget*>(page); d->mPageToInt[static_cast<TQWidget*>(page)] = d->mNextPageIndex; mPageStack->addWidget( page, 0 ); if (items.isEmpty()) { kdDebug() << "Invalid TQStringList, with zero items" << endl; return; } if( mFace == TreeList ) { InsertTreeListItem(items, pixmap, page); } else // mFace == IconList { TQString itemName = items.last(); IconListItem *item = new IconListItem( mIconList, pixmap, itemName ); mIconListToPageStack.insert(item, page); mIconList->invalidateHeight(); mIconList->invalidateWidth(); if (mIconList->isVisible()) mIconList->updateWidth(); } // // Make sure the title label is sufficiently wide // TQString lastName = items.last(); const TQString &title = (!header.isNull() ? header : lastName); TQRect r = mTitleLabel->fontMetrics().boundingRect( title ); if( mTitleLabel->minimumWidth() < r.width() ) { mTitleLabel->setMinimumWidth( r.width() ); } d->mIntToTitle[d->mNextPageIndex] = title; if( d->mIntToTitle.count() == 1 ) { showPage(0); } d->mNextPageIndex++; } else { kdDebug() << "KJanusWidget::addPageWidget: can only add a page in Tabbed, TreeList or IconList modes" << endl; } }
TQString TDEStorageDevice::mountEncryptedDevice(TQString passphrase, TQString mediaName, TDEStorageMountOptions mountOptions, TQString* errRet, int* retcode) { int internal_retcode; if (!retcode) { retcode = &internal_retcode; } TQString ret = mountPath(); if (!ret.isNull()) { return ret; } // Create dummy password file KTempFile passwordFile(TQString::null, "tmp", 0600); passwordFile.setAutoDelete(true); TQFile* pwFile = passwordFile.file(); if (!pwFile) { return TQString::null; } pwFile->writeBlock(passphrase.ascii(), passphrase.length()); pwFile->flush(); TQString optionString; if (mountOptions["ro"] == "true") { optionString.append(" -r"); } if (mountOptions["atime"] != "true") { optionString.append(" -A"); } if (mountOptions["utf8"] == "true") { optionString.append(" -c utf8"); } if (mountOptions["sync"] == "true") { optionString.append(" -s"); } if (mountOptions.contains("filesystem") && !mountOptions["filesystem"].isEmpty()) { optionString.append(TQString(" -t %1").arg(mountOptions["filesystem"])); } if (mountOptions.contains("locale")) { optionString.append(TQString(" -c %1").arg(mountOptions["locale"])); } TQString passFileName = passwordFile.name(); TQString devNode = deviceNode(); passFileName.replace("'", "'\\''"); devNode.replace("'", "'\\''"); mediaName.replace("'", "'\\''"); TQString command = TQString("pmount -p '%1' %2 '%3' '%4' 2>&1").arg(passFileName).arg(optionString).arg(devNode).arg(mediaName); FILE *exepipe = popen(command.local8Bit(), "r"); if (exepipe) { TQString mount_output; TQTextStream ts(exepipe, IO_ReadOnly); mount_output = ts.read(); *retcode = pclose(exepipe); if (errRet) { *errRet = mount_output; } } // Update internal mount data TDEGlobal::hardwareDevices()->processModifiedMounts(); ret = mountPath(); return ret; }
TQString TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageMountOptions mountOptions, TQString* errRet, int* retcode) { int internal_retcode; if (!retcode) { retcode = &internal_retcode; } TQString ret = mountPath(); // Device is already mounted if (!ret.isNull()) { return ret; } TQString command; TQString devNode = deviceNode(); devNode.replace("'", "'\\''"); mediaName.replace("'", "'\\''"); #if defined(WITH_UDISKS2) || defined(WITH_UDISKS) // Prepare filesystem options for mount TQStringList udisksOptions; TQString optionString; if (mountOptions["ro"] == "true") { udisksOptions.append("ro"); } if (mountOptions["atime"] != "true") { udisksOptions.append("noatime"); } if (mountOptions["sync"] == "true") { udisksOptions.append("sync"); } if( (mountOptions["filesystem"] == "fat") || (mountOptions["filesystem"] == "vfat") || (mountOptions["filesystem"] == "msdos") || (mountOptions["filesystem"] == "umsdos") ) { if (mountOptions.contains("shortname")) { udisksOptions.append(TQString("shortname=%1").arg(mountOptions["shortname"])); } } if( (mountOptions["filesystem"] == "jfs")) { if (mountOptions["utf8"] == "true") { // udisks/udisks2 for now does not support option iocharset= for jfs // udisksOptions.append("iocharset=utf8"); } } if( (mountOptions["filesystem"] == "ntfs-3g") ) { if (mountOptions.contains("locale")) { udisksOptions.append(TQString("locale=%1").arg(mountOptions["locale"])); } } if( (mountOptions["filesystem"] == "ext3") || (mountOptions["filesystem"] == "ext4") ) { if (mountOptions.contains("journaling")) { // udisks/udisks2 for now does not support option data= for ext3/ext4 // udisksOptions.append(TQString("data=%1").arg(mountOptions["journaling"])); } } for (TQStringList::Iterator it = udisksOptions.begin(); it != udisksOptions.end(); ++it) { optionString.append(","); optionString.append(*it); } if (!optionString.isEmpty()) { optionString.remove(0, 1); } #endif // defined(WITH_UDISKS2) || defined(WITH_UDISKS) #ifdef WITH_UDISKS2 if(command.isEmpty()) { // Try to use UDISKS v2 via DBUS, if available TQString errorString; TQString fileSystemType; if (mountOptions.contains("filesystem") && !mountOptions["filesystem"].isEmpty()) { fileSystemType = mountOptions["filesystem"]; } int uDisks2Ret = mountDriveUDisks2(devNode, fileSystemType, optionString, &errorString); if (uDisks2Ret == 0) { // Update internal mount data TDEGlobal::hardwareDevices()->processModifiedMounts(); ret = mountPath(); return ret; } else if (uDisks2Ret == -1) { if (errRet) { *errRet = errorString; } // Update internal mount data TDEGlobal::hardwareDevices()->processModifiedMounts(); ret = mountPath(); return ret; } else { // The UDISKS v2 DBUS service was either not available or was unusable; try another method... command = TQString::null; } } #endif // WITH_UDISKS2 #ifdef WITH_UDISKS if(command.isEmpty()) { // Try to use UDISKS v1 via DBUS, if available TQString errorString; TQString fileSystemType; if (mountOptions.contains("filesystem") && !mountOptions["filesystem"].isEmpty()) { fileSystemType = mountOptions["filesystem"]; } int uDisksRet = mountDriveUDisks(devNode, fileSystemType, udisksOptions, &errorString); if (uDisksRet == 0) { // Update internal mount data TDEGlobal::hardwareDevices()->processModifiedMounts(); ret = mountPath(); return ret; } else if (uDisksRet == -1) { if (errRet) { *errRet = errorString; } // Update internal mount data TDEGlobal::hardwareDevices()->processModifiedMounts(); ret = mountPath(); return ret; } else { // The UDISKS v1 DBUS service was either not available or was unusable; try another method... command = TQString::null; } } #endif // WITH_UDISKS if(command.isEmpty()) { // Use 'pmount' command, if available TQString pmountProg = TDEGlobal::dirs()->findExe("pmount"); if (!pmountProg.isEmpty()) { // Create dummy password file KTempFile passwordFile(TQString::null, "tmp", 0600); passwordFile.setAutoDelete(true); TQString optionString; if (mountOptions["ro"] == "true") { optionString.append(" -r"); } if (mountOptions["atime"] != "true") { optionString.append(" -A"); } if (mountOptions["utf8"] == "true") { optionString.append(" -c utf8"); } if (mountOptions["sync"] == "true") { optionString.append(" -s"); } if (mountOptions.contains("filesystem") && !mountOptions["filesystem"].isEmpty()) { optionString.append(TQString(" -t %1").arg(mountOptions["filesystem"])); } if (mountOptions.contains("locale")) { optionString.append(TQString(" -c %1").arg(mountOptions["locale"])); } TQString passFileName = passwordFile.name(); passFileName.replace("'", "'\\''"); command = TQString("pmount -p '%1' %2 '%3' '%4' 2>&1").arg(passFileName).arg(optionString).arg(devNode).arg(mediaName); } } if(command.isEmpty()) { if (errRet) { *errRet = i18n("No supported mounting methods were detected on your system"); } return ret; } FILE *exepipe = popen(command.local8Bit(), "r"); if (exepipe) { TQString mount_output; TQTextStream ts(exepipe, IO_ReadOnly); mount_output = ts.read(); *retcode = pclose(exepipe); if (errRet) { *errRet = mount_output; } } // Update internal mount data TDEGlobal::hardwareDevices()->processModifiedMounts(); ret = mountPath(); return ret; }
void KCMStyle::loadStyle( TDEConfig& config ) { cbStyle->clear(); // Create a dictionary of WidgetStyle to Name and Desc. mappings, // as well as the config page info styleEntries.clear(); styleEntries.setAutoDelete(true); TQString strWidgetStyle; TQStringList list = TDEGlobal::dirs()->findAllResources("themes", "*.themerc", true, true); for (TQStringList::iterator it = list.begin(); it != list.end(); ++it) { KSimpleConfig config( *it, true ); if ( !(config.hasGroup("KDE") && config.hasGroup("Misc")) ) continue; config.setGroup("KDE"); strWidgetStyle = config.readEntry("WidgetStyle"); if (strWidgetStyle.isNull()) continue; // We have a widgetstyle, so lets read the i18n entries for it... StyleEntry* entry = new StyleEntry; config.setGroup("Misc"); entry->name = config.readEntry("Name"); entry->desc = config.readEntry("Comment", i18n("No description available.")); entry->configPage = config.readEntry("ConfigPage", TQString::null); // Check if this style should be shown config.setGroup("Desktop Entry"); entry->hidden = config.readBoolEntry("Hidden", false); // Insert the entry into our dictionary. styleEntries.insert(strWidgetStyle.lower(), entry); } // Obtain all style names TQStringList allStyles = TQStyleFactory::keys(); // Get translated names, remove all hidden style entries. TQStringList styles; StyleEntry* entry; for (TQStringList::iterator it = allStyles.begin(); it != allStyles.end(); it++) { TQString id = (*it).lower(); // Find the entry. if ( (entry = styleEntries.find(id)) != 0 ) { // Do not add hidden entries if (entry->hidden) continue; styles += entry->name; nameToStyleKey[entry->name] = id; } else { styles += (*it); //Fall back to the key (but in original case) nameToStyleKey[*it] = id; } } // Sort the style list, and add it to the combobox styles.sort(); cbStyle->insertStringList( styles ); // Find out which style is currently being used config.setGroup( "General" ); TQString defaultStyle = TDEStyle::defaultStyle(); TQString cfgStyle = config.readEntry( "widgetStyle", defaultStyle ); // Select the current style // Do not use cbStyle->listBox() as this may be NULL for some styles when // they use QPopupMenus for the drop-down list! // ##### Since Trolltech likes to seemingly copy & paste code, // TQStringList::findItem() doesn't have a Qt::StringComparisonMode field. // We roll our own (yuck) cfgStyle = cfgStyle.lower(); int item = 0; for( int i = 0; i < cbStyle->count(); i++ ) { TQString id = nameToStyleKey[cbStyle->text(i)]; item = i; if ( id == cfgStyle ) // ExactMatch break; else if ( id.contains( cfgStyle ) ) break; else if ( id.contains( TQApplication::style().className() ) ) break; item = 0; } cbStyle->setCurrentItem( item ); m_bStyleDirty = false; switchStyle( currentStyle() ); // make resets visible }
void KPaletteTable::readNamedColor( void ) { if( mNamedColorList->count() != 0 ) { return; // Strings already present } TDEGlobal::locale()->insertCatalogue("tdelibs_colors"); // // Code somewhat inspired by KPalette. // const char * const *path = namedColorFilePath(); for( int i=0; path[i]; ++i ) { TQFile paletteFile( path[i] ); if( !paletteFile.open( IO_ReadOnly ) ) { continue; } TQString line; TQStringList list; while( paletteFile.readLine( line, 100 ) != -1 ) { int red, green, blue; int pos = 0; if( sscanf(line.ascii(), "%d %d %d%n", &red, &green, &blue, &pos ) == 3 ) { // // Remove duplicates. Every name with a space and every name // that start with "gray". // TQString name = line.mid(pos).stripWhiteSpace(); if( name.isNull() || name.find(' ') != -1 || name.find( "gray" ) != -1 || name.find( "grey" ) != -1 ) { continue; } const TQColor color ( red, green, blue ); if ( color.isValid() ) { const TQString colorName( i18n("color", name.latin1() ) ); list.append( colorName ); d->m_namedColorMap[ colorName ] = color; } } } list.sort(); mNamedColorList->insertStringList( list ); break; } if( mNamedColorList->count() == 0 ) { // // Give the error dialog box a chance to center above the // widget (or dialog). If we had displayed it now we could get a // situation where the (modal) error dialog box pops up first // preventing the real dialog to become visible until the // error dialog box is removed (== bad UI). // TQTimer::singleShot( 10, this, TQT_SLOT(slotShowNamedColorReadError()) ); } }