Exemple #1
0
KMTitleBar::KMTitleBar(QWidget *parent) :
    KMTitleBarBase(parent),
    m_titleCombo(new KMTitleBarCombo(this)),
    m_create(generateButton("://image/public/create.png")),
    m_settings(generateButton("://image/public/settings.png"))
{
    //Set properties.
    setFixedHeight(m_titleCombo->height());
    //Link the title combo.
    connect(m_titleCombo, &KMTitleBarCombo::clicked,
            this, &KMTitleBar::requireShowUnibar);
    connect(m_settings, &KMTitleBarButton::clicked,
            this, &KMTitleBar::requireShowPreference);
    //Link the create button.
    connect(m_create, &KMTitleBarButton::clicked,
            this, &KMTitleBar::onActionCompose);

    //Configure the main layout.
    QBoxLayout *mainLayout=new QBoxLayout(QBoxLayout::LeftToRight,
                                          this);
    //Reconfigure the main layout.
    mainLayout->setContentsMargins(0,0,0,0);
    mainLayout->setSpacing(0);
    //Set the layout to title bar.
    setLayout(mainLayout);
    //Add widget to main layout.
    mainLayout->addWidget(m_titleCombo, 1);
    mainLayout->addWidget(m_create);
    mainLayout->addWidget(m_settings);
}
Exemple #2
0
KNMessageBox::KNMessageBox(QWidget *parent) :
    QDialog(parent),
    m_topBlock(new KNMessageBoxBlock(this)),
    m_bottomBlock(new KNMessageBoxBlock(this)),
    m_content(new KNMessageBoxContent(this)),
    m_okayButton(generateButton("://public/ok.png")),
    m_cancelButton(generateButton("://public/cancel.png")),
    m_titleText(QString()),
    m_showCancelButton(false),
    m_showOkayButton(true),
    m_showAnime(new QSequentialAnimationGroup(this)),
    m_hideAnime(new QParallelAnimationGroup(this)),
    m_zoomIn(new QPropertyAnimation(this, "geometry", this)),
    m_fadeIn(new QPropertyAnimation(this, "windowOpacity", this)),
    m_expand(new QPropertyAnimation(this, "geometry", this)),
    m_fold(new QPropertyAnimation(this, "geometry", this)),
    m_fadeOut(new QPropertyAnimation(this, "windowOpacity", this)),
    m_dialogResizing(new QPropertyAnimation(this, "geometry", this)),
    m_pressed(false)
{
    //Set properties.
    setAutoFillBackground(true);
    setWindowOpacity(0.9);
    //Reset window flags, SAO style show be no border, ToolTip is the best
    //choice. Why not Qt::FramelessWindowHint? Ask Gnome Shell, I don't know.
    //Here's a Mac OS X hack. We need to set it to FramelessWindowHint.
#ifdef Q_OS_MACX
    setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);
#else
    setWindowFlags(Qt::ToolTip);
#endif
    //Set the focus policy after set the tooltip window flags.
    setFocusPolicy(Qt::StrongFocus);

    //Set palette, the color of SAO style window cannot be changed.
    QPalette pal=palette();
    pal.setColor(QPalette::Window, QColor(240,240,240));
    pal.setColor(QPalette::WindowText, QColor(100,100,100));
    setPalette(pal);

    //Initial elements.
    initialBlocks();
    initialAnimes();

    //Initial the main layout of the message box.
    QBoxLayout *mainLayout=new QBoxLayout(QBoxLayout::TopToBottom,
                                          this);
    mainLayout->setContentsMargins(0,0,0,0);
    mainLayout->setSpacing(0);
    setLayout(mainLayout);
    //Add blocks and content container to layout.
    mainLayout->addWidget(m_topBlock, 1);
    mainLayout->addWidget(m_content);
    mainLayout->addWidget(m_bottomBlock, 1);

    //Raise the widget.
    m_content->raise();
}
Exemple #3
0
/**
 * @brief Main code generator dispatch.
 *
 * According to the type of the input signal, generateCode calls
 * the appropriate generator with appropriate arguments.
 *
 * @param	sig			The signal expression to compile.
 * @param	priority	The environment priority of the expression.
 * @return	<string>	The LaTeX code translation of the signal.
 */
string DocCompiler::generateCode (Tree sig, int priority)
{
	int 	i;
	double	r;
    Tree 	c, sel, x, y, z, u, label, ff, largs, type, name, file;
	
	if ( getUserData(sig) )							{ printGCCall(sig,"generateXtended");	return generateXtended	(sig, priority);		}
	else if ( isSigInt(sig, &i) ) 					{ printGCCall(sig,"generateNumber");	return generateNumber	(sig, docT(i));			}
	else if ( isSigReal(sig, &r) ) 					{ printGCCall(sig,"generateNumber");	return generateNumber	(sig, docT(r));			}
	else if ( isSigInput(sig, &i) ) 				{ printGCCall(sig,"generateInput");		return generateInput	(sig, docT(i+1)); 		}
	else if ( isSigOutput(sig, &i, x) ) 			{ printGCCall(sig,"generateOutput");	return generateOutput	(sig, docT(i+1), CS(x, priority));	}
	
	else if ( isSigFixDelay(sig, x, y) ) 			{ printGCCall(sig,"generateFixDelay");	return generateFixDelay	(sig, x, y, priority); 	}
	else if ( isSigPrefix(sig, x, y) ) 				{ printGCCall(sig,"generatePrefix");	return generatePrefix	(sig, x, y, priority); 	}
	else if ( isSigIota(sig, x) ) 					{ printGCCall(sig,"generateIota");		return generateIota 	(sig, x); 				}
	
	else if ( isSigBinOp(sig, &i, x, y) )			{ printGCCall(sig,"generateBinOp");		return generateBinOp	(sig, i, x, y, priority); 		}
	else if ( isSigFFun(sig, ff, largs) )			{ printGCCall(sig,"generateFFun");		return generateFFun 	(sig, ff, largs, priority); 	}
    else if ( isSigFConst(sig, type, name, file) )  { printGCCall(sig,"generateFConst");	return generateFConst	(sig, tree2str(file), tree2str(name)); }
    else if ( isSigFVar(sig, type, name, file) )    { printGCCall(sig,"generateFVar");		return generateFVar		(sig, tree2str(file), tree2str(name)); }
	
    // new special tables for documentation purposes

    else if ( isSigDocConstantTbl(sig, x, y) )      { printGCCall(sig,"generateDocConstantTbl");    return generateDocConstantTbl (sig, x, y);	}
    else if ( isSigDocWriteTbl(sig,x,y,z,u) )       { printGCCall(sig,"generateDocWriteTbl");       return generateDocWriteTbl (sig, x, y, z, u); }
    else if ( isSigDocAccessTbl(sig, x, y) )        { printGCCall(sig, "generateDocAccessTbl");     return generateDocAccessTbl(sig, x, y); }


	else if ( isSigSelect2(sig, sel, x, y) ) 		{ printGCCall(sig,"generateSelect2");	return generateSelect2 	(sig, sel, x, y, priority); 	}
	else if ( isSigSelect3(sig, sel, x, y, z) ) 	{ printGCCall(sig,"generateSelect3");	return generateSelect3 	(sig, sel, x, y, z, priority); 	}
	
    else if ( isProj(sig, &i, x) )                  { printGCCall(sig,"generateRecProj");	return generateRecProj	(sig, x, i, priority);	}
	
	else if ( isSigIntCast(sig, x) ) 				{ printGCCall(sig,"generateIntCast");	return generateIntCast	(sig, x, priority); 	}
	else if ( isSigFloatCast(sig, x) ) 				{ printGCCall(sig,"generateFloatCast");	return generateFloatCast(sig, x, priority); 	}
	
	else if ( isSigButton(sig, label) ) 			{ printGCCall(sig,"generateButton");	return generateButton   (sig, label); 			}
	else if ( isSigCheckbox(sig, label) ) 			{ printGCCall(sig,"generateCheckbox");	return generateCheckbox (sig, label); 			}
	else if ( isSigVSlider(sig, label,c,x,y,z) )	{ printGCCall(sig,"generateVSlider");	return generateVSlider 	(sig, label, c,x,y,z);	}
	else if ( isSigHSlider(sig, label,c,x,y,z) )	{ printGCCall(sig,"generateHSlider");	return generateHSlider 	(sig, label, c,x,y,z);	}
	else if ( isSigNumEntry(sig, label,c,x,y,z) )	{ printGCCall(sig,"generateNumEntry");	return generateNumEntry (sig, label, c,x,y,z);	}
	
	else if ( isSigVBargraph(sig, label,x,y,z) )	{ printGCCall(sig,"generateVBargraph");	return CS(z, priority);}//generateVBargraph 	(sig, label, x, y, CS(z, priority)); }
	else if ( isSigHBargraph(sig, label,x,y,z) )	{ printGCCall(sig,"generateHBargraph");	return CS(z, priority);}//generateHBargraph 	(sig, label, x, y, CS(z, priority)); }
    else if ( isSigAttach(sig, x, y) )				{ printGCCall(sig,"generateAttach");	return generateAttach	(sig, x, y, priority); }
    else if ( isSigEnable(sig, x, y) )				{ printGCCall(sig,"generateEnable");      return generateEnable	(sig, x, y, priority); }

	else {
        stringstream error;
        error << "ERROR in d signal, unrecognized signal : " << *sig << endl;
        throw faustexception(error.str());
	}
    faustassert(0);
	return "error in generate code";
}
KNAccountRegisterPanel::KNAccountRegisterPanel(QWidget *parent) :
    QWidget(parent),
    m_validColor(QColor(0x41, 0x92, 0x57)),
    m_invalidColor(QColor(0x9a, 0x25, 0x38)),
    m_emptyColor(QColor(0x9D, 0x9D, 0x9D)),
    m_title(new QLabel(this)),
    m_emailHint(new QLabel(this)),
    m_errorHint(new QLabel(this)),
    m_agreeLicense(new QCheckBox(this)),
    m_username(new KNLabelLineEdit(this)),
    m_password(new KNLabelLineEdit(this)),
    m_email(new KNLabelLineEdit(this)),
    m_okay(generateButton("://public/ok.png")),
    m_cancel(generateButton("://public/cancel.png")),
    m_errorCode(-1)
{
    //Set properties.
    setFixedHeight(knDpi->height(270));
    //Configure the title label.
    m_title->setAlignment(Qt::AlignCenter);
    QFont titleFont=m_title->font();
    titleFont.setPixelSize(knDpi->height(18));
    m_title->setFont(titleFont);
    //Configure the user name line edit.
    m_username->setMinimumLightness(0xC0);
    m_username->setMediumLightness(0xE0);
    m_username->setLabelIcon(QPixmap("://public/generate_username.png"));
    connect(m_username, &KNLabelLineEdit::textChanged,
            this, &KNAccountRegisterPanel::onActionCheckValid);
    //Configure password line edit.
    m_password->setMinimumLightness(0xC0);
    m_password->setMediumLightness(0xE0);
    m_password->setLabelIcon(QPixmap("://public/generate_password.png"));
    m_password->setEchoMode(QLineEdit::Password);
    connect(m_password, &KNLabelLineEdit::textChanged,
            this, &KNAccountRegisterPanel::onActionCheckValid);
    //Configure the E-mail.
    m_email->setMinimumLightness(0xC0);
    m_email->setMediumLightness(0xE0);
    m_email->setLabelIcon(QPixmap("://public/generate_email.png"));
    connect(m_email, &KNLabelLineEdit::textChanged,
            this, &KNAccountRegisterPanel::onActionCheckValid);
    //Configure the check box.
    connect(m_agreeLicense, &QCheckBox::stateChanged,
            this, &KNAccountRegisterPanel::onActionCheckValid);
    //Configure the hint label.
    QPalette hintPal=palette();
    hintPal.setColor(QPalette::WindowText, QColor(157, 157, 157));
    // E-mail Hint.
    m_emailHint->setPalette(hintPal);
    m_emailHint->setContentsMargins(knDpi->margins(5, 0, 0, 0));
    // Error Hint.
    m_errorHint->setAlignment(Qt::AlignCenter);
    // Error Hint.
    QPalette errorPal=m_errorHint->palette();
    errorPal.setColor(QPalette::WindowText, QColor(0x9a, 0x25, 0x38));
    m_errorHint->setPalette(errorPal);
    //Okay buttons.
    m_okay->hide();
    //Connect buttons.
    connect(m_okay, SIGNAL(clicked(bool)), this, SIGNAL(requireRegister()));
    connect(m_cancel, SIGNAL(clicked(bool)), this, SLOT(onActionCancel()));

    //Initial the box layout.
    QBoxLayout *mainLayout=new QBoxLayout(QBoxLayout::TopToBottom, this);
    mainLayout->setSpacing(0);
    setLayout(mainLayout);
    //Add widget to layout
    mainLayout->addSpacing(knDpi->height(7));
    mainLayout->addWidget(m_title);
    mainLayout->addSpacing(knDpi->height(3));
    mainLayout->addWidget(m_errorHint);
    mainLayout->addSpacing(knDpi->height(3));
    mainLayout->addWidget(m_username);
    mainLayout->addSpacing(knDpi->height(3));
    mainLayout->addWidget(m_password);
    mainLayout->addSpacing(knDpi->height(2));
    //Generate the label palette.
    QPalette labelPalette=palette();
    labelPalette.setColor(QPalette::WindowText, m_emptyColor);
    //Initial the hint label.
    for(int i=0; i<PasswordHintTypeCount; ++i)
    {
        //Initial the password hint.
        m_passwordHint[i]=new QLabel(this);
        //Set porperties.
        m_passwordHint[i]->setContentsMargins(5, 0, 0, 0);
        m_passwordHint[i]->setWordWrap(true);
        //Set the palette.
        m_passwordHint[i]->setPalette(labelPalette);
        //Add hint to main layout.
        mainLayout->addWidget(m_passwordHint[i]);
    }
    mainLayout->addSpacing(knDpi->height(5));
    mainLayout->addWidget(m_email);
    mainLayout->addSpacing(knDpi->height(2));
    mainLayout->addWidget(m_emailHint);
    mainLayout->addSpacing(knDpi->height(3));
    mainLayout->addWidget(m_agreeLicense, 0, Qt::AlignHCenter);
    mainLayout->addSpacing(knDpi->height(1));

    //Initial button layout.
    QBoxLayout *buttonLayout=new QBoxLayout(QBoxLayout::LeftToRight,
                                            mainLayout->widget());
    buttonLayout->setContentsMargins(knDpi->margins(1,3,1,3));
    mainLayout->addLayout(buttonLayout);
    mainLayout->addStretch();
    //Add all buttons.
    buttonLayout->addWidget(m_okay);
    buttonLayout->addWidget(m_cancel);

    //Link the retranslator.
    knI18n->link(this, &KNAccountRegisterPanel::retranslate);
    retranslate();
}
KNMusicPlaylistViewer::KNMusicPlaylistViewer(QWidget *parent, KNMusicTab *tab) :
    QWidget(parent),
    m_treeView(new KNMusicPlaylistTreeView(this, tab)),
    m_title(new KNScrollLabel(this)),
    m_detail(new QLabel(this)),
    m_leftShadow(new KNSideShadowWidget(KNSideShadowWidget::LeftShadow,
                                        this)),
    m_modelLinkHandler(new KNConnectionHandler()),
    m_playPlaylist(
        generateButton(":/plugin/music/playlist/playlist_control_play.png")),
    m_shufflePlaylist(
        generateButton(":/plugin/music/playlist/playlist_control_random.png")),
    m_addToPlaylist(
        generateButton(":/plugin/music/playlist/playlist_control_add.png"))
{
    //Configure the tree view.
    setFocusProxy(m_treeView);
    setAcceptDrops(true);
    //Configure title label.
    m_title->setObjectName("PlaylistViewerLabel");
    m_title->setContentsMargins(0,0,0,0);
    QFont labelFont=m_title->font();
    labelFont.setBold(true);
    labelFont.setPixelSize(17);
    m_title->setFont(labelFont);
    //Configure the buttons.
    connect(m_playPlaylist, &KNOpacityAnimeButton::clicked,
            this, &KNMusicPlaylistViewer::onActionPlayCurrent);
    connect(m_shufflePlaylist, &KNOpacityAnimeButton::clicked,
            this, &KNMusicPlaylistViewer::onActionShuffle);
    connect(m_addToPlaylist, &KNOpacityAnimeButton::clicked,
            this, &KNMusicPlaylistViewer::onActionAddToPlaylist);
    //Link the theme manager with the label.
    knTheme->registerWidget(m_title);
    //Configure detail label.
    m_detail->setObjectName("PlaylistDetailLabel");
    knTheme->registerWidget(m_detail);

    //Initial the main layout.
    QBoxLayout *mainLayout=new QBoxLayout(QBoxLayout::TopToBottom,
                                          this);
    mainLayout->setContentsMargins(0,0,0,0);
    mainLayout->setSpacing(0);
    setLayout(mainLayout);

    //Initial the information container.
    KNMouseSenseWidget *infoContainer=new KNMouseSenseWidget(this);
    infoContainer->updateObjectName("PlaylistInformationContainer");
    infoContainer->setContentsMargins(20, 12, 20, 8);
    //Add widget to layout.
    mainLayout->addWidget(infoContainer);
    mainLayout->addWidget(m_treeView, 1);
    //Initial the information container layout.
    QBoxLayout *informationLayout=new QBoxLayout(QBoxLayout::TopToBottom,
                                                 infoContainer);
    informationLayout->setContentsMargins(0,0,0,0);
    informationLayout->setSpacing(0);
    infoContainer->setLayout(informationLayout);
    //Add labels to information layout.
    informationLayout->addWidget(m_title);
    //Initial the detail layout.
    QBoxLayout *detailLayout=new QBoxLayout(QBoxLayout::LeftToRight,
                                            informationLayout->widget());
    detailLayout->setContentsMargins(0,0,0,0);
    detailLayout->setSpacing(5);
    informationLayout->addLayout(detailLayout);
    //Add widget to detail layout.
    detailLayout->addWidget(m_detail);
    detailLayout->addWidget(m_playPlaylist);
    detailLayout->addWidget(m_shufflePlaylist);
    detailLayout->addWidget(m_addToPlaylist);
    detailLayout->addStretch();

    //Link the search.
    connect(knMusicGlobal->search(), &KNMusicSearchBase::requireSearch,
            this, &KNMusicPlaylistViewer::onActionSearch);

    //Move the shadow to the top of the widget.
    m_leftShadow->setDarkness(100);
    m_leftShadow->raise();

    //Link with locale manager.
    knI18n->link(this, &KNMusicPlaylistViewer::retranslate);
    retranslate();
}
KNAccountResetPanel::KNAccountResetPanel(QWidget *parent) :
    QWidget(parent),
    m_emailExp(QRegExp("[\\w\\._-]+@(\\w)+((\\.(\\w)+)+)$")),
    m_resetLogo(new KNImageLabel(this)),
    m_title(new QLabel(this)),
    m_hintLabel(new QLabel(this)),
    m_emailAddress(new KNLabelLineEdit(this)),
    m_okay(generateButton("://public/ok.png")),
    m_cancel(generateButton("://public/cancel.png"))
{
    //Set properties.
    setFixedHeight(270);

    //Configure the hint and title lable.
    m_title->setAlignment(Qt::AlignCenter);
    QFont titleFont=m_title->font();
    titleFont.setPixelSize(18);
    m_title->setFont(titleFont);
    //Configure the logo label.
    m_resetLogo->setFixedSize(LogoSize, LogoSize);
    m_resetLogo->setPixmap(QPixmap("://public/reset-password.png"));
    //Configure the hint label.
    m_hintLabel->setWordWrap(true);
    QPalette hintPal=palette();
    hintPal.setColor(QPalette::WindowText, QColor(157, 157, 157));
    m_hintLabel->setPalette(hintPal);
    //Configure the E-mail line edit.
    m_emailAddress->setMinimumLightness(0xC0);
    m_emailAddress->setMediumLightness(0xE0);
    m_emailAddress->setLabelIcon(QPixmap("://public/generate_email.png"));
    connect(m_emailAddress, &KNLabelLineEdit::textChanged,
            this, &KNAccountResetPanel::onActionCheckEmail);
    //Configure okay button.
    m_okay->hide();
    connect(m_okay, &KNOpacityAnimeButton::clicked,
            this, &KNAccountResetPanel::onActionSentEmail);
    //Configure the button.
    connect(m_cancel, &KNOpacityAnimeButton::clicked,
            this, &KNAccountResetPanel::requireCancel);
    //Initial the layout.
    QBoxLayout *mainLayout=new QBoxLayout(QBoxLayout::TopToBottom, this);
    setLayout(mainLayout);
    //Add widget to layout
    mainLayout->addStretch();
    mainLayout->addWidget(m_resetLogo, 0, Qt::AlignHCenter);
    mainLayout->addSpacing(7);
    mainLayout->addWidget(m_title);
    mainLayout->addWidget(m_hintLabel);
    mainLayout->addSpacing(14);
    mainLayout->addWidget(m_emailAddress);
    //Initial button layout.
    QBoxLayout *buttonLayout=new QBoxLayout(QBoxLayout::LeftToRight,
                                            mainLayout->widget());
    mainLayout->addSpacing(14);
    mainLayout->addLayout(buttonLayout);
    mainLayout->addStretch();
    //Add all buttons.
    buttonLayout->addWidget(m_okay);
    buttonLayout->addWidget(m_cancel);

    //Link the retranslate part.
    knI18n->link(this, &KNAccountResetPanel::retranslate);
    retranslate();
}