Пример #1
0
PreviewCursor::PreviewCursor (const XCursorThemeData &theme, const QString &name) {
  // Create the preview pixmap
  QImage image = theme.loadImage(name, previewSize);
  if (image.isNull()) return;
  int maxSize = previewSize*2;
  if (image.height() > maxSize || image.width() > maxSize)
    image = image.scaled(maxSize, maxSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
  mPixmap = QPixmap::fromImage(image);
  // load the cursor
  mCursor = theme.loadCursor(name, previewSize);
}
Пример #2
0
bool applyTheme (const XCursorThemeData &theme) {
  // Require the Xcursor version that shipped with X11R6.9 or greater, since
  // in previous versions the Xfixes code wasn't enabled due to a bug in the
  // build system (freedesktop bug #975).
  if (!haveXfixes()) return false;

  QByteArray themeName = QFile::encodeName(theme.name());

  // Set up the proper launch environment for newly started apps
  //k8:!!!:KToolInvocation::klauncher()->setLaunchEnv("XCURSOR_THEME", themeName);

  // Update the Xcursor X resources
  //k8:!!!:runRdb(0);

  // Reload the standard cursors
  QStringList names;
  // Qt cursors
  names << "left_ptr"       << "up_arrow"      << "cross"      << "wait"
        << "left_ptr_watch" << "ibeam"         << "size_ver"   << "size_hor"
        << "size_bdiag"     << "size_fdiag"    << "size_all"   << "split_v"
        << "split_h"        << "pointing_hand" << "openhand"
        << "closedhand"     << "forbidden"     << "whats_this";
  // X core cursors
  names << "X_cursor"            << "right_ptr"           << "hand1"
        << "hand2"               << "watch"               << "xterm"
        << "crosshair"           << "left_ptr_watch"      << "center_ptr"
        << "sb_h_double_arrow"   << "sb_v_double_arrow"   << "fleur"
        << "top_left_corner"     << "top_side"            << "top_right_corner"
        << "right_side"          << "bottom_right_corner" << "bottom_side"
        << "bottom_left_corner"  << "left_side"           << "question_arrow"
        << "pirate";

  //QX11Info x11Info;
  foreach (const QString &name, names) {
    QCursor cursor = theme.loadCursor(name);
    XFixesChangeCursorByName(QX11Info::display(), cursor.handle(), QFile::encodeName(name));
  }