<commit_before>///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2015, STEREOLABS.
//
// All rights reserved.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////

/****************************************************************************************************
 ** This sample is a wrapper for the ZED library in order to use the ZED Camera with ROS.          **
 ** You can publish Left+Depth or Left+Right images and camera info on the topics of your choice.  **
 **                                                                                **
 ** A set of parameters can be specified in the launch file.                                       **
 ****************************************************************************************************/

//standard includes
#include <csignal>
#include <cstdio>
#include <math.h>
#include <limits>
#include <thread>
#include <chrono>

//ROS includes
#include <ros/ros.h>
#include <sensor_msgs/Image.h>
#include <sensor_msgs/CameraInfo.h>
#include <sensor_msgs/distortion_models.h>
#include <cv_bridge/cv_bridge.h>
#include <sensor_msgs/image_encodings.h>
#include <image_transport/image_transport.h>
#include <dynamic_reconfigure/server.h>
#include <zed_wrapper/ZedConfig.h>

//opencv includes
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/calib3d/calib3d.hpp>

//PCL includes
#include <sensor_msgs/PointCloud2.h>
#include <pcl_conversions/pcl_conversions.h>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>

//ZED Includes
#include <zed/Camera.hpp>

using namespace sl::zed;
using namespace std;

int confidence;
bool computeDepth;
bool pointCloudThreadRunning;

/* \brief Publish a cv::Mat image with a ros Publisher
 * \param img : the image to publish
 * \param pub_img : the publisher object to use
 * \param img_frame_id : the id of the reference frame of the image
 * \param t : the ros::Time to stamp the image
 */
void publishImage(cv::Mat img, image_transport::Publisher &pub_img, string img_frame_id, ros::Time t) {
    cv_bridge::CvImage img_im;
    img_im.image = img;
    img_im.encoding = sensor_msgs::image_encodings::BGR8;
    img_im.header.frame_id = img_frame_id;
    img_im.header.stamp = t;
    pub_img.publish(img_im.toImageMsg());
}

/* \brief Publish a cv::Mat depth image with a ros Publisher
 * \param depth : the depth image to publish
 * \param pub_depth : the publisher object to use
 * \param depth_frame_id : the id of the reference frame of the depth image
 * \param t : the ros::Time to stamp the depth image
 */
void publishDepth(cv::Mat depth, image_transport::Publisher &pub_depth, string depth_frame_id, ros::Time t) {
    cv_bridge::CvImage depth_im;
    depth_im.image = depth;
    depth_im.encoding = sensor_msgs::image_encodings::TYPE_16UC1;
    depth_im.header.frame_id = depth_frame_id;
    depth_im.header.stamp = t;
    pub_depth.publish(depth_im.toImageMsg());
}

/* \brief Publish a pointCloud with a ros Publisher
 * \param p_could : the float pointer to point cloud datas
 * \param width : the width of the point cloud
 * \param height : the height of the point cloud
 * \param pub_cloud : the publisher object to use
 * \param cloud_frame_id : the id of the reference frame of the point cloud
 * \param t : the ros::Time to stamp the point cloud
 */
void publishPointCloud(float* p_cloud, int width, int height, ros::Publisher &pub_cloud, string cloud_frame_id, ros::Time t) {
    pcl::PointCloud<pcl::PointXYZRGB> point_cloud;
    point_cloud.width = width;
    point_cloud.height = height;
    int size = width*height;
    point_cloud.points.resize(size);
    int index4 = 0;
    float color;
    for (int i = 0; i < size; i++) {
        if(p_cloud[index4+2] < 0) { // Check if it's an unvalid point, the depth is lower than 0
            index4 += 4;
            continue;
        }
        pcl::PointXYZRGB point;
        point.y = -p_cloud[index4++];
        point.z = -p_cloud[index4++];
        point.x = p_cloud[index4++];
        color = p_cloud[index4++];
        uint32_t color_uint = *(uint32_t*) & color; // Convert the color
        unsigned char* color_uchar = (unsigned char*) &color_uint;
        color_uint = ((uint32_t) color_uchar[0] << 16 | (uint32_t) color_uchar[1] << 8 | (uint32_t) color_uchar[2]);
        point.rgb = *reinterpret_cast<float*> (&color_uint);
        point_cloud.points[i] = point;
    }
    sensor_msgs::PointCloud2 output;
    pcl::toROSMsg(point_cloud, output); // Convert the point cloud to a ROS message
    output.header.frame_id = cloud_frame_id;// Set the header values of the ROS message
    output.header.stamp = t;
    pub_cloud.publish(output);
    pointCloudThreadRunning = false;
}

/* \brief Publish the informations of a camera with a ros Publisher
 * \param cam_info_msg : the information message to publish
 * \param pub_cam_info : the publisher object to use
 * \param t : the ros::Time to stamp the message
 */
void publishCamInfo(sensor_msgs::CameraInfoPtr cam_info_msg, ros::Publisher pub_cam_info, ros::Time t) {
    static int seq = 0;
    cam_info_msg->header.stamp = t;
    cam_info_msg->header.seq = seq;
    pub_cam_info.publish(cam_info_msg);
    seq++;
}

/* \brief Get the information of the ZED cameras and store them in an information message
 * \param zed : the sl::zed::Camera* pointer to an instance
 * \param left_cam_info_msg : the information message to fill with the left camera informations
 * \param right_cam_info_msg : the information message to fill with the right camera informations
 * \param left_frame_id : the id of the reference frame of the left camera
 * \param right_frame_id : the id of the reference frame of the right camera
 */
void fillCamInfo(Camera* zed, sensor_msgs::CameraInfoPtr left_cam_info_msg, sensor_msgs::CameraInfoPtr right_cam_info_msg,
        string left_frame_id, string right_frame_id) {

    int width = zed->getImageSize().width;
    int height = zed->getImageSize().height;

    sl::zed::StereoParameters* zedParam = zed->getParameters();

    float baseline = zedParam->baseline;

    float fx = zedParam->LeftCam.fx;
    float fy = zedParam->LeftCam.fy;
    float cx = zedParam->LeftCam.cx;
    float cy = zedParam->LeftCam.cy;

    // There is no distorsions since the images are rectified
    double k1 = 0;
    double k2 = 0;
    double k3 = 0;
    double p1 = 0;
    double p2 = 0;

    left_cam_info_msg->distortion_model = sensor_msgs::distortion_models::PLUMB_BOB;
    right_cam_info_msg->distortion_model = sensor_msgs::distortion_models::PLUMB_BOB;

    left_cam_info_msg->D.resize(5);
    right_cam_info_msg->D.resize(5);
    left_cam_info_msg->D[0] = right_cam_info_msg->D[0] = k1;
    left_cam_info_msg->D[1] = right_cam_info_msg->D[1] = k2;
    left_cam_info_msg->D[2] = right_cam_info_msg->D[2] = k3;
    left_cam_info_msg->D[3] = right_cam_info_msg->D[3] = p1;
    left_cam_info_msg->D[4] = right_cam_info_msg->D[4] = p2;

    left_cam_info_msg->K.fill(0.0);
    right_cam_info_msg->K.fill(0.0);
    left_cam_info_msg->K[0] = right_cam_info_msg->K[0] = fx;
    left_cam_info_msg->K[2] = right_cam_info_msg->K[2] = cx;
    left_cam_info_msg->K[4] = right_cam_info_msg->K[4] = fy;
    left_cam_info_msg->K[5] = right_cam_info_msg->K[5] = cy;
    left_cam_info_msg->K[8] = right_cam_info_msg->K[8] = 1.0;

    left_cam_info_msg->R.fill(0.0);
    right_cam_info_msg->R.fill(0.0);

    left_cam_info_msg->P.fill(0.0);
    right_cam_info_msg->P.fill(0.0);
    left_cam_info_msg->P[0] = right_cam_info_msg->P[0] = fx;
    left_cam_info_msg->P[2] = right_cam_info_msg->P[2] = cx;
    left_cam_info_msg->P[5] = right_cam_info_msg->P[5] = fy;
    left_cam_info_msg->P[6] = right_cam_info_msg->P[6] = cy;
    left_cam_info_msg->P[10] = right_cam_info_msg->P[10] = 1.0;
    right_cam_info_msg->P[3] = (-1 * fx * (baseline / 1000));

    left_cam_info_msg->width = right_cam_info_msg->width = width;
    left_cam_info_msg->height = right_cam_info_msg->height = height;

    left_cam_info_msg->header.frame_id = left_frame_id;
    right_cam_info_msg->header.frame_id = right_frame_id;
}

void callback(zed_ros_wrapper::ZedConfig &config, uint32_t level) {
  ROS_INFO("Reconfigure confidence : %d",
            config.confidence);
  confidence = config.confidence;
}

int main(int argc, char **argv) {
    // Launch file parameters
    int resolution = sl::zed::VGA;
    int quality = sl::zed::MODE::PERFORMANCE;
    int sensing_mode = sl::zed::SENSING_MODE::RAW;
    int rate = 30;

    std::string img_topic = "image_rect";
#if 0
    // Used in some package
    img_topic = "image_raw";
#endif

    // Set the default topic names
    string rgb_topic = "rgb/" + img_topic ;
    string rgb_cam_info_topic =  "rgb/camera_info";
    string rgb_frame_id = "/zed_rgb_optical_frame";

    string left_topic = "left/" + img_topic;
    string left_cam_info_topic = "left/camera_info";
    string left_frame_id = "/zed_left_optical_frame";

    string right_topic = "right/" + img_topic;
    string right_cam_info_topic = "right/camera_info";
    string right_frame_id = "/zed_right_optical_frame";

    string depth_topic = "depth/" + img_topic;
    string depth_cam_info_topic = "depth/camera_info";
    string depth_frame_id = "/zed_depth_optical_frame";

    string point_cloud_topic = "point_cloud/" + img_topic;
    string cloud_frame_id = "/zed_point_cloud";

    ros::init(argc, argv, "zed_depth_stereo_wrapper_node");
    ROS_INFO("ZED_WRAPPER Node initialized");

    ros::NodeHandle nh;
    ros::NodeHandle nh_ns("~");

    // Get parameters from launch file
    nh_ns.getParam("resolution", resolution);
    nh_ns.getParam("quality", quality);
    nh_ns.getParam("sensing_mode", sensing_mode);
    nh_ns.getParam("frame_rate", rate);

    nh_ns.getParam("rgb_topic", rgb_topic);
    nh_ns.getParam("rgb_cam_info_topic", rgb_cam_info_topic);
    nh_ns.getParam("rgb_frame_id", rgb_frame_id);

    nh_ns.getParam("left_topic", left_topic);
    nh_ns.getParam("left_cam_info_topic", left_cam_info_topic);
    nh_ns.getParam("left_frame_id", left_frame_id);

    nh_ns.getParam("right_topic", right_topic);
    nh_ns.getParam("right_cam_info_topic", right_cam_info_topic);
    nh_ns.getParam("right_frame_id", right_frame_id);

    nh_ns.getParam("depth_topic", depth_topic);
    nh_ns.getParam("depth_cam_info_topic", depth_cam_info_topic);
    nh_ns.getParam("depth_frame_id", depth_frame_id);

    nh_ns.getParam("point_cloud_topic", point_cloud_topic);
    nh_ns.getParam("cloud_frame_id", cloud_frame_id);

    // Create the ZED object
    sl::zed::Camera *zed;
    if (argc == 2) {
        zed = new sl::zed::Camera(argv[1]); // Argument "svo_file" in launch file
        ROS_INFO_STREAM("Reading SVO file : " << argv[1]);
    } else {
        zed = new sl::zed::Camera(static_cast<sl::zed::ZEDResolution_mode> (resolution), rate);
        ROS_INFO_STREAM("Using ZED Camera");
    }

    // Try to initialize the ZED
    ERRCODE err = ERRCODE::ZED_NOT_AVAILABLE;
    while(err != SUCCESS){
        err = zed->init(static_cast<sl::zed::MODE> (quality), -1, true);
        ROS_INFO_STREAM(errcode2str(err));
        std::this_thread::sleep_for(std::chrono::milliseconds(2000));
    }
    zed->setBaselineRatio(0.001); // convert the ZED values in meters

    //ERRCODE display
    dynamic_reconfigure::Server<zed_ros_wrapper::ZedConfig> server;
    dynamic_reconfigure::Server<zed_ros_wrapper::ZedConfig>::CallbackType f;

    f = boost::bind(&callback, _1, _2);
    server.setCallback(f);
    confidence = 80;

    // Get the parameters of the ZED images
    int width = zed->getImageSize().width;
    int height = zed->getImageSize().height;
    ROS_DEBUG_STREAM("Image size : " << width << "x" << height);

    cv::Size cvSize(width, height);
    cv::Mat leftImRGBA(cvSize, CV_8UC4);
    cv::Mat leftImRGB(cvSize, CV_8UC3);
    cv::Mat rightImRGBA(cvSize, CV_8UC4);
    cv::Mat rightImRGB(cvSize, CV_8UC3);
    cv::Mat rightIm;
    cv::Mat depthIm;

    // Create the array to store the pointCloud
    float* p_cloud = new float[height * width * 4];

    // Create all the publishers
    // Image publishers
    image_transport::ImageTransport it_zed(nh);
    image_transport::Publisher pub_rgb = it_zed.advertise(rgb_topic, 1); //rgb
    ROS_INFO_STREAM("Advertized on topic " << rgb_topic);
    image_transport::Publisher pub_left = it_zed.advertise(left_topic, 1); //left
    ROS_INFO_STREAM("Advertized on topic " << left_topic);
    image_transport::Publisher pub_right = it_zed.advertise(right_topic, 1); //right
    ROS_INFO_STREAM("Advertized on topic " << right_topic);
    image_transport::Publisher pub_depth = it_zed.advertise(depth_topic, 1); //depth
    ROS_INFO_STREAM("Advertized on topic " << depth_topic);

    //PointCloud publisher
    ros::Publisher pub_cloud = nh.advertise<sensor_msgs::PointCloud2> (point_cloud_topic, 1);
    ROS_INFO_STREAM("Advertized on topic " << point_cloud_topic);

    // Camera info publishers
    ros::Publisher pub_rgb_cam_info = nh.advertise<sensor_msgs::CameraInfo>(rgb_cam_info_topic, 1); //rgb
    ROS_INFO_STREAM("Advertized on topic " << rgb_cam_info_topic);
    ros::Publisher pub_left_cam_info = nh.advertise<sensor_msgs::CameraInfo>(left_cam_info_topic, 1); //left
    ROS_INFO_STREAM("Advertized on topic " << left_cam_info_topic);
    ros::Publisher pub_right_cam_info = nh.advertise<sensor_msgs::CameraInfo>(right_cam_info_topic, 1); //right
    ROS_INFO_STREAM("Advertized on topic " << right_cam_info_topic);
    ros::Publisher pub_depth_cam_info = nh.advertise<sensor_msgs::CameraInfo>(depth_cam_info_topic, 1); //depth
    ROS_INFO_STREAM("Advertized on topic " << depth_cam_info_topic);

    // Create and fill the camera information messages
    sensor_msgs::CameraInfoPtr rgb_cam_info_msg(new sensor_msgs::CameraInfo());
    sensor_msgs::CameraInfoPtr left_cam_info_msg(new sensor_msgs::CameraInfo());
    sensor_msgs::CameraInfoPtr right_cam_info_msg(new sensor_msgs::CameraInfo());
    sensor_msgs::CameraInfoPtr depth_cam_info_msg(new sensor_msgs::CameraInfo());
    fillCamInfo(zed, left_cam_info_msg, right_cam_info_msg, left_frame_id, right_frame_id);
    rgb_cam_info_msg = depth_cam_info_msg = left_cam_info_msg; // the reference camera is the Left one (next to the ZED logo)

    ros::Rate loop_rate(rate);
    ros::Time old_t = ros::Time::now();
    bool old_image = false;
    pointCloudThreadRunning = false;
    std::thread* pointCloudThread = NULL;

    try {
        // Main loop
        while (ros::ok()) {
            // Check for subscribers
            int rgb_SubNumber = pub_rgb.getNumSubscribers();
            int left_SubNumber = pub_left.getNumSubscribers();
            int right_SubNumber = pub_right.getNumSubscribers();
            int depth_SubNumber = pub_depth.getNumSubscribers();
            int cloud_SubNumber = pub_cloud.getNumSubscribers();
            bool runLoop = (rgb_SubNumber + left_SubNumber + right_SubNumber + depth_SubNumber + cloud_SubNumber) > 0;
            // Run the loop only if there is some subscribers
            if (runLoop) {
                computeDepth = (depth_SubNumber + cloud_SubNumber) > 0; // Detect if one of the subscriber need to have the depth information
                ros::Time t = ros::Time::now(); // Get current time

                if (computeDepth) {
                    int actual_confidence = zed->getConfidenceThreshold();
                    if(actual_confidence != confidence)
                        zed->setConfidenceThreshold(confidence);
                    old_image = zed->grab(static_cast<sl::zed::SENSING_MODE> (sensing_mode), true, true); // Ask to compute the depth
                }
                else
                    old_image = zed->grab(static_cast<sl::zed::SENSING_MODE> (sensing_mode), false, false); // Ask to not compute the depth

                if (old_image) { // Detect if a error occuried (for exemple: the zed have been disconnected) and re-initialize the ZED
                    ROS_WARN("Wait for a new image to proceed");
                    std::this_thread::sleep_for(std::chrono::milliseconds(2));
                    if ((t - old_t).toSec() > 5) {
                        sl::zed::Camera* corruptedObject = zed;
                        delete corruptedObject;
                        if (argc == 2) {
                            zed = new sl::zed::Camera(argv[1]); // Argument "svo_file" in launch file
                            ROS_INFO_STREAM("Reading SVO file : " << argv[1]);
                        } else {
                            zed = new sl::zed::Camera(static_cast<sl::zed::ZEDResolution_mode> (resolution), rate);
                            ROS_INFO_STREAM("Using ZED Camera");
                        }
                        ROS_INFO("Reinit camera");
                        ERRCODE err = ERRCODE::ZED_NOT_AVAILABLE;
                        while(err != SUCCESS) {
                            err = zed->init(static_cast<sl::zed::MODE> (quality), -1, true); // Try to initialize the ZED
                            ROS_INFO_STREAM(errcode2str(err));
                            std::this_thread::sleep_for(std::chrono::milliseconds(2000));
                        }
                        zed->setBaselineRatio(0.001); // convert the ZED values in meters
                    }
                    continue;
                }

                old_t = ros::Time::now();

                // Publish the left == rgb image if someone has subscribed to
                if(left_SubNumber>0 || rgb_SubNumber>0) {
                    slMat2cvMat(zed->retrieveImage(sl::zed::SIDE::LEFT)).copyTo(leftImRGBA);// Retrieve RGBA Left image
                    cv::cvtColor(leftImRGBA, leftImRGB, CV_RGBA2RGB); // Convert to RGB
                    if(left_SubNumber>0) {
                        publishCamInfo(left_cam_info_msg, pub_left_cam_info, t);
                        publishImage(leftImRGB, pub_left, left_frame_id, t);
                    }
                    if(rgb_SubNumber>0) {
                        publishCamInfo(rgb_cam_info_msg, pub_rgb_cam_info, t);
                        publishImage(leftImRGB, pub_rgb, rgb_frame_id, t); // rgb is the left image
                    }
                }

                // Publish the right image if someone has subscribed to
                if(right_SubNumber>0) {
                    slMat2cvMat(zed->retrieveImage(sl::zed::SIDE::RIGHT)).copyTo(rightImRGBA);// Retrieve RGBA Right image
                    cv::cvtColor(rightImRGBA, rightImRGB, CV_RGBA2RGB); // Convert to RGB
                    publishCamInfo(right_cam_info_msg, pub_right_cam_info, t);
                    publishImage(rightImRGB, pub_right, right_frame_id, t);
                }

                // Publish the depth image if someone has subscribed to
                if (depth_SubNumber>0) {
                    // Retrieve raw depth data and convert it to 16_bit data
                    slMat2cvMat(zed->retrieveMeasure(sl::zed::MEASURE::DEPTH)).convertTo(depthIm, CV_16UC1);
                    publishDepth(depthIm, pub_depth, depth_frame_id, t);
                }

                // Publish the point cloud if someone has subscribed to
                if (cloud_SubNumber>0 && pointCloudThreadRunning == false) {
                    // Retrieve raw pointCloud data
                    float* cloud = (float*) zed->retrieveMeasure(sl::zed::MEASURE::XYZRGBA).data;
                    // Run the point cloud convertion asynchronously to avoid slowing down all the program
                    pointCloudThreadRunning = true;
                    if(pointCloudThread)
                        pointCloudThread->join();
                    pointCloudThread = new std::thread(&publishPointCloud, cloud, width, height, std::ref(pub_cloud), cloud_frame_id, t);

                }

                ros::spinOnce();
                loop_rate.sleep();
            } else std::this_thread::sleep_for(std::chrono::milliseconds(10)); // No subscribers, we just wait
        }
    } catch (...) {
        ROS_ERROR("Unknown error.");
        return 1;
    }
    ROS_INFO("Quitting zed_depth_stereo_wrapper_node ...\n");

    delete zed;

    return 0;
}
<commit_msg>Delete zed_wrapper_node.cpp<commit_after><|endoftext|>


<commit_before>//===---------- llvm/unittest/Support/Casting.cpp - Casting tests ---------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"

#include "gtest/gtest.h"
#include <cstdlib>

namespace llvm {

// set up two example classes
// with conversion facility
//
struct bar {
  bar() {}
  struct foo *baz();
  struct foo *caz();
  struct foo *daz();
  struct foo *naz();
private:
  bar(const bar &);
};
struct foo {
  void ext() const;
  /*  static bool classof(const bar *X) {
    cerr << "Classof: " << X << "\n";
    return true;
    }*/
};

template <> struct isa_impl<foo, bar> {
  static inline bool doit(const bar &Val) {
    dbgs() << "Classof: " << &Val << "\n";
    return true;
  }
};

foo *bar::baz() {
    return cast<foo>(this);
}

foo *bar::caz() {
    return cast_or_null<foo>(this);
}

foo *bar::daz() {
    return dyn_cast<foo>(this);
}

foo *bar::naz() {
    return dyn_cast_or_null<foo>(this);
}

bar *fub();
} // End llvm namespace

using namespace llvm;

namespace {

const foo *null_foo = NULL;

bar B;
extern bar &B1;
bar &B1 = B;
extern const bar *B2;
// test various configurations of const
const bar &B3 = B1;
const bar *const B4 = B2;

TEST(CastingTest, isa) {
  EXPECT_TRUE(isa<foo>(B1));
  EXPECT_TRUE(isa<foo>(B2));
  EXPECT_TRUE(isa<foo>(B3));
  EXPECT_TRUE(isa<foo>(B4));
}

TEST(CastingTest, cast) {
  foo &F1 = cast<foo>(B1);
  EXPECT_NE(&F1, null_foo);
  const foo *F3 = cast<foo>(B2);
  EXPECT_NE(F3, null_foo);
  const foo *F4 = cast<foo>(B2);
  EXPECT_NE(F4, null_foo);
  const foo &F5 = cast<foo>(B3);
  EXPECT_NE(&F5, null_foo);
  const foo *F6 = cast<foo>(B4);
  EXPECT_NE(F6, null_foo);
  foo *F7 = cast<foo>(fub());
  EXPECT_EQ(F7, null_foo);
  foo *F8 = B1.baz();
  EXPECT_NE(F8, null_foo);
}

TEST(CastingTest, cast_or_null) {
  const foo *F11 = cast_or_null<foo>(B2);
  EXPECT_NE(F11, null_foo);
  const foo *F12 = cast_or_null<foo>(B2);
  EXPECT_NE(F12, null_foo);
  const foo *F13 = cast_or_null<foo>(B4);
  EXPECT_NE(F13, null_foo);
  const foo *F14 = cast_or_null<foo>(fub());  // Shouldn't print.
  EXPECT_EQ(F14, null_foo);
  foo *F15 = B1.caz();
  EXPECT_NE(F15, null_foo);
}

TEST(CastingTest, dyn_cast) {
  const foo *F1 = dyn_cast<foo>(B2);
  EXPECT_NE(F1, null_foo);
  const foo *F2 = dyn_cast<foo>(B2);
  EXPECT_NE(F2, null_foo);
  const foo *F3 = dyn_cast<foo>(B4);
  EXPECT_NE(F3, null_foo);
  // foo *F4 = dyn_cast<foo>(fub()); // not permittible
  // EXPECT_EQ(F4, null_foo);
  foo *F5 = B1.daz();
  EXPECT_NE(F5, null_foo);
}

TEST(CastingTest, dyn_cast_or_null) {
  const foo *F1 = dyn_cast_or_null<foo>(B2);
  EXPECT_NE(F1, null_foo);
  const foo *F2 = dyn_cast_or_null<foo>(B2);
  EXPECT_NE(F2, null_foo);
  const foo *F3 = dyn_cast_or_null<foo>(B4);
  EXPECT_NE(F3, null_foo);
  foo *F4 = dyn_cast_or_null<foo>(fub());
  EXPECT_EQ(F4, null_foo);
  foo *F5 = B1.naz();
  EXPECT_NE(F5, null_foo);
}

// These lines are errors...
//foo *F20 = cast<foo>(B2);  // Yields const foo*
//foo &F21 = cast<foo>(B3);  // Yields const foo&
//foo *F22 = cast<foo>(B4);  // Yields const foo*
//foo &F23 = cast_or_null<foo>(B1);
//const foo &F24 = cast_or_null<foo>(B3);

const bar *B2 = &B;
}  // anonymous namespace

bar *llvm::fub() { return 0; }
<commit_msg>Don't pass a null pointer to cast<> in its unit tests.<commit_after>//===---------- llvm/unittest/Support/Casting.cpp - Casting tests ---------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"

#include "gtest/gtest.h"
#include <cstdlib>

namespace llvm {

// set up two example classes
// with conversion facility
//
struct bar {
  bar() {}
  struct foo *baz();
  struct foo *caz();
  struct foo *daz();
  struct foo *naz();
private:
  bar(const bar &);
};
struct foo {
  void ext() const;
  /*  static bool classof(const bar *X) {
    cerr << "Classof: " << X << "\n";
    return true;
    }*/
};

template <> struct isa_impl<foo, bar> {
  static inline bool doit(const bar &Val) {
    dbgs() << "Classof: " << &Val << "\n";
    return true;
  }
};

foo *bar::baz() {
    return cast<foo>(this);
}

foo *bar::caz() {
    return cast_or_null<foo>(this);
}

foo *bar::daz() {
    return dyn_cast<foo>(this);
}

foo *bar::naz() {
    return dyn_cast_or_null<foo>(this);
}

bar *fub();
} // End llvm namespace

using namespace llvm;

namespace {

const foo *null_foo = NULL;

bar B;
extern bar &B1;
bar &B1 = B;
extern const bar *B2;
// test various configurations of const
const bar &B3 = B1;
const bar *const B4 = B2;

TEST(CastingTest, isa) {
  EXPECT_TRUE(isa<foo>(B1));
  EXPECT_TRUE(isa<foo>(B2));
  EXPECT_TRUE(isa<foo>(B3));
  EXPECT_TRUE(isa<foo>(B4));
}

TEST(CastingTest, cast) {
  foo &F1 = cast<foo>(B1);
  EXPECT_NE(&F1, null_foo);
  const foo *F3 = cast<foo>(B2);
  EXPECT_NE(F3, null_foo);
  const foo *F4 = cast<foo>(B2);
  EXPECT_NE(F4, null_foo);
  const foo &F5 = cast<foo>(B3);
  EXPECT_NE(&F5, null_foo);
  const foo *F6 = cast<foo>(B4);
  EXPECT_NE(F6, null_foo);
  // Can't pass null pointer to cast<>.
  // foo *F7 = cast<foo>(fub());
  // EXPECT_EQ(F7, null_foo);
  foo *F8 = B1.baz();
  EXPECT_NE(F8, null_foo);
}

TEST(CastingTest, cast_or_null) {
  const foo *F11 = cast_or_null<foo>(B2);
  EXPECT_NE(F11, null_foo);
  const foo *F12 = cast_or_null<foo>(B2);
  EXPECT_NE(F12, null_foo);
  const foo *F13 = cast_or_null<foo>(B4);
  EXPECT_NE(F13, null_foo);
  const foo *F14 = cast_or_null<foo>(fub());  // Shouldn't print.
  EXPECT_EQ(F14, null_foo);
  foo *F15 = B1.caz();
  EXPECT_NE(F15, null_foo);
}

TEST(CastingTest, dyn_cast) {
  const foo *F1 = dyn_cast<foo>(B2);
  EXPECT_NE(F1, null_foo);
  const foo *F2 = dyn_cast<foo>(B2);
  EXPECT_NE(F2, null_foo);
  const foo *F3 = dyn_cast<foo>(B4);
  EXPECT_NE(F3, null_foo);
  // Can't pass null pointer to dyn_cast<>.
  // foo *F4 = dyn_cast<foo>(fub());
  // EXPECT_EQ(F4, null_foo);
  foo *F5 = B1.daz();
  EXPECT_NE(F5, null_foo);
}

TEST(CastingTest, dyn_cast_or_null) {
  const foo *F1 = dyn_cast_or_null<foo>(B2);
  EXPECT_NE(F1, null_foo);
  const foo *F2 = dyn_cast_or_null<foo>(B2);
  EXPECT_NE(F2, null_foo);
  const foo *F3 = dyn_cast_or_null<foo>(B4);
  EXPECT_NE(F3, null_foo);
  foo *F4 = dyn_cast_or_null<foo>(fub());
  EXPECT_EQ(F4, null_foo);
  foo *F5 = B1.naz();
  EXPECT_NE(F5, null_foo);
}

// These lines are errors...
//foo *F20 = cast<foo>(B2);  // Yields const foo*
//foo &F21 = cast<foo>(B3);  // Yields const foo&
//foo *F22 = cast<foo>(B4);  // Yields const foo*
//foo &F23 = cast_or_null<foo>(B1);
//const foo &F24 = cast_or_null<foo>(B3);

const bar *B2 = &B;
}  // anonymous namespace

bar *llvm::fub() { return 0; }
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: templdlg.hxx,v $
 *
 *  $Revision: 1.5 $
 *
 *  last change: $Author: pb $ $Date: 2001-06-19 06:25:14 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/
#ifndef _SVTOOLS_TEMPLDLG_HXX
#define _SVTOOLS_TEMPLDLG_HXX

#include <vcl/button.hxx>
#include <vcl/dialog.hxx>
#include <vcl/fixed.hxx>

struct SvtTmplDlg_Impl;

// class SvtDocumentTemplateDialog ---------------------------------------
class SvtTemplateWindow;
class SvtDocumentTemplateDialog : public ModalDialog
{
private:
    FixedLine           aLine;
    PushButton          aManageBtn;
    PushButton          aEditBtn;
    OKButton            aOKBtn;
    CancelButton        aCancelBtn;
    HelpButton          aHelpBtn;

    SvtTmplDlg_Impl*    pImpl;

    DECL_LINK(          SelectHdl_Impl, SvtTemplateWindow* );
    DECL_LINK(          DoubleClickHdl_Impl, SvtTemplateWindow* );
    DECL_LINK(          NewFolderHdl_Impl, SvtTemplateWindow* );
    DECL_LINK(          OKHdl_Impl, PushButton* );
    DECL_LINK(          UpdateHdl_Impl, Timer* );

    void                UpdateDocumentTemplates_Impl();

public:
    SvtDocumentTemplateDialog( Window* pParent );
    ~SvtDocumentTemplateDialog();
};

#endif // _SVTOOLS_TEMPLDLG_HXX

<commit_msg>fix: #88769# methods for keyinput handling added<commit_after>/*************************************************************************
 *
 *  $RCSfile: templdlg.hxx,v $
 *
 *  $Revision: 1.6 $
 *
 *  last change: $Author: pb $ $Date: 2001-07-05 12:47:57 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/
#ifndef _SVTOOLS_TEMPLDLG_HXX
#define _SVTOOLS_TEMPLDLG_HXX

#include <vcl/button.hxx>
#include <vcl/dialog.hxx>
#include <vcl/fixed.hxx>

struct SvtTmplDlg_Impl;

// class SvtDocumentTemplateDialog ---------------------------------------

class SvtTemplateWindow;

class SvtDocumentTemplateDialog : public ModalDialog
{
private:
    FixedLine           aLine;
    PushButton          aManageBtn;
    PushButton          aEditBtn;
    OKButton            aOKBtn;
    CancelButton        aCancelBtn;
    HelpButton          aHelpBtn;

    SvtTmplDlg_Impl*    pImpl;

    DECL_LINK(          SelectHdl_Impl, SvtTemplateWindow* );
    DECL_LINK(          DoubleClickHdl_Impl, SvtTemplateWindow* );
    DECL_LINK(          NewFolderHdl_Impl, SvtTemplateWindow* );
    DECL_LINK(          SendFocusHdl_Impl, SvtTemplateWindow* );
    DECL_LINK(          OKHdl_Impl, PushButton* );
    DECL_LINK(          UpdateHdl_Impl, Timer* );

    void                UpdateDocumentTemplates_Impl();

protected:
    virtual long        PreNotify( NotifyEvent& rNEvt );

public:
    SvtDocumentTemplateDialog( Window* pParent );
    ~SvtDocumentTemplateDialog();
};

#endif // _SVTOOLS_TEMPLDLG_HXX

<|endoftext|>


<commit_before>/*
    knode.cpp

    KNode, the KDE newsreader
    Copyright (c) 1999-2000 the KNode authors.
    See file AUTHORS for details

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software Foundation,
    Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, US
*/

#include <qpixmap.h>

#include <kconfig.h>
#include <kglobal.h>
#include <kmessagebox.h>
#include <kkeydialog.h>
#include <kedittoolbar.h>
#include <kstdaction.h>
#include <kaccel.h>
#include <kurl.h>
#include <klocale.h>
#include <kwin.h>
#include <kdebug.h>
#include <kmenubar.h>

#include "knode.h"
#include "knfiltermanager.h"
#include "knodeview.h"
#include "knlistview.h"
#include "utilities.h"
#include "knglobals.h"
#include "knconfigmanager.h"
#include "knaccountmanager.h"
#include "knserverinfo.h"
#include "knarticlewidget.h"
#include "knnetaccess.h"

KNGlobals knGlobals;

//======================================================================================================

KNProgress::KNProgress (int desiredHeight, int minValue, int maxValue, int value, KProgress::Orientation orient, QWidget *parent, const char *name)
 : KProgress(minValue, maxValue, value, orient, parent, name), desHeight(desiredHeight)
{
  setFixedWidth(110);
  setFrameStyle(QFrame::Box | QFrame::Raised);
  setLineWidth(1);
  setBackgroundMode(QWidget::PaletteBackground);
  disableProgressBar();
}

KNProgress::~KNProgress()
{}

// 0% and no text
void KNProgress::disableProgressBar()
{
  setFormat(QString::null);
  setValue(0);
  repaint(false);
}

// manual operation
void KNProgress::setProgressBar(int value,const QString& text)
{
  setFormat(text);
  if (value>1000) {
    setValue(1000);
    update();       // circumvent the optimization of setValue
  } else
    setValue(value);
}

QSize KNProgress::sizeHint() const
{
  return QSize(KProgress::sizeHint().width(),desHeight);
}

//===============================================================================================

KNMainWindow::KNMainWindow() : KMainWindow(0,"mainWindow"), b_lockInput(false)
{
  knGlobals.top=this;
  knGlobals.topWidget=this;
  kapp->setMainWidget(this);  // this makes the external viewer windows close on shutdown...

  //statusbar
  KStatusBar *sb=statusBar();
  p_rogBar=new KNProgress(sb->sizeHint().height()-4,0,1000,0, KProgress::Horizontal,sb );
  knGlobals.progressBar=p_rogBar;
  sb->addWidget(p_rogBar);
  sb->insertItem(QString::null, SB_MAIN,2);
  sb->setItemAlignment (SB_MAIN,AlignLeft | AlignVCenter);
  sb->insertItem(QString::null, SB_FILTER,2);
  sb->setItemAlignment (SB_FILTER,AlignLeft | AlignVCenter);
  sb->insertItem(QString::null,SB_GROUP,3);
  sb->setItemAlignment (SB_GROUP,AlignLeft | AlignVCenter);

  //view
  setCaption(i18n("KDE News Reader"));
  v_iew=new KNodeView(this, "knodeView");
  setCentralWidget(v_iew);
  knGlobals.view=v_iew;

  //actions
  a_ccel=new KAccel(this);
  v_iew->a_ctNavReadThrough->plugAccel(a_ccel);
  v_iew->a_ctArtFilterKeyb->plugAccel(a_ccel);
  v_iew->a_ctArtSortHeadersKeyb->plugAccel(a_ccel);
  v_iew->articleView()->setCharsetKeyboardAction()->plugAccel(a_ccel);

  KStdAction::quit(kapp, SLOT(closeAllWindows()), actionCollection());
  KStdAction::keyBindings(this, SLOT(slotConfKeys()), actionCollection());
  KStdAction::configureToolbars(this, SLOT(slotConfToolbar()), actionCollection());
  KStdAction::preferences(this, SLOT(slotSettings()), actionCollection());

  a_ctWinToggleToolbar   = KStdAction::showToolbar(this, SLOT(slotWinToggleToolbar()), actionCollection());
  a_ctWinToggleStatusbar = KStdAction::showStatusbar(this, SLOT(slotWinToggleStatusbar()), actionCollection());

  createGUI("knodeui.rc");
  v_iew->initPopups(this);

  //apply settings
  KConfig *conf = KGlobal::config();
  conf->setGroup("mainWindow_options");
  resize(787,478);  // default optimized for 800x600
  applyMainWindowSettings(conf);
  a_ctWinToggleToolbar->setChecked(!toolBar()->isHidden());
  a_ctWinToggleStatusbar->setChecked(!statusBar()->isHidden());

  // set the keyboard focus indicator on the first item in the Collection View
  // we do this here because everything needs to be properly setup when we
  // call setActive()
  if(v_iew->collectionView()->firstChild()) {
    QListViewItem *i = v_iew->collectionView()->firstChild();
    bool open = i->isOpen();
    v_iew->collectionView()->setActive(i,true);
    i->setOpen(open);
  }
  v_iew->collectionView()->setFocus();

  setStatusMsg();

  if(firstStart()) {  // open the config dialog on the first start
    show();              // the settings dialog must appear in front of the main window!
    slotSettings();
  }
}

KNMainWindow::~KNMainWindow()
{
  delete a_ccel;
}

//================================== GUI =================================

void KNMainWindow::setStatusMsg(const QString& text, int id)
{
  statusBar()->clear();
  if (text.isEmpty() && (id==SB_MAIN))
    if (knGlobals.netAccess->currentMsg().isEmpty())
      statusBar()->changeItem(i18n(" Ready"),SB_MAIN);
    else
      statusBar()->changeItem(knGlobals.netAccess->currentMsg(), SB_MAIN);   // restore the original message
  else
    statusBar()->changeItem(text, id);
}

void KNMainWindow::setStatusHelpMsg(const QString& text)
{
   statusBar()->message(text, 2000);
}

void KNMainWindow::setCursorBusy(bool b)
{
  if(b) kapp->setOverrideCursor(waitCursor);
  else  kapp->restoreOverrideCursor();
}

void KNMainWindow::blockUI(bool b)
{
  b_lockInput = b;
  menuBar()->setEnabled(!b);
  a_ccel->setEnabled(!b);
  v_iew->blockUI(b);
  setCursorBusy(b);
}

// processEvents with some blocking
void KNMainWindow::secureProcessEvents()
{
  b_lockInput = true;
  menuBar()->setEnabled(false);
  a_ccel->setEnabled(false);
  v_iew->blockUI(true);

  kapp->processEvents();

  b_lockInput = false;
  v_iew->blockUI(false);
  menuBar()->setEnabled(true);
  a_ccel->setEnabled(true);
}

QSize KNMainWindow::sizeHint() const
{
  return QSize(759,478);    // default optimized for 800x600
}

void KNMainWindow::slotWinToggleToolbar()
{
  if(toolBar()->isVisible())
    toolBar()->hide();
  else
    toolBar()->show();
}

void KNMainWindow::slotWinToggleStatusbar()
{
  if (statusBar()->isVisible())
    statusBar()->hide();
  else
    statusBar()->show();
}

void KNMainWindow::slotConfKeys()
{
  KActionCollection coll(*actionCollection());

  coll.take(v_iew->a_ctArtSortHeaders);   // hack, remove actions which cant have a shortcut
  coll.take(v_iew->a_ctArtFilter);
  coll.take(v_iew->articleView()->setCharsetAction());

  KKeyDialog::configureKeys(&coll, xmlFile(), true, this);
}

void KNMainWindow::slotConfToolbar()
{
  KEditToolbar *dlg = new KEditToolbar(guiFactory(),this);

  if (dlg->exec()) {
    createGUI("knodeui.rc");
    v_iew->initPopups(this);
  }

  delete dlg;
}

void KNMainWindow::slotSettings()
{
  v_iew->c_fgManager->configure();
}

bool KNMainWindow::firstStart()
{
  KConfig *conf=KGlobal::config();
  conf->setGroup("GENERAL");
  QString ver = conf->readEntry("Version");
  if(!ver.isEmpty())
    return false;

  KConfig emailConf("emaildefaults");

  emailConf.setGroup("Defaults");
  QString group = emailConf.readEntry("Profile","Default");

  emailConf.setGroup(QString("PROFILE_%1").arg(group));
  KNConfig::Identity *id=knGlobals.cfgManager->identity();
  id->setName(emailConf.readEntry("FullName"));
  id->setEmail(emailConf.readEntry("EmailAddress").latin1());
  id->setOrga(emailConf.readEntry("Organization"));
  id->setReplyTo(emailConf.readEntry("ReplyAddr"));
  id->save();

  KNServerInfo *smtp=knGlobals.accManager->smtp();
  smtp->setServer(emailConf.readEntry("OutgoingServer").latin1());
  smtp->setPort(25);
  conf->setGroup("MAILSERVER");
  smtp->saveConf(conf);

  conf->setGroup("GENERAL");
  conf->writeEntry("Version", KNODE_VERSION);

  return true;
}

bool KNMainWindow::queryClose()
{
  if(b_lockInput)
    return false;
  if(!v_iew->requestShutdown())
    return false;

  KConfig *conf = KGlobal::config();
  conf->setGroup("mainWindow_options");
  saveMainWindowSettings(conf);
  v_iew->prepareShutdown();

  return true;
}

void KNMainWindow::fontChange( const QFont & )
{
  p_rogBar->setFont(font());    // should be called automatically?
}

void KNMainWindow::paletteChange( const QPalette & )
{
  p_rogBar->setPalette(palette());    // should be called automatically?
}

//--------------------------------

#include "knode.moc"
<commit_msg>don't unhide hidden toolbars after KEditToolbar is used<commit_after>/*
    knode.cpp

    KNode, the KDE newsreader
    Copyright (c) 1999-2000 the KNode authors.
    See file AUTHORS for details

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software Foundation,
    Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, US
*/

#include <qpixmap.h>

#include <kconfig.h>
#include <kglobal.h>
#include <kmessagebox.h>
#include <kkeydialog.h>
#include <kedittoolbar.h>
#include <kstdaction.h>
#include <kaccel.h>
#include <kurl.h>
#include <klocale.h>
#include <kwin.h>
#include <kdebug.h>
#include <kmenubar.h>

#include "knode.h"
#include "knfiltermanager.h"
#include "knodeview.h"
#include "knlistview.h"
#include "utilities.h"
#include "knglobals.h"
#include "knconfigmanager.h"
#include "knaccountmanager.h"
#include "knserverinfo.h"
#include "knarticlewidget.h"
#include "knnetaccess.h"

KNGlobals knGlobals;

//======================================================================================================

KNProgress::KNProgress (int desiredHeight, int minValue, int maxValue, int value, KProgress::Orientation orient, QWidget *parent, const char *name)
 : KProgress(minValue, maxValue, value, orient, parent, name), desHeight(desiredHeight)
{
  setFixedWidth(110);
  setFrameStyle(QFrame::Box | QFrame::Raised);
  setLineWidth(1);
  setBackgroundMode(QWidget::PaletteBackground);
  disableProgressBar();
}

KNProgress::~KNProgress()
{}

// 0% and no text
void KNProgress::disableProgressBar()
{
  setFormat(QString::null);
  setValue(0);
  repaint(false);
}

// manual operation
void KNProgress::setProgressBar(int value,const QString& text)
{
  setFormat(text);
  if (value>1000) {
    setValue(1000);
    update();       // circumvent the optimization of setValue
  } else
    setValue(value);
}

QSize KNProgress::sizeHint() const
{
  return QSize(KProgress::sizeHint().width(),desHeight);
}

//===============================================================================================

KNMainWindow::KNMainWindow() : KMainWindow(0,"mainWindow"), b_lockInput(false)
{
  knGlobals.top=this;
  knGlobals.topWidget=this;
  kapp->setMainWidget(this);  // this makes the external viewer windows close on shutdown...

  //statusbar
  KStatusBar *sb=statusBar();
  p_rogBar=new KNProgress(sb->sizeHint().height()-4,0,1000,0, KProgress::Horizontal,sb );
  knGlobals.progressBar=p_rogBar;
  sb->addWidget(p_rogBar);
  sb->insertItem(QString::null, SB_MAIN,2);
  sb->setItemAlignment (SB_MAIN,AlignLeft | AlignVCenter);
  sb->insertItem(QString::null, SB_FILTER,2);
  sb->setItemAlignment (SB_FILTER,AlignLeft | AlignVCenter);
  sb->insertItem(QString::null,SB_GROUP,3);
  sb->setItemAlignment (SB_GROUP,AlignLeft | AlignVCenter);

  //view
  setCaption(i18n("KDE News Reader"));
  v_iew=new KNodeView(this, "knodeView");
  setCentralWidget(v_iew);
  knGlobals.view=v_iew;

  //actions
  a_ccel=new KAccel(this);
  v_iew->a_ctNavReadThrough->plugAccel(a_ccel);
  v_iew->a_ctArtFilterKeyb->plugAccel(a_ccel);
  v_iew->a_ctArtSortHeadersKeyb->plugAccel(a_ccel);
  v_iew->articleView()->setCharsetKeyboardAction()->plugAccel(a_ccel);

  KStdAction::quit(kapp, SLOT(closeAllWindows()), actionCollection());
  KStdAction::keyBindings(this, SLOT(slotConfKeys()), actionCollection());
  KStdAction::configureToolbars(this, SLOT(slotConfToolbar()), actionCollection());
  KStdAction::preferences(this, SLOT(slotSettings()), actionCollection());

  a_ctWinToggleToolbar   = KStdAction::showToolbar(this, SLOT(slotWinToggleToolbar()), actionCollection());
  a_ctWinToggleStatusbar = KStdAction::showStatusbar(this, SLOT(slotWinToggleStatusbar()), actionCollection());

  createGUI("knodeui.rc");
  v_iew->initPopups(this);

  //apply settings
  resize(787,478);  // default optimized for 800x600
  applyMainWindowSettings(KGlobal::config(),"mainWindow_options");
  a_ctWinToggleToolbar->setChecked(!toolBar()->isHidden());
  a_ctWinToggleStatusbar->setChecked(!statusBar()->isHidden());

  // set the keyboard focus indicator on the first item in the Collection View
  // we do this here because everything needs to be properly setup when we
  // call setActive()
  if(v_iew->collectionView()->firstChild()) {
    QListViewItem *i = v_iew->collectionView()->firstChild();
    bool open = i->isOpen();
    v_iew->collectionView()->setActive(i,true);
    i->setOpen(open);
  }
  v_iew->collectionView()->setFocus();

  setStatusMsg();

  if(firstStart()) {  // open the config dialog on the first start
    show();              // the settings dialog must appear in front of the main window!
    slotSettings();
  }
}

KNMainWindow::~KNMainWindow()
{
  delete a_ccel;
}

//================================== GUI =================================

void KNMainWindow::setStatusMsg(const QString& text, int id)
{
  statusBar()->clear();
  if (text.isEmpty() && (id==SB_MAIN))
    if (knGlobals.netAccess->currentMsg().isEmpty())
      statusBar()->changeItem(i18n(" Ready"),SB_MAIN);
    else
      statusBar()->changeItem(knGlobals.netAccess->currentMsg(), SB_MAIN);   // restore the original message
  else
    statusBar()->changeItem(text, id);
}

void KNMainWindow::setStatusHelpMsg(const QString& text)
{
   statusBar()->message(text, 2000);
}

void KNMainWindow::setCursorBusy(bool b)
{
  if(b) kapp->setOverrideCursor(waitCursor);
  else  kapp->restoreOverrideCursor();
}

void KNMainWindow::blockUI(bool b)
{
  b_lockInput = b;
  menuBar()->setEnabled(!b);
  a_ccel->setEnabled(!b);
  v_iew->blockUI(b);
  setCursorBusy(b);
}

// processEvents with some blocking
void KNMainWindow::secureProcessEvents()
{
  b_lockInput = true;
  menuBar()->setEnabled(false);
  a_ccel->setEnabled(false);
  v_iew->blockUI(true);

  kapp->processEvents();

  b_lockInput = false;
  v_iew->blockUI(false);
  menuBar()->setEnabled(true);
  a_ccel->setEnabled(true);
}

QSize KNMainWindow::sizeHint() const
{
  return QSize(759,478);    // default optimized for 800x600
}

void KNMainWindow::slotWinToggleToolbar()
{
  if(toolBar()->isVisible())
    toolBar()->hide();
  else
    toolBar()->show();
}

void KNMainWindow::slotWinToggleStatusbar()
{
  if (statusBar()->isVisible())
    statusBar()->hide();
  else
    statusBar()->show();
}

void KNMainWindow::slotConfKeys()
{
  KActionCollection coll(*actionCollection());

  coll.take(v_iew->a_ctArtSortHeaders);   // hack, remove actions which cant have a shortcut
  coll.take(v_iew->a_ctArtFilter);
  coll.take(v_iew->articleView()->setCharsetAction());

  KKeyDialog::configureKeys(&coll, xmlFile(), true, this);
}

void KNMainWindow::slotConfToolbar()
{
  saveMainWindowSettings(KGlobal::config(),"mainWindow_options");
  KEditToolbar *dlg = new KEditToolbar(guiFactory(),this);

  if (dlg->exec()) {
    createGUI("knodeui.rc");
    v_iew->initPopups(this);
    applyMainWindowSettings(KGlobal::config(),"mainWindow_options");
  }

  delete dlg;
}

void KNMainWindow::slotSettings()
{
  v_iew->c_fgManager->configure();
}

bool KNMainWindow::firstStart()
{
  KConfig *conf=KGlobal::config();
  conf->setGroup("GENERAL");
  QString ver = conf->readEntry("Version");
  if(!ver.isEmpty())
    return false;

  KConfig emailConf("emaildefaults");

  emailConf.setGroup("Defaults");
  QString group = emailConf.readEntry("Profile","Default");

  emailConf.setGroup(QString("PROFILE_%1").arg(group));
  KNConfig::Identity *id=knGlobals.cfgManager->identity();
  id->setName(emailConf.readEntry("FullName"));
  id->setEmail(emailConf.readEntry("EmailAddress").latin1());
  id->setOrga(emailConf.readEntry("Organization"));
  id->setReplyTo(emailConf.readEntry("ReplyAddr"));
  id->save();

  KNServerInfo *smtp=knGlobals.accManager->smtp();
  smtp->setServer(emailConf.readEntry("OutgoingServer").latin1());
  smtp->setPort(25);
  conf->setGroup("MAILSERVER");
  smtp->saveConf(conf);

  conf->setGroup("GENERAL");
  conf->writeEntry("Version", KNODE_VERSION);

  return true;
}

bool KNMainWindow::queryClose()
{
  if(b_lockInput)
    return false;
  if(!v_iew->requestShutdown())
    return false;

  saveMainWindowSettings(KGlobal::config(),"mainWindow_options");
  v_iew->prepareShutdown();

  return true;
}

void KNMainWindow::fontChange( const QFont & )
{
  p_rogBar->setFont(font());    // should be called automatically?
}

void KNMainWindow::paletteChange( const QPalette & )
{
  p_rogBar->setPalette(palette());    // should be called automatically?
}

//--------------------------------

#include "knode.moc"
<|endoftext|>


<commit_before>/*
    Kopete , The KDE Instant Messenger
    Copyright (c) 2001-2002 by Duncan Mac-Vicar Prett <duncan@kde.org>

    Viva Chile Mierda!
    Started at Wed Dec 26 03:12:10 CLST 2001, Santiago de Chile

    Kopete    (c) 2002-2003 by the Kopete developers  <kopete-devel@kde.org>

    *************************************************************************
    *                                                                       *
    * This program is free software; you can redistribute it and/or modify  *
    * it under the terms of the GNU General Public License as published by  *
    * the Free Software Foundation; either version 2 of the License, or     *
    * (at your option) any later version.                                   *
    *                                                                       *
    *************************************************************************
*/

#include <kcmdlineargs.h>
#include <kaboutdata.h>
#include <klocale.h>
#include "kopete.h"

#include <dcopclient.h>
#include "kopeteiface.h"

static const char *description =
	I18N_NOOP("Kopete, the KDE Instant Messenger");

#define KOPETE_VERSION "0.6.0cvs >= 20030216"

static KCmdLineOptions options[] =
{
	{ "noplugins", I18N_NOOP("Do not load plugins"), 0 },
	{ "disable <plugin>", I18N_NOOP("Do not load specified plugin"), 0 },
	{ "!+[plugin]", I18N_NOOP("Load specified plugins"), 0 },
	KCmdLineLastOption
};

int main(int argc, char *argv[])
{
	KAboutData aboutData( "kopete", I18N_NOOP("Kopete"),
		KOPETE_VERSION, description, KAboutData::License_GPL,
		I18N_NOOP("(c) 2001,2002, Duncan Mac-Vicar Prett\n(c) 2002,2003, The Kopete Development Team"), "kopete-devel@kde.org", "http://kopete.kde.org");

	aboutData.addAuthor ( "Duncan Mac-Vicar Prett", I18N_NOOP("Original author, core developer"), "duncan@kde.org", "http://www.mac-vicar.com" );
	aboutData.addAuthor ( "Nick Betcher", I18N_NOOP("Core developer, fastest plugin developer on earth."), "nbetcher@kde.org", "http://www.kdedevelopers.net" );
	aboutData.addAuthor ( "Martijn Klingens", I18N_NOOP("Core developer"), "klingens@kde.org" );
	aboutData.addAuthor ( "Daniel Stone", I18N_NOOP("Core developer, Jabber plugin"), "dstone@kde.org", "http://raging.dropbear.id.au/daniel/");
	aboutData.addAuthor ( "Till Gerken", I18N_NOOP("Core developer, Jabber plugin"), "till@tantalo.net");
	aboutData.addAuthor ( "Olivier Goffart", I18N_NOOP("Core developer, MSN Plugin"), "ogoffart@tiscalinet.be");
	aboutData.addAuthor ( "Stefan Gehn", I18N_NOOP("Developer"), "metz@gehn.net", "http://metz.gehn.net" );
	aboutData.addAuthor ( "Gav Wood", I18N_NOOP("Winpopup plugin"), "gjw102@york.ac.uk" );
	aboutData.addAuthor ( "Zack Rusin", I18N_NOOP("Core developer, Gadu plugin"), "zack@kde.org" );
	aboutData.addAuthor ( "Chris TenHarmsel", I18N_NOOP("Developer"), "tenharmsel@users.sourceforge.net", "http://bemis.kicks-ass.net");
	aboutData.addAuthor ( "Chris Howells", I18N_NOOP("Connection status plugin author"), "howells@kde.org", "http://chrishowells.co.uk");
	aboutData.addAuthor ( "Jason Keirstead", I18N_NOOP("Core developer"), "jason@keirstead.org", "http://www.keirstead.org");
	aboutData.addAuthor ( "Andy Goossens", I18N_NOOP("Developer"), "andygoossens@pandora.be" );

	aboutData.addCredit ( "Luciash d' Being", I18N_NOOP("Icon Author") );
	aboutData.addCredit ( "Vladimir Shutoff", I18N_NOOP("SIM icq library") );
	aboutData.addCredit ( "Herwin Jan Steehouwer", I18N_NOOP("KxEngine icq code") );
	aboutData.addCredit ( "Olaf Lueg", I18N_NOOP("Kmerlin MSN code") );
	//aboutData.addCredit ( "Neil Stevens", I18N_NOOP("TAim engine AIM code") );
	aboutData.addCredit ( "Justin Karneges", I18N_NOOP("Psi Jabber code") );
	aboutData.addCredit ( "Steve Cable", I18N_NOOP("Sounds") );

	aboutData.addCredit ( "Ryan Cumming", I18N_NOOP("Old developer"), "ryan@kde.org" );
	aboutData.addCredit ( "Richard Stellingwerff", I18N_NOOP("Old Developer"), "remenic@linuxfromscratch.org");
	aboutData.addCredit ( "Hendrik vom Lehn", I18N_NOOP("Old Developer"), "hennevl@hennevl.de", "http://www.hennevl.de");
	aboutData.addCredit ( "Andres Krapf", I18N_NOOP("Old Developer"), "dae@chez.com" );
	aboutData.addCredit ( "Carsten Pfeiffer", I18N_NOOP("Misc Bugfixes and Enhancelets"), "pfeiffer@kde.org" );

	KCmdLineArgs::init( argc, argv, &aboutData );
	KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.
	KUniqueApplication::addCmdLineOptions();

	Kopete kopete;
	kapp->dcopClient()->setDefaultObject( (new KopeteIface())->objId() ); // Has to be called before exec
	kopete.exec();
}
/*
 * Local variables:
 * c-indentation-style: k&r
 * c-basic-offset: 8
 * indent-tabs-mode: t
 * End:
 */
// vim: set noet ts=4 sts=4 sw=4:

<commit_msg>Make the HEAD version string easily noticeable<commit_after>/*
    Kopete , The KDE Instant Messenger
    Copyright (c) 2001-2002 by Duncan Mac-Vicar Prett <duncan@kde.org>

    Viva Chile Mierda!
    Started at Wed Dec 26 03:12:10 CLST 2001, Santiago de Chile

    Kopete    (c) 2002-2003 by the Kopete developers  <kopete-devel@kde.org>

    *************************************************************************
    *                                                                       *
    * This program is free software; you can redistribute it and/or modify  *
    * it under the terms of the GNU General Public License as published by  *
    * the Free Software Foundation; either version 2 of the License, or     *
    * (at your option) any later version.                                   *
    *                                                                       *
    *************************************************************************
*/

#include <kcmdlineargs.h>
#include <kaboutdata.h>
#include <klocale.h>
#include "kopete.h"

#include <dcopclient.h>
#include "kopeteiface.h"

static const char *description =
	I18N_NOOP("Kopete, the KDE Instant Messenger");

#define KOPETE_VERSION "0.6.90cvs >= 20030218"

static KCmdLineOptions options[] =
{
	{ "noplugins", I18N_NOOP("Do not load plugins"), 0 },
	{ "disable <plugin>", I18N_NOOP("Do not load specified plugin"), 0 },
	{ "!+[plugin]", I18N_NOOP("Load specified plugins"), 0 },
	KCmdLineLastOption
};

int main(int argc, char *argv[])
{
	KAboutData aboutData( "kopete", I18N_NOOP("Kopete"),
		KOPETE_VERSION, description, KAboutData::License_GPL,
		I18N_NOOP("(c) 2001,2002, Duncan Mac-Vicar Prett\n(c) 2002,2003, The Kopete Development Team"), "kopete-devel@kde.org", "http://kopete.kde.org");

	aboutData.addAuthor ( "Duncan Mac-Vicar Prett", I18N_NOOP("Original author, core developer"), "duncan@kde.org", "http://www.mac-vicar.com" );
	aboutData.addAuthor ( "Nick Betcher", I18N_NOOP("Core developer, fastest plugin developer on earth."), "nbetcher@kde.org", "http://www.kdedevelopers.net" );
	aboutData.addAuthor ( "Martijn Klingens", I18N_NOOP("Core developer"), "klingens@kde.org" );
	aboutData.addAuthor ( "Daniel Stone", I18N_NOOP("Core developer, Jabber plugin"), "dstone@kde.org", "http://raging.dropbear.id.au/daniel/");
	aboutData.addAuthor ( "Till Gerken", I18N_NOOP("Core developer, Jabber plugin"), "till@tantalo.net");
	aboutData.addAuthor ( "Olivier Goffart", I18N_NOOP("Core developer, MSN Plugin"), "ogoffart@tiscalinet.be");
	aboutData.addAuthor ( "Stefan Gehn", I18N_NOOP("Developer"), "metz@gehn.net", "http://metz.gehn.net" );
	aboutData.addAuthor ( "Gav Wood", I18N_NOOP("Winpopup plugin"), "gjw102@york.ac.uk" );
	aboutData.addAuthor ( "Zack Rusin", I18N_NOOP("Core developer, Gadu plugin"), "zack@kde.org" );
	aboutData.addAuthor ( "Chris TenHarmsel", I18N_NOOP("Developer"), "tenharmsel@users.sourceforge.net", "http://bemis.kicks-ass.net");
	aboutData.addAuthor ( "Chris Howells", I18N_NOOP("Connection status plugin author"), "howells@kde.org", "http://chrishowells.co.uk");
	aboutData.addAuthor ( "Jason Keirstead", I18N_NOOP("Core developer"), "jason@keirstead.org", "http://www.keirstead.org");
	aboutData.addAuthor ( "Andy Goossens", I18N_NOOP("Developer"), "andygoossens@pandora.be" );

	aboutData.addCredit ( "Luciash d' Being", I18N_NOOP("Icon Author") );
	aboutData.addCredit ( "Vladimir Shutoff", I18N_NOOP("SIM icq library") );
	aboutData.addCredit ( "Herwin Jan Steehouwer", I18N_NOOP("KxEngine icq code") );
	aboutData.addCredit ( "Olaf Lueg", I18N_NOOP("Kmerlin MSN code") );
	//aboutData.addCredit ( "Neil Stevens", I18N_NOOP("TAim engine AIM code") );
	aboutData.addCredit ( "Justin Karneges", I18N_NOOP("Psi Jabber code") );
	aboutData.addCredit ( "Steve Cable", I18N_NOOP("Sounds") );

	aboutData.addCredit ( "Ryan Cumming", I18N_NOOP("Old developer"), "ryan@kde.org" );
	aboutData.addCredit ( "Richard Stellingwerff", I18N_NOOP("Old Developer"), "remenic@linuxfromscratch.org");
	aboutData.addCredit ( "Hendrik vom Lehn", I18N_NOOP("Old Developer"), "hennevl@hennevl.de", "http://www.hennevl.de");
	aboutData.addCredit ( "Andres Krapf", I18N_NOOP("Old Developer"), "dae@chez.com" );
	aboutData.addCredit ( "Carsten Pfeiffer", I18N_NOOP("Misc Bugfixes and Enhancelets"), "pfeiffer@kde.org" );

	KCmdLineArgs::init( argc, argv, &aboutData );
	KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.
	KUniqueApplication::addCmdLineOptions();

	Kopete kopete;
	kapp->dcopClient()->setDefaultObject( (new KopeteIface())->objId() ); // Has to be called before exec
	kopete.exec();
}
/*
 * Local variables:
 * c-indentation-style: k&r
 * c-basic-offset: 8
 * indent-tabs-mode: t
 * End:
 */
// vim: set noet ts=4 sts=4 sw=4:

<|endoftext|>


<commit_before>/*
    Kopete , The KDE Instant Messenger
    Copyright (c) 2001-2002 by Duncan Mac-Vicar Prett <duncan@kde.org>

    Viva Chile Mierda!
    Started at Wed Dec 26 03:12:10 CLST 2001, Santiago de Chile

    Kopete    (c) 2002-2005 by the Kopete developers  <kopete-devel@kde.org>

    *************************************************************************
    *                                                                       *
    * This program is free software; you can redistribute it and/or modify  *
    * it under the terms of the GNU General Public License as published by  *
    * the Free Software Foundation; either version 2 of the License, or     *
    * (at your option) any later version.                                   *
    *                                                                       *
    *************************************************************************
*/

#include <kcmdlineargs.h>
#include <kaboutdata.h>
#include "kopeteapplication.h"
#include <klocale.h>
#include "kopeteversion.h"

static const char description[] =
	I18N_NOOP( "Kopete, the KDE Instant Messenger" );

static KCmdLineOptions options[] =
{
	{ "noplugins",              I18N_NOOP( "Do not load plugins. This option overrides all other options." ), 0 },
	{ "noconnect",              I18N_NOOP( "Disable auto-connection" ), 0 },
	{ "autoconnect <accounts>", I18N_NOOP( "Auto-connect the specified accounts. Use a comma-separated list\n"
		"to auto-connect multiple accounts." ), 0 },
	{ "disable <plugins>",      I18N_NOOP( "Do not load the specified plugin. Use a comma-separated list\n"
		"to disable multiple plugins." ), 0 },
	{ "load-plugins <plugins>", I18N_NOOP( "Load only the specified plugins. Use a comma-separated list\n"
		"to load multiple plugins. This option has no effect when\n"
		"--noplugins is set and overrides all other plugin related\n"
		"command line options." ), 0 },
//	{ "url <url>",              I18N_NOOP( "Load the given Kopete URL" ), 0 },
//	{ "!+[plugin]",            I18N_NOOP( "Load specified plugins" ), 0 },
	{ "!+[URL]",                 I18N_NOOP("URLs to pass to kopete / emoticon themes to install"), 0},
	KCmdLineLastOption
};

int main( int argc, char *argv[] )
{
	KAboutData aboutData( "kopete", I18N_NOOP("Kopete"),
		KOPETE_VERSION_STRING, description, KAboutData::License_GPL,
		I18N_NOOP("(c) 2001-2004, Duncan Mac-Vicar Prett\n(c) 2002-2005, Kopete Development Team"), "kopete-devel@kde.org", "http://kopete.kde.org");

	aboutData.addAuthor ( "Duncan Mac-Vicar Prett", I18N_NOOP("Developer and Project founder"), "duncan@kde.org", "http://www.mac-vicar.org/~duncan" );
	aboutData.addAuthor ( "Andre Duffeck", I18N_NOOP("Developer, Yahoo plugin maintainer"), "andre@duffeck.de" );
	aboutData.addAuthor ( "Andy Goossens", I18N_NOOP("Developer"), "andygoossens@telenet.be" );
	aboutData.addAuthor ( "Chris Howells", I18N_NOOP("Developer, Connection status plugin author"), "howells@kde.org", "http://chrishowells.co.uk");
	aboutData.addAuthor ( "Cláudio da Silveira Pinheiro", I18N_NOOP("Developer, Video device support"), "taupter@gmail.com", "http://taupter.homelinux.org" );
	aboutData.addAuthor ( "Gregg Edghill", I18N_NOOP("Developer, MSN"), "gregg.edghill@gmail.com");
	aboutData.addAuthor ( "Grzegorz Jaskiewicz", I18N_NOOP("Developer, Gadu plugin maintainer"), "gj@pointblue.com.pl" );
	aboutData.addAuthor ( "Jason Keirstead", I18N_NOOP("Developer"), "jason@keirstead.org", "http://www.keirstead.org");
	aboutData.addAuthor ( "Matt Rogers", I18N_NOOP("Lead Developer, AIM and ICQ plugin maintainer"), "mattr@kde.org" );
	aboutData.addAuthor ( "Michel Hermier", I18N_NOOP("IRC plugin maintainer"), "michel.hermier@wanadoo.fr" );
	aboutData.addAuthor ( "Michaël Larouche", I18N_NOOP("Lead Developer"), "larouche@kde.org", "http://www.tehbisnatch.org/" );
	aboutData.addAuthor ( "Olivier Goffart", I18N_NOOP("Lead Developer, MSN plugin maintainer"), "ogoffart @ kde.org");
	aboutData.addAuthor ( "Ollivier Lapeyre Johann", I18N_NOOP("Artist / Developer, Artwork maintainer"), "johann.ollivierlapeyre@gmail.com" );
	aboutData.addAuthor ( "Richard Smith", I18N_NOOP("Developer, UI maintainer"), "kde@metafoo.co.uk" );
	aboutData.addAuthor ( "Till Gerken", I18N_NOOP("Developer, Jabber plugin maintainer"), "till@tantalo.net");
	aboutData.addAuthor ( "Will Stephenson", I18N_NOOP("Lead Developer, GroupWise maintainer"), "lists@stevello.free-online.co.uk" );

	aboutData.addCredit ( "Vally8", I18N_NOOP("Konki style author"), "vally8@gmail.com", "http://vally8.free.fr/" );
	aboutData.addCredit ( "Tm_T", I18N_NOOP("Hacker style author"), "jussi.kekkonen@gmail.com");
	aboutData.addCredit ( "Luciash d' Being", I18N_NOOP("Kopete's icon author") );
	aboutData.addCredit ( "Steve Cable", I18N_NOOP("Sounds") );
	aboutData.addCredit ( "Jessica Hall", I18N_NOOP("Kopete Docugoddess, Bug and Patch Testing.") );
	aboutData.addCredit ( "Justin Karneges", I18N_NOOP("Iris Jabber Backend Library") );
	aboutData.addCredit ( "Tom Linsky", I18N_NOOP("OscarSocket author"), "twl6@po.cwru.edu" );
	aboutData.addCredit ( "Olaf Lueg", I18N_NOOP("Kmerlin MSN code") );
    aboutData.addCredit ( "Chetan Reddy", I18N_NOOP("Former developer"), "chetan13@gmail.com" );
	aboutData.addCredit ( "Nick Betcher", I18N_NOOP("Former developer, project co-founder"), "nbetcher@kde.org");
	aboutData.addCredit ( "Ryan Cumming", I18N_NOOP("Former developer"), "ryan@kde.org" );
	aboutData.addCredit ( "Stefan Gehn", I18N_NOOP("Former developer"), "metz@gehn.net", "http://metz.gehn.net" );
	aboutData.addCredit ( "Martijn Klingens", I18N_NOOP("Former developer"), "klingens@kde.org" );
	aboutData.addCredit ( "Andres Krapf", I18N_NOOP("Former developer"), "dae@chez.com" );
	aboutData.addCredit ( "Carsten Pfeiffer", I18N_NOOP("Misc bugfixes and enhancements"), "pfeiffer@kde.org" );
	aboutData.addCredit ( "Zack Rusin", I18N_NOOP("Former developer, original Gadu plugin author"), "zack@kde.org" );
	aboutData.addCredit ( "Richard Stellingwerff", I18N_NOOP("Former developer"), "remenic@linuxfromscratch.org");
	aboutData.addCredit ( "Daniel Stone", I18N_NOOP("Former developer, Jabber plugin author"), "daniel@fooishbar.org", "http://fooishbar.org");
	aboutData.addCredit ( "Chris TenHarmsel", I18N_NOOP("Former developer, Oscar plugin"), "tenharmsel@users.sourceforge.net");
	aboutData.addCredit ( "Hendrik vom Lehn", I18N_NOOP("Former developer"), "hennevl@hennevl.de", "http://www.hennevl.de");
	aboutData.addCredit ( "Gav Wood", I18N_NOOP("Former developer and WinPopup maintainer"), "gav@indigoarchive.net" );

	aboutData.setTranslator( ki18nc("NAME OF TRANSLATORS","Your names"),
		ki18nc("EMAIL OF TRANSLATORS","Your emails") );

	KCmdLineArgs::init( argc, argv, &aboutData );
	KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.
	KUniqueApplication::addCmdLineOptions();

	KopeteApplication kopete;
//	new KIMIfaceImpl();
//	kapp->dcopClient()->registerAs( "kopete", false );
//	kapp->dcopClient()->setDefaultObject( (new KopeteIface())->objId() ); // Has to be called before exec

	return kopete.exec();
}
// vim: set noet ts=4 sts=4 sw=4:
<commit_msg>add Rafael (ereslibre)<commit_after>/*
    Kopete , The KDE Instant Messenger
    Copyright (c) 2001-2002 by Duncan Mac-Vicar Prett <duncan@kde.org>

    Viva Chile Mierda!
    Started at Wed Dec 26 03:12:10 CLST 2001, Santiago de Chile

    Kopete    (c) 2002-2005 by the Kopete developers  <kopete-devel@kde.org>

    *************************************************************************
    *                                                                       *
    * This program is free software; you can redistribute it and/or modify  *
    * it under the terms of the GNU General Public License as published by  *
    * the Free Software Foundation; either version 2 of the License, or     *
    * (at your option) any later version.                                   *
    *                                                                       *
    *************************************************************************
*/

#include <kcmdlineargs.h>
#include <kaboutdata.h>
#include "kopeteapplication.h"
#include <klocale.h>
#include "kopeteversion.h"

static const char description[] =
	I18N_NOOP( "Kopete, the KDE Instant Messenger" );

static KCmdLineOptions options[] =
{
	{ "noplugins",              I18N_NOOP( "Do not load plugins. This option overrides all other options." ), 0 },
	{ "noconnect",              I18N_NOOP( "Disable auto-connection" ), 0 },
	{ "autoconnect <accounts>", I18N_NOOP( "Auto-connect the specified accounts. Use a comma-separated list\n"
		"to auto-connect multiple accounts." ), 0 },
	{ "disable <plugins>",      I18N_NOOP( "Do not load the specified plugin. Use a comma-separated list\n"
		"to disable multiple plugins." ), 0 },
	{ "load-plugins <plugins>", I18N_NOOP( "Load only the specified plugins. Use a comma-separated list\n"
		"to load multiple plugins. This option has no effect when\n"
		"--noplugins is set and overrides all other plugin related\n"
		"command line options." ), 0 },
//	{ "url <url>",              I18N_NOOP( "Load the given Kopete URL" ), 0 },
//	{ "!+[plugin]",            I18N_NOOP( "Load specified plugins" ), 0 },
	{ "!+[URL]",                 I18N_NOOP("URLs to pass to kopete / emoticon themes to install"), 0},
	KCmdLineLastOption
};

int main( int argc, char *argv[] )
{
	KAboutData aboutData( "kopete", I18N_NOOP("Kopete"),
		KOPETE_VERSION_STRING, description, KAboutData::License_GPL,
		I18N_NOOP("(c) 2001-2004, Duncan Mac-Vicar Prett\n(c) 2002-2005, Kopete Development Team"), "kopete-devel@kde.org", "http://kopete.kde.org");

	aboutData.addAuthor ( "Duncan Mac-Vicar Prett", I18N_NOOP("Developer and Project founder"), "duncan@kde.org", "http://www.mac-vicar.org/~duncan" );
	aboutData.addAuthor ( "Andre Duffeck", I18N_NOOP("Developer, Yahoo plugin maintainer"), "andre@duffeck.de" );
	aboutData.addAuthor ( "Andy Goossens", I18N_NOOP("Developer"), "andygoossens@telenet.be" );
	aboutData.addAuthor ( "Chris Howells", I18N_NOOP("Developer, Connection status plugin author"), "howells@kde.org", "http://chrishowells.co.uk");
	aboutData.addAuthor ( "Cláudio da Silveira Pinheiro", I18N_NOOP("Developer, Video device support"), "taupter@gmail.com", "http://taupter.homelinux.org" );
	aboutData.addAuthor ( "Gregg Edghill", I18N_NOOP("Developer, MSN"), "gregg.edghill@gmail.com");
	aboutData.addAuthor ( "Grzegorz Jaskiewicz", I18N_NOOP("Developer, Gadu plugin maintainer"), "gj@pointblue.com.pl" );
	aboutData.addAuthor ( "Jason Keirstead", I18N_NOOP("Developer"), "jason@keirstead.org", "http://www.keirstead.org");
	aboutData.addAuthor ( "Matt Rogers", I18N_NOOP("Lead Developer, AIM and ICQ plugin maintainer"), "mattr@kde.org" );
	aboutData.addAuthor ( "Michel Hermier", I18N_NOOP("IRC plugin maintainer"), "michel.hermier@wanadoo.fr" );
	aboutData.addAuthor ( "Michaël Larouche", I18N_NOOP("Lead Developer"), "larouche@kde.org", "http://www.tehbisnatch.org/" );
	aboutData.addAuthor ( "Olivier Goffart", I18N_NOOP("Lead Developer, MSN plugin maintainer"), "ogoffart @ kde.org");
	aboutData.addAuthor ( "Ollivier Lapeyre Johann", I18N_NOOP("Artist / Developer, Artwork maintainer"), "johann.ollivierlapeyre@gmail.com" );
	aboutData.addAuthor ( "Richard Smith", I18N_NOOP("Developer, UI maintainer"), "kde@metafoo.co.uk" );
	aboutData.addAuthor ( "Till Gerken", I18N_NOOP("Developer, Jabber plugin maintainer"), "till@tantalo.net");
	aboutData.addAuthor ( "Will Stephenson", I18N_NOOP("Lead Developer, GroupWise maintainer"), "lists@stevello.free-online.co.uk" );
	aboutData.addAuthor ( "Rafael Fernández López", I18N_NOOP("Developer"), "ereslibre@gmail.com" );

	aboutData.addCredit ( "Vally8", I18N_NOOP("Konki style author"), "vally8@gmail.com", "http://vally8.free.fr/" );
	aboutData.addCredit ( "Tm_T", I18N_NOOP("Hacker style author"), "jussi.kekkonen@gmail.com");
	aboutData.addCredit ( "Luciash d' Being", I18N_NOOP("Kopete's icon author") );
	aboutData.addCredit ( "Steve Cable", I18N_NOOP("Sounds") );
	aboutData.addCredit ( "Jessica Hall", I18N_NOOP("Kopete Docugoddess, Bug and Patch Testing.") );
	aboutData.addCredit ( "Justin Karneges", I18N_NOOP("Iris Jabber Backend Library") );
	aboutData.addCredit ( "Tom Linsky", I18N_NOOP("OscarSocket author"), "twl6@po.cwru.edu" );
	aboutData.addCredit ( "Olaf Lueg", I18N_NOOP("Kmerlin MSN code") );
    aboutData.addCredit ( "Chetan Reddy", I18N_NOOP("Former developer"), "chetan13@gmail.com" );
	aboutData.addCredit ( "Nick Betcher", I18N_NOOP("Former developer, project co-founder"), "nbetcher@kde.org");
	aboutData.addCredit ( "Ryan Cumming", I18N_NOOP("Former developer"), "ryan@kde.org" );
	aboutData.addCredit ( "Stefan Gehn", I18N_NOOP("Former developer"), "metz@gehn.net", "http://metz.gehn.net" );
	aboutData.addCredit ( "Martijn Klingens", I18N_NOOP("Former developer"), "klingens@kde.org" );
	aboutData.addCredit ( "Andres Krapf", I18N_NOOP("Former developer"), "dae@chez.com" );
	aboutData.addCredit ( "Carsten Pfeiffer", I18N_NOOP("Misc bugfixes and enhancements"), "pfeiffer@kde.org" );
	aboutData.addCredit ( "Zack Rusin", I18N_NOOP("Former developer, original Gadu plugin author"), "zack@kde.org" );
	aboutData.addCredit ( "Richard Stellingwerff", I18N_NOOP("Former developer"), "remenic@linuxfromscratch.org");
	aboutData.addCredit ( "Daniel Stone", I18N_NOOP("Former developer, Jabber plugin author"), "daniel@fooishbar.org", "http://fooishbar.org");
	aboutData.addCredit ( "Chris TenHarmsel", I18N_NOOP("Former developer, Oscar plugin"), "tenharmsel@users.sourceforge.net");
	aboutData.addCredit ( "Hendrik vom Lehn", I18N_NOOP("Former developer"), "hennevl@hennevl.de", "http://www.hennevl.de");
	aboutData.addCredit ( "Gav Wood", I18N_NOOP("Former developer and WinPopup maintainer"), "gav@indigoarchive.net" );

	aboutData.setTranslator( ki18nc("NAME OF TRANSLATORS","Your names"),
		ki18nc("EMAIL OF TRANSLATORS","Your emails") );

	KCmdLineArgs::init( argc, argv, &aboutData );
	KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.
	KUniqueApplication::addCmdLineOptions();

	KopeteApplication kopete;
//	new KIMIfaceImpl();
//	kapp->dcopClient()->registerAs( "kopete", false );
//	kapp->dcopClient()->setDefaultObject( (new KopeteIface())->objId() ); // Has to be called before exec

	return kopete.exec();
}
// vim: set noet ts=4 sts=4 sw=4:
<|endoftext|>


<commit_before>/***************************************************************************
                          main.cpp  -  description
                             -------------------
    begin                : Wed Dec 26 03:12:10 CLST 2001
    copyright            : (C) 2001 by Duncan Mac-Vicar Prett
    email                : duncan@puc.cl
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include <kcmdlineargs.h>
#include <kaboutdata.h>
#include <klocale.h>
#include "kopete.h"

static const char *description =
	I18N_NOOP("Kopete, the KDE Messenger");
// INSERT A DESCRIPTION FOR YOUR APPLICATION HERE
static const char *version="0.0.1";

static KCmdLineOptions options[] =
{
  { 0, 0, 0 }
  // INSERT YOUR COMMANDLINE OPTIONS HERE
};

int main(int argc, char *argv[])
{

  KAboutData aboutData( "kopete", I18N_NOOP("Kopete"),
    version, description, KAboutData::License_GPL,
    "(c) 2001, Duncan Mac-Vicar Prett", 0, 0, "duncan@puc.cl");
  aboutData.addAuthor("Duncan Mac-Vicar Prett","Author, core developer", "duncan@puc.cl","http://www.mac-vicar.com");
  aboutData.addAuthor ("Nick Betcher", "core developer","nbetcher@usinternet.com", "http://www.kdedevelopers.net" );
  KCmdLineArgs::init( argc, argv, &aboutData );
  KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.
	KUniqueApplication::addCmdLineOptions();

  Kopete kopete;
//kopete->show();
  kopete.exec();
}
<commit_msg>- Some credits added<commit_after>/***************************************************************************
                          main.cpp  -  description
                             -------------------
    begin                : Wed Dec 26 03:12:10 CLST 2001
    copyright            : (C) 2001 by Duncan Mac-Vicar Prett
    email                : duncan@puc.cl
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include <kcmdlineargs.h>
#include <kaboutdata.h>
#include <klocale.h>
#include "kopete.h"

static const char *description =
	I18N_NOOP("Kopete, the KDE Messenger");
// INSERT A DESCRIPTION FOR YOUR APPLICATION HERE
static const char *version="0.0.1";

static KCmdLineOptions options[] =
{
  { 0, 0, 0 }
  // INSERT YOUR COMMANDLINE OPTIONS HERE
};

int main(int argc, char *argv[])
{

  KAboutData aboutData( "kopete", I18N_NOOP("Kopete"),
    version, description, KAboutData::License_GPL,
    "(c) 2001, Duncan Mac-Vicar Prett", 0, 0, "duncan@puc.cl");

	aboutData.addAuthor("Duncan Mac-Vicar Prett","Author, core developer", "duncan@puc.cl","http://www.mac-vicar.com");
	aboutData.addAuthor ("Nick Betcher", "core developer","nbetcher@usinternet.com", "http://www.kdedevelopers.net" );

	aboutData.addCredit("Herwin Jan Steehouwer", I18N_NOOP("KxEngine ICQ code"));
	aboutData.addCredit("Olaf Lueg", I18N_NOOP("Kmerlin MSN Code"));
	aboutData.addCredit("Neil Stevens", I18N_NOOP("TAim engine AIM Code"));

	KCmdLineArgs::init( argc, argv, &aboutData );
	KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.
	KUniqueApplication::addCmdLineOptions();

  Kopete kopete;
//kopete->show();
  kopete.exec();
}
<|endoftext|>


<commit_before>/*********************************************************************************
 *
 * Inviwo - Interactive Visualization Workshop
 *
 * Copyright (c) 2013-2015 Inviwo Foundation
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *********************************************************************************/

#include "inviwosplashscreen.h"

#include <QApplication>
#include <QPainter>
#include <QSplashScreen>
#include <QTextStream>
#include <QDesktopWidget>

#include <inviwo/core/util/commandlineparser.h>
#include <inviwo/qt/widgets/inviwoapplicationqt.h>

namespace inviwo {

InviwoSplashScreen::InviwoSplashScreen(QWidget* parent, bool enable)
    : QSplashScreen(parent, QPixmap(":/images/splashscreen.png"))
    , showSplashScreen_(enable) {}

InviwoSplashScreen::~InviwoSplashScreen() {}

void InviwoSplashScreen::show() {
    if (showSplashScreen_) QSplashScreen::show();
}

void InviwoSplashScreen::drawContents(QPainter* painter) {
    QSplashScreen::drawContents(painter);
    QString versionLabel;
    QTextStream labelStream(&versionLabel);
    labelStream << "Version " << QString::fromStdString(IVW_VERSION);
    painter->drawText(13, 265, versionLabel);
}

void InviwoSplashScreen::showMessage(std::string message) {
    // show message and add whitespace to match layout
    if (showSplashScreen_)
        QSplashScreen::showMessage(QString::fromStdString("   " + message),
                                   Qt::AlignLeft | Qt::AlignBottom, Qt::white);
}

void InviwoSplashScreen::finish(QWidget* mainWindow) {
    if (showSplashScreen_) QSplashScreen::finish(mainWindow);
}

}  // namespace<commit_msg>Qt: SpashScreen text alignment fix<commit_after>/*********************************************************************************
 *
 * Inviwo - Interactive Visualization Workshop
 *
 * Copyright (c) 2013-2015 Inviwo Foundation
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *********************************************************************************/

#include "inviwosplashscreen.h"

#include <QApplication>
#include <QPainter>
#include <QSplashScreen>
#include <QTextStream>
#include <QDesktopWidget>

#include <inviwo/core/util/commandlineparser.h>
#include <inviwo/qt/widgets/inviwoapplicationqt.h>

namespace inviwo {

InviwoSplashScreen::InviwoSplashScreen(QWidget* parent, bool enable)
    : QSplashScreen(parent, QPixmap(":/images/splashscreen.png"))
    , showSplashScreen_(enable) {}

InviwoSplashScreen::~InviwoSplashScreen() {}

void InviwoSplashScreen::show() {
    if (showSplashScreen_) QSplashScreen::show();
}

void InviwoSplashScreen::drawContents(QPainter* painter) {
    QString versionLabel;
    QTextStream labelStream(&versionLabel);
    labelStream << "Version " << QString::fromStdString(IVW_VERSION);
    painter->setPen(Qt::white);
    painter->drawText(15, 270, versionLabel);
    painter->drawText(15, 290, message());
}

void InviwoSplashScreen::showMessage(std::string message) {
    if (showSplashScreen_) QSplashScreen::showMessage(QString::fromStdString(message));
}

void InviwoSplashScreen::finish(QWidget* mainWindow) {
    if (showSplashScreen_) QSplashScreen::finish(mainWindow);
}

}  // namespace<|endoftext|>


<commit_before>// ======================================================================== //
// Copyright 2009-2017 Intel Corporation                                    //
//                                                                          //
// Licensed under the Apache License, Version 2.0 (the "License");          //
// you may not use this file except in compliance with the License.         //
// You may obtain a copy of the License at                                  //
//                                                                          //
//     http://www.apache.org/licenses/LICENSE-2.0                           //
//                                                                          //
// Unless required by applicable law or agreed to in writing, software      //
// distributed under the License is distributed on an "AS IS" BASIS,        //
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
// See the License for the specific language governing permissions and      //
// limitations under the License.                                           //
// ======================================================================== //

// ospray
#include "SimpleAO.h"
#include "SimpleAOMaterial.h"
// ispc exports
#include "SimpleAO_ispc.h"

namespace ospray {

  //! \brief Constructor
  SimpleAO::SimpleAO(int defaultNumSamples)
    : defaultNumSamples(defaultNumSamples)
  {
    ispcEquivalent = ispc::SimpleAO_create(this);
  }

  /*! \brief create a material of given type */
  ospray::Material *SimpleAO::createMaterial(const char * /*type*/)
  {
    return new simpleao::Material;
  }

  /*! \brief common function to help printf-debugging */
  std::string SimpleAO::toString() const
  {
    return "ospray::render::SimpleAO";
  }

  /*! \brief commit the object's outstanding changes
   *         (such as changed parameters etc) */
  void SimpleAO::commit()
  {
    Renderer::commit();

    int   numSamples = getParam1i("aoSamples", defaultNumSamples);
    float rayLength  = getParam1f("aoOcclusionDistance", 1e20f);
    ispc::SimpleAO_set(getIE(), numSamples, rayLength);
  }

  // OSP_REGISTER_RENDERER(SimpleAO, ao);

  /*! \note Reintroduce aoX renderers for compatibility, they should be
            deprecated!*/
  OSP_REGISTER_RENDERER(SimpleAO(4), ao);
  OSP_REGISTER_RENDERER(SimpleAO(1), ao1);
  OSP_REGISTER_RENDERER(SimpleAO(2), ao2);
  OSP_REGISTER_RENDERER(SimpleAO(4), ao4);
  OSP_REGISTER_RENDERER(SimpleAO(8), ao8);
  OSP_REGISTER_RENDERER(SimpleAO(16), ao16);

} // ::ospray

<commit_msg>match scivis 'aoDistance' param name in ao renderer<commit_after>// ======================================================================== //
// Copyright 2009-2017 Intel Corporation                                    //
//                                                                          //
// Licensed under the Apache License, Version 2.0 (the "License");          //
// you may not use this file except in compliance with the License.         //
// You may obtain a copy of the License at                                  //
//                                                                          //
//     http://www.apache.org/licenses/LICENSE-2.0                           //
//                                                                          //
// Unless required by applicable law or agreed to in writing, software      //
// distributed under the License is distributed on an "AS IS" BASIS,        //
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
// See the License for the specific language governing permissions and      //
// limitations under the License.                                           //
// ======================================================================== //

// ospray
#include "SimpleAO.h"
#include "SimpleAOMaterial.h"
// ispc exports
#include "SimpleAO_ispc.h"

namespace ospray {

  //! \brief Constructor
  SimpleAO::SimpleAO(int defaultNumSamples)
    : defaultNumSamples(defaultNumSamples)
  {
    ispcEquivalent = ispc::SimpleAO_create(this);
  }

  /*! \brief create a material of given type */
  ospray::Material *SimpleAO::createMaterial(const char * /*type*/)
  {
    return new simpleao::Material;
  }

  /*! \brief common function to help printf-debugging */
  std::string SimpleAO::toString() const
  {
    return "ospray::render::SimpleAO";
  }

  /*! \brief commit the object's outstanding changes
   *         (such as changed parameters etc) */
  void SimpleAO::commit()
  {
    Renderer::commit();

    int   numSamples = getParam1i("aoSamples", defaultNumSamples);
    float rayLength  = getParam1f("aoDistance", 1e20f);
    ispc::SimpleAO_set(getIE(), numSamples, rayLength);
  }

  // OSP_REGISTER_RENDERER(SimpleAO, ao);

  /*! \note Reintroduce aoX renderers for compatibility, they should be
            deprecated!*/
  OSP_REGISTER_RENDERER(SimpleAO(4), ao);
  OSP_REGISTER_RENDERER(SimpleAO(1), ao1);
  OSP_REGISTER_RENDERER(SimpleAO(2), ao2);
  OSP_REGISTER_RENDERER(SimpleAO(4), ao4);
  OSP_REGISTER_RENDERER(SimpleAO(8), ao8);
  OSP_REGISTER_RENDERER(SimpleAO(16), ao16);

} // ::ospray

<|endoftext|>


<commit_before><commit_msg>修正 Camera 的 Update/Prepare 没有被调用的问题。<commit_after><|endoftext|>


<commit_before>////////////////////////////////////////////////////////////////////////
// This file is part of Grappa, a system for scaling irregular
// applications on commodity clusters.

// Copyright (C) 2010-2014 University of Washington and Battelle
// Memorial Institute. University of Washington authorizes use of this
// Grappa software.

// Grappa is free software: you can redistribute it and/or modify it
// under the terms of the Affero General Public License as published
// by Affero, Inc., either version 1 of the License, or (at your
// option) any later version.

// Grappa is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// Affero General Public License for more details.

// You should have received a copy of the Affero General Public
// License along with this program. If not, you may obtain one from
// http://www.affero.org/oagpl.html.
////////////////////////////////////////////////////////////////////////

#pragma once

#include "Addressing.hpp"
#include "FlatCombiner.hpp"
#include "LocaleSharedMemory.hpp"
#include "GlobalAllocator.hpp"
#include "Collective.hpp"

namespace Grappa {

class GlobalCounter {
public:

  struct Master {
    long count;
    Core core;
  } master;

  GlobalAddress<GlobalCounter> self;

  struct Proxy {
    GlobalCounter* outer;
    long delta;

    Proxy(GlobalCounter* outer): outer(outer), delta(0) {}
    Proxy* clone_fresh() { return locale_new<Proxy>(outer); }

    void sync() {
      auto s = outer->self;
      auto d = delta;
      delegate::call(outer->master.core, [s,d]{ s->master.count += d; });
    }

    void clear() { delta = 0; }
    bool is_full() { return false; }
  };
  FlatCombiner<Proxy> comb;

  GlobalCounter(long initial_count = 0, Core master_core = 0): comb(locale_new<Proxy>(this)) {
    master.count = initial_count;
    master.core = master_core;
  }

  void incr(long d = 1) {
    comb.combine([d](Proxy& p){
      p.delta += d;
      return FCStatus::BLOCKED;
    });
  }

  long count() {
    auto s = self;
    return delegate::call(master.core, [s]{ return s->master.count; });
  }

  static GlobalAddress<GlobalCounter> create(long initial_count = 0) {
    auto a = symmetric_global_alloc<GlobalCounter>();
    auto master_core = mycore();
    call_on_all_cores([a,master_core]{ new (a.localize()) GlobalCounter(0, master_core); });
    return a;
  }

  void destroy() {
    auto a = self;
    call_on_all_cores([a]{ a->~GlobalCounter(); });
  }
} GRAPPA_BLOCK_ALIGNED;

} // namespace Grappa
<commit_msg>fix initialization bug in GlobalCounter<commit_after>////////////////////////////////////////////////////////////////////////
// This file is part of Grappa, a system for scaling irregular
// applications on commodity clusters.

// Copyright (C) 2010-2014 University of Washington and Battelle
// Memorial Institute. University of Washington authorizes use of this
// Grappa software.

// Grappa is free software: you can redistribute it and/or modify it
// under the terms of the Affero General Public License as published
// by Affero, Inc., either version 1 of the License, or (at your
// option) any later version.

// Grappa is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// Affero General Public License for more details.

// You should have received a copy of the Affero General Public
// License along with this program. If not, you may obtain one from
// http://www.affero.org/oagpl.html.
////////////////////////////////////////////////////////////////////////

#pragma once

#include "Addressing.hpp"
#include "FlatCombiner.hpp"
#include "LocaleSharedMemory.hpp"
#include "GlobalAllocator.hpp"
#include "Collective.hpp"

namespace Grappa {

class GlobalCounter {
public:

  struct Master {
    long count;
    Core core;
  } master;

  GlobalAddress<GlobalCounter> self;

  struct Proxy {
    GlobalCounter* outer;
    long delta;

    Proxy(GlobalCounter* outer): outer(outer), delta(0) {}
    Proxy* clone_fresh() { return locale_new<Proxy>(outer); }

    void sync() {
      auto s = outer->self;
      auto d = delta;
      delegate::call(outer->master.core, [s,d]{ s->master.count += d; });
    }

    void clear() { delta = 0; }
    bool is_full() { return false; }
  };
  FlatCombiner<Proxy> comb;

  GlobalCounter(GlobalAddress<GlobalCounter> self, long initial_count = 0, Core master_core = 0): self(self), comb(locale_new<Proxy>(this)) {
    master.count = initial_count;
    master.core = master_core;
  }

  void incr(long d = 1) {
    comb.combine([d](Proxy& p){
      p.delta += d;
      return FCStatus::BLOCKED;
    });
  }

  long count() {
    auto s = self;
    return delegate::call(master.core, [s]{ return s->master.count; });
  }

  static GlobalAddress<GlobalCounter> create(long initial_count = 0) {
    auto a = symmetric_global_alloc<GlobalCounter>();
    auto master_core = mycore();
    call_on_all_cores([a,initial_count,master_core]{ new (a.localize()) GlobalCounter(a, initial_count, master_core); });
    return a;
  }

  void destroy() {
    auto a = self;
    call_on_all_cores([a]{ a->~GlobalCounter(); });
  }
} GRAPPA_BLOCK_ALIGNED;

} // namespace Grappa
<|endoftext|>