Пример #1
0
/* static */
QIcon UIIconPool::defaultIcon(UIDefaultIcon def, const QWidget *pWidget /* = 0 */)
{
    QIcon icon;
    QStyle *pStyle = pWidget ? pWidget->style() : QApplication::style();
    switch (def)
    {
    case MessageBoxInformationIcon:
    {
        icon = pStyle->standardIcon(QStyle::SP_MessageBoxInformation, 0, pWidget);
        break;
    }
    case MessageBoxQuestionIcon:
    {
        icon = pStyle->standardIcon(QStyle::SP_MessageBoxQuestion, 0, pWidget);
        break;
    }
    case MessageBoxWarningIcon:
    {
#ifdef Q_WS_MAC
        /* At least in Qt 4.3.4/4.4 RC1 SP_MessageBoxWarning is the application
         * icon. So change this to the critical icon. (Maybe this would be
         * fixed in a later Qt version) */
        icon = pStyle->standardIcon(QStyle::SP_MessageBoxCritical, 0, pWidget);
#else /* Q_WS_MAC */
        icon = pStyle->standardIcon(QStyle::SP_MessageBoxWarning, 0, pWidget);
#endif /* !Q_WS_MAC */
        break;
    }
    case MessageBoxCriticalIcon:
    {
        icon = pStyle->standardIcon(QStyle::SP_MessageBoxCritical, 0, pWidget);
        break;
    }
    case DialogCancelIcon:
    {
        icon = pStyle->standardIcon(QStyle::SP_DialogCancelButton, 0, pWidget);
        if (icon.isNull())
            icon = iconSet(":/cancel_16px.png");
        break;
    }
    case DialogHelpIcon:
    {
        icon = pStyle->standardIcon(QStyle::SP_DialogHelpButton, 0, pWidget);
        if (icon.isNull())
            icon = iconSet(":/help_16px.png");
        break;
    }
    case ArrowBackIcon:
    {
        icon = pStyle->standardIcon(QStyle::SP_ArrowBack, 0, pWidget);
        if (icon.isNull())
            icon = iconSet(":/list_moveup_16px.png",
                           ":/list_moveup_disabled_16px.png");
        break;
    }
    case ArrowForwardIcon:
    {
        icon = pStyle->standardIcon(QStyle::SP_ArrowForward, 0, pWidget);
        if (icon.isNull())
            icon = iconSet(":/list_movedown_16px.png",
                           ":/list_movedown_disabled_16px.png");
        break;
    }
    default:
    {
        AssertMsgFailed(("Unknown default icon type!"));
        break;
    }
    }
    return icon;
}
Пример #2
0
bool c_graph_item::sceneEventFilter(QGraphicsItem *watched, QEvent *event){

    //ajout fleche rouge sur le hover
    if(event->type() == QEvent::GraphicsSceneHoverEnter && !model_graph->getTransClicked() && !model_graph->getNodeCLicked() && !model_graph->getFinalClicked()	){

        if( !model_graph->addedToScene){

           std::cout << "mouse enter QGraphics item\n";
           //creation de la ligne bleu
           m_transition * selectedTransition = getTransitionFromQGraphicsItem(watched,event);
           QLineF * transition_line = selectedTransition->getGraphicalComponentLine();
           QPointF p1(transition_line->p1().x(),transition_line->p1().y());
           QPointF p2(transition_line->p2().x(),transition_line->p2().y());

           //creation du polygon bleu
           QPointF destPoint = p2.toPoint();
           int arrowSize = 10;
           double angle = ::acos(transition_line->dx() / transition_line->length());
            if (transition_line->dy() >= 0)
               angle = TwoPi - angle;

            QPointF destArrowP1 = destPoint + QPointF(    sin(angle - Pi / 3)      * arrowSize, cos(angle - Pi / 3)      * arrowSize);
            QPointF destArrowP2 = destPoint + QPointF(    sin(angle - Pi + Pi / 3) * arrowSize, cos(angle - Pi + Pi / 3) * arrowSize);


            QPolygonF tmp_polygon;
            tmp_polygon << p2 << destArrowP1 << destArrowP2;


           model_graph->line = new QGraphicsLineItem(QLineF(p1,p2));
           model_graph->arrow = new QGraphicsPolygonItem(tmp_polygon);

           QPen * pen = new QPen();
           pen->setColor(Qt::red);
           pen->setBrush(Qt::red);
           pen->setWidth(3);
           model_graph->line->setPen(*pen);
           model_graph->arrow->setPen(*pen);
           model_graph->arrow->setBrush(Qt::red);

               model_graph->view_graph->scene()->addItem(dynamic_cast<QGraphicsItem *>(model_graph->line));
               model_graph->view_graph->scene()->addItem(dynamic_cast<QGraphicsItem *>(model_graph->arrow));
               //view_graph->scene()->update();
               model_graph->addedToScene = true;

           }

    }
    if(event->type() == QEvent::GraphicsSceneHoverLeave	 && !model_graph->getTransClicked() && !model_graph->getNodeCLicked() && !model_graph->getFinalClicked()){

        if(model_graph->addedToScene){
            model_graph->view_graph->scene()->removeItem(dynamic_cast<QGraphicsItem *>(model_graph->line));
            model_graph->view_graph->scene()->removeItem(dynamic_cast<QGraphicsItem *>(model_graph->arrow));
            delete model_graph->line;
            delete model_graph->arrow;
            model_graph->addedToScene = false;
        }

    }

   if(event->type() == QEvent::GraphicsSceneMousePress && !model_graph->getTransClicked() && !model_graph->getNodeCLicked() && !model_graph->getFinalClicked()){

       if(QGraphicsSceneMouseEvent* mouseEvent = static_cast<QGraphicsSceneMouseEvent*>(event)){

           if(mouseEvent->button() == Qt::RightButton){ //ajoute un menu pour le changement de couleur de la transition CLICK DROIT

               std::cout << "           the right button :D\n";

               std::cout <<"declanche right button \n";
               QSize iconSize = QSize (30,30);
               QPixmap iconPmap (iconSize);
               iconPmap.fill (Qt::transparent);

               QPainter painter (&iconPmap);
               painter.setBrush (QBrush (*m_colors::colorNonParcouru));
               painter.setPen(QPen(Qt::NoPen));
               painter.drawRect (0,0,30,30);
               painter.drawPixmap (0, 0, iconPmap);

               QIcon retIconNonParoucru;
               retIconNonParoucru.addPixmap(iconPmap, QIcon::Normal, QIcon::Off);
               retIconNonParoucru.addPixmap(iconPmap, QIcon::Normal, QIcon::On);

               painter.setBrush (QBrush (*m_colors::colorActif));
               painter.drawRect (0,0,30,30);
               painter.drawPixmap (0, 0, iconPmap);

               QIcon retIconActif;
               retIconActif.addPixmap(iconPmap, QIcon::Normal, QIcon::Off);
               retIconActif.addPixmap(iconPmap, QIcon::Normal, QIcon::On);

               painter.setBrush (QBrush (*m_colors::colorParcouru));
               painter.drawRect (0,0,30,30);
               painter.drawPixmap (0, 0, iconPmap);

               QIcon retIconParcouru;
               retIconParcouru.addPixmap(iconPmap, QIcon::Normal, QIcon::Off);
               retIconParcouru.addPixmap(iconPmap, QIcon::Normal, QIcon::On);

               painter.setBrush (QBrush (*m_colors::colorSolution));
               painter.drawRect (0,0,30,30);
               painter.drawPixmap (0, 0, iconPmap);

               QIcon retIconSolution;
               retIconSolution.addPixmap(iconPmap, QIcon::Normal, QIcon::Off);
               retIconSolution.addPixmap(iconPmap, QIcon::Normal, QIcon::On);

               menu = new QMenu(watched->scene()->views().at(0));
               menu->setStyleSheet("background-color:#8e8e8e;");


               action_non_parcouru = new QAction(retIconNonParoucru,"Non parcouru", watched->scene()->views().at(0));
               action_actif = new QAction(retIconActif,"Actif", watched->scene()->views().at(0));
               action_parcouru = new QAction(retIconParcouru, "Parcouru", watched->scene()->views().at(0));
               action_solution = new QAction(retIconSolution,"Solution",watched->scene()->views().at(0));

               model_graph->setRightClickedTransition(getTransitionFromQGraphicsItem(watched,event));

               QObject::connect(action_solution,SIGNAL(triggered()),this, SLOT(setSolutionTransColor()));
               QObject::connect(action_non_parcouru,SIGNAL(triggered()),this, SLOT(setNonParcouruTransColor()));
               QObject::connect(action_parcouru,SIGNAL(triggered()),this, SLOT(setParcouruTransColor()));
               QObject::connect(action_actif,SIGNAL(triggered()),this, SLOT(setActifTransColor()));


               menu->addAction(action_non_parcouru);
               menu->addAction(action_actif);
               menu->addAction(action_parcouru);
               menu->addAction(action_solution);


               menu->exec(mouseEvent->screenPos()); //euqivalent au global pos


           }
           else if(mouseEvent->button() == Qt::LeftButton){//ajoute fleche bleue sur le clic


                model_graph->removeAllSelectedTransitions();

                std::cout << "transClicked \n";
                model_graph->transition_clicked = true;
                //supprime les transition de hover (qui pourron donc etre reutiliser apres)
              // view_graph->scene()->removeItem(dynamic_cast<QGraphicsItem *>(line));
                //view_graph->scene()->removeItem(dynamic_cast<QGraphicsItem *>(arrow));
                model_graph->addedToScene = false;

                std::cout << "mouse enter QGraphics item\n";
                //creation de la ligne bleu
                m_transition * selectedTransition = getTransitionFromQGraphicsItem(watched,event);

                model_graph->clickedTransition = selectedTransition;
                QLineF * transition_line = selectedTransition->getGraphicalComponentLine();
                QPointF p1(transition_line->p1().x(),transition_line->p1().y());
                QPointF p2(transition_line->p2().x(),transition_line->p2().y());

                //creation du polygon bleu
                QPointF destPoint = p2.toPoint();
                int arrowSize = 10;
                double angle = ::acos(transition_line->dx() / transition_line->length());
                 if (transition_line->dy() >= 0)
                    angle = TwoPi - angle;

                 QPointF destArrowP1 = destPoint + QPointF(    sin(angle - Pi / 3)      * arrowSize, cos(angle - Pi / 3)      * arrowSize);
                 QPointF destArrowP2 = destPoint + QPointF(    sin(angle - Pi + Pi / 3) * arrowSize, cos(angle - Pi + Pi / 3) * arrowSize);


                 QPolygonF tmp_polygon;
                 tmp_polygon << p2 << destArrowP1 << destArrowP2;


                model_graph->line_click = new QGraphicsLineItem(QLineF(p1,p2));
                model_graph->arrow_click = new QGraphicsPolygonItem(tmp_polygon);

                QPen * pen = new QPen();
                pen->setColor(Qt::blue);
                pen->setBrush(Qt::blue);
                pen->setWidth(3);
                model_graph->line_click->setPen(*pen);
                model_graph->arrow_click->setPen(*pen);
                model_graph->arrow_click->setBrush(Qt::blue);

                model_graph->view_graph->scene()->addItem(dynamic_cast<QGraphicsItem *>(model_graph->line_click));
                model_graph->view_graph->scene()->addItem(dynamic_cast<QGraphicsItem *>(model_graph->arrow_click));
                //view_graph->scene()->update();
                model_graph->addedToScene = true;

                //supression des eventuelle selection de nodes (on ne peut pas selectionner a la fois une transition et un node)
                std::vector<m_node *> * nodes = model_graph->getNodes();
                for(int i =0;i<(int)nodes->size();i++){
                    m_node * tmp_node = nodes->at(i);
                    tmp_node->removePermanentSelection();
                }
           }
       }
    }


    return true;
}
Пример #3
0
QBalloonTip::QBalloonTip(QSystemTrayIcon::MessageIcon icon, const QString& title,
                         const QString& message, QSystemTrayIcon *ti)
    : QWidget(0, Qt::ToolTip), trayIcon(ti), timerId(-1)
{
    setAttribute(Qt::WA_DeleteOnClose);
    QObject::connect(ti, SIGNAL(destroyed()), this, SLOT(close()));

    QLabel *titleLabel = new QLabel;
    titleLabel->installEventFilter(this);
    titleLabel->setText(title);
    QFont f = titleLabel->font();
    f.setBold(true);
#ifdef Q_WS_WINCE
    f.setPointSize(f.pointSize() - 2);
#endif
    titleLabel->setFont(f);
    titleLabel->setTextFormat(Qt::PlainText); // to maintain compat with windows

#ifdef Q_WS_WINCE
    const int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize);
    const int closeButtonSize = style()->pixelMetric(QStyle::PM_SmallIconSize) - 2;
#else
    const int iconSize = 18;
    const int closeButtonSize = 15;
#endif

    QPushButton *closeButton = new QPushButton;
    closeButton->setIcon(style()->standardIcon(QStyle::SP_TitleBarCloseButton));
    closeButton->setIconSize(QSize(closeButtonSize, closeButtonSize));
    closeButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    closeButton->setFixedSize(closeButtonSize, closeButtonSize);
    QObject::connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));

    QLabel *msgLabel = new QLabel;
#ifdef Q_WS_WINCE
    f.setBold(false);
    msgLabel->setFont(f);
#endif
    msgLabel->installEventFilter(this);
    msgLabel->setText(message);
    msgLabel->setTextFormat(Qt::PlainText);
    msgLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);

    // smart size for the message label
#ifdef Q_WS_WINCE
    int limit = QApplication::desktop()->availableGeometry(msgLabel).size().width() / 2;
#else
    int limit = QApplication::desktop()->availableGeometry(msgLabel).size().width() / 3;
#endif
    if (msgLabel->sizeHint().width() > limit) {
        msgLabel->setWordWrap(true);
        if (msgLabel->sizeHint().width() > limit) {
            msgLabel->d_func()->ensureTextControl();
            if (QTextControl *control = msgLabel->d_func()->control) {
                QTextOption opt = control->document()->defaultTextOption();
                opt.setWrapMode(QTextOption::WrapAnywhere);
                control->document()->setDefaultTextOption(opt);
            }
        }
#ifdef Q_WS_WINCE
        // Make sure that the text isn't wrapped "somewhere" in the balloon widget
        // in the case that we have a long title label.
        setMaximumWidth(limit);
#else
        // Here we allow the text being much smaller than the balloon widget
        // to emulate the weird standard windows behavior.
        msgLabel->setFixedSize(limit, msgLabel->heightForWidth(limit));
#endif
    }

    QIcon si;
    switch (icon) {
    case QSystemTrayIcon::Warning:
        si = style()->standardIcon(QStyle::SP_MessageBoxWarning);
        break;
    case QSystemTrayIcon::Critical:
	si = style()->standardIcon(QStyle::SP_MessageBoxCritical);
        break;
    case QSystemTrayIcon::Information:
	si = style()->standardIcon(QStyle::SP_MessageBoxInformation);
        break;
    case QSystemTrayIcon::NoIcon:
    default:
        break;
    }

    QGridLayout *layout = new QGridLayout;
    if (!si.isNull()) {
        QLabel *iconLabel = new QLabel;
        iconLabel->setPixmap(si.pixmap(iconSize, iconSize));
        iconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
        iconLabel->setMargin(2);
        layout->addWidget(iconLabel, 0, 0);
        layout->addWidget(titleLabel, 0, 1);
    } else {
        layout->addWidget(titleLabel, 0, 0, 1, 2);
    }

    layout->addWidget(closeButton, 0, 2);
    layout->addWidget(msgLabel, 1, 0, 1, 3);
    layout->setSizeConstraint(QLayout::SetFixedSize);
    layout->setMargin(3);
    setLayout(layout);

    QPalette pal = palette();
    pal.setColor(QPalette::Window, QColor(0xff, 0xff, 0xe1));
    pal.setColor(QPalette::WindowText, Qt::black);
    setPalette(pal);
}
Пример #4
0
QIcon QFileIconProviderPrivate::getWinIcon(const QFileInfo &fileInfo) const
{
    QIcon retIcon;
    static int defaultFolderIIcon = -1;

    QString key;
    QPixmap pixmap;
    // If it's a file, non-{exe,lnk,ico} then we might have it cached already
    if (isCacheable(fileInfo)) {
        const QString fileExtension = QLatin1Char('.') + fileInfo.suffix().toUpper();
        key = QLatin1String("qt_") + fileExtension;
        QPixmapCache::find(key, pixmap);
        if (!pixmap.isNull()) {
            retIcon.addPixmap(pixmap);
            if (QPixmapCache::find(key + QLatin1Char('l'), pixmap))
                retIcon.addPixmap(pixmap);
            return retIcon;
        }
    }

    const bool cacheableDirIcon = fileInfo.isDir() && !fileInfo.isRoot();
    if (!useCustomDirectoryIcons && defaultFolderIIcon >= 0 && cacheableDirIcon) {
        // We already have the default folder icon, just return it
        key = QString::fromLatin1("qt_dir_%1").arg(defaultFolderIIcon);
        QPixmapCache::find(key, pixmap);
        if (!pixmap.isNull()) {
            retIcon.addPixmap(pixmap);
            if (QPixmapCache::find(key + QLatin1Char('l'), pixmap))
                retIcon.addPixmap(pixmap);
            return retIcon;
        }
    }

    /* We don't use the variable, but by storing it statically, we
     * ensure CoInitialize is only called once. */
    static HRESULT comInit = CoInitialize(NULL);
    Q_UNUSED(comInit);

    SHFILEINFO info;
    unsigned long val = 0;

    //Get the small icon

    unsigned int flags =
        SHGFI_ICON|SHGFI_SYSICONINDEX|SHGFI_ADDOVERLAYS|SHGFI_OVERLAYINDEX;

    if (cacheableDirIcon && !useCustomDirectoryIcons) {
        flags |= SHGFI_USEFILEATTRIBUTES;
        val = SHGetFileInfo(L"dummy",
                            FILE_ATTRIBUTE_DIRECTORY, &info,
                            sizeof(SHFILEINFO), flags | SHGFI_SMALLICON);
    } else {
        val = SHGetFileInfo((const wchar_t *)QDir::toNativeSeparators(fileInfo.filePath()).utf16(),
                            0, &info, sizeof(SHFILEINFO), flags | SHGFI_SMALLICON);
    }

    // Even if GetFileInfo returns a valid result, hIcon can be empty in some cases
    if (val && info.hIcon) {
        if (fileInfo.isDir() && !fileInfo.isRoot()) {
            if (!useCustomDirectoryIcons && defaultFolderIIcon < 0)
                defaultFolderIIcon = info.iIcon;
            //using the unique icon index provided by windows save us from duplicate keys
            key = QString::fromLatin1("qt_dir_%1").arg(info.iIcon);
            QPixmapCache::find(key, pixmap);
            if (!pixmap.isNull()) {
                retIcon.addPixmap(pixmap);
                if (QPixmapCache::find(key + QLatin1Char('l'), pixmap))
                    retIcon.addPixmap(pixmap);
                DestroyIcon(info.hIcon);
                return retIcon;
            }
        }
        if (pixmap.isNull()) {
            pixmap = QPixmap::fromWinHICON(info.hIcon);

            if (!pixmap.isNull()) {
                retIcon.addPixmap(pixmap);
                if (!key.isEmpty())
                    QPixmapCache::insert(key, pixmap);
            }
            else {
              qWarning("QFileIconProviderPrivate::getWinIcon() no small icon found");
            }
        }
        DestroyIcon(info.hIcon);
    }

    //Get the big icon
    val = SHGetFileInfo((const wchar_t *)QDir::toNativeSeparators(fileInfo.filePath()).utf16(), 0, &info,
                        sizeof(SHFILEINFO), SHGFI_ICON|SHGFI_LARGEICON|SHGFI_SYSICONINDEX|SHGFI_ADDOVERLAYS|SHGFI_OVERLAYINDEX);

    if (val && info.hIcon) {
        if (fileInfo.isDir() && !fileInfo.isRoot()) {
            //using the unique icon index provided by windows save us from duplicate keys
            key = QString::fromLatin1("qt_dir_%1").arg(info.iIcon);
        }
        pixmap = QPixmap::fromWinHICON(info.hIcon);

        if (!pixmap.isNull()) {
            retIcon.addPixmap(pixmap);
            if (!key.isEmpty())
                QPixmapCache::insert(key + QLatin1Char('l'), pixmap);
        }
        else {
            qWarning("QFileIconProviderPrivate::getWinIcon() no large icon found");
        }
        DestroyIcon(info.hIcon);
    }
    return retIcon;
}
Пример #5
0
QIcon QFileIconProvider::icon(const QFileInfo &info) const
{
    Q_D(const QFileIconProvider);

    QIcon platformIcon = qt_guiPlatformPlugin()->fileSystemIcon(info);
    if (!platformIcon.isNull())
        return platformIcon;

#if defined(Q_WS_X11) && !defined(QT_NO_STYLE_GTK)
    if (X11->desktopEnvironment == DE_GNOME) {
        QIcon gtkIcon = QGtkStylePrivate::getFilesystemIcon(info);
        if (!gtkIcon.isNull())
            return gtkIcon;
    }
#endif

#ifdef Q_WS_MAC
    QIcon retIcon = d->getMacIcon(info);
    if (!retIcon.isNull())
        return retIcon;
#elif defined Q_WS_WIN
    QIcon icon = d->getWinIcon(info);
    if (!icon.isNull())
        return icon;
#endif
    if (info.isRoot())
#if defined (Q_WS_WIN)
    {
        UINT type = GetDriveType((wchar_t *)info.absoluteFilePath().utf16());

        switch (type) {
        case DRIVE_REMOVABLE:
            return d->getIcon(QStyle::SP_DriveFDIcon);
        case DRIVE_FIXED:
            return d->getIcon(QStyle::SP_DriveHDIcon);
        case DRIVE_REMOTE:
            return d->getIcon(QStyle::SP_DriveNetIcon);
        case DRIVE_CDROM:
            return d->getIcon(QStyle::SP_DriveCDIcon);
        case DRIVE_RAMDISK:
        case DRIVE_UNKNOWN:
        case DRIVE_NO_ROOT_DIR:
        default:
            return d->getIcon(QStyle::SP_DriveHDIcon);
        }
    }
#else
    return d->getIcon(QStyle::SP_DriveHDIcon);
#endif
    if (info.isFile()) {
        if (info.isSymLink())
            return d->getIcon(QStyle::SP_FileLinkIcon);
        else
            return d->getIcon(QStyle::SP_FileIcon);
    }
  if (info.isDir()) {
    if (info.isSymLink()) {
      return d->getIcon(QStyle::SP_DirLinkIcon);
    } else {
      if (info.absoluteFilePath() == d->homePath) {
        return d->getIcon(QStyle::SP_DirHomeIcon);
      } else {
        return d->getIcon(QStyle::SP_DirIcon);
      }
    }
  }
  return QIcon();
}
Пример #6
0
void EditorToolSettings::setToolIcon(const QIcon& icon)
{
    d->toolIcon->setPixmap(icon.pixmap(style()->pixelMetric(QStyle::PM_SmallIconSize)));
}
Пример #7
0
void IconSetter::setActionIcon(QPixmap pixmap )
{
#if 0
//#define SAVE_ICONS 1
#define SAVE(name) { QPixmap p = pixmap.copy(n*24, 0, 24, 24); \
                     QString s = "/tmp/" name ".png"; \
                     p.save(s); }

    for(int n = 0; n < 10; ++n )
    {
        QIcon icon;
        icon.addPixmap(pixmap.copy(n*24, 0, 24, 24), QIcon::Normal, QIcon::Off);
        icon.addPixmap(pixmap.copy(n*24, 24, 24, 24), QIcon::Active, QIcon::Off);
        icon.addPixmap(pixmap.copy(n*24, 48, 24, 24), QIcon::Selected, QIcon::Off);
        icon.addPixmap(pixmap.copy(n*24, 72, 24, 24), QIcon::Disabled, QIcon::Off);
        QAction * action = 0;
		//ActionTools::findAction("aaa", toolbar_actions);
        switch(n)
        {
        case 0: action = ActionTools::findAction("open_file", toolbar_actions);
				if (action) ICON_ADD(icon, "file")
				#if SAVE_ICONS
				SAVE("open")
				#endif
                break;
        case 1: action = ActionTools::findAction("open_directory", toolbar_actions);
				if (action) ICON_ADD(icon, "file")
				#if SAVE_ICONS
				SAVE("open_folder")
				#endif
                break;
        case 2: action = ActionTools::findAction("open_dvd", toolbar_actions);
				if (action) ICON_ADD(icon, "file")
				#if SAVE_ICONS
				SAVE("dvd")
				#endif
                break;
        case 3: action = ActionTools::findAction("open_url", toolbar_actions);
				if (action) ICON_ADD(icon, "file")
				#if SAVE_ICONS
				SAVE("url")
				#endif
                break;
        case 4: action = ActionTools::findAction("screenshot", toolbar_actions);
				if (action) ICON_ADD(icon, "file")
				#if SAVE_ICONS
				SAVE("screenshot")
				#endif
                break;
        case 5: action = ActionTools::findAction("show_file_properties", toolbar_actions);
				if (action) ICON_ADD(icon, "file")
				#if SAVE_ICONS
				SAVE("info")
				#endif
                break;
        case 6: action = ActionTools::findAction("show_find_sub_dialog", toolbar_actions);
				if (action) ICON_ADD(icon, "file")
				#if SAVE_ICONS
				SAVE("download_subs")
				#endif
                break;
        case 7: action = ActionTools::findAction("show_preferences", toolbar_actions);
				if (action) ICON_ADD(icon, "file")
				#if SAVE_ICONS
				SAVE("prefs")
				#endif
                break;
        }
        if (action) action->setIcon(icon);
    }
#endif
}
Пример #8
0
ObjectSimpleViewer::
ObjectSimpleViewer(
  bool is3D,
  bool isBlending):
QWidget(
  0,
  Qt::SubWindow | Qt::Window),
root(NULL),
views_root_s(NULL),
views_root_t(NULL),
blinker_root(NULL),
m_clipPlaneManip(NULL),
m_clipPlane(NULL),
m_clipManipulatorButtonBi(NULL),
m_obliqueSliceButton(NULL),
m_clipLandmarkButton(NULL),
m_blinkButton(NULL),
m_mixSlider(NULL),
m_viewAll(true)
{
  QLayout *mix = NULL;
  if(isBlending)
  {
    QGridLayout * l2 = new QGridLayout;

    m_mixSlider = new QSlider(Qt::Vertical, NULL);;
    l2->addWidget(m_mixSlider, 0, 0, Qt::AlignBottom | Qt::AlignHCenter);
    m_mixSlider->setRange(0, 100);
    m_mixSlider->setSingleStep(1);
    m_mixSlider->setPageStep(10);
    m_mixSlider->setValue(100);

    QLabel * label = new QLabel("Mix", NULL);
    label->setAlignment(Qt::AlignLeft | Qt::AlignTop);
    label->setMargin(0);
    l2->addWidget(label, 1, 0, Qt::AlignTop | Qt::AlignHCenter);
    mix = l2;
    QWidget::connect(m_mixSlider, SIGNAL(valueChanged(int)),
	this, SLOT(transparencyChanged(int)));
  }

  QList <QWidget*> *buttons=new QList <QWidget*>;
  QIcon icon;
  //blink button on/off
  icon.addPixmap(QPixmap(QString::fromUtf8(":/icons/images/blink.png")),
      QIcon::Normal);
  m_blinkButton=new QPushButton(this);
  m_blinkButton->setCheckable(true);
  m_blinkButton->setChecked(false);
  m_blinkButton->setIcon(icon);
  m_blinkButton->setToolTip("Flash source on/off");
  m_blinkButton->setVisible(false);
  connect(m_blinkButton, SIGNAL(clicked(bool)),
          this, SLOT(setFlashSourceTarget(bool)));

  if(is3D)
  {
    m_clipManipulatorButtonBi=new ClipPlaneButtonBiDirection(this);
    m_clipManipulatorButtonBi->setCheckable(false);
    m_clipManipulatorButtonBi->setToolTip("Clip manipulator on/clip/off");
    buttons->append(m_clipManipulatorButtonBi);

    icon.addPixmap(QPixmap(
        QString::fromUtf8(":/icons/images/orthosliceon.png")),
	QIcon::Normal, QIcon::Off);
    icon.addPixmap(QPixmap(
        QString::fromUtf8(":/icons/images/orthosliceoff.png")),
	QIcon::Normal, QIcon::On);
    m_obliqueSliceButton=new QPushButton(this);
    m_obliqueSliceButton->setCheckable(true);
    m_obliqueSliceButton->setIcon(icon);
    m_obliqueSliceButton->setToolTip("Oblique slice on/off");

    buttons->append(m_obliqueSliceButton);

    //landmark clip on/off
    icon.addPixmap(QPixmap(
        QString::fromUtf8(":/icons/images/cuttinglandmarksoff.png")),
	QIcon::Normal, QIcon::Off);
    icon.addPixmap(
        QPixmap(QString::fromUtf8(":/icons/images/cuttinglandmarkson.png")),
	QIcon::Normal, QIcon::On);
    m_clipLandmarkButton=new QPushButton(this);
    m_clipLandmarkButton->setCheckable(true);
    m_clipLandmarkButton->setChecked(true);
    m_clipLandmarkButton->setIcon(icon);
    m_clipLandmarkButton->setToolTip("Clip landmarks on/off");
    m_clipLandmarkButton->setVisible(false);
    buttons->append(m_clipLandmarkButton);

    buttons->append(m_blinkButton);
    m_viewer = (Viewer2D3D*) new Viewer3D(this, mix, buttons);
    connect(m_clipManipulatorButtonBi,
            SIGNAL(stateChanged(ClipPlaneButton::statetype)),
	    this, SLOT(stateChanged(ClipPlaneButton::statetype)));
  }
  else
  {
    buttons->append(m_blinkButton);
    m_viewer = (Viewer2D3D *)new Viewer2D(this, mix, buttons);
  }
  Q_ASSERT(m_viewer);
  root = new SoSeparator;
  Q_ASSERT(root);
  root->ref();

  SoEventCallback * cb = new SoEventCallback;
  cb->addEventCallback(SoMouseButtonEvent::getClassTypeId(),
      mouseEventCB, this);
  root->insertChild(cb, 0);

  blinker_root = new SoSwitch;
  Q_ASSERT(blinker_root);
  blinker_root->ref();
  blinker_root->whichChild = 0; // select non blinking

  SoSeparator* noblinker = new SoSeparator;
  Q_ASSERT(noblinker);
  blinker_root->addChild(noblinker);

  SoBlinker* blinker = new SoBlinker;
  Q_ASSERT(blinker);
  blinker->on = true;

  blinker_root->addChild(blinker);

  views_root_s = new SoSeparator;
  Q_ASSERT(views_root_s);
  blinker->addChild(views_root_s);
  noblinker->addChild(views_root_s);

  views_root_t = new SoSeparator;
  Q_ASSERT(views_root_t);
  blinker->addChild(views_root_t);
  noblinker->addChild(views_root_t);

  root->addChild(blinker_root);

  m_viewer ->setSceneGraph(root);

  //this has to go in the Editor
  m_activateAction = new QAction (this);
  m_activateAction -> setCheckable(true);
  connect(m_activateAction, SIGNAL(triggered()), this, SLOT(show()));
  connect(m_activateAction, SIGNAL(triggered()), this, SLOT(raise()));
  connect(m_activateAction, SIGNAL(triggered()), this, SLOT(setFocus()));
  this->setSizePolicy (  QSizePolicy::Expanding, QSizePolicy::Expanding );
}
Пример #9
0
BGDialog::BGDialog(QWidget *parent, const KSharedConfigPtr &_config)
    : BGDialog_UI(parent), m_readOnly(false)
{
    m_pGlobals = new KGlobalBackgroundSettings(_config);
    m_pDirs = KGlobal::dirs();
    m_previewUpdates = true;

    m_numScreens = QApplication::desktop()->numScreens();

    QString multiHead = getenv("KDE_MULTIHEAD");
    if (multiHead.toLower() == "true")
        m_numScreens = 1;

    m_screen = QApplication::desktop()->screenNumber(this);
    if (m_screen >= (int)m_numScreens)
        m_screen = m_numScreens - 1;

    getEScreen();
    m_copyAllScreens = true;

    if (m_numScreens < 2) {
        m_comboScreen->hide();
        m_buttonIdentifyScreens->hide();
        m_screen = 0;
        m_eScreen = 0;
    }

    connect(m_buttonIdentifyScreens, SIGNAL(clicked()), SLOT(slotIdentifyScreens()));

    // preview monitor
    m_pMonitorArrangement = new BGMonitorArrangement(m_screenArrangement);
    m_pMonitorArrangement->setObjectName("monitor arrangement");
    connect(m_pMonitorArrangement, SIGNAL(imageDropped(QString)), SLOT(slotImageDropped(QString)));
    if (m_numScreens > 1) {
        connect(m_comboScreen, SIGNAL(activated(int)),
                SLOT(slotSelectScreen(int)));
    }

    // background image settings
    QIcon iconSet = KIcon(QLatin1String("document-open"));
    QPixmap pixMap = iconSet.pixmap(
             style()->pixelMetric(QStyle::PM_SmallIconSize), QIcon::Normal);
    m_urlWallpaperButton->setIcon(iconSet);
    m_urlWallpaperButton->setFixedSize(pixMap.width() + 8, pixMap.height() + 8);
    m_urlWallpaperButton->setToolTip(i18n("Open file dialog"));

    connect(m_buttonGroupBackground, SIGNAL(clicked(int)),
            SLOT(slotWallpaperTypeChanged(int)));
    connect(m_urlWallpaperBox, SIGNAL(activated(int)),
            SLOT(slotWallpaper(int)));
    connect(m_urlWallpaperButton, SIGNAL(clicked()),
            SLOT(slotWallpaperSelection()));
    connect(m_comboWallpaperPos, SIGNAL(activated(int)),
            SLOT(slotWallpaperPos(int)));
    connect(m_buttonSetupWallpapers, SIGNAL(clicked()),
            SLOT(slotSetupMulti()));

    // set up the background colour stuff
    connect(m_colorPrimary, SIGNAL(changed(QColor)),
            SLOT(slotPrimaryColor(QColor)));
    connect(m_colorSecondary, SIGNAL(changed(QColor)),
            SLOT(slotSecondaryColor(QColor)));
    connect(m_comboPattern, SIGNAL(activated(int)),
            SLOT(slotPattern(int)));

    // blend
    connect(m_comboBlend, SIGNAL(activated(int)), SLOT(slotBlendMode(int)));
    connect(m_sliderBlend, SIGNAL(valueChanged(int)),
            SLOT(slotBlendBalance(int)));
    connect(m_cbBlendReverse, SIGNAL(toggled(bool)),
            SLOT(slotBlendReverse(bool)));

    // advanced options
    connect(m_buttonAdvanced, SIGNAL(clicked()),
            SLOT(slotAdvanced()));

    connect(m_buttonGetNew, SIGNAL(clicked()),
            SLOT(slotGetNewStuff()));

    // renderers
    if (m_numScreens > 1) {
        // Setup the merged-screen renderer
        KBackgroundRenderer *r = new KBackgroundRenderer(0, false, _config);
        m_renderer.insert(0, r);
        connect(r, SIGNAL(imageDone(int)), SLOT(slotPreviewDone(int)));

        // Setup the common-screen renderer
        r = new KBackgroundRenderer(0, true, _config);
        m_renderer.insert(1, r);
        connect(r, SIGNAL(imageDone(int)), SLOT(slotPreviewDone(int)));

        // Setup the remaining renderers for each screen
        for (unsigned j = 0; j < m_numScreens; ++j) {
            r = new KBackgroundRenderer(j, true, _config);
            m_renderer.insert(j + 2, r);
            connect(r, SIGNAL(imageDone(int)), SLOT(slotPreviewDone(int)));
        }
    } else {
        // set up the common desktop renderer
        KBackgroundRenderer *r = new KBackgroundRenderer(0, false, _config);
        m_renderer.insert(0, r);
        connect(r, SIGNAL(imageDone(int)), SLOT(slotPreviewDone(int)));
    }

    // Random or InOrder
    m_slideShowRandom = eRenderer()->multiWallpaperMode();
    if (m_slideShowRandom == KBackgroundSettings::NoMultiRandom)
        m_slideShowRandom = KBackgroundSettings::Random;
    if (m_slideShowRandom == KBackgroundSettings::NoMulti)
        m_slideShowRandom = KBackgroundSettings::InOrder;

    // Wallpaper Position
    m_wallpaperPos = eRenderer()->wallpaperMode();
    if (m_wallpaperPos == KBackgroundSettings::NoWallpaper)
        m_wallpaperPos = KBackgroundSettings::Centred; // Default

    if (KGlobal::dirs()->isRestrictedResource("wallpaper")) {
        m_urlWallpaperButton->hide();
        m_buttonSetupWallpapers->hide();
        m_radioSlideShow->hide();
    }

    initUI();
    updateUI();

    connect(qApp->desktop(), SIGNAL(resized(int)), SLOT(desktopResized())); // RANDR support
}
Пример #10
0
    void setupUi(QWidget *MainWindow2)
    {
        if (MainWindow2->objectName().isEmpty())
            MainWindow2->setObjectName(QString::fromUtf8("MainWindow2"));
        MainWindow2->resize(529, 407);
        MainWindow2->setStyleSheet(QString::fromUtf8("\n"
            "QWidget2 {\n"
"    background-color: green;\n"
"}\n"
""));
        actionNew = new QAction(MainWindow2);
        actionNew->setObjectName(QString::fromUtf8("actionNew"));
        QIcon icon;
        icon.addFile(QString::fromUtf8(":/icons/document-new.svg"), QSize(), QIcon::Normal, QIcon::Off);
        actionNew->setIcon(icon);
        actionLoad = new QAction(MainWindow2);
        actionLoad->setObjectName(QString::fromUtf8("actionLoad"));
        QIcon icon1;
        icon1.addFile(QString::fromUtf8(":/icons/document-open.svg"), QSize(), QIcon::Normal, QIcon::Off);
        actionLoad->setIcon(icon1);
        actionSave = new QAction(MainWindow2);
        actionSave->setObjectName(QString::fromUtf8("actionSave"));
        actionSave->setEnabled(false);
        QIcon icon2;
        icon2.addFile(QString::fromUtf8(":/icons/document-save.svg"), QSize(), QIcon::Normal, QIcon::Off);
        actionSave->setIcon(icon2);
        actionPrint = new QAction(MainWindow2);
        actionPrint->setObjectName(QString::fromUtf8("actionPrint"));
        QIcon icon3;
        icon3.addFile(QString::fromUtf8(":/icons/document-print.svg"), QSize(), QIcon::Normal, QIcon::Off);
        actionPrint->setIcon(icon3);
        gridLayout = new QGridLayout(MainWindow2);
        gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
        ActionPanel = new QSint::ActionPanel(MainWindow2);
        ActionPanel->setObjectName(QString::fromUtf8("ActionPanel"));
        QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
        sizePolicy.setHorizontalStretch(0);
        sizePolicy.setVerticalStretch(0);
        sizePolicy.setHeightForWidth(ActionPanel->sizePolicy().hasHeightForWidth());
        ActionPanel->setSizePolicy(sizePolicy);

        gridLayout->addWidget(ActionPanel, 0, 0, 2, 1);

        ActionGroup1 = new QSint::ActionGroup(MainWindow2);
        ActionGroup1->setObjectName(QString::fromUtf8("ActionGroup1"));
        ActionGroup1->setProperty("expandable", QVariant(true));
        ActionGroup1->setProperty("header", QVariant(true));
        verticalLayout = new QVBoxLayout(ActionGroup1);
        verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
        rbDefaultScheme = new QRadioButton(ActionGroup1);
        rbDefaultScheme->setObjectName(QString::fromUtf8("rbDefaultScheme"));
        rbDefaultScheme->setChecked(true);

        verticalLayout->addWidget(rbDefaultScheme);

        rbXPBlueScheme = new QRadioButton(ActionGroup1);
        rbXPBlueScheme->setObjectName(QString::fromUtf8("rbXPBlueScheme"));

        verticalLayout->addWidget(rbXPBlueScheme);

        rbXPBlue2Scheme = new QRadioButton(ActionGroup1);
        rbXPBlue2Scheme->setObjectName(QString::fromUtf8("rbXPBlue2Scheme"));

        verticalLayout->addWidget(rbXPBlue2Scheme);

        rbVistaScheme = new QRadioButton(ActionGroup1);
        rbVistaScheme->setObjectName(QString::fromUtf8("rbVistaScheme"));

        verticalLayout->addWidget(rbVistaScheme);

        rbMacScheme = new QRadioButton(ActionGroup1);
        rbMacScheme->setObjectName(QString::fromUtf8("rbMacScheme"));

        verticalLayout->addWidget(rbMacScheme);

        rbAndroidScheme = new QRadioButton(ActionGroup1);
        rbAndroidScheme->setObjectName(QString::fromUtf8("rbAndroidScheme"));

        verticalLayout->addWidget(rbAndroidScheme);


        gridLayout->addWidget(ActionGroup1, 0, 1, 1, 1);

        verticalSpacer = new QSpacerItem(20, 57, QSizePolicy::Minimum, QSizePolicy::Expanding);

        gridLayout->addItem(verticalSpacer, 1, 1, 1, 1);


        retranslateUi(MainWindow2);

        QMetaObject::connectSlotsByName(MainWindow2);
    } // setupUi
Пример #11
0
void RssListItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    QStyledItemDelegate::paint(painter,option,index);

    painter->save();

    QFont font = QApplication::font();
    QFont SubFont = QApplication::font();
    QFont dateFont = QApplication::font();

    //font.setPixelSize(font.weight()+);
    font.setBold(true);
    SubFont.setWeight(SubFont.weight()-2);
    QFontMetrics fm(font);
    QFontMetrics dfm(dateFont);

    QIcon icon = qvariant_cast<QIcon>(index.data(IconRole));
    QString headerText = qvariant_cast<QString>(index.data(HeaderTextRole));
    QString subText = qvariant_cast<QString>(index.data(DescriptionRole));
    QString dateText = qvariant_cast<QString>(index.data(DateRole));

    QSize iconsize = icon.actualSize(option.decorationSize);

    QRect headerRect = option.rect;
    QRect subheaderRect = option.rect;
    QRect iconRect = subheaderRect;
    QRect dateRect = subheaderRect;

    iconRect.setRight(iconsize.width()+30);
    iconRect.setTop(iconRect.top()+5);
    headerRect.setLeft(iconRect.right());
    headerRect.setTop(headerRect.top()+5);
    headerRect.setBottom(headerRect.top()+fm.height());

    int dateWidth = 0;
    if(!dateText.isEmpty()) {
        dateWidth = dfm.width(dateText) + 5;
        dateRect.setLeft(iconRect.right());
        dateRect.setTop(headerRect.bottom()+17);
    }


    subheaderRect.setLeft(iconRect.right() + dateWidth);
    subheaderRect.setTop(headerRect.bottom()+17);


    //painter->drawPixmap(QPoint(iconRect.right()/2,iconRect.top()/2),icon.pixmap(iconsize.width(),iconsize.height()));
    painter->drawPixmap(QPoint(iconRect.left()+iconsize.width()/2+2,iconRect.top()+iconsize.height()/2+3),icon.pixmap(iconsize.width(),iconsize.height()));

    painter->setFont(font);
    painter->drawText(headerRect,headerText);


    painter->setFont(SubFont);
    painter->drawText(subheaderRect.left(),subheaderRect.top(),subText);

    if(dateWidth) {
        painter->setFont(dateFont);
        painter->drawText(dateRect.left(), dateRect.top(), dateText);
    }

    painter->restore();

}
Пример #12
0
TaskPanelView::TaskPanelView(QWidget *parent)
  : QWidget(parent)
{
    Gui::ActionFunction* func = new Gui::ActionFunction(this);
    QAction* action = new QAction(this);
    func->trigger(action, boost::bind(&TaskPanelView::executeAction, this));

#if defined(QSINT_ACTIONPANEL)

    QGridLayout* customLayout = new QGridLayout(this);
    QTabWidget* tabWidget = new QTabWidget(this);
    customLayout->addWidget(tabWidget, 0, 0);
    this->resize(642, 850);

    {
    Ui_TaskActionBox* ui(new Ui_TaskActionBox);
    QWidget* page1 = new QWidget();
    ui->setupUi(page1);
    tabWidget->addTab(page1, QLatin1String("Action Box"));

    // setup ActionBox 1
    ui->ActionBox1->setIcon(QPixmap(QString::fromLatin1(":/icons/document-open.svg")));
    ui->ActionBox1->header()->setText(QString::fromLatin1("Header of the group"));
    connect(ui->ActionBox1->header(), SIGNAL(clicked()), action, SIGNAL(triggered()));

    QSint::ActionLabel *a1 = ui->ActionBox1->createItem(QString::fromLatin1("This action has no icon"));
    connect(a1, SIGNAL(clicked()), action, SIGNAL(triggered()));
    QSint::ActionLabel *a2 = ui->ActionBox1->createItem(QPixmap(QString::fromLatin1(":/icons/document-print.svg")),
                                                QString::fromLatin1("This action has icon"));
    connect(a2, SIGNAL(clicked()), action, SIGNAL(triggered()));

    QLayout *hbl1 = ui->ActionBox1->createHBoxLayout();
    QSint::ActionLabel *a3 = ui->ActionBox1->createItem(QString::fromLatin1("1st action in row"), hbl1);
    connect(a3, SIGNAL(clicked()), action, SIGNAL(triggered()));
    QSint::ActionLabel *a4 = ui->ActionBox1->createItem(QString::fromLatin1("2nd action in row"), hbl1);
    connect(a4, SIGNAL(clicked()), action, SIGNAL(triggered()));

    // setup ActionBox 2
    ui->ActionBox2->setIcon(QPixmap(QString::fromLatin1(":/icons/document-save.png")));
    ui->ActionBox2->header()->setText(QString::fromLatin1("Checkable actions allowed"));
    connect(ui->ActionBox2->header(), SIGNAL(clicked()), action, SIGNAL(triggered()));

    QSint::ActionLabel *b1 = ui->ActionBox2->createItem(QString::fromLatin1("Action 1 (Exclusive)"));
    b1->setCheckable(true);
    b1->setAutoExclusive(true);
    b1->setChecked(true);
    QSint::ActionLabel *b2 = ui->ActionBox2->createItem(QString::fromLatin1("Action 2 (Exclusive)"));
    b2->setCheckable(true);
    b2->setAutoExclusive(true);
    QSint::ActionLabel *b3 = ui->ActionBox2->createItem(QString::fromLatin1("Action 3 (Exclusive)"));
    b3->setCheckable(true);
    b3->setAutoExclusive(true);

    QSint::ActionLabel *b4 = ui->ActionBox2->createItem(QString::fromLatin1("Non-exclusive but still checkable"));
    b4->setCheckable(true);

    // setup ActionBox 3
    ui->ActionBox3->setIcon(QPixmap(QString::fromLatin1(":/icons/document-print.png")));
    ui->ActionBox3->header()->setText(QString::fromLatin1("Also, widgets allowed as well"));

    ui->ActionBox3->addWidget(new QPushButton(QString::fromLatin1("PushButton"), this));
    ui->ActionBox3->addWidget(new QCheckBox(QString::fromLatin1("CheckBox"), this));
    QLayout *hbl3 = ui->ActionBox3->createHBoxLayout();
    ui->ActionBox3->addWidget(new QRadioButton(QString::fromLatin1("RadioButton 1"), this), hbl3);
    ui->ActionBox3->addWidget(new QRadioButton(QString::fromLatin1("RadioButton 2"), this), hbl3);

    // setup ActionBox 4
    ui->ActionBox4->setIcon(QPixmap(QString::fromLatin1(":/icons/document-open.png")));
    ui->ActionBox4->header()->setText(QString::fromLatin1("ActionBox with different scheme"));

    ui->ActionBox4->createItem(QString::fromLatin1("This action has no icon"));
    ui->ActionBox4->createItem(QPixmap(QString::fromLatin1(":/icons/document-print.png")),
                                                QString::fromLatin1("This action has icon"));
    QLayout *hbl4 = ui->ActionBox4->createHBoxLayout();
    ui->ActionBox4->createItem(QString::fromLatin1("1st action in row"), hbl4);
    ui->ActionBox4->createItem(QString::fromLatin1("2nd action in row"), hbl4);
    ui->ActionBox4->createItem(QString::fromLatin1("3rd action in row"), hbl4);

    const char* ActionBoxNewStyle =
        "QSint--ActionBox {"
            "background-color: #333333;"
            "border: 1px solid #000000;"
            "text-align: left;"
        "}"

        "QSint--ActionBox:hover {"
            "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #666666, stop: 1 #333333);"
            "border: 1px solid #222222;"
        "}"

        "QSint--ActionBox QSint--ActionLabel[class='header'] {"
            "text-align: center;"
            "font: 14px bold;"
            "color: #999999;"
            "background-color: transparent;"
            "border: 1px solid transparent;"
        "}"

        "QSint--ActionBox QSint--ActionLabel[class='header']:hover {"
            "color: #aaaaaa;"
            "text-decoration: underline;"
            "border: 1px dotted #aaaaaa;"
        "}"

        "QSint--ActionBox QSint--ActionLabel[class='action'] {"
            "background-color: transparent;"
            "border: none;"
            "color: #777777;"
            "text-align: left;"
            "font: 11px;"
        "}"

        "QSint--ActionBox QSint--ActionLabel[class='action']:hover {"
            "color: #888888;"
            "text-decoration: underline;"
        "}"

        "QSint--ActionBox QSint--ActionLabel[class='action']:on {"
            "background-color: #ddeeff;"
            "color: #006600;"
        "}"
    ;

    ui->ActionBox4->setStyleSheet(QString::fromLatin1(ActionBoxNewStyle));

    // setup ActionBox 5
    Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
    ui->ActionBox5->setIcon(QPixmap(QString::fromLatin1(":/icons/document-save.png")));
    ui->ActionBox5->header()->setText(QString::fromLatin1("TaskGroup with different scheme"));

    rcCmdMgr.addTo("Std_New", ui->ActionBox5);
    rcCmdMgr.addTo("Std_Open", ui->ActionBox5);
    rcCmdMgr.addTo("Std_Save", ui->ActionBox5);
    ui->ActionBox5->setStyleSheet(QString::fromLatin1(ActionBoxNewStyle));
    }
    {
    Ui_TaskGroup* ui(new Ui_TaskGroup);
    QWidget* page2 = new QWidget();
    ui->setupUi(page2);
    tabWidget->addTab(page2, QLatin1String("Action Group"));

    this->actionGroup = ui->ActionPanel;

    // create ActionGroups on ActionPanel
    QIcon save = QIcon::fromTheme(QString::fromLatin1("document-save"));
    QSint::ActionGroup *group1 = ui->ActionPanel->createGroup(save.pixmap(24,24), QString::fromLatin1("Expandable Group"));
    group1->addAction(ui->actionNew);
    group1->addAction(ui->actionLoad);
    group1->addWidget(new QPushButton(QString::fromLatin1("Just a button"), this));
    group1->addAction(ui->actionSave);
    group1->addAction(ui->actionPrint);
    group1->addWidget(new QPushButton(QString::fromLatin1("Just another button"), this));

    QIcon redo = QIcon::fromTheme(QString::fromLatin1("edit-redo"));
    QSint::ActionGroup *group2 = ui->ActionPanel->createGroup(redo.pixmap(24,24), QString::fromLatin1("Non-Expandable Group"), false);
    group2->addAction(ui->actionNew);
    group2->addAction(ui->actionLoad);
    group2->addAction(ui->actionSave);
    group2->addAction(ui->actionPrint);

    ui->ActionPanel->addWidget(new QLabel(QString::fromLatin1("Action Group without header"), this));

    QSint::ActionGroup *group3 = ui->ActionPanel->createGroup();
    group3->addAction(ui->actionNew);

    QHBoxLayout *hbl = new QHBoxLayout();
    group3->groupLayout()->addLayout(hbl);
    hbl->addWidget(group3->addAction(ui->actionLoad, false));
    hbl->addWidget(group3->addAction(ui->actionSave, false));

    group3->addAction(ui->actionPrint);

    ui->ActionPanel->addStretch();


    // setup standalone ActionGroup

    ui->ActionGroup1->setScheme(QSint::WinXPPanelScheme::defaultScheme());

    ui->ActionGroup1->addWidget(ui->rbDefaultScheme);
    ui->ActionGroup1->addWidget(ui->rbXPBlueScheme);
    ui->ActionGroup1->addWidget(ui->rbXPBlue2Scheme);
    ui->ActionGroup1->addWidget(ui->rbVistaScheme);
    ui->ActionGroup1->addWidget(ui->rbMacScheme);
    ui->ActionGroup1->addWidget(ui->rbAndroidScheme);

    Gui::ActionFunction* func = new Gui::ActionFunction(this);

    QAction* defaultAction = new QAction(this);
    connect(ui->rbDefaultScheme, SIGNAL(toggled(bool)), defaultAction, SIGNAL(toggled(bool)));
    func->toggle(defaultAction, boost::bind(&TaskPanelView::on_rbDefaultScheme_toggled, this, _1));

    QAction* xpBlueAction = new QAction(this);
    connect(ui->rbXPBlueScheme, SIGNAL(toggled(bool)), xpBlueAction, SIGNAL(toggled(bool)));
    func->toggle(xpBlueAction, boost::bind(&TaskPanelView::on_rbXPBlueScheme_toggled, this, _1));

    QAction* xpBlue2Action = new QAction(this);
    connect(ui->rbXPBlue2Scheme, SIGNAL(toggled(bool)), xpBlue2Action, SIGNAL(toggled(bool)));
    func->toggle(xpBlue2Action, boost::bind(&TaskPanelView::on_rbXPBlue2Scheme_toggled, this, _1));

    QAction* vistaAction = new QAction(this);
    connect(ui->rbVistaScheme, SIGNAL(toggled(bool)), vistaAction, SIGNAL(toggled(bool)));
    func->toggle(vistaAction, boost::bind(&TaskPanelView::on_rbVistaScheme_toggled, this, _1));

    QAction* macAction = new QAction(this);
    connect(ui->rbMacScheme, SIGNAL(toggled(bool)), macAction, SIGNAL(toggled(bool)));
    func->toggle(macAction, boost::bind(&TaskPanelView::on_rbMacScheme_toggled, this, _1));

    QAction* androidAction = new QAction(this);
    connect(ui->rbAndroidScheme, SIGNAL(toggled(bool)), androidAction, SIGNAL(toggled(bool)));
    func->toggle(androidAction, boost::bind(&TaskPanelView::on_rbAndroidScheme_toggled, this, _1));
    }
#else
    setWindowTitle(QLatin1String("Task View"));

    QGridLayout* gridLayout = new QGridLayout(this);
    iisTaskPanel *taskPanel = new iisTaskPanel(this);
    iisTaskBox *tb1 = new iisTaskBox(
        QPixmap(QString::fromLatin1(":/icons/document-save.svg")),QLatin1String("Expandable Group"),true, this);
    taskPanel->addWidget(tb1);
    gridLayout->addWidget(taskPanel, 0, 0, 2, 1);

    iisIconLabel *i1 = new iisIconLabel(
        Gui::BitmapFactory().iconFromTheme("document-new"), QLatin1String("Create new file"), tb1);
    tb1->addIconLabel(i1);
    connect(i1, SIGNAL(activated()), action, SIGNAL(triggered()));

    iisIconLabel *i2 = new iisIconLabel(
        Gui::BitmapFactory().iconFromTheme("document-open"), QLatin1String("Load a file"), tb1);
    tb1->addIconLabel(i2);
    connect(i2, SIGNAL(activated()), action, SIGNAL(triggered()));

    tb1->groupLayout()->addWidget(new QPushButton(QLatin1String("Just a button"), this));

    iisIconLabel *i3 = new iisIconLabel(
        Gui::BitmapFactory().iconFromTheme("document-save"), QLatin1String("Save current file"), tb1);
    tb1->addIconLabel(i3);

    iisIconLabel *i4 = new iisIconLabel(
        Gui::BitmapFactory().iconFromTheme("document-print"), QLatin1String("Print file contents"), tb1);
    tb1->addIconLabel(i4);
    i4->setColors(Qt::red, Qt::green, Qt::gray);
    i4->setFocusPen(QPen());

    tb1->groupLayout()->addWidget(new QPushButton(QLatin1String("Just another button"), this));

    iisTaskBox *tb2 = new iisTaskBox(
        Gui::BitmapFactory().pixmap("edit-redo"), QLatin1String("Non-expandable Group"), false, this);
    taskPanel->addWidget(tb2);

    iisIconLabel *i21 = new iisIconLabel(
        Gui::BitmapFactory().iconFromTheme("document-new"), QLatin1String("Create new file"), tb2);
    tb2->addIconLabel(i21);

    iisIconLabel *i22 = new iisIconLabel(
        Gui::BitmapFactory().iconFromTheme("document-open"), QLatin1String("Load a file"), tb2);
    tb2->addIconLabel(i22);

    iisIconLabel *i23 = new iisIconLabel(
        Gui::BitmapFactory().iconFromTheme("document-save"), QLatin1String("Save current file"), tb2);
    tb2->addIconLabel(i23);
    i23->setEnabled(false);

    iisIconLabel *i24 = new iisIconLabel(
        Gui::BitmapFactory().iconFromTheme("document-print"), QLatin1String("Print file contents"), tb2);
    tb2->addIconLabel(i24);


    // Other widgets can be also added to the panel
    QLabel *l1 = new QLabel(QLatin1String("Action Group without header"), this);
    taskPanel->addWidget(l1);

    iisTaskGroup *tb3 = new iisTaskGroup(this);
    taskPanel->addWidget(tb3);

    iisIconLabel *i31 = new iisIconLabel(
        Gui::BitmapFactory().iconFromTheme("document-new"), QLatin1String("Create new file"), tb3);
    tb3->addIconLabel(i31);

    QHBoxLayout *hb3 = new QHBoxLayout();
    tb3->groupLayout()->addLayout(hb3);

    iisIconLabel *i32 = new iisIconLabel(
        Gui::BitmapFactory().iconFromTheme("document-open"), QLatin1String("Load a file"), tb3);
    tb3->addIconLabel(i32);
    hb3->addWidget(i32);

    iisIconLabel *i33 = new iisIconLabel(
        Gui::BitmapFactory().iconFromTheme("document-save"), QLatin1String("Save current file"), tb3);
    tb3->addIconLabel(i33);
    i33->setDisabled(true);
    hb3->addWidget(i33);

    iisIconLabel *i34 = new iisIconLabel(
        Gui::BitmapFactory().iconFromTheme("document-print"), QLatin1String("Print file contents"), tb3);
    tb3->addIconLabel(i34);

    taskPanel->addStretch();
    taskPanel->setScheme(iisWinXPTaskPanelScheme::defaultScheme());
    tb1->setScheme(iisWinXPTaskPanelScheme::defaultScheme());
    tb2->setScheme(iisWinXPTaskPanelScheme2::defaultScheme());
    tb3->setScheme(iisTaskPanelScheme::defaultScheme());
#endif
}
Пример #13
0
    void setupUi(QWidget *MainWindow)
    {
        MainWindow->resize(642, 850);
        QSizePolicy sizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
        sizePolicy.setHorizontalStretch(0);
        sizePolicy.setVerticalStretch(0);
        sizePolicy.setHeightForWidth(MainWindow->sizePolicy().hasHeightForWidth());
        MainWindow->setSizePolicy(sizePolicy);
        MainWindow->setStyleSheet(QString::fromUtf8("\n"
"SandboxGui--TaskPanelView {\n"
"	background-color: green;\n"
"}\n"
""));
        verticalLayout = new QVBoxLayout(MainWindow);
        verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
        verticalLayout_3 = new QVBoxLayout();
        verticalLayout_3->setObjectName(QString::fromUtf8("verticalLayout_3"));
        label = new QLabel(MainWindow);
        label->setObjectName(QString::fromUtf8("label"));
        QSizePolicy sizePolicy1(QSizePolicy::Preferred, QSizePolicy::Maximum);
        sizePolicy1.setHorizontalStretch(0);
        sizePolicy1.setVerticalStretch(0);
        sizePolicy1.setHeightForWidth(label->sizePolicy().hasHeightForWidth());
        label->setSizePolicy(sizePolicy1);

        verticalLayout_3->addWidget(label);

        line_2 = new QFrame(MainWindow);
        line_2->setObjectName(QString::fromUtf8("line_2"));
        line_2->setFrameShape(QFrame::HLine);
        line_2->setFrameShadow(QFrame::Sunken);

        verticalLayout_3->addWidget(line_2);


        verticalLayout->addLayout(verticalLayout_3);

        gridLayout_2 = new QGridLayout();
        gridLayout_2->setObjectName(QString::fromUtf8("gridLayout_2"));
        ActionBox1 = new QSint::ActionBox(MainWindow);
        ActionBox1->setObjectName(QString::fromUtf8("ActionBox1"));
        ActionBox1->setFrameShape(QFrame::StyledPanel);
        ActionBox1->setFrameShadow(QFrame::Raised);

        gridLayout_2->addWidget(ActionBox1, 0, 0, 1, 1);

        ActionBox2 = new QSint::ActionBox(MainWindow);
        ActionBox2->setObjectName(QString::fromUtf8("ActionBox2"));
        ActionBox2->setFrameShape(QFrame::StyledPanel);
        ActionBox2->setFrameShadow(QFrame::Raised);

        gridLayout_2->addWidget(ActionBox2, 1, 0, 1, 1);

        verticalSpacer = new QSpacerItem(94, 28, QSizePolicy::Minimum, QSizePolicy::Minimum);

        gridLayout_2->addItem(verticalSpacer, 3, 0, 1, 1);

        ActionBox3 = new QSint::ActionBox(MainWindow);
        ActionBox3->setObjectName(QString::fromUtf8("ActionBox3"));
        ActionBox3->setFrameShape(QFrame::StyledPanel);
        ActionBox3->setFrameShadow(QFrame::Raised);

        gridLayout_2->addWidget(ActionBox3, 0, 1, 1, 1);

        ActionBox4 = new QSint::ActionBox(MainWindow);
        ActionBox4->setObjectName(QString::fromUtf8("ActionBox4"));
        ActionBox4->setFrameShape(QFrame::StyledPanel);
        ActionBox4->setFrameShadow(QFrame::Raised);

        gridLayout_2->addWidget(ActionBox4, 1, 1, 1, 1);

        ActionBox5 = new Gui::TaskView::TaskGroup(MainWindow);
        ActionBox5->setObjectName(QString::fromUtf8("ActionBox5"));
        ActionBox5->setFrameShape(QFrame::StyledPanel);
        ActionBox5->setFrameShadow(QFrame::Raised);

        gridLayout_2->addWidget(ActionBox5, 2, 1, 1, 1);

        verticalLayout->addLayout(gridLayout_2);

        verticalLayout_4 = new QVBoxLayout();
        verticalLayout_4->setObjectName(QString::fromUtf8("verticalLayout_4"));
        label_2 = new QLabel(MainWindow);
        label_2->setObjectName(QString::fromUtf8("label_2"));
        sizePolicy1.setHeightForWidth(label_2->sizePolicy().hasHeightForWidth());
        label_2->setSizePolicy(sizePolicy1);

        verticalLayout_4->addWidget(label_2);

        line = new QFrame(MainWindow);
        line->setObjectName(QString::fromUtf8("line"));
        line->setFrameShape(QFrame::HLine);
        line->setFrameShadow(QFrame::Sunken);

        verticalLayout_4->addWidget(line);


        verticalLayout->addLayout(verticalLayout_4);

        verticalLayout_2 = new QVBoxLayout();
        verticalLayout_2->setObjectName(QString::fromUtf8("verticalLayout_2"));
        ActionLabel1 = new QSint::ActionLabel(MainWindow);
        ActionLabel1->setObjectName(QString::fromUtf8("ActionLabel1"));
        QSizePolicy sizePolicy2(QSizePolicy::Preferred, QSizePolicy::Fixed);
        sizePolicy2.setHorizontalStretch(0);
        sizePolicy2.setVerticalStretch(0);
        sizePolicy2.setHeightForWidth(ActionLabel1->sizePolicy().hasHeightForWidth());
        ActionLabel1->setSizePolicy(sizePolicy2);

        verticalLayout_2->addWidget(ActionLabel1);

        ActionLabel2 = new QSint::ActionLabel(MainWindow);
        ActionLabel2->setObjectName(QString::fromUtf8("ActionLabel2"));
        sizePolicy2.setHeightForWidth(ActionLabel2->sizePolicy().hasHeightForWidth());
        ActionLabel2->setSizePolicy(sizePolicy2);
        QIcon icon;
        icon.addFile(QString::fromUtf8(":/icons/document-open.svg"), QSize(), QIcon::Normal, QIcon::Off);
        ActionLabel2->setIcon(icon);

        verticalLayout_2->addWidget(ActionLabel2);

        ActionLabel3 = new QSint::ActionLabel(MainWindow);
        ActionLabel3->setObjectName(QString::fromUtf8("ActionLabel3"));
        sizePolicy2.setHeightForWidth(ActionLabel3->sizePolicy().hasHeightForWidth());
        ActionLabel3->setSizePolicy(sizePolicy2);
        QIcon icon1;
        icon1.addFile(QString::fromUtf8(":/icons/document-print.svg"), QSize(), QIcon::Normal, QIcon::Off);
        ActionLabel3->setIcon(icon1);

        verticalLayout_2->addWidget(ActionLabel3);


        verticalLayout->addLayout(verticalLayout_2);


        retranslateUi(MainWindow);
    } // setupUi
Пример #14
0
void QgsMessageBarItem::writeContent()
{
  if ( mLayout == 0 )
  {
    mLayout = new QHBoxLayout( this );
    mLayout->setContentsMargins( 0, 0, 0, 0 );
    mTextEdit = 0;
    mLblIcon = 0;
  }

  // ICON
  if ( mLblIcon == 0 )
  {
    mLblIcon = new QLabel( this );
    mLayout->addWidget( mLblIcon );
  }
  QIcon icon;
  if ( !mUserIcon.isNull() )
  {
    icon = mUserIcon;
  }
  else
  {
    QString msgIcon( "/mIconInfo.png" );
    switch ( mLevel )
    {
      case QgsMessageBar::CRITICAL:
        msgIcon = QString( "/mIconCritical.png" );
        break;
      case QgsMessageBar::WARNING:
        msgIcon = QString( "/mIconWarn.png" );
        break;
      case QgsMessageBar::SUCCESS:
        msgIcon = QString( "/mIconSuccess.png" );
        break;
      default:
        break;
    }
    icon = QgsApplication::getThemeIcon( msgIcon );
  }
  mLblIcon->setPixmap( icon.pixmap( 24 ) );

  // TITLE AND TEXT
  if ( mTitle.isEmpty() && mText.isEmpty() )
  {
    if ( mTextEdit != 0 )
    {
      delete mTextEdit;
      mTextEdit = 0;
    }
  }
  else
  {
    if ( mTextEdit == 0 )
    {
      mTextEdit = new QTextEdit( this );
      mTextEdit->setObjectName( "textEdit" );
      mTextEdit->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Maximum );
      mTextEdit->setReadOnly( true );
      mTextEdit->setFrameShape( QFrame::NoFrame );
      // stylesheet set here so Qt-style substitued scrollbar arrows can show within limited height
      // adjusts to height of font set in app options
      mTextEdit->setStyleSheet( "QTextEdit { background-color: rgba(0,0,0,0); margin-top: 0.25em; max-height: 1.75em; min-height: 1.75em; } "
                                "QScrollBar { background-color: rgba(0,0,0,0); } "
                                "QScrollBar::add-page,QScrollBar::sub-page,QScrollBar::handle { background-color: rgba(0,0,0,0); color: rgba(0,0,0,0); } "
                                "QScrollBar::up-arrow,QScrollBar::down-arrow { color: rgb(0,0,0); } " );
      mLayout->addWidget( mTextEdit );
    }
    QString content = mText;
    if ( !mTitle.isEmpty() )
    {
      // add ':' to end of title
      QString t = mTitle.trimmed();
      if ( !content.isEmpty() && !t.endsWith( ':' ) && !t.endsWith( ": " ) )
        t += ": ";
      content.prepend( QLatin1String( "<b>" ) + t + " </b>" );
    }
    mTextEdit->setText( content );
  }

  // WIDGET
  if ( mWidget != 0 )
  {
    QLayoutItem *item = mLayout->itemAt( 2 );
    if ( !item || item->widget() != mWidget )
    {
      mLayout->addWidget( mWidget );
    }
  }

  // STYLESHEET
  if ( mLevel == QgsMessageBar::SUCCESS )
  {
    mStyleSheet = "QgsMessageBar { background-color: #dff0d8; border: 1px solid #8e998a; } "
                  "QLabel,QTextEdit { color: black; } ";
  }
  else if ( mLevel == QgsMessageBar::CRITICAL )
  {
    mStyleSheet = "QgsMessageBar { background-color: #d65253; border: 1px solid #9b3d3d; } "
                  "QLabel,QTextEdit { color: white; } ";
  }
  else if ( mLevel == QgsMessageBar::WARNING )
  {
    mStyleSheet = "QgsMessageBar { background-color: #ffc800; border: 1px solid #e0aa00; } "
                  "QLabel,QTextEdit { color: black; } ";
  }
  else if ( mLevel == QgsMessageBar::INFO )
  {
    mStyleSheet = "QgsMessageBar { background-color: #e7f5fe; border: 1px solid #b9cfe4; } "
                  "QLabel,QTextEdit { color: #2554a1; } ";
  }
  mStyleSheet += "QLabel#mItemCount { font-style: italic; }";
}
Пример #15
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindowClass)
{
    ui->setupUi(this);
    ui->view->setScrollBar( ui->scroll );

	QIcon icon = QIcon(":/icons/icons/cr3.png");
	CRLog::warn("\n\n\n*** ######### application icon %s\n\n\n", icon.isNull() ? "null" : "found");
	qApp->setWindowIcon(icon);

    addAction(ui->actionOpen);
    addAction(ui->actionRecentBooks);
    addAction(ui->actionTOC);
    addAction(ui->actionToggle_Full_Screen);
    addAction(ui->actionSettings);
    addAction(ui->actionClose);
    addAction(ui->actionToggle_Pages_Scroll);
    addAction(ui->actionMinimize);
    addAction(ui->actionNextPage);
    addAction(ui->actionPrevPage);
    addAction(ui->actionNextPage2);
    addAction(ui->actionPrevPage2);
    addAction(ui->actionNextPage3);
    addAction(ui->actionNextLine);
    addAction(ui->actionPrevLine);
    addAction(ui->actionFirstPage);
    addAction(ui->actionLastPage);
    addAction(ui->actionBack);
    addAction(ui->actionForward);
    addAction(ui->actionNextChapter);
    addAction(ui->actionPrevChapter);
    addAction(ui->actionZoom_In);
    addAction(ui->actionZoom_Out);
    addAction(ui->actionCopy);
    addAction(ui->actionCopy2); // alternative shortcut
    addAction(ui->actionAddBookmark);
    addAction(ui->actionShowBookmarksList);
    addAction(ui->actionToggleEditMode);
    addAction(ui->actionNextSentence);
    addAction(ui->actionPrevSentence);

#ifdef _LINUX
    QString homeDir = QDir::toNativeSeparators(QDir::homePath() + "/.cr3/");
#else
    QString homeDir = QDir::toNativeSeparators(QDir::homePath() + "/cr3/");
#endif
#ifdef _LINUX
    QString exeDir = QString(CR3_DATA_DIR);
#else
    QString exeDir = QDir::toNativeSeparators(qApp->applicationDirPath() + "/"); //QDir::separator();
#endif
    QString cacheDir = homeDir + "cache";
    QString bookmarksDir = homeDir + "bookmarks";
    QString histFile = exeDir + "cr3hist.bmk";
    QString histFile2 = homeDir + "cr3hist.bmk";
    QString iniFile2 = exeDir + "cr3.ini";
    QString iniFile = homeDir + "cr3.ini";
    QString cssFile = homeDir + "fb2.css";
    QString cssFile2 = exeDir + "fb2.css";
    //QString translations = exeDir + "i18n";
    //CRLog::info("Translations directory: %s", LCSTR(qt2cr(translations)) );
    QString hyphDir = exeDir + "hyph" + QDir::separator();
    ui->view->setHyphDir(hyphDir);
    ui->view->setHyphDir(homeDir + "hyph" + QDir::separator(), false);

    ldomDocCache::init( qt2cr( cacheDir ), DOC_CACHE_SIZE );
    ui->view->setPropsChangeCallback( this );
    if ( !ui->view->loadSettings( iniFile ) )
        ui->view->loadSettings( iniFile2 );
    if ( !ui->view->loadHistory( histFile ) )
        ui->view->loadHistory( histFile2 );
    if ( !ui->view->loadCSS( cssFile ) )
        ui->view->loadCSS( cssFile2 );
#if ENABLE_BOOKMARKS_DIR==1
    ui->view->setBookmarksDir( bookmarksDir );
#endif
    QStringList args( qApp->arguments() );
    for ( int i=1; i<args.length(); i++ ) {
        if ( args[i].startsWith("--") ) {
            // option
        } else {
            // filename to open
            if ( _filenameToOpen.length()==0 )
                _filenameToOpen = args[i];
        }
    }

//     QTranslator qtTranslator;
//     if (qtTranslator.load("qt_" + QLocale::system().name(),
//             QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
//        QApplication::installTranslator(&qtTranslator);
//
//     QTranslator myappTranslator;
//     QString trname = "cr3_" + QLocale::system().name();
//     CRLog::info("Using translation file %s from dir %s", UnicodeToUtf8(qt2cr(trname)).c_str(), UnicodeToUtf8(qt2cr(translations)).c_str() );
//     if ( myappTranslator.load(trname, translations) )
//         QApplication::installTranslator(&myappTranslator);
    ui->view->restoreWindowPos( this, "main.", true );
}
Пример #16
0
void
KnobGuiString::createWidget(QHBoxLayout* layout)
{
    boost::shared_ptr<KnobString> knob = _knob.lock();

    if ( knob->isMultiLine() ) {
        _container = new QWidget( layout->parentWidget() );
        _mainLayout = new QVBoxLayout(_container);
        _mainLayout->setContentsMargins(0, 0, 0, 0);
        _mainLayout->setSpacing(0);

        bool useRichText = knob->usesRichText();
        _textEdit = new AnimatingTextEdit(shared_from_this(), 0, _container);
        _textEdit->setAcceptRichText(useRichText);


        _mainLayout->addWidget(_textEdit);

        QObject::connect( _textEdit, SIGNAL(editingFinished()), this, SLOT(onTextChanged()) );
        // layout->parentWidget()->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
        _textEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

        ///set the copy/link actions in the right click menu
        enableRightClickMenu(_textEdit, 0);

        if ( knob->isCustomHTMLText() ) {
            _textEdit->setReadOnlyNatron(true);
        }

        if (useRichText) {
            _richTextOptions = new QWidget(_container);
            _richTextOptionsLayout = new QHBoxLayout(_richTextOptions);
            _richTextOptionsLayout->setContentsMargins(0, 0, 0, 0);
            _richTextOptionsLayout->setSpacing(8);

            _fontCombo = new QFontComboBox(_richTextOptions);
            _fontCombo->setCurrentFont( QApplication::font() );
            _fontCombo->setToolTip( GuiUtils::convertFromPlainText(tr("Font."), Qt::WhiteSpaceNormal) );
            _richTextOptionsLayout->addWidget(_fontCombo);

            _fontSizeSpinBox = new SpinBox(_richTextOptions);
            _fontSizeSpinBox->setMinimum(1);
            _fontSizeSpinBox->setMaximum(100);
            _fontSizeSpinBox->setValue(6);
            QObject::connect( _fontSizeSpinBox, SIGNAL(valueChanged(double)), this, SLOT(onFontSizeChanged(double)) );
            _fontSizeSpinBox->setToolTip( GuiUtils::convertFromPlainText(tr("Font size."), Qt::WhiteSpaceNormal) );
            _richTextOptionsLayout->addWidget(_fontSizeSpinBox);

            QPixmap pixBoldChecked, pixBoldUnchecked, pixItalicChecked, pixItalicUnchecked;
            appPTR->getIcon(NATRON_PIXMAP_BOLD_CHECKED, &pixBoldChecked);
            appPTR->getIcon(NATRON_PIXMAP_BOLD_UNCHECKED, &pixBoldUnchecked);
            appPTR->getIcon(NATRON_PIXMAP_ITALIC_CHECKED, &pixItalicChecked);
            appPTR->getIcon(NATRON_PIXMAP_ITALIC_UNCHECKED, &pixItalicUnchecked);
            QIcon boldIcon;
            boldIcon.addPixmap(pixBoldChecked, QIcon::Normal, QIcon::On);
            boldIcon.addPixmap(pixBoldUnchecked, QIcon::Normal, QIcon::Off);
            _setBoldButton = new Button(boldIcon, QString(), _richTextOptions);
            _setBoldButton->setIconSize( QSize(NATRON_MEDIUM_BUTTON_ICON_SIZE, NATRON_MEDIUM_BUTTON_ICON_SIZE) );
            _setBoldButton->setCheckable(true);
            _setBoldButton->setToolTip( GuiUtils::convertFromPlainText(tr("Bold."), Qt::WhiteSpaceNormal) );
            _setBoldButton->setMaximumSize(18, 18);
            QObject::connect( _setBoldButton, SIGNAL(clicked(bool)), this, SLOT(boldChanged(bool)) );
            _richTextOptionsLayout->addWidget(_setBoldButton);

            QIcon italicIcon;
            italicIcon.addPixmap(pixItalicChecked, QIcon::Normal, QIcon::On);
            italicIcon.addPixmap(pixItalicUnchecked, QIcon::Normal, QIcon::Off);

            _setItalicButton = new Button(italicIcon, QString(), _richTextOptions);
            _setItalicButton->setCheckable(true);
            _setItalicButton->setIconSize( QSize(NATRON_MEDIUM_BUTTON_ICON_SIZE, NATRON_MEDIUM_BUTTON_ICON_SIZE) );
            _setItalicButton->setToolTip( GuiUtils::convertFromPlainText(tr("Italic."), Qt::WhiteSpaceNormal) );
            _setItalicButton->setMaximumSize(18, 18);
            QObject::connect( _setItalicButton, SIGNAL(clicked(bool)), this, SLOT(italicChanged(bool)) );
            _richTextOptionsLayout->addWidget(_setItalicButton);

            QPixmap pixBlack(15, 15);
            pixBlack.fill(Qt::black);
            _fontColorButton = new Button(QIcon(pixBlack), QString(), _richTextOptions);
            _fontColorButton->setCheckable(false);
            _fontColorButton->setIconSize( QSize(NATRON_MEDIUM_BUTTON_ICON_SIZE, NATRON_MEDIUM_BUTTON_ICON_SIZE) );
            _fontColorButton->setToolTip( GuiUtils::convertFromPlainText(tr("Font color."), Qt::WhiteSpaceNormal) );
            _fontColorButton->setMaximumSize(18, 18);
            QObject::connect( _fontColorButton, SIGNAL(clicked(bool)), this, SLOT(colorFontButtonClicked()) );
            _richTextOptionsLayout->addWidget(_fontColorButton);

            _richTextOptionsLayout->addStretch();

            _mainLayout->addWidget(_richTextOptions);

            restoreTextInfoFromString();

            ///Connect the slot after restoring
            QObject::connect( _fontCombo, SIGNAL(currentFontChanged(QFont)), this, SLOT(onCurrentFontChanged(QFont)) );
        }

        layout->addWidget(_container);
    } else if ( knob->isLabel() ) {
Пример #17
0
void BitcoinGUI::createActions()
{
    QActionGroup *tabGroup = new QActionGroup(this);

    //const QSize& iconsize = new QSize(64,64);

//    overviewAction = new QAction(QIcon(":/icons/overview"), tr("&My Wallet"), this);
    QIcon overviewIcon;
    overviewIcon.addFile(":/icons/grey_overview", QSize(), QIcon::Normal, QIcon::Off);
    overviewIcon.addFile(":/icons/orange_overview", QSize(), QIcon::Active, QIcon::Off);
    overviewIcon.addFile(":/icons/orange_overview", QSize(), QIcon::Normal, QIcon::On);
    overviewAction = new QAction(overviewIcon, tr("&My Wallet"), this);
    overviewAction->setToolTip(tr("Show general overview of wallet"));
    overviewAction->setCheckable(true);
    overviewAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_1));
    tabGroup->addAction(overviewAction);

//    historyAction = new QAction(QIcon(":/icons/history"), tr("&Transactions"), this);
    QIcon historyIcon;
    historyIcon.addFile(":/icons/grey_transactions", QSize(), QIcon::Normal, QIcon::Off);
    historyIcon.addFile(":/icons/orange_transactions", QSize(), QIcon::Active, QIcon::Off);
    historyIcon.addFile(":/icons/orange_transactions", QSize(), QIcon::Normal, QIcon::On);
    historyAction = new QAction(historyIcon, tr("&Transactions"), this);
    historyAction->setToolTip(tr("Browse transaction history"));
    historyAction->setCheckable(true);
    historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4));
    tabGroup->addAction(historyAction);

//    sendCoinsAction = new QAction(QIcon(":/icons/send"), tr("&Send"), this);
    QIcon sendIcon;
    sendIcon.addFile(":/icons/grey_send", QSize(), QIcon::Normal, QIcon::Off);
    sendIcon.addFile(":/icons/orange_send", QSize(), QIcon::Active, QIcon::Off);
    sendIcon.addFile(":/icons/orange_send", QSize(), QIcon::Normal, QIcon::On);
    sendCoinsAction = new QAction(sendIcon, tr("&Send"), this);
    sendCoinsAction->setToolTip(sendCoinsAction->statusTip());
    sendCoinsAction->setCheckable(true);
    sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2));
    tabGroup->addAction(sendCoinsAction);

//    receiveCoinsAction = new QAction(QIcon(":/icons/receiving_addresses"), tr("&Receive"), this);
    QIcon receiveIcon;
    receiveIcon.addFile(":/icons/grey_receive", QSize(), QIcon::Normal, QIcon::Off);
    receiveIcon.addFile(":/icons/orange_receive", QSize(), QIcon::Active, QIcon::Off);
    receiveIcon.addFile(":/icons/orange_receive", QSize(), QIcon::Normal, QIcon::On);
    receiveCoinsAction = new QAction(receiveIcon, tr("&Receive"), this);
    receiveCoinsAction->setToolTip(tr("Show the list of addresses for receiving payments"));
    receiveCoinsAction->setCheckable(true);
    receiveCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_3));
    tabGroup->addAction(receiveCoinsAction);

//    addressBookAction = new QAction(QIcon(":/icons/address-book"), tr("&Address Book"), this);
    QIcon addressBookIcon;
    addressBookIcon.addFile(":/icons/grey_addressbook", QSize(), QIcon::Normal, QIcon::Off);
    addressBookIcon.addFile(":/icons/orange_addressbook", QSize(), QIcon::Active, QIcon::Off);
    addressBookIcon.addFile(":/icons/orange_addressbook", QSize(), QIcon::Normal, QIcon::On);
    addressBookAction = new QAction(addressBookIcon, tr("&Address Book"), this);
    addressBookAction->setToolTip(tr("Edit the list of stored addresses and labels"));
    addressBookAction->setCheckable(true);
    addressBookAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_5));
    tabGroup->addAction(addressBookAction);

    connect(overviewAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
    connect(overviewAction, SIGNAL(triggered()), this, SLOT(gotoOverviewPage()));
    connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
    connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage()));
    connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
    connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage()));
    connect(historyAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
    connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage()));
    connect(addressBookAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
    connect(addressBookAction, SIGNAL(triggered()), this, SLOT(gotoAddressBookPage()));

    quitAction = new QAction(QIcon(":/icons/quit"), tr("E&xit"), this);
    quitAction->setToolTip(tr("Quit application"));
    quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
    quitAction->setMenuRole(QAction::QuitRole);
    aboutAction = new QAction(QIcon(":/icons/bitcoin"), tr("&About LEOcoin"), this);
    aboutAction->setToolTip(tr("Show information about LEOcoin"));
    aboutAction->setMenuRole(QAction::AboutRole);
    aboutQtAction = new QAction(QIcon(":/trolltech/qmessagebox/images/qtlogo-64.png"), tr("About &Qt"), this);
    aboutQtAction->setToolTip(tr("Show information about Qt"));
    aboutQtAction->setMenuRole(QAction::AboutQtRole);
//    optionsAction = new QAction(QIcon(":/icons/options"), tr("&Options..."), this);
    QIcon optionsIcon;
    optionsIcon.addFile(":/icons/grey_settings", QSize(), QIcon::Normal, QIcon::Off);
    optionsIcon.addFile(":/icons/orange_settings", QSize(), QIcon::Active, QIcon::Off);
    optionsIcon.addFile(":/icons/orange_settings", QSize(), QIcon::Normal, QIcon::On);
    optionsAction = new QAction(optionsIcon, tr("&Options..."), this);
    optionsAction->setToolTip(tr("Modify configuration options for LEOcoin"));
    optionsAction->setMenuRole(QAction::PreferencesRole);
    toggleHideAction = new QAction(QIcon(":/icons/bitcoin"), tr("&Show / Hide"), this);
    encryptWalletAction = new QAction(QIcon(":/icons/lock_closed"), tr("&Encrypt Wallet..."), this);
    encryptWalletAction->setToolTip(tr("Encrypt or decrypt wallet"));
    encryptWalletAction->setCheckable(true);
    backupWalletAction = new QAction(QIcon(":/icons/filesave"), tr("&Backup Wallet..."), this);
    backupWalletAction->setToolTip(tr("Backup wallet to another location"));
    changePassphraseAction = new QAction(QIcon(":/icons/key"), tr("&Change Passphrase..."), this);
    changePassphraseAction->setToolTip(tr("Change the passphrase used for wallet encryption"));
    signMessageAction = new QAction(QIcon(":/icons/edit"), tr("Sign &message..."), this);
    verifyMessageAction = new QAction(QIcon(":/icons/transaction_0"), tr("&Verify message..."), this);

//    exportAction = new QAction(QIcon(":/icons/export"), tr("&Export..."), this);
    QIcon exportIcon;
    exportIcon.addFile(":/icons/grey_export", QSize(), QIcon::Normal, QIcon::Off);
    exportIcon.addFile(":/icons/orange_export", QSize(), QIcon::Active, QIcon::Off);
    exportIcon.addFile(":/icons/orange_export", QSize(), QIcon::Normal, QIcon::On);
    exportAction = new QAction(exportIcon, tr("&Export..."), this);
    exportAction->setToolTip(tr("Export the data in the current tab to a file"));
    openRPCConsoleAction = new QAction(QIcon(":/icons/debugwindow"), tr("&Debug window"), this);
    openRPCConsoleAction->setToolTip(tr("Open debugging and diagnostic console"));

    connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
    connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked()));
    connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
    connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked()));
    connect(toggleHideAction, SIGNAL(triggered()), this, SLOT(toggleHidden()));
    connect(encryptWalletAction, SIGNAL(triggered(bool)), this, SLOT(encryptWallet(bool)));
    connect(backupWalletAction, SIGNAL(triggered()), this, SLOT(backupWallet()));
    connect(changePassphraseAction, SIGNAL(triggered()), this, SLOT(changePassphrase()));
    connect(signMessageAction, SIGNAL(triggered()), this, SLOT(gotoSignMessageTab()));
    connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(gotoVerifyMessageTab()));
}
Пример #18
0
// Draws a cached pixmap with shadow
void StyleHelper::drawIconWithShadow(const QIcon& icon, const QRect& rect,
                                     QPainter* p, QIcon::Mode iconMode,
                                     int radius, const QColor& color,
                                     const QPoint& offset) {
  QPixmap cache;
  QString pixmapName =
      QString("icon %0 %1 %2").arg(icon.cacheKey()).arg(iconMode).arg(
          rect.height());

  if (!QPixmapCache::find(pixmapName, cache)) {
    QPixmap px = icon.pixmap(rect.size());
    cache = QPixmap(px.size() + QSize(radius * 2, radius * 2));
    cache.fill(Qt::transparent);

    QPainter cachePainter(&cache);
    if (iconMode == QIcon::Disabled) {
      QImage im = px.toImage().convertToFormat(QImage::Format_ARGB32);
      for (int y = 0; y < im.height(); ++y) {
        QRgb* scanLine = (QRgb*)im.scanLine(y);
        for (int x = 0; x < im.width(); ++x) {
          QRgb pixel = *scanLine;
          char intensity = qGray(pixel);
          *scanLine = qRgba(intensity, intensity, intensity, qAlpha(pixel));
          ++scanLine;
        }
      }
      px = QPixmap::fromImage(im);
    }

    // Draw shadow
    QImage tmp(px.size() + QSize(radius * 2, radius * 2 + 1),
               QImage::Format_ARGB32_Premultiplied);
    tmp.fill(Qt::transparent);

    QPainter tmpPainter(&tmp);
    tmpPainter.setCompositionMode(QPainter::CompositionMode_Source);
    tmpPainter.drawPixmap(QPoint(radius, radius), px);
    tmpPainter.end();

    // blur the alpha channel
    QImage blurred(tmp.size(), QImage::Format_ARGB32_Premultiplied);
    blurred.fill(Qt::transparent);
    QPainter blurPainter(&blurred);
    qt_blurImage(&blurPainter, tmp, radius, false, true);
    blurPainter.end();

    tmp = blurred;

    // blacken the image...
    tmpPainter.begin(&tmp);
    tmpPainter.setCompositionMode(QPainter::CompositionMode_SourceIn);
    tmpPainter.fillRect(tmp.rect(), color);
    tmpPainter.end();

    tmpPainter.begin(&tmp);
    tmpPainter.setCompositionMode(QPainter::CompositionMode_SourceIn);
    tmpPainter.fillRect(tmp.rect(), color);
    tmpPainter.end();

    // draw the blurred drop shadow...
    cachePainter.drawImage(
        QRect(0, 0, cache.rect().width(), cache.rect().height()), tmp);

    // Draw the actual pixmap...
    cachePainter.drawPixmap(QPoint(radius, radius) + offset, px);
    QPixmapCache::insert(pixmapName, cache);
  }

  QRect targetRect = cache.rect();
  targetRect.moveCenter(rect.center());
  p->drawPixmap(targetRect.topLeft() - offset, cache);
}
Пример #19
0
QVariant QgsReportSectionModel::data( const QModelIndex &index, int role ) const
{
  if ( !index.isValid() )
    return QVariant();

  QgsAbstractReportSection *section = sectionForIndex( index );
  if ( !section )
    return QVariant();

  switch ( role )
  {
    case Qt::DisplayRole:
    case Qt::ToolTipRole:
    {
      switch ( index.column() )
      {
        case 0:
          return section->description();
        default:
          return QVariant();
      }
      break;
    }

    case Qt::DecorationRole:
      switch ( index.column() )
      {
        case 0:
        {
          QIcon icon = section->icon();

          if ( section == mEditedSection )
          {
            const int iconSize = QgsGuiUtils::scaleIconSize( 16 );
            QPixmap pixmap( icon.pixmap( iconSize, iconSize ) );

            QPainter painter( &pixmap );
            painter.drawPixmap( 0, 0, iconSize, iconSize, QgsApplication::getThemePixmap( QStringLiteral( "/mActionToggleEditing.svg" ) ) );
            painter.end();

            return QIcon( pixmap );
          }
          else
          {
            return icon;
          }
        }

        default:
          return QVariant();
      }
      break;

    case Qt::TextAlignmentRole:
    {
      return ( index.column() == 2 || index.column() == 3 ) ? Qt::AlignRight : Qt::AlignLeft;
    }

    case Qt::EditRole:
    {
      switch ( index.column() )
      {
        case 0:
          return section->type();

        default:
          return QVariant();
      }
      break;
    }

    default:
      return QVariant();
  }

  return QVariant();
}
Пример #20
0
AudioChatWidgetHolder::AudioChatWidgetHolder(ChatWidget *chatWidget)
	: QObject(), ChatWidgetHolder(chatWidget)
{
	audioListenToggleButton = new QToolButton ;
	audioListenToggleButton->setMinimumSize(QSize(28,28)) ;
	audioListenToggleButton->setMaximumSize(QSize(28,28)) ;
	audioListenToggleButton->setText(QString()) ;
	audioListenToggleButton->setToolTip(tr("Mute yourself"));

	std::cerr << "****** VOIPLugin: Creating new AudioChatWidgetHolder !!" << std::endl;

	QIcon icon ;
	icon.addPixmap(QPixmap(":/images/audio-volume-muted-22.png")) ;
	icon.addPixmap(QPixmap(":/images/audio-volume-medium-22.png"),QIcon::Normal,QIcon::On) ;
	icon.addPixmap(QPixmap(":/images/audio-volume-medium-22.png"),QIcon::Disabled,QIcon::On) ;
	icon.addPixmap(QPixmap(":/images/audio-volume-medium-22.png"),QIcon::Active,QIcon::On) ;
	icon.addPixmap(QPixmap(":/images/audio-volume-medium-22.png"),QIcon::Selected,QIcon::On) ;

	audioListenToggleButton->setIcon(icon) ;
	audioListenToggleButton->setIconSize(QSize(22,22)) ;
	audioListenToggleButton->setAutoRaise(true) ;
	audioListenToggleButton->setCheckable(true);

	audioMuteCaptureToggleButton = new QToolButton ;
	audioMuteCaptureToggleButton->setMinimumSize(QSize(28,28)) ;
	audioMuteCaptureToggleButton->setMaximumSize(QSize(28,28)) ;
	audioMuteCaptureToggleButton->setText(QString()) ;
	audioMuteCaptureToggleButton->setToolTip(tr("Start Call"));

	QIcon icon2 ;
	icon2.addPixmap(QPixmap(":/images/call-start-22.png")) ;
	icon2.addPixmap(QPixmap(":/images/call-hold-22.png"),QIcon::Normal,QIcon::On) ;
	icon2.addPixmap(QPixmap(":/images/call-hold-22.png"),QIcon::Disabled,QIcon::On) ;
	icon2.addPixmap(QPixmap(":/images/call-hold-22.png"),QIcon::Active,QIcon::On) ;
	icon2.addPixmap(QPixmap(":/images/call-hold-22.png"),QIcon::Selected,QIcon::On) ;

	audioMuteCaptureToggleButton->setIcon(icon2) ;
	audioMuteCaptureToggleButton->setIconSize(QSize(22,22)) ;
	audioMuteCaptureToggleButton->setAutoRaise(true) ;
	audioMuteCaptureToggleButton->setCheckable(true) ;
	
	hangupButton = new QToolButton ;
	hangupButton->setIcon(QIcon(":/images/call-stop-22.png")) ;
	hangupButton->setIconSize(QSize(22,22)) ;
	hangupButton->setMinimumSize(QSize(28,28)) ;
	hangupButton->setMaximumSize(QSize(28,28)) ;
	hangupButton->setCheckable(false) ;
	hangupButton->setAutoRaise(true) ;		
	hangupButton->setText(QString()) ;
	hangupButton->setToolTip(tr("Hangup Call"));

	connect(audioListenToggleButton, SIGNAL(clicked()), this , SLOT(toggleAudioListen()));
	connect(audioMuteCaptureToggleButton, SIGNAL(clicked()), this , SLOT(toggleAudioMuteCapture()));
	connect(hangupButton, SIGNAL(clicked()), this , SLOT(hangupCall()));

	mChatWidget->addChatBarWidget(audioListenToggleButton) ;
	mChatWidget->addChatBarWidget(audioMuteCaptureToggleButton) ;
	mChatWidget->addChatBarWidget(hangupButton) ;

	outputProcessor = NULL ;
	outputDevice = NULL ;
	inputProcessor = NULL ;
	inputDevice = NULL ;
}
Пример #21
0
void QgsComposerLegend::drawLayerChildItems( QPainter* p, QStandardItem* layerItem, double& currentYCoord, double& maxXCoord, int layerOpacity )
{
  if ( !layerItem )
  {
    return;
  }

  //Draw all symbols first and the texts after (to find out the x coordinate to have the text aligned)
  QList<double> childYCoords;
  QList<double> realItemHeights;

  double textHeight = fontHeightCharacterMM( mItemFont, QChar( '0' ) );
  double itemHeight = qMax( mSymbolHeight, textHeight );

  double textAlignCoord = 0; //alignment for legend text

  QStandardItem* currentItem;

  int numChildren = layerItem->rowCount();

  for ( int i = 0; i < numChildren; ++i )
  {
    //real symbol height. Can be different from standard height in case of point symbols
    double realSymbolHeight;
    double realItemHeight = itemHeight; //will be adjusted if realSymbolHeight turns out to be larger

    currentYCoord += mSymbolSpace;
    double currentXCoord = mBoxSpace;

    currentItem = layerItem->child( i, 0 );

    if ( !currentItem )
    {
      continue;
    }

    QgsSymbol* symbol = 0;
    QgsComposerSymbolItem* symbolItem = dynamic_cast<QgsComposerSymbolItem*>( currentItem );
    if ( symbolItem )
    {
      symbol = symbolItem->symbol();
    }

    QgsSymbolV2* symbolNg = 0;
    QgsComposerSymbolV2Item* symbolV2Item = dynamic_cast<QgsComposerSymbolV2Item*>( currentItem );
    if ( symbolV2Item )
    {
      symbolNg = symbolV2Item->symbolV2();
    }
    QgsComposerRasterSymbolItem* rasterItem = dynamic_cast<QgsComposerRasterSymbolItem*>( currentItem );

    if ( symbol )  //item with symbol?
    {
      //draw symbol
      drawSymbol( p, symbol, currentYCoord + ( itemHeight - mSymbolHeight ) / 2, currentXCoord, realSymbolHeight, layerOpacity );
      realItemHeight = qMax( realSymbolHeight, itemHeight );
      currentXCoord += mIconLabelSpace;
    }
    else if ( symbolNg ) //item with symbol NG?
    {
      drawSymbolV2( p, symbolNg, currentYCoord + ( itemHeight - mSymbolHeight ) / 2, currentXCoord, realSymbolHeight, layerOpacity );
      realItemHeight = qMax( realSymbolHeight, itemHeight );
      currentXCoord += mIconLabelSpace;
    }
    else if ( rasterItem )
    {
      if ( p )
      {
        p->setBrush( rasterItem->color() );
        p->drawRect( QRectF( currentXCoord, currentYCoord + ( itemHeight - mSymbolHeight ) / 2, mSymbolWidth, mSymbolHeight ) );
      }
      currentXCoord += mSymbolWidth;
      currentXCoord += mIconLabelSpace;
    }
    else //item with icon?
    {
      QIcon symbolIcon = currentItem->icon();
      if ( !symbolIcon.isNull() && p )
      {
        symbolIcon.paint( p, currentXCoord, currentYCoord + ( itemHeight - mSymbolHeight ) / 2, mSymbolWidth, mSymbolHeight );
        currentXCoord += mSymbolWidth;
        currentXCoord += mIconLabelSpace;
      }
    }

    childYCoords.push_back( currentYCoord );
    realItemHeights.push_back( realItemHeight );
    currentYCoord += realItemHeight;
    textAlignCoord = qMax( currentXCoord, textAlignCoord );
  }

  maxXCoord = textAlignCoord;
  for ( int i = 0; i < numChildren; ++i )
  {
    if ( p )
    {
      p->setPen( QColor( 0, 0, 0 ) );
      drawText( p, textAlignCoord, childYCoords.at( i ) + textHeight + ( realItemHeights.at( i ) - textHeight ) / 2, layerItem->child( i, 0 )->text(), mItemFont );
      maxXCoord = qMax( maxXCoord, textAlignCoord + mBoxSpace + textWidthMillimeters( mItemFont,  layerItem->child( i, 0 )->text() ) );
    }
  }
}
Пример #22
0
void
KnobGuiButton::createWidget(QHBoxLayout* layout)
{
    boost::shared_ptr<KnobButton> knob = _knob.lock();
    QString label = QString::fromUtf8( knob->getLabel().c_str() );
    QString onIconFilePath = QString::fromUtf8( knob->getIconLabel(true).c_str() );
    QString offIconFilePath = QString::fromUtf8( knob->getIconLabel(false).c_str() );


    if ( !onIconFilePath.isEmpty() && !QFile::exists(onIconFilePath) ) {
        EffectInstance* isEffect = dynamic_cast<EffectInstance*>( knob->getHolder() );
        if (isEffect) {
            //Prepend the resources path
            QString resourcesPath = QString::fromUtf8( isEffect->getNode()->getPluginResourcesPath().c_str() );
            if ( !resourcesPath.endsWith( QLatin1Char('/') ) ) {
                resourcesPath += QLatin1Char('/');
            }
            onIconFilePath.prepend(resourcesPath);
        }
    }
    if ( !offIconFilePath.isEmpty() && !QFile::exists(offIconFilePath) ) {
        EffectInstance* isEffect = dynamic_cast<EffectInstance*>( knob->getHolder() );
        if (isEffect) {
            //Prepend the resources path
            QString resourcesPath = QString::fromUtf8( isEffect->getNode()->getPluginResourcesPath().c_str() );
            if ( !resourcesPath.endsWith( QLatin1Char('/') ) ) {
                resourcesPath += QLatin1Char('/');
            }
            offIconFilePath.prepend(resourcesPath);
        }
    }

    bool checkable = knob->getIsCheckable();
    QIcon icon;
    QPixmap pixChecked, pixUnchecked;
    if ( !offIconFilePath.isEmpty() ) {
        if ( pixUnchecked.load(offIconFilePath) ) {
            icon.addPixmap(pixUnchecked, QIcon::Normal, QIcon::Off);
        }
    }
    if ( !onIconFilePath.isEmpty() ) {
        if ( pixChecked.load(onIconFilePath) ) {
            icon.addPixmap(pixChecked, QIcon::Normal, QIcon::On);
        }
    }

    if ( !icon.isNull() ) {
        _button = new Button( icon, QString(), layout->parentWidget() );
        _button->setFixedSize(NATRON_MEDIUM_BUTTON_SIZE, NATRON_MEDIUM_BUTTON_SIZE);
        _button->setIconSize( QSize(NATRON_MEDIUM_BUTTON_ICON_SIZE, NATRON_MEDIUM_BUTTON_ICON_SIZE) );
    } else {
        _button = new Button( label, layout->parentWidget() );
    }
    if (checkable) {
        _button->setCheckable(true);
        bool checked = knob->getValue();
        _button->setChecked(checked);
        _button->setDown(checked);
    }
    QObject::connect( _button, SIGNAL(clicked(bool)), this, SLOT(emitValueChanged(bool)) );
    if ( hasToolTip() ) {
        _button->setToolTip( toolTip() );
    }
    layout->addWidget(_button);
} // KnobGuiButton::createWidget
Пример #23
0
QIcon QFileIconProviderPrivate::getMacIcon(const QFileInfo &fi) const
{
    QIcon retIcon;
    QString fileExtension = fi.suffix().toUpper();
    fileExtension.prepend(QLatin1String("."));

    const QString keyBase = QLatin1String("qt_") + fileExtension;

    QPixmap pixmap;
    if (fi.isFile() && !fi.isExecutable() && !fi.isSymLink()) {
        QPixmapCache::find(keyBase + QLatin1String("16"), pixmap);
    }

    if (!pixmap.isNull()) {
        retIcon.addPixmap(pixmap);
        if (QPixmapCache::find(keyBase + QLatin1String("32"), pixmap)) {
            retIcon.addPixmap(pixmap);
            if (QPixmapCache::find(keyBase + QLatin1String("64"), pixmap)) {
                retIcon.addPixmap(pixmap);
                if (QPixmapCache::find(keyBase + QLatin1String("128"), pixmap)) {
                    retIcon.addPixmap(pixmap);
                    return retIcon;
                }
            }
        }
    }


    FSRef macRef;
    OSStatus status = FSPathMakeRef(reinterpret_cast<const UInt8*>(fi.canonicalFilePath().toUtf8().constData()),
                                    &macRef, 0);
    if (status != noErr)
        return retIcon;
    FSCatalogInfo info;
    HFSUniStr255 macName;
    status = FSGetCatalogInfo(&macRef, kIconServicesCatalogInfoMask, &info, &macName, 0, 0);
    if (status != noErr)
        return retIcon;
    IconRef iconRef;
    SInt16 iconLabel;
    status = GetIconRefFromFileInfo(&macRef, macName.length, macName.unicode,
                                    kIconServicesCatalogInfoMask, &info, kIconServicesNormalUsageFlag,
                                    &iconRef, &iconLabel);
    if (status != noErr)
        return retIcon;
    qt_mac_constructQIconFromIconRef(iconRef, 0, &retIcon);
    ReleaseIconRef(iconRef);

    if (fi.isFile() && !fi.isExecutable() && !fi.isSymLink()) {
        pixmap = retIcon.pixmap(16);
        QPixmapCache::insert(keyBase + QLatin1String("16"), pixmap);
        pixmap = retIcon.pixmap(32);
        QPixmapCache::insert(keyBase + QLatin1String("32"), pixmap);
        pixmap = retIcon.pixmap(64);
        QPixmapCache::insert(keyBase + QLatin1String("64"), pixmap);
        pixmap = retIcon.pixmap(128);
        QPixmapCache::insert(keyBase + QLatin1String("128"), pixmap);
    }

    return retIcon;
}
Пример #24
0
void TitleBar::setWindowIcon(const QIcon &pix)
{
    icon->setPixmap(pix.pixmap(24, 24));
}
Пример #25
0
/** Default constructor */
ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::WindowFlags flags)
    : ChatDialog(parent, flags), lobbyId(lid)
{
    /* Invoke Qt Designer generated QObject setup routine */
    ui.setupUi(this);

    lastUpdateListTime = 0;

    //connect(ui.actionChangeNickname, SIGNAL(triggered()), this, SLOT(changeNickname()));
    connect(ui.participantsList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(participantsTreeWidgetCustomPopupMenu(QPoint)));
    connect(ui.participantsList, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(participantsTreeWidgetDoubleClicked(QTreeWidgetItem*,int)));

    int S = QFontMetricsF(font()).height() ;
    ui.participantsList->setIconSize(QSize(1.3*S,1.3*S));

    ui.participantsList->setColumnCount(COLUMN_COUNT);
    ui.participantsList->setColumnWidth(COLUMN_ICON, 1.4*S);
    ui.participantsList->setColumnHidden(COLUMN_ACTIVITY,true);
    ui.participantsList->setColumnHidden(COLUMN_ID,true);

    muteAct = new QAction(QIcon(), tr("Mute participant"), this);
    distantChatAct = new QAction(QIcon(":/images/chat_24.png"), tr("Start private chat"), this);
    sendMessageAct = new QAction(QIcon(":/images/mail_new.png"), tr("Send Message"), this);

    connect(muteAct, SIGNAL(triggered()), this, SLOT(changePartipationState()));
    connect(distantChatAct, SIGNAL(triggered()), this, SLOT(distantChatParticipant()));
    connect(sendMessageAct, SIGNAL(triggered()), this, SLOT(sendMessage()));

    // Add a button to invite friends.
    //
    inviteFriendsButton = new QToolButton ;
    inviteFriendsButton->setMinimumSize(QSize(2*S,2*S)) ;
    inviteFriendsButton->setMaximumSize(QSize(2*S,2*S)) ;
    inviteFriendsButton->setText(QString()) ;
    inviteFriendsButton->setAutoRaise(true) ;
    inviteFriendsButton->setToolTip(tr("Invite friends to this lobby"));

    mParticipantCompareRole = new RSTreeWidgetItemCompareRole;
    mParticipantCompareRole->setRole(0, Qt::UserRole);

    {
        QIcon icon ;
        icon.addPixmap(QPixmap(":/images/edit_add24.png")) ;
        inviteFriendsButton->setIcon(icon) ;
        inviteFriendsButton->setIconSize(QSize(2*S,2*S)) ;
    }

    connect(inviteFriendsButton, SIGNAL(clicked()), this , SLOT(inviteFriends()));

    getChatWidget()->addChatBarWidget(inviteFriendsButton) ;

    RsGxsId current_id;
    rsMsgs->getIdentityForChatLobby(lobbyId, current_id);

    ownIdChooser = new GxsIdChooser() ;
    ownIdChooser->loadIds(IDCHOOSER_ID_REQUIRED,current_id) ;

    QWidgetAction *checkableAction = new QWidgetAction(this);
    checkableAction->setDefaultWidget(ownIdChooser);

    ui.chatWidget->addToolsAction(checkableAction);
    //getChatWidget()->addChatBarWidget(ownIdChooser);



    connect(ownIdChooser,SIGNAL(currentIndexChanged(int)),this,SLOT(changeNickname())) ;

    unsubscribeButton = new QToolButton ;
    unsubscribeButton->setMinimumSize(QSize(2*S,2*S)) ;
    unsubscribeButton->setMaximumSize(QSize(2*S,2*S)) ;
    unsubscribeButton->setText(QString()) ;
    unsubscribeButton->setAutoRaise(true) ;
    unsubscribeButton->setToolTip(tr("Leave this lobby (Unsubscribe)"));

    {
        QIcon icon ;
        icon.addPixmap(QPixmap(":/images/door_in.png")) ;
        unsubscribeButton->setIcon(icon) ;
        unsubscribeButton->setIconSize(QSize(1.5*S,1.5*S)) ;
    }

    /* Initialize splitter */
    ui.splitter->setStretchFactor(0, 1);
    ui.splitter->setStretchFactor(1, 0);

    connect(unsubscribeButton, SIGNAL(clicked()), this , SLOT(leaveLobby()));

    getChatWidget()->addChatBarWidget(unsubscribeButton) ;
}
Пример #26
0
void MainWindow::applySystemIcon(QAction* action, QString path)
{
	QIcon icon = QIcon::fromTheme(path);
	if (!icon.isNull())
		action->setIcon(icon);
}
Пример #27
0
void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
                                 const QModelIndex &index) const
{
    QStyledItemDelegate::paint(painter,option,index);

    if (qvariant_cast<bool>(index.data(AddButton))) {
        QSize hint = sizeHint(option, index);
        QStyleOptionButton opt;
        static_cast<QStyleOption&>(opt) = option;
        // only keep the flags interesting for the button:
        opt.state = QStyle::State_Enabled;
        opt.text = addFolderText();
        opt.rect.setWidth(qMin(opt.rect.width(), hint.width()));
        QApplication::style()->drawControl(QStyle::CE_PushButton, &opt, painter
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
                , option.widget
#endif
            );
        return;
    }

    if (static_cast<const FolderStatusModel *>(index.model())->classify(index) != FolderStatusModel::RootFolder) {
        return;
    }
    painter->save();

    QFont aliasFont = option.font;
    QFont subFont   = option.font;
    QFont errorFont = subFont;
    QFont progressFont = subFont;

    progressFont.setPointSize( subFont.pointSize()-2);
    //font.setPixelSize(font.weight()+);
    aliasFont.setBold(true);
    aliasFont.setPointSize( subFont.pointSize()+2 );

    QFontMetrics subFm( subFont );
    QFontMetrics aliasFm( aliasFont );
    QFontMetrics progressFm( progressFont );

    int aliasMargin = aliasFm.height()/2;
    int margin = subFm.height()/4;

    QIcon statusIcon      = qvariant_cast<QIcon>(index.data(FolderStatusIconRole));
    QString aliasText     = qvariant_cast<QString>(index.data(FolderAliasRole));
    QString pathText      = qvariant_cast<QString>(index.data(FolderPathRole));
    QString remotePath    = qvariant_cast<QString>(index.data(FolderSecondPathRole));
    QStringList errorTexts= qvariant_cast<QStringList>(index.data(FolderErrorMsg));

    int overallPercent    = qvariant_cast<int>(index.data(SyncProgressOverallPercent));
    QString overallString = qvariant_cast<QString>(index.data(SyncProgressOverallString));
    QString itemString    = qvariant_cast<QString>(index.data(SyncProgressItemString));
    int warningCount      = qvariant_cast<int>(index.data(WarningCount));
    bool syncOngoing      = qvariant_cast<bool>(index.data(SyncRunning));

    // QString statusText = qvariant_cast<QString>(index.data(FolderStatus));
    bool syncEnabled = index.data(FolderAccountConnected).toBool();
    // QString syncStatus = syncEnabled? tr( "Enabled" ) : tr( "Disabled" );

    QRect iconRect = option.rect;
    QRect aliasRect = option.rect;

    iconRect.setLeft( option.rect.left() + aliasMargin );
    iconRect.setTop( iconRect.top() + aliasMargin ); // (iconRect.height()-iconsize.height())/2);

    // alias box
    aliasRect.setTop(aliasRect.top() + aliasMargin );
    aliasRect.setBottom(aliasRect.top() + aliasFm.height());
    aliasRect.setRight(aliasRect.right() - aliasMargin );

    // remote directory box
    QRect remotePathRect = aliasRect;
    remotePathRect.setTop(aliasRect.bottom() + margin );
    remotePathRect.setBottom(remotePathRect.top() + subFm.height());

    // local directory box
    QRect localPathRect = remotePathRect;
    localPathRect.setTop( remotePathRect.bottom() + margin );
    localPathRect.setBottom( localPathRect.top() + subFm.height());

    iconRect.setBottom(localPathRect.bottom());
    iconRect.setWidth(iconRect.height());

    int nextToIcon = iconRect.right()+aliasMargin;
    aliasRect.setLeft(nextToIcon);
    localPathRect.setLeft(nextToIcon);
    remotePathRect.setLeft(nextToIcon);

    int iconSize = iconRect.width();

    QPixmap pm = statusIcon.pixmap(iconSize, iconSize, syncEnabled ? QIcon::Normal : QIcon::Disabled );
    painter->drawPixmap(QPoint(iconRect.left(), iconRect.top()), pm);

    // only show the warning icon if the sync is running. Otherwise its
    // encoded in the status icon.
    if( warningCount > 0 && syncOngoing) {
        QRect warnRect;
        warnRect.setLeft(iconRect.left());
        warnRect.setTop(iconRect.bottom()-17);
        warnRect.setWidth(16);
        warnRect.setHeight(16);

        QIcon warnIcon(":/client/resources/warning");
        QPixmap pm = warnIcon.pixmap(16,16, syncEnabled ? QIcon::Normal : QIcon::Disabled );
        painter->drawPixmap(QPoint(warnRect.left(), warnRect.top()),pm );
    }

    auto palette = option.palette;

    if (qApp->style()->inherits("QWindowsVistaStyle")) {
        // Hack: Windows Vista's light blue is not contrasting enough for white

        // (code from QWindowsVistaStyle::drawControl for CE_ItemViewItem)
        palette.setColor(QPalette::All, QPalette::HighlightedText, palette.color(QPalette::Active, QPalette::Text));
        palette.setColor(QPalette::All, QPalette::Highlight, palette.base().color().darker(108));
    }


    QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
                            ? QPalette::Normal : QPalette::Disabled;
    if (cg == QPalette::Normal && !(option.state & QStyle::State_Active))
        cg = QPalette::Inactive;

    if (option.state & QStyle::State_Selected) {
        painter->setPen(palette.color(cg, QPalette::HighlightedText));
    } else {
        painter->setPen(palette.color(cg, QPalette::Text));
    }
    QString elidedAlias = aliasFm.elidedText(aliasText, Qt::ElideRight, aliasRect.width());
    painter->setFont(aliasFont);
    painter->drawText(aliasRect, elidedAlias);

    painter->setFont(subFont);
    QString elidedRemotePathText;

    if (remotePath.isEmpty() || remotePath == QLatin1String("/")) {
        elidedRemotePathText = subFm.elidedText(tr("Syncing all files in your account with"),
                                                Qt::ElideRight, remotePathRect.width());
    } else {
        elidedRemotePathText = subFm.elidedText(tr("Remote path: %1").arg(remotePath),
                                                Qt::ElideMiddle, remotePathRect.width());
    }
    painter->drawText(remotePathRect, elidedRemotePathText);

    QString elidedPathText = subFm.elidedText(pathText, Qt::ElideMiddle, localPathRect.width());
    painter->drawText(localPathRect, elidedPathText);

    // paint an error overlay if there is an error string

    int h = iconRect.bottom();
    if( !errorTexts.isEmpty() ) {
        h += aliasMargin;
        QRect errorRect = localPathRect;
        errorRect.setLeft( iconRect.left());
        errorRect.setTop( h );
        errorRect.setHeight(errorTexts.count() * subFm.height()+aliasMargin);
        errorRect.setRight( option.rect.right()-aliasMargin );

        painter->setBrush( QColor(0xbb, 0x4d, 0x4d) );
        painter->setPen( QColor(0xaa, 0xaa, 0xaa));
        painter->drawRoundedRect( errorRect, 4, 4 );

        painter->setPen( Qt::white );
        painter->setFont(errorFont);
        QRect errorTextRect = errorRect;
        errorTextRect.setLeft( errorTextRect.left()+aliasMargin );
        errorTextRect.setTop( errorTextRect.top()+aliasMargin/2 );

        int x = errorTextRect.left();
        int y = errorTextRect.top()+aliasMargin/2 + subFm.height()/2;

        foreach( QString eText, errorTexts ) {
            painter->drawText(x, y, subFm.elidedText( eText, Qt::ElideLeft, errorTextRect.width()-2*aliasMargin));
            y += subFm.height();
        }
Пример #28
0
QPixmap QRibbonButtonBar::makeDisabledBitmap(const QPixmap& original)
{
	QIcon icon = QIcon(original);
	return icon.pixmap(original.size(), QIcon::Disabled);
}
Пример #29
0
ConfigGadgetWidget::ConfigGadgetWidget(QWidget *parent) : QWidget(parent)
{
    setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);

    ftw = new MyTabbedStackWidget(this, true, true);
    ftw->setIconSize(64);

    QVBoxLayout *layout = new QVBoxLayout;
    layout->setContentsMargins(0, 0, 0, 0);
    layout->addWidget(ftw);
    setLayout(layout);

    // *********************
    QWidget *qwd;

    QIcon *icon = new QIcon();
    icon->addFile(":/configgadget/images/hardware_normal.png", QSize(), QIcon::Normal, QIcon::Off);
    icon->addFile(":/configgadget/images/hardware_selected.png", QSize(), QIcon::Selected, QIcon::Off);
    qwd = new DefaultHwSettingsWidget(this, false);
    ftw->insertTab(ConfigGadgetWidget::hardware, qwd, *icon, QString("Hardware"));

    icon = new QIcon();
    icon->addFile(":/configgadget/images/vehicle_normal.png", QSize(), QIcon::Normal, QIcon::Off);
    icon->addFile(":/configgadget/images/vehicle_selected.png", QSize(), QIcon::Selected, QIcon::Off);
    qwd = new ConfigVehicleTypeWidget(this);
    ftw->insertTab(ConfigGadgetWidget::aircraft, qwd, *icon, QString("Vehicle"));

    icon = new QIcon();
    icon->addFile(":/configgadget/images/input_normal.png", QSize(), QIcon::Normal, QIcon::Off);
    icon->addFile(":/configgadget/images/input_selected.png", QSize(), QIcon::Selected, QIcon::Off);
    qwd = new ConfigInputWidget(this);
    ftw->insertTab(ConfigGadgetWidget::input, qwd, *icon, QString("Input"));

    icon = new QIcon();
    icon->addFile(":/configgadget/images/output_normal.png", QSize(), QIcon::Normal, QIcon::Off);
    icon->addFile(":/configgadget/images/output_selected.png", QSize(), QIcon::Selected, QIcon::Off);
    qwd = new ConfigOutputWidget(this);
    ftw->insertTab(ConfigGadgetWidget::output, qwd, *icon, QString("Output"));

    icon = new QIcon();
    icon->addFile(":/configgadget/images/ins_normal.png", QSize(), QIcon::Normal, QIcon::Off);
    icon->addFile(":/configgadget/images/ins_selected.png", QSize(), QIcon::Selected, QIcon::Off);
    qwd = new ConfigAttitudeWidget(this);
    ftw->insertTab(ConfigGadgetWidget::sensors, qwd, *icon, QString("Attitude"));

    icon = new QIcon();
    icon->addFile(":/configgadget/images/stabilization_normal.png", QSize(), QIcon::Normal, QIcon::Off);
    icon->addFile(":/configgadget/images/stabilization_selected.png", QSize(), QIcon::Selected, QIcon::Off);
    qwd = new ConfigStabilizationWidget(this);
    ftw->insertTab(ConfigGadgetWidget::stabilization, qwd, *icon, QString("Stabilization"));

    icon = new QIcon();
    icon->addFile(":/configgadget/images/autotune_normal.png", QSize(), QIcon::Normal, QIcon::Off);
    icon->addFile(":/configgadget/images/autotune_selected.png", QSize(), QIcon::Selected, QIcon::Off);
    qwd = new ConfigAutotuneWidget(this);
    ftw->insertTab(ConfigGadgetWidget::autotune, qwd, *icon, QString("Autotune"));

    icon = new QIcon();
    icon->addFile(":/configgadget/images/camstab_normal.png", QSize(), QIcon::Normal, QIcon::Off);
    icon->addFile(":/configgadget/images/camstab_selected.png", QSize(), QIcon::Selected, QIcon::Off);
    qwd = new ConfigCameraStabilizationWidget(this);
    ftw->insertTab(ConfigGadgetWidget::camerastabilization, qwd, *icon, QString("Camera Stab"));

    icon = new QIcon();
    icon->addFile(":/configgadget/images/txpid_normal.png", QSize(), QIcon::Normal, QIcon::Off);
    icon->addFile(":/configgadget/images/txpid_selected.png", QSize(), QIcon::Selected, QIcon::Off);
    qwd = new ConfigTxPIDWidget(this);
    ftw->insertTab(ConfigGadgetWidget::txpid, qwd, *icon, QString("TxPID"));

    ftw->setCurrentIndex(ConfigGadgetWidget::hardware);
    // *********************
    // Listen to autopilot connection events

    ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
    TelemetryManager* telMngr = pm->getObject<TelemetryManager>();
    connect(telMngr, SIGNAL(connected()), this, SLOT(onAutopilotConnect()));
    connect(telMngr, SIGNAL(disconnected()), this, SLOT(onAutopilotDisconnect()));

    // And check whether by any chance we are not already connected
    if (telMngr->isConnected()) {
        onAutopilotConnect();    
    }

    help = 0;
    connect(ftw,SIGNAL(currentAboutToShow(int,bool*)),this,SLOT(tabAboutToChange(int,bool*)));//,Qt::BlockingQueuedConnection);

    // Connect to the PipXStatus object updates
    UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
    oplinkStatusObj = dynamic_cast<UAVDataObject*>(objManager->getObject("OPLinkStatus"));
    if (oplinkStatusObj != NULL ) {
        connect(oplinkStatusObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updateOPLinkStatus(UAVObject*)));
    } else {
Пример #30
0
/**
  * Constructor of this class.
  */
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QCoreApplication::setOrganizationName("Fudeco Oy");
    QCoreApplication::setOrganizationDomain("fudeco.com");
    QCoreApplication::setApplicationName("Speed Freak");

    helpDialog = NULL;
    accstart = NULL;
    routeSaveDialog = NULL;
    topResultDialog = NULL;

    usersDialog = NULL;

    settingsDialog = new SettingsDialog;
    connect(settingsDialog, SIGNAL(sendregistration()), this, SLOT(clientRegUserToServer()));
    connect(settingsDialog, SIGNAL(userNameChanged()),  this, SLOT(clientUserLogin()));
    connect(settingsDialog, SIGNAL(logout()),           this, SLOT(setUsernameToMainPanel()));
    connect(settingsDialog, SIGNAL(saveprofile()),      this, SLOT(saveProfile()));

    httpClient = new HttpClient(this);
    connect(httpClient->myXmlreader, SIGNAL(receivedCategoryList()), this, SLOT(setCategoryCompoBox()));
    connect(httpClient->myXmlreader, SIGNAL(receivedTop10List()), this, SLOT(showTop10()));    

    welcomeDialog = new WelcomeDialog;
    welcomeDialog->show();

    this->setUsernameToMainPanel();

    // Create icon for acceleration start button
    QIcon* icon = new QIcon();
    icon->addFile(QString(":/new/prefix1/Graphics/Speedometer.png"), QSize(125,125), QIcon::Normal, QIcon::Off);
    icon->addFile(QString(":/new/prefix1/Graphics/Speedometer2.png"), QSize(125,125), QIcon::Normal, QIcon::On);

    // Acceleration start button

    customButtonAccelerate = new CustomButton(this,icon);
    delete icon;

    int buttons_x = 50,buttons_y = 165;
    customButtonAccelerate->setGeometry(buttons_x,buttons_y,130,130);
    connect(customButtonAccelerate, SIGNAL(OpenDialog()), this, SLOT(OpenAccStartDialog()));
    customButtonAccelerate->show();

    // Create icon for route dialog button
    icon = new QIcon();
    icon->addFile(QString(":/new/prefix1/Graphics/route.png"), QSize(125,125), QIcon::Normal, QIcon::Off);
    icon->addFile(QString(":/new/prefix1/Graphics/route_selected.png"), QSize(125,125), QIcon::Normal, QIcon::On);

    // Route dialog button
    customButtonRoute = new CustomButton(this,icon);
    delete icon;

    buttons_x += 140;
    customButtonRoute->setGeometry(buttons_x,buttons_y,130,130);
    connect(customButtonRoute, SIGNAL(OpenDialog()), this, SLOT(OpenRouteDialog()));
    customButtonRoute->show();

    // Create icon for results dialog button
    icon = new QIcon();
    icon->addFile(QString(":/new/prefix1/Graphics/trophy_gold.png"), QSize(125,125), QIcon::Normal, QIcon::Off);
    icon->addFile(QString(":/new/prefix1/Graphics/trophy_gold_selected.png"), QSize(125,125), QIcon::Normal, QIcon::On);

    // Results dialog button
    customButtonResults = new CustomButton(this,icon);
    delete icon;

    buttons_x += 140;
    customButtonResults->setGeometry(buttons_x,buttons_y,130,130);
    connect(customButtonResults, SIGNAL(OpenDialog()), this, SLOT(OpenResultDialog()));
    customButtonResults->show();
    //Create icon for settings dialog button
    icon = new QIcon();
    icon->addFile(QString(":/new/prefix1/Graphics/settings.png"), QSize(125,125), QIcon::Normal, QIcon::Off);
    icon->addFile(QString(":/new/prefix1/Graphics/settings_selected.png"), QSize(125,125), QIcon::Normal, QIcon::On);

    // Settings dialog button
    customButtonSettings = new CustomButton(this,icon);
    delete icon;

    buttons_x += 140;
    customButtonSettings->setGeometry(buttons_x,buttons_y,130,130);
    connect(customButtonSettings, SIGNAL(OpenDialog()), this, SLOT(OpenSettingsDialog()));
    customButtonSettings->show();

    //Create icon for users dialog button
    icon = new QIcon();
    icon->addFile(QString(":/new/prefix1/Graphics/users.png"), QSize(125,125), QIcon::Normal, QIcon::Off);
    icon->addFile(QString(":/new/prefix1/Graphics/users_selected.png"), QSize(125,125), QIcon::Normal, QIcon::On);

    //Users dialog button
    customButtonUsers = new CustomButton(this,icon);

    // Create icon for www page button
    icon = new QIcon();
    icon->addFile(QString(":/new/prefix1/Graphics/applications_internet.png"), QSize(125,125), QIcon::Normal, QIcon::Off);
    icon->addFile(QString(":/new/prefix1/Graphics/applications_internet_selected.png"), QSize(125,125), QIcon::Normal, QIcon::On);

    // WWW page button
    customButtonWWW = new CustomButton(this,icon);

    delete icon;

    buttons_x += 140;
    customButtonUsers->setGeometry(buttons_x,buttons_y,130,130);
    connect(customButtonUsers, SIGNAL(OpenDialog()), this, SLOT(openUsersDialog()));
    customButtonUsers->show();

    // Create icon for help dialog button
    icon = new QIcon();
    icon->addFile(QString(":/new/prefix1/Graphics/info.png"), QSize(85,85), QIcon::Normal, QIcon::Off);
    icon->addFile(QString(":/new/prefix1/Graphics/info_selected.png"), QSize(85,85), QIcon::Normal, QIcon::On);

    // Help dialog button
    customButtonHelp = new CustomButton(this,icon);
    delete icon;

    customButtonHelp->setGeometry(670,10,105,105);
    connect(customButtonHelp, SIGNAL(OpenDialog()), this, SLOT(OpenHelpDialog()));
    customButtonHelp->show();


    //Create icon for www page button
    icon = new QIcon();
    icon->addFile(QString(":/new/prefix1/Graphics/applications_internet.png"), QSize(85,85), QIcon::Normal, QIcon::Off);
    icon->addFile(QString(":/new/prefix1/Graphics/applications_internet_selected.png"), QSize(85,85), QIcon::Normal, QIcon::On);

    //WWW page button
    customButtonWWW = new CustomButton(this,icon);
    delete icon;

    customButtonWWW->setGeometry(670,320,105,105);
    connect(customButtonWWW, SIGNAL(OpenDialog()), this, SLOT(OpenWWWPage()));
    customButtonWWW->show();

}