// Get a pixmap when its size is given (this can distort the image) const QPixmap ThemeManager::getPixmap(const QString &svgid,const QSize &size) { if (size.width() < 1 || size.height() < 1) kFatal() << "ThemeManager::getPixmap Cannot create svgid ID " << svgid << " with zero size" << size; QPixmap pixmap; // Cached pixmap? if (mPixmapCache.contains(svgid)) { pixmap = mPixmapCache[svgid]; if (pixmap.size() == size) { return pixmap; } } // Create new image QImage image(size, QImage::Format_ARGB32_Premultiplied); image.fill(0); QPainter p(&image); mRenderer->render(&p, svgid); p.end(); pixmap = QPixmap::fromImage(image); if (pixmap.isNull()) kFatal() << "ThemeManager::getPixmap Cannot load svgid ID " << svgid; // Cache image mPixmapCache[svgid] = pixmap; return pixmap; }
void OpenSearchManager::jobFinished(KJob *job) { if (job->error()) { return; // just silently return } if (m_state == REQ_SUGGESTION) { const QStringList suggestionsList = m_activeEngine->parseSuggestion(m_jobData); kDebug(1202) << "Received suggestion from " << m_activeEngine->name() << ": " << suggestionsList; emit suggestionReceived(suggestionsList); } else if (m_state == REQ_DESCRIPTION) { OpenSearchReader reader; OpenSearchEngine *engine = reader.read(m_jobData); if (engine) { m_enginesMap.insert(engine->name(), engine); QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("/konqueror/opensearch/"), QStandardPaths::LocateDirectory) + "/"; QString fileName = trimmedEngineName(engine->name()); QFile file(path + fileName + ".xml"); OpenSearchWriter writer; writer.write(&file, engine); QString searchUrl = OpenSearchEngine::parseTemplate(QStringLiteral("\\{@}"), engine->searchUrlTemplate()); emit openSearchEngineAdded(engine->name(), searchUrl, fileName); } else { kFatal() << "Error while adding new open search engine"; } } }
Attribute::Attribute(const QDomElement& element) : m_references() { if (element.firstChildElement() != element.lastChildElement()) { kFatal() << "We don't handle complex attributes so far"; } QDomElement content = element.firstChildElement(); if (content.tagName() == "ref") { m_references << content.attribute("name"); } m_name = element.attribute("name"); m_values = listValuesFromNode(element); if (m_name == "style:border-line-width") m_requiredExtraAttributes["fo:border"] = "double"; else if (m_name == "style:border-line-width-left") m_requiredExtraAttributes["fo:border-left"] = "double"; else if (m_name == "style:border-line-width-right") m_requiredExtraAttributes["fo:border-right"] = "double"; else if (m_name == "style:border-line-width-top") m_requiredExtraAttributes["fo:border-top"] = "double"; else if (m_name == "style:border-line-width-bottom") m_requiredExtraAttributes["fo:border-bottom"] = "double"; else if (m_name == "style:diagonal-tl-br-widths") m_requiredExtraAttributes["style:diagonal-tl-br"] = "double"; else if (m_name == "style:diagonal-bl-tr-widths") m_requiredExtraAttributes["style:diagonal-bl-tr"] = "double"; }
QDateTime KipiImageInfoShared::time(KIPI::TimeSpec timeSpec) { if (d->dateTime.isValid()) return d->dateTime; if ( ! _url.isLocalFile() ) { kFatal() << "KIPI::ImageInfoShared::time does not yet support non local files, please fix\n"; return QDateTime(); } else { KExiv2Iface::KExiv2* const exiv2Iface = new KExiv2Iface::KExiv2; exiv2Iface->load(_url.path()); d->dateTime = exiv2Iface->getImageDateTime(); delete exiv2Iface; if (!d->dateTime.isValid()) { d->dateTime = ImageInfoShared::time(timeSpec); } return d->dateTime; } }
int main(int argc, char **argv) { KCmdLineArgs::init(argc,argv, "netaccesstest", 0, ki18n("netaccesstest"), 0); KApplication app; KUrl srcURL( "ftp://ftp.kde.org/pub/kde/README" ); #ifdef Q_WS_WIN KUrl tmpURL( "file://" + QDir::tempPath() + "/netaccesstest_README" ); #else KUrl tmpURL( "file:/tmp/netaccesstest_README" ); #endif for ( uint i = 0; i < 4 ; ++i ) { kDebug() << "file_copy"; KIO::Job* job = KIO::file_copy(srcURL, tmpURL, -1, KIO::Overwrite); if ( !KIO::NetAccess::synchronousRun(job, 0) ) kError() << "file_copy failed: " << KIO::NetAccess::lastErrorString() << endl; else { QFile f( tmpURL.path() ); if (!f.open(QIODevice::ReadOnly)) kFatal() << "Cannot open: " << f.fileName() << ". The error was: " << f.errorString(); else { f.close(); } } } return 0; }
KMMsgPartDialog::Encoding KMMsgPartDialog::encoding() const { QString s = mEncoding->currentText(); for ( int i = 0 ; i < mI18nizedEncodings.count() ; ++i ) if ( s == mI18nizedEncodings.at(i) ) return encodingTypes[i].encoding; kFatal() << "Unknown encoding encountered!"; return None; // keep compiler happy }
void JobRemoteTest::initTestCase() { s_referenceTimeStamp = QDateTime::currentDateTime().addSecs( -30 ); // 30 seconds ago // Start with a clean base dir cleanupTestCase(); if ( !myExists( remoteTmpDir() ) ) { bool ok = myMkdir( remoteTmpDir() ); if ( !ok ) kFatal() << "Couldn't create " << remoteTmpDir(); } if ( !myExists( localTmpDir() ) ) { bool ok = myMkdir( localTmpDir() ); if ( !ok ) kFatal() << "Couldn't create " << localTmpDir(); } }
template <typename T> T* BuildASTVisitor::stackTop() { if( aststack.isEmpty() ) { kDebug(9024) << kBacktrace(); kFatal(9024) << "ERROR: AST stack is empty, this should never happen"; exit(255); } T* ast = dynamic_cast<T*>(aststack.top()); if( !ast ) { kDebug(9024) << kBacktrace(); kFatal(9024) << "ERROR: AST stack is screwed, doing a hard exit" << aststack.top()->type(); exit(255); } return ast; }
bool KTLayer::expandFrame(int position, int size) { kFatal() << "KTLayer::expandFrame -> Just Tracing!"; if (position < 0 || position >= k->frames.count()) { kFatal() << "KTLayer::expandFrame -> pos: " << position << " - size: " << size; return false; } KTFrame *toExpand = frame(position); if (toExpand) { k->frames.expandValue(position, size); return true; } return false; }
// Remove a card from the given position. Typically if the void Player::deleteCard(int cardPosition) { if (cardPosition >= mCards.size()) { kFatal() << "Player" << mId << "tries to delete non esxisting card position " << cardPosition <<" >=" << mCards.size(); } mCards[cardPosition] = -1; }
// Add a card to the player void Player::addCard(int cardPosition, int card) { if (cardPosition >= mCards.size()) { kFatal() << "Player" << mId << "tries to add to esxisting card position " << cardPosition <<" >=" << mCards.size(); } mCards[cardPosition] = card; }
// Retrieve a card won by this player. int Player::getWonCard(int no) { if (no>=mWonCards.size()) { kFatal() << "Player::getWonCard This card" << no << "is not available. " << "Only" << mWonCards.size() << "cards stored."; return -1; } return mWonCards[no]; }
GreeterWindow::GreeterWindow(QWidget *parent) : QDeclarativeView(parent), m_greeter(new GreeterWrapper(this)) { setResizeMode(QDeclarativeView::SizeRootObjectToView); KDeclarative kdeclarative; kdeclarative.setDeclarativeEngine(engine()); kdeclarative.initialize(); //binds things like kconfig and icons kdeclarative.setupBindings(); KConfig config(LIGHTDM_CONFIG_DIR "/lightdm-kde-greeter.conf"); KConfigGroup configGroup = config.group("greeter"); QString theme = configGroup.readEntry("theme-name", "userbar"); QStringList dirs = KGlobal::dirs()->findDirs("appdata", "themes/"); Plasma::PackageStructure::Ptr packageStructure(new LightDMPackageStructure(this)); Plasma::Package package(dirs.last() + "/" + theme, packageStructure); if (!package.isValid()) { kError() << theme << " is not a valid theme. Falling back to \"userbar\" theme."; package = Plasma::Package(dirs.last() + "/" + "userbar", packageStructure); } if (!package.isValid()) { kFatal() << "Cannot find QML file for \"userbar\" theme. Something is wrong with this installation. Aborting."; } KGlobal::locale()->insertCatalog("lightdm_theme_" + theme); rootContext()->setContextProperty("config", new ConfigWrapper(package.filePath("configfile"), this)); rootContext()->setContextProperty("greeter", m_greeter); setSource(package.filePath("mainscript")); // Prevent screen flickering when the greeter starts up. This really needs to be sorted out in QML/Qt... setAttribute(Qt::WA_OpaquePaintEvent); setAttribute(Qt::WA_NoSystemBackground); // Shortcut to take a screenshot of the screen. Handy because it is not // possible to take a screenshot of the greeter in test mode without // including the cursor. QShortcut* cut = new QShortcut(this); cut->setKey(Qt::CTRL + Qt::ALT + Qt::Key_S); connect(cut, SIGNAL(activated()), SLOT(screenshot())); connect(m_greeter, SIGNAL(aboutToLogin()), SLOT(setRootImage())); QRect screen = QApplication::desktop()->rect(); setGeometry(screen); new PowerManagement(this); }
const AttachmentStrategy * AttachmentStrategy::create( Type type ) { switch ( type ) { case Iconic: return iconic(); case Smart: return smart(); case Inlined: return inlined(); case Hidden: return hidden(); } kFatal( 5006 ) << "Unknown attachment startegy ( type ==" << (int)type << ") requested!"; return 0; // make compiler happy }
// Retrive card value at given logical position int Player::getCard(int playerNumber) { if (playerNumber >= mCards.size()) { kFatal() << "Player" << mId << "tries to get non esxisting card " << playerNumber <<" >=" << mCards.size(); } int card = mCards[playerNumber]; return card; }
Kopete::MessageHandlerChain::Ptr Kopete::ChatSession::chainForDirection( Kopete::Message::MessageDirection dir ) { if( dir < 0 || dir >= CHAIN_COUNT) kFatal(14000) << "invalid message direction " << dir; if( !d->chains[dir] ) { TempFactory theTempFactory; d->chains[dir] = Kopete::MessageHandlerChain::create( this, dir ); } return d->chains[dir]; }
void KMMsgPartDialog::setEncoding( Encoding encoding ) { for ( int i = 0 ; i < numEncodingTypes ; ++i ) if ( encodingTypes[i].encoding == encoding ) { QString text = mI18nizedEncodings.at(i); for ( int j = 0 ; j < mEncoding->count() ; ++j ) if ( mEncoding->itemText(j) == text ) { mEncoding->setCurrentIndex( j ); return; } mEncoding->insertItem( 0, text ); mEncoding->setCurrentIndex( 0 ); } kFatal() << "Unknown encoding encountered!"; }
// Deal a number of cards to this player void Player::deal(int amount) { if (!mDeck) { kFatal() << "No deck set to player."; return; } mCards.clear(); mCards.resize(amount); for (int i=0; i<amount; i++) { int card = mDeck->drawCard(); mCards[i] = card; } // Reset moves and points mMovesWon = 0; setPoints(0); mWonCards.clear(); refresh(); }
// Update the theme file and refresh all registered objects. Used // to really change the theme. void ThemeManager::updateTheme(const QString &themefile) { mThemeFileChanged = true; // Empty cache mPixmapCache.clear(); // Process dirs QString rcfile = KStandardDirs::locate("kwin4theme", themefile); kDebug() << "ThemeManager LOAD with theme "<<rcfile; // Read config and SVG file for theme delete mConfig; mConfig = new KConfig(rcfile, KConfig::NoGlobals); QString svgfile = config("general").readEntry("svgfile"); svgfile = KStandardDirs::locate("kwin4theme", svgfile); kDebug() << "Reading SVG master file =" << svgfile; mAspectRatio = config("general").readEntry("aspect-ratio", 1.0); kDebug() << "Aspect ration =" << mAspectRatio; delete mRenderer; mRenderer = new QSvgRenderer(this); bool result = mRenderer->load(svgfile); if (!result) { delete mRenderer; mRenderer = 0; kFatal() << "Cannot open file" << svgfile; } kDebug() << "Renderer" << mRenderer<<" =" << result; // Notify all theme objects of a change foreach(Themeable *object, mObjects) { object->changeTheme(); } }
void KApplicationPrivate::init() { if ((getuid() != geteuid()) || (getgid() != getegid())) { fprintf(stderr, "The KDE libraries are not designed to run with suid privileges.\n"); ::exit(127); } KApplication::KApp = q; // make sure the clipboard is created before setting the window icon (bug 209263) (void) QApplication::clipboard(); parseCommandLine(); (void) KClipboardSynchronizer::self(); QApplication::setDesktopSettingsAware( false ); #ifdef Q_WS_X11 // create all required atoms in _one_ roundtrip to the X server const int max = 20; Atom* atoms[max]; char* names[max]; Atom atoms_return[max]; int n = 0; atoms[n] = &atom_DesktopWindow; names[n++] = (char *) "KDE_DESKTOP_WINDOW"; atoms[n] = &atom_NetSupported; names[n++] = (char *) "_NET_SUPPORTED"; atoms[n] = &kde_xdnd_drop; names[n++] = (char *) "XdndDrop"; XInternAtoms( QX11Info::display(), names, n, false, atoms_return ); for (int i = 0; i < n; i++ ) *atoms[i] = atoms_return[i]; #endif // sanity checking, to make sure we've connected QDBusConnectionInterface *bus = 0; if (!QDBusConnection::sessionBus().isConnected() || !(bus = QDBusConnection::sessionBus().interface())) { kFatal(240) << "Session bus not found" << endl << "To circumvent this problem try the following command (with Linux and bash)" << endl << "export $(dbus-launch)"; ::exit(125); } extern bool s_kuniqueapplication_startCalled; if ( bus && !s_kuniqueapplication_startCalled ) // don't register again if KUniqueApplication did so already { QStringList parts = q->organizationDomain().split(QLatin1Char('.'), QString::SkipEmptyParts); QString reversedDomain; if (parts.isEmpty()) reversedDomain = QLatin1String("local."); else foreach (const QString& s, parts) { reversedDomain.prepend(QLatin1Char('.')); reversedDomain.prepend(s); }
bool KTPaletteParser::startTag(const QString &tag, const QXmlAttributes &atts) { if (root() == "Palette") { if (tag == root()) { k->paletteName = atts.value("name"); if (atts.value("editable") == "true") k->isEditable = true; else k->isEditable = false; } else if (tag == "Color") { QColor c = QColor(atts.value("colorName")); c.setAlpha( atts.value("alpha").toInt() ); if (c.isValid()) { k->brushes << c; } else { #ifdef K_DEBUG kError() << "Invalid Color"; #endif } } else if (tag == "Gradient") { if (k->gradient) delete k->gradient; k->gradient = 0; k->gradientStops.clear(); QGradient::Type type = QGradient::Type(atts.value("type").toInt()); QGradient::Spread spread = QGradient::Spread(atts.value("spread").toInt()); switch (type) { case QGradient::LinearGradient: { k->gradient = new QLinearGradient(atts.value("startX").toDouble(), atts.value("startY").toDouble(),atts.value("finalX").toDouble(), atts.value("finalY").toDouble()); } break; case QGradient::RadialGradient: { k->gradient = new QRadialGradient(atts.value("centerX").toDouble(), atts.value("centerY").toDouble(), atts.value("radius").toDouble(), atts.value("focalX").toDouble(),atts.value("focalY").toDouble() ); } break; case QGradient::ConicalGradient: { k->gradient = new QConicalGradient(atts.value("centerX").toDouble(), atts.value("centerY").toDouble(),atts.value("angle").toDouble()); } break; default: { #ifdef K_DEBUG kFatal() << "No gradient type: " << type; #endif } break; } k->gradient->setSpread(spread); } else if (tag == "Stop") { QColor c(atts.value("colorName") ); c.setAlpha(atts.value("alpha").toInt() ); k->gradientStops << qMakePair(atts.value("value").toDouble(), c); } } return true; }
bool ClientApp::doIt() { KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); const int argc = args->count(); checkArgumentCount(argc, 1, 0); if ( !args->isSet( "ninteractive" ) ) { s_interactive = false; s_jobFlags = KIO::HideProgressInfo; } #if !defined(KIOCLIENT_AS_KDEOPEN) if (args->isSet("overwrite")) { s_jobFlags |= KIO::Overwrite; } #endif kDebug() << "Creating ClientApp"; int fake_argc = 0; char** fake_argv = 0; ClientApp app( fake_argc, fake_argv ); KComponentData componentData("kioclient"); // needed by KIO's internal use of KConfig app.setApplicationName(componentData.componentName()); KGlobal::ref(); KGlobal::setAllowQuit(true); // KIO needs dbus (for uiserver communication) extern void qDBusBindToApplication(); qDBusBindToApplication(); if (!QDBusConnection::sessionBus().isConnected()) kFatal(101) << "Session bus not found" ; #ifdef KIOCLIENT_AS_KDEOPEN return app.kde_open(args->url(0), QByteArray(), false); #elif defined(KIOCLIENT_AS_KDECP) checkArgumentCount(argc, 2, 0); return app.doCopy(0); #elif defined(KIOCLIENT_AS_KDEMV) checkArgumentCount(argc, 2, 0); return app.doMove(0); #else // Normal kioclient mode const QByteArray command = args->arg(0).toLocal8Bit(); if ( command == "openProperties" ) { checkArgumentCount(argc, 2, 2); // openProperties <url> KPropertiesDialog * p = new KPropertiesDialog( args->url(1), 0 /*no parent*/ ); QObject::connect( p, SIGNAL( destroyed() ), &app, SLOT( quit() )); QObject::connect( p, SIGNAL( canceled() ), &app, SLOT( slotDialogCanceled() )); p->show(); app.exec(); return m_ok; } else if ( command == "cat" ) { checkArgumentCount(argc, 2, 2); // cat <url> KIO::TransferJob* job = KIO::get(args->url(1), KIO::NoReload, s_jobFlags); if ( !s_interactive ) job->setUiDelegate( 0 ); connect(job, SIGNAL(data(KIO::Job*,QByteArray) ), &app, SLOT(slotPrintData(KIO::Job*,QByteArray))); connect( job, SIGNAL( result( KJob * ) ), &app, SLOT( slotResult( KJob * ) ) ); app.exec(); return m_ok; }
QStringList Attribute::listValuesFromNode(const QDomElement &m_node) { QStringList result; if (m_references.size() == 0) { // Parse the content of the attribute QDomElement content = m_node.firstChildElement(); if ((content.tagName() == "choice") && (m_name != "style:text-emphasize")) { QDomElement valueChild = content.firstChildElement(); do { if (valueChild.tagName() == "value") { result << valueChild.text(); } else if (valueChild.tagName() == "ref") { m_references << valueChild.attribute("name"); } else if (valueChild.tagName() == "list") { // Parse that sublist if (valueChild.childNodes().length() != 1) { kFatal() << "Unrecognized list element in " << m_name; } QDomElement subElement = valueChild.firstChildElement(); if (subElement.nodeName() == "oneOrMore") { // Build a list of each sub item QStringList allowedValues; QDomElement subChoices = subElement.firstChildElement(); if (subChoices.nodeName() != "choice") { kFatal() << "Unrecognized oneOrMore element in " << m_name; } QDomElement subValueChild = subChoices.firstChildElement(); do { if (subValueChild.nodeName() == "value") { allowedValues << subValueChild.text(); } else { kFatal() << "Unrecognized oneOrMore element in " << m_name; } subValueChild = subValueChild.nextSiblingElement(); } while (!subValueChild.isNull()); QStringList mergedAllowedValues; while (mergedAllowedValues.length() != (pow((double) allowedValues.length(), allowedValues.length()))) { foreach (QString baseValue, allowedValues) { if (!mergedAllowedValues.contains(baseValue)) mergedAllowedValues << baseValue; foreach (QString knownValue, mergedAllowedValues) { if ((knownValue == baseValue) || (knownValue.contains(baseValue + ' ')) || (knownValue.contains(' ' + baseValue))) { continue; } QString builtValue = knownValue + ' ' + baseValue; if (!mergedAllowedValues.contains(builtValue)) mergedAllowedValues << builtValue; } } } foreach (QString allowedValue, mergedAllowedValues) { QStringList equivalenceList; equivalenceList << allowedValue; QStringList currentList = allowedValue.split(' '); currentList.sort(); foreach (QString otherAllowedValue, mergedAllowedValues) { if (otherAllowedValue == allowedValue) continue; QStringList otherList = otherAllowedValue.split(' '); otherList.sort(); if (otherList == currentList) equivalenceList << otherAllowedValue; } equivalenceList.sort(); if (!m_equivalences.contains(equivalenceList)) m_equivalences << equivalenceList; } result << mergedAllowedValues; } } else {
static int xErrorHandler(Display *dpy, XErrorEvent *err) { if (getppid() == 1) kFatal() << "Got X error after loss of parent process. Terminating."; return oldXErrorHandler(dpy, err); }