Exemple #1
0
QHelpBox::QHelpBox(QWidget *_parent) : QWidget(_parent)
{
    defaultMsg = "";
    parent = _parent;
    helpBox = new QLabel();
    helpBox->setStyleSheet("border: 1px solid; border-color: rgb(71,127,249); background-color: rgb(245,245,245); margin-top:0px; "
                                               "margin-bottom:0px; margin-left: 0px; padding-right: 4px; padding-top:2px; padding-bottom:2px; padding-left:60px; text-align:justify;"
                           "");
    helpBox->setWordWrap(true);

  
    QFont tinyFont = QApplication::font();
	#if defined Q_OS_WIN
    tinyFont.setPointSize(7);
	#endif
    helpBox->setFont(tinyFont);

    QPixmap pixmap(":/icons/help.png");
    helpIcon = new QLabel();
    helpIcon->setPixmap(pixmap.scaled(35,35, Qt::KeepAspectRatio, Qt::SmoothTransformation));
    helpIcon->setStyleSheet("margin-left: 10px");

    QStackedLayout *helpLayout = new QStackedLayout();
    helpLayout->addWidget(helpBox);
    helpLayout->addWidget(helpIcon);
    helpLayout->setStackingMode(QStackedLayout::StackAll);
    setLayout(helpLayout);
}
Exemple #2
0
////public////
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent,Qt::FramelessWindowHint)

{

//    this->setAutoFillBackground(true);
//    QPalette palette;
//    QPixmap pixmap(":/images/dialogbackground.jpg");
//    palette.setBrush(QPalette::Window, QBrush(pixmap));
//    this->setPalette(palette);
    this->setWindowIcon(QIcon(":./iamges/window.icon"));
    this->setAttribute(Qt::WA_TranslucentBackground);

    arcR=10;
    centralwidget=new CentralWidget(this);

     play_label=new PlayLabel(centralwidget);
     player = new SimPlayer;
     contralwidget=new ContralWidget(this,player);
//   contralwidget->setMainWindow(this);



     play_label->setPlayer(player);



     //////////////////////////////////////////////////布局
 //    this->setCentralWidget(centralwidget);
     QStackedLayout *stack =new  QStackedLayout;
     stack->setStackingMode(QStackedLayout::StackAll);


     stack->addWidget(play_label);
     stack->addWidget(contralwidget);
 //   play_label->show();
      centralwidget->setLayout(stack);


      this->setGeometry(100,100,760,460);
      BaseSetting::readSettings();

      centralwidget->setGeometry(0,0,this->width()-15,this->height()-15);



    HideSDLWindow(); //先设置好这个,再创建线程

    connect(player,SIGNAL(display()),play_label,SLOT(display()));

}
Exemple #3
0
Speed::Speed(QWidget *parent): QWidget(parent)
{
	QHBoxLayout *layout = new QHBoxLayout();
	layout->setSpacing(0);
	layout->setMargin(0);
	
	setStyleSheet("padding: 0;");
	
		QVBoxLayout *contentLayout = new QVBoxLayout();
		contentLayout->setSpacing(2);
		contentLayout->setMargin(0);
		contentLayout->setContentsMargins(0, 2, 0, 0);
		
		QWidget *content = new QWidget();
		content->setLayout(contentLayout);
		content->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
			
			QStackedLayout *speedometerLayout = new QStackedLayout(contentLayout);
			speedometerLayout->setSpacing(2);
			speedometerLayout->setMargin(0);
			speedometerLayout->setContentsMargins(0, 2, 0, 0);
			speedometerLayout->setStackingMode(QStackedLayout::StackAll);
			
			speedometerNeedle = new RotatableImageView(":/resources/speedometer-needle_160x160.png");
			speedometerNeedle->rotate(-129);
			speedometerLayout->addWidget(speedometerNeedle);
			
			QLabel *speedometer = new QLabel();
			speedometer->setPixmap(QPixmap(":/resources/speedometer_160x160.png"));
			speedometer->setMargin(2);
			speedometerLayout->addWidget(speedometer);
			
			speedometerLabel = new QLabel("N/A");
			speedometerLabel->setAlignment(Qt::AlignCenter);
			speedometerLabel->setStyleSheet("font: 13pt; font-weight: bold;");
			contentLayout->addWidget(speedometerLabel);
		
		TitledBox *box = new TitledBox(tr("Speed"), content);
		layout->addWidget(box);
		
	QGraphicsDropShadowEffect *dropShadow = new QGraphicsDropShadowEffect();
	dropShadow->setBlurRadius(6);
	dropShadow->setColor(QColor(0, 0, 0));
	dropShadow->setOffset(0, 0);
	
	setGraphicsEffect(dropShadow);
	
	setLayout(layout);
}
Exemple #4
0
QHelpBox::QHelpBox(QWidget *_parent) : QWidget(_parent)
{
    parent = _parent;

    backgroundPanel = new QLabel();
    backgroundPanel->setStyleSheet("border: 1px solid; border-color: rgb(71,127,249); background-color: rgb(245,245,245); margin-top:0px; "
                                               "margin-bottom:0px; margin-left: 0px; padding-right: 4px; padding-top:4px; padding-bottom:4px; padding-left:60px;"
                           "");

    helpBox = new QLabel();

    #ifdef Q_OS_LINUX
    QFont tinyFont = QApplication::font();
    tinyFont.setPointSize(9);
    helpBox->setFont(tinyFont);
    #endif

    helpBox->setStyleSheet("margin-top:0px; margin-bottom:0px; margin-left: 0px; padding-right: 4px; padding-top:4px; padding-bottom:4px; padding-left:60px; text-align:justify;");
    helpBox->setWordWrap(true);    
    helpBox->setTextFormat(Qt::RichText);
    helpBox->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
    helpBox->setOpenExternalLinks(true);
    QPixmap pixmap(":/icons/help2.png");
    helpIcon = new QLabel();
    helpIcon->setPixmap(pixmap.scaled(50,50, Qt::KeepAspectRatio, Qt::SmoothTransformation));
    helpIcon->setStyleSheet("margin-left: 5px");

    QStackedLayout *helpLayout = new QStackedLayout();
    helpLayout->addWidget(backgroundPanel);
    helpLayout->addWidget(helpIcon);
    helpLayout->addWidget(helpBox);
    helpLayout->setStackingMode(QStackedLayout::StackAll);
    setLayout(helpLayout);

    #ifdef Q_OS_MAC
    this->setFixedHeight(90);
    #endif
    #ifdef Q_OS_WIN32
    this->setFixedHeight(120);
    #endif
    #ifdef Q_OS_LINUX
    this->setFixedHeight(120);
    #endif

}
Exemple #5
0
void
MainWindow::useNewUI()
{
#if (QT_VERSION >= 0x040400)
    QVBoxLayout *mainLayout;
    QStackedLayout *logoLayout;
    QGridLayout *bottomLayout;

    QHBoxLayout *pathSizeLayout;
    QPushButton *writeButton;

    // Set the background colour
    QPalette pal = palette();
    pal.setColor(QPalette::Window, Qt::white);
    setPalette(pal);

    imageLabel = new CustomLabel(this);
    imageLabel->setBackgroundRole(QPalette::Base);
    imageLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    imageLabel->setScaledContents(false);
    QImage image(":logo-empty.png");
    imageLabel->setPixmap(QPixmap::fromImage(image));
    imageLabel->setAlignment(Qt::AlignCenter);

    directive = new CustomLabel(this);
    directive->setText(tr("Drag disk image here\n or click to select."));
    directive->setAlignment(Qt::AlignCenter);
    deviceComboBox = new QComboBox;
    deviceComboBox->addItem(DROPDOWN_DIRECTIVE);
    writeButton = new QPushButton(tr("Write"));
    connect(writeButton, SIGNAL(clicked()), this, SLOT(write()));

    // These layouts are kind of a mess
    logoLayout = new QStackedLayout;
    logoLayout->setStackingMode(QStackedLayout::StackAll);
    logoLayout->addWidget(directive);
    logoLayout->addWidget(imageLabel);

    pathSizeLayout = new QHBoxLayout;
    pathSizeLayout->addWidget(fileLabel, Qt::AlignLeft);
    pathSizeLayout->addWidget(fileSize, Qt::AlignLeft);

    bottomLayout = new QGridLayout;
    bottomLayout->addLayout(pathSizeLayout, 0, 0);

    mainLayout = new QVBoxLayout;
    AboutLabel *aboutLabel = new AboutLabel();
    aboutLabel->setText("<u>About</u>");

    mainLayout->addWidget(aboutLabel,0,Qt::AlignTop|Qt::AlignLeft);
    mainLayout->addLayout(logoLayout, Qt::AlignHCenter);

    QGridLayout *comboLayout = new QGridLayout;
    comboLayout->addLayout(bottomLayout, 0, 0, Qt::AlignBottom);
    comboLayout->addWidget(deviceComboBox, 1,0);
    comboLayout->addWidget(writeButton, 1, 1, Qt::AlignRight);
    mainLayout->addLayout(comboLayout);

    setLayout(mainLayout);
    if (!mMaximized)
        resize(600, 400);

    setAcceptDrops(true);
#endif

    return;
}
void RackWindow::createPluginHost(int position)
{
    //layout settings widget:
    QWidget *settingsWidget = new QWidget;
    settingsWidget->setPalette(QPalette(QColor(0,0,0,160)));
    settingsWidget->setAutoFillBackground(true);

    RPushButton *leftButton = new RPushButton;
    leftButton->setObjectName("rackSettingsLeftArrowButton");
    RPushButton *rightButton = new RPushButton;
    rightButton->setObjectName("rackSettingsRightArrowButton");
    RPushButton *topButton = new RPushButton;
    topButton->setObjectName("rackSettingsTopArrowButton");
    RPushButton *bottomButton = new RPushButton;
    bottomButton->setObjectName("rackSettingsBottomArrowButton");
    RPushButton *closeButton = new RPushButton;
    closeButton->setObjectName("rackSettingsCloseButton");

    //vertical toolbar for plugin buttons:
    QToolBar *pluginHostToolBar = new QToolBar;
    pluginHostToolBar->setObjectName("rackPluginHostToolBar");
    pluginHostToolBar->setOrientation(Qt::Vertical);
    //actiongroup for exclusive handling of buttons:
    QActionGroup *ag = new QActionGroup(pluginHostToolBar);
    ag->setExclusive(true);

    RPushButton *addPluginWidgetButton = new RPushButton(tr("Add Widget ..."));
    addPluginWidgetButton->setObjectName("rackAddPluginWidgetButton");

    QWidget *middleWidget = new QWidget;
    QVBoxLayout *middleLayout = new QVBoxLayout(middleWidget);
    middleLayout->setSpacing(0);
    middleLayout->setContentsMargins(0,0,0,0);
    middleLayout->addWidget(pluginHostToolBar, 0, Qt::AlignHCenter);
    middleLayout->addWidget(addPluginWidgetButton, 0, Qt::AlignHCenter);

    QGridLayout *settingsLayout = new QGridLayout(settingsWidget);
    settingsLayout->setSpacing(0);
    settingsLayout->setContentsMargins(0,0,0,0);
    settingsLayout->addWidget(topButton,0,1, Qt::AlignTop | Qt::AlignHCenter);
    settingsLayout->addWidget(closeButton,0,2, Qt::AlignTop | Qt::AlignRight);
    settingsLayout->addWidget(leftButton,1,0, Qt::AlignLeft);
    settingsLayout->addWidget(rightButton,1,2, Qt::AlignRight);
    settingsLayout->addWidget(bottomButton,2,1, Qt::AlignBottom| Qt::AlignHCenter);
    settingsLayout->addWidget(middleWidget,1,1);

    QStackedWidget *pluginStack = new QStackedWidget;
    pluginStack->setObjectName("rackPluginStack");
    pluginStack->setAutoFillBackground(true);

    QWidget *pluginHost = new QWidget;
    pluginHost->setMinimumSize(200,80);

    QStackedLayout *overlayLayout = new QStackedLayout(pluginHost);
    overlayLayout->setStackingMode(QStackedLayout::StackAll);
    overlayLayout->addWidget(pluginStack);
    overlayLayout->addWidget(settingsWidget);
    overlayLayout->setCurrentIndex(1);

    //enter/leave settings signals:
    QSignalMapper *mapperShowSettingsMode = new QSignalMapper(pluginHost);
    QObject::connect(this, SIGNAL(enterSettingsMode()), mapperShowSettingsMode, SLOT(map()));
    mapperShowSettingsMode->setMapping(this, 1);
    QSignalMapper *mapperHideSettingsMode = new QSignalMapper(pluginHost);
    QObject::connect(this, SIGNAL(leaveSettingsMode()), mapperHideSettingsMode, SLOT(map()));
    mapperHideSettingsMode->setMapping(this, 0);
    QObject::connect(mapperShowSettingsMode, SIGNAL(mapped(int)), overlayLayout, SLOT(setCurrentIndex(int)));
    QObject::connect(mapperHideSettingsMode, SIGNAL(mapped(int)), overlayLayout, SLOT(setCurrentIndex(int)));

    //create plugin host widget signals:
    QSignalMapper *mapperCreatePluginHost = new QSignalMapper(pluginHost);
    QObject::connect(leftButton, SIGNAL(clicked()), mapperCreatePluginHost, SLOT(map()));
    QObject::connect(rightButton, SIGNAL(clicked()), mapperCreatePluginHost, SLOT(map()));
    QObject::connect(topButton, SIGNAL(clicked()), mapperCreatePluginHost, SLOT(map()));
    QObject::connect(bottomButton, SIGNAL(clicked()), mapperCreatePluginHost, SLOT(map()));
    mapperCreatePluginHost->setMapping(leftButton, NewSplitterLeft);
    mapperCreatePluginHost->setMapping(rightButton, NewSplitterRight);
    mapperCreatePluginHost->setMapping(topButton, NewSplitterTop);
    mapperCreatePluginHost->setMapping(bottomButton, NewSplitterBottom);
    QObject::connect(mapperCreatePluginHost, SIGNAL(mapped(int)), SLOT(createPluginHost(int)));

    //load plugin signal:
    QObject::connect(addPluginWidgetButton, SIGNAL(clicked()), m_mapperLoadNewPlugin, SLOT(map()));
    m_mapperLoadNewPlugin->setMapping(addPluginWidgetButton, pluginHost);

    //close plugin host signal:
    QObject::connect(closeButton, SIGNAL(clicked()), m_mapperClosePluginHost, SLOT(map()));
    m_mapperClosePluginHost->setMapping(closeButton, pluginHost);

    //create plugin switch signalmapper
    QSignalMapper *mapperSwitchPlugin = new QSignalMapper(pluginHost);
    mapperSwitchPlugin->setObjectName("rackPluginSwitchMapper");
    QObject::connect(mapperSwitchPlugin, SIGNAL(mapped(QWidget *)), pluginStack, SLOT(setCurrentWidget(QWidget *)));


    ////test show/hide plugin widget

    ////QObject::connect(mapperSwitchPlugin, SIGNAL(mapped(QWidget *)), this, SLOT(showHidePluginWidget(QWidget*)));


    //////


    //create plugin toolbar for mainwindow
    QToolBar *pluginToolBar = new QToolBar;
    pluginToolBar->setObjectName("rackPluginToolBar");
    pluginToolBar->setMovable(false);
    pluginToolBar->hide();
    addToolBar(Qt::BottomToolBarArea, pluginToolBar);

    //store the toolbar pointer as dynamic property to access later when creating plugin toolbar buttons
    pluginHost->setProperty("pluginToolBar", qVariantFromValue((QWidget *)pluginToolBar));

    //plugin bar signals & slots:
    QObject::connect(this, SIGNAL(enterSettingsMode()), pluginToolBar, SLOT(hide()));
    QObject::connect(this, SIGNAL(leaveSettingsMode()), pluginToolBar, SLOT(show()));







    //insert new pluginhost widget in splitter, create new splitter if necessary
    if (position == 0)
    {
        m_mainSplitter->addWidget(pluginHost);
        return;
    }
    QSignalMapper *sm = qobject_cast<QSignalMapper *>(sender());
    QWidget *senderPluginHost = qobject_cast<QWidget *>(sm->mapping(position)->parent()->parent());
    RSplitter *parentSplitter = qobject_cast<RSplitter *>(senderPluginHost->parent());
    QList<int> widgetsizes;
    int senderpos = parentSplitter->indexOf(senderPluginHost);
    int newposition;
    if ((position == NewSplitterLeft) or (position == NewSplitterTop)) newposition = senderpos;
    else newposition = senderpos + 1;
    switch (position + parentSplitter->orientation()) {             //horizontal=1 vertical=2
    case 0:                                                         //left   horizontal / top vertical
    case 2:                                                         //right  horizontal
    case 4:                                                         //bottom vertical
        widgetsizes = parentSplitter->sizes();
        widgetsizes.replace(senderpos, int(widgetsizes.at(senderpos)/2));
        widgetsizes.insert(senderpos + 1, widgetsizes.at(senderpos));
        parentSplitter->insertWidget(newposition, pluginHost);
        parentSplitter->setSizes(widgetsizes);
        break;
    case  1:                                                        //left  vertical
    case  3:                                                        //right vertical / bottom horizontal
    case -1:                                                        //top   horizontal
        if (parentSplitter->count() == 1)
        {
            parentSplitter->setOrientation(Qt::Orientation(abs(position)));
            widgetsizes = parentSplitter->sizes();
            widgetsizes.replace(0, int(widgetsizes.at(0)/2));
            widgetsizes.append(widgetsizes.at(0));
            parentSplitter->insertWidget(newposition, pluginHost);
            parentSplitter->setSizes(widgetsizes);
        }
        else if (parentSplitter->count() > 1)
        {
            RSplitter *newSplitter = new RSplitter(Qt::Orientation(abs(position)));
            QObject::connect(this, SIGNAL(enterSettingsMode()), newSplitter, SIGNAL(enterSettingsMode()));
            QObject::connect(this, SIGNAL(leaveSettingsMode()), newSplitter, SIGNAL(leaveSettingsMode()));
            widgetsizes = parentSplitter->sizes();
            parentSplitter->insertWidget(parentSplitter->indexOf(senderPluginHost), newSplitter);
            newSplitter->addWidget(senderPluginHost);
            QList<int> newsizes = newSplitter->sizes();
            newsizes.replace(0, int(newsizes.at(0)/2));
            newsizes.append(newsizes.at(0));
            if ((position == NewSplitterLeft) or (position == NewSplitterTop)) newSplitter->insertWidget(0, pluginHost);
            else newSplitter->addWidget(pluginHost);
            newSplitter->setSizes(newsizes);
            parentSplitter->setSizes(widgetsizes);
        }
        break;
    }
}