UIMJSelect::UIMJSelect( DJDesktopMahjongController *mjController, const MJCardsGroups& groups, QWidget * parent, Qt::WindowFlags f ) :QDialog( parent, f ) { setupUi(this); m_rows = new QButtonGroup(this); qreal scale = 0.5; for( MJCardsGroupsConstIterator groupsIt = groups.begin(); groupsIt != groups.end(); groupsIt++ ) { const MJCards& cards = *groupsIt; QList<QPixmap> pixmaps; for( MJCardsConstIterator cardsIt = cards.begin(); cardsIt != cards.end(); cardsIt++ ) { MJCard card = *cardsIt; QString resPath = mjController->cardResPath( card, DJDesktopMahjongController::Standing, 1 ); QSvgRenderer *renderer = mjController->cardRenderer( resPath ); if ( renderer ) { QPixmap pix = SvgRender2Pixmap( renderer ); pixmaps << pix; } } QPixmap conjointPix = CreateConjointPixmap( pixmaps ); ScalePixmap( conjointPix, scale ); QRadioButton *button = new QRadioButton; button->setIconSize( conjointPix.size() ); button->setIcon( conjointPix ); button->setChecked( true ); m_rows->addButton( button ); vboxLayout1->addWidget( button ); } }
Login::Login(QWidget *parent) : QWidget(parent), ui(new Ui::Login) { ui->setupUi(this); QIcon icon; icon.addFile(QString::fromUtf8(":image/icon.png"), QSize(), QIcon::Normal, QIcon::Off); this->setWindowIcon(icon); group = new QButtonGroup(this); QStringListModel * model = AdminDAO::getAdminDAOInstance()->getUsernames(); QString img = ":/users/0.jpg"; QRadioButton * tmpbutton = ui->userButton_0; for (int i = 0; i < model->rowCount(); i++) { img = QString(":/users/%1.jpg").arg(i); switch (i) { case 0: tmpbutton = ui->userButton_0; break; case 1: tmpbutton = ui->userButton_1; break; case 2: tmpbutton = ui->userButton_2; break; case 3: tmpbutton = ui->userButton_3; break; case 4: tmpbutton = ui->userButton_4; break; case 5: tmpbutton = ui->userButton_5; break; default: tmpbutton = ui->userButton_0; break; } tmpbutton->setIcon(QPixmap(img)); tmpbutton->setIconSize(QSize(40,40)); } group->addButton(ui->userButton_0); group->addButton(ui->userButton_1); group->addButton(ui->userButton_2); group->addButton(ui->userButton_3); group->addButton(ui->userButton_4); group->addButton(ui->userButton_5); group->setId(ui->userButton_0, 0); group->setId(ui->userButton_1, 1); group->setId(ui->userButton_2, 2); group->setId(ui->userButton_3, 3); group->setId(ui->userButton_4, 4); group->setId(ui->userButton_5, 5); connect(ui->userButton_0, SIGNAL(clicked()), this, SLOT(sellectOneUser())); connect(ui->userButton_1, SIGNAL(clicked()), this, SLOT(sellectOneUser())); connect(ui->userButton_2, SIGNAL(clicked()), this, SLOT(sellectOneUser())); connect(ui->userButton_3, SIGNAL(clicked()), this, SLOT(sellectOneUser())); connect(ui->userButton_4, SIGNAL(clicked()), this, SLOT(sellectOneUser())); connect(ui->userButton_5, SIGNAL(clicked()), this, SLOT(sellectOneUser())); }
bool HandlerChoiceDialog::AddCommon (const IInfo *ii, const QString& addedAs) { QString name; QString tooltip; QIcon icon; try { name = ii->GetName (); tooltip = ii->GetInfo (); icon = ii->GetIcon (); } catch (const std::exception& e) { qWarning () << Q_FUNC_INFO << "could not query" << e.what () << ii; return false; } catch (...) { qWarning () << Q_FUNC_INFO << "could not query" << ii; return false; } QRadioButton *but = new QRadioButton (name, this); but->setToolTip (tooltip); but->setIconSize (QSize (32, 32)); but->setIcon (icon); but->setProperty ("AddedAs", "IDownload"); but->setProperty ("PluginID", ii->GetUniqueID ()); if (Buttons_->buttons ().isEmpty ()) but->setChecked (true); Buttons_->addButton (but); Ui_.DownloadersLayout_->addWidget (but); Infos_ [name] = ii; Ui_.DownloadersLabel_->show (); if (Downloaders_.size () + Handlers_.size () == 1) populateLocationsBox (); return true; }
static inline QRadioButton* buildRadioButton(QString text, QString icon, int mode, QGroupBox *groupBox, QHBoxLayout *hbox, LogWidgetModel *m_viewmodel) { QRadioButton *build = new QRadioButton(text, groupBox); build->setIcon(QIcon(QString(":/in/%0").arg(icon))); build->setProperty("mode", mode); build->setToolTip(build->text()); hbox->addWidget(build); QObject::connect(build, SIGNAL(toggled(bool)), m_viewmodel, SLOT(changeMode(bool))); return build; }
ScreenPositionWidget::ScreenPositionWidget(QWidget *parent) : QWidget(parent), mButtonGroup(new QButtonGroup(this)) { QHBoxLayout *mainLayout = new QHBoxLayout(); int screenCount = QApplication::desktop()->numScreens(); for(int screen=0;screen<screenCount;++screen) { QGroupBox *screenPositionGroupBox = new QGroupBox(tr("Screen %1").arg(screen+1)); QGridLayout *gridLayout = new QGridLayout(); gridLayout->setMargin(0); gridLayout->setSpacing(0); int i = 0; for(int column=0;column<3;++column) { for(int row=0;row<3;++row,++i) { QRadioButton *radioButton = new QRadioButton(this); radioButton->setIconSize(QSize(40, 40)); radioButton->setIcon(QIcon(QString(":/images/monitor_%1.png").arg(iconNames[row][column]))); mButtonGroup->addButton(radioButton, screen * 9 + i); mRadioButtons.append(radioButton); gridLayout->addWidget(radioButton, row, column, Qt::AlignCenter); } } screenPositionGroupBox->setLayout(gridLayout); mainLayout->addWidget(screenPositionGroupBox); } setLayout(mainLayout); }
GeneralPage::GeneralPage(QWidget* parent) : QWidget(parent) { QSettings settings( PENCIL2D, PENCIL2D ); QVBoxLayout* lay = new QVBoxLayout(); QGroupBox* languageBox = new QGroupBox( tr("Language", "GroupBox title in Preference") ); QGroupBox* windowOpacityBox = new QGroupBox( tr( "Window opacity", "GroupBox title in Preference" ) ); QGroupBox* backgroundBox = new QGroupBox( tr( "Background", "GroupBox title in Preference" ) ); QGroupBox* appearanceBox = new QGroupBox( tr( "Appearance", "GroupBox title in Preference" ) ); QGroupBox* displayBox = new QGroupBox( tr( "Rendering", "GroupBox title in Preference" ) ); QGroupBox* editingBox = new QGroupBox( tr( "Editing", "GroupBox title in Preference" ) ); mLanguageCombo = new QComboBox; mLanguageCombo->addItem( tr( "<System-Language>" ), "" ); mLanguageCombo->addItem( tr( "Czech" ), "cs" ); mLanguageCombo->addItem( tr( "Danish" ), "da" ); mLanguageCombo->addItem( tr( "English" ), "en" ); mLanguageCombo->addItem( tr( "German" ), "de" ); mLanguageCombo->addItem( tr( "Spanish" ), "es" ); mLanguageCombo->addItem( tr( "French" ), "fr" ); mLanguageCombo->addItem( tr( "Italian" ), "it" ); mLanguageCombo->addItem( tr( "Japanese" ), "ja" ); mLanguageCombo->addItem( tr( "Portuguese - Brazil" ), "pt-BR" ); mLanguageCombo->addItem( tr( "Russian" ), "ja" ); mLanguageCombo->addItem( tr( "Chinese - Taiwan" ), "zh-TW" ); QLabel* windowOpacityLabel = new QLabel(tr("Opacity")); mWindowOpacityLevel = new QSlider(Qt::Horizontal); mWindowOpacityLevel->setMinimum(30); mWindowOpacityLevel->setMaximum(100); int value = settings.value("windowOpacity").toInt(); mWindowOpacityLevel->setValue( 100 - value ); mBackgroundButtons = new QButtonGroup(); QRadioButton* checkerBackgroundButton = new QRadioButton(); QRadioButton* whiteBackgroundButton = new QRadioButton(); QRadioButton* greyBackgroundButton = new QRadioButton(); QRadioButton* dotsBackgroundButton = new QRadioButton(); QRadioButton* weaveBackgroundButton = new QRadioButton(); QPixmap previewCheckerboard( ":background/checkerboard.png" ); QPixmap previewWhite(32,32); QPixmap previewGrey(32,32); QPixmap previewDots( ":background/dots.png" ); QPixmap previewWeave( ":background/weave.jpg" ); previewWhite.fill( Qt::white ); previewGrey.fill( Qt:: lightGray ); checkerBackgroundButton->setIcon( previewCheckerboard.scaled(32, 32) ); whiteBackgroundButton->setIcon( previewWhite ); greyBackgroundButton->setIcon( previewGrey ); dotsBackgroundButton->setIcon( previewDots.scaled(32, 32) ); weaveBackgroundButton->setIcon( previewWeave.scaled(32, 32) ); mBackgroundButtons->addButton(checkerBackgroundButton); mBackgroundButtons->addButton(whiteBackgroundButton); mBackgroundButtons->addButton(greyBackgroundButton); mBackgroundButtons->addButton(dotsBackgroundButton); mBackgroundButtons->addButton(weaveBackgroundButton); mBackgroundButtons->setId(checkerBackgroundButton, 1); mBackgroundButtons->setId(whiteBackgroundButton, 2); mBackgroundButtons->setId(greyBackgroundButton, 3); mBackgroundButtons->setId(dotsBackgroundButton, 4); mBackgroundButtons->setId(weaveBackgroundButton, 5); QHBoxLayout* backgroundLayout = new QHBoxLayout(); backgroundBox->setLayout(backgroundLayout); backgroundLayout->addWidget(checkerBackgroundButton); backgroundLayout->addWidget(whiteBackgroundButton); backgroundLayout->addWidget(greyBackgroundButton); backgroundLayout->addWidget(dotsBackgroundButton); backgroundLayout->addWidget(weaveBackgroundButton); mShadowsBox = new QCheckBox(tr("Shadows")); mToolCursorsBox = new QCheckBox(tr("Tool Cursors")); mAntialiasingBox = new QCheckBox(tr("Antialiasing")); mDottedCursorBox = new QCheckBox(tr("Dotted Cursor")); QGridLayout* langLayout = new QGridLayout; languageBox->setLayout( langLayout ); langLayout->addWidget( mLanguageCombo ); QGridLayout* windowOpacityLayout = new QGridLayout(); windowOpacityBox->setLayout(windowOpacityLayout); windowOpacityLayout->addWidget(windowOpacityLabel, 0, 0); windowOpacityLayout->addWidget(mWindowOpacityLevel, 0, 1); QVBoxLayout* appearanceLayout = new QVBoxLayout(); appearanceBox->setLayout(appearanceLayout); appearanceLayout->addWidget(mShadowsBox); appearanceLayout->addWidget(mToolCursorsBox); appearanceLayout->addWidget(mDottedCursorBox); QGridLayout* displayLayout = new QGridLayout(); displayBox->setLayout(displayLayout); displayLayout->addWidget(mAntialiasingBox, 0, 0); QLabel* curveSmoothingLabel = new QLabel(tr("Vector curve smoothing")); mCurveSmoothingLevel = new QSlider(Qt::Horizontal); mCurveSmoothingLevel->setMinimum(1); mCurveSmoothingLevel->setMaximum(100); value = settings.value("curveSmoothing").toInt(); mCurveSmoothingLevel->setValue( value ); mHighResBox = new QCheckBox(tr("Tablet high-resolution position")); QGridLayout* editingLayout = new QGridLayout(); editingBox->setLayout(editingLayout); editingLayout->addWidget(curveSmoothingLabel, 0, 0); editingLayout->addWidget(mCurveSmoothingLevel, 1, 0); editingLayout->addWidget(mHighResBox, 2, 0); lay->addWidget( languageBox ); lay->addWidget( windowOpacityBox ); lay->addWidget( appearanceBox ); lay->addWidget( backgroundBox ); lay->addWidget( displayBox ); lay->addWidget( editingBox ); PreferencesDialog* preference = qobject_cast< PreferencesDialog* >( parent ); auto kButtonClicked = static_cast< void (QButtonGroup::* )( int ) >( &QButtonGroup::buttonClicked ); auto kCurIndexChagned = static_cast< void( QComboBox::* )( int ) >( &QComboBox::currentIndexChanged ); connect( mLanguageCombo, kCurIndexChagned, this, &GeneralPage::languageChanged ); connect( mWindowOpacityLevel, &QSlider::valueChanged, preference, &PreferencesDialog::windowOpacityChange ); connect( mBackgroundButtons, kButtonClicked, this, &GeneralPage::backgroundChange ); connect( mShadowsBox, &QCheckBox::stateChanged, this, &GeneralPage::shadowsCheckboxStateChanged ); connect( mToolCursorsBox, &QCheckBox::stateChanged, this, &GeneralPage::toolCursorsCheckboxStateChanged ); connect( mAntialiasingBox, &QCheckBox::stateChanged, this, &GeneralPage::antiAliasCheckboxStateChanged ); connect( mCurveSmoothingLevel, &QSlider::valueChanged, this, &GeneralPage::curveSmoothingChange ); connect( mHighResBox, &QCheckBox::stateChanged, this, &GeneralPage::highResCheckboxStateChanged ); connect( mDottedCursorBox, &QCheckBox::stateChanged, this, &GeneralPage::dottedCursorCheckboxStateChanged ); setLayout(lay); }
void PathStrokeControls::createCommonControls(QWidget* parent) { m_capGroup = new QGroupBox(parent); m_capGroup->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); QRadioButton *flatCap = new QRadioButton(m_capGroup); QRadioButton *squareCap = new QRadioButton(m_capGroup); QRadioButton *roundCap = new QRadioButton(m_capGroup); m_capGroup->setTitle(tr("Cap Style")); flatCap->setText(tr("Flat")); squareCap->setText(tr("Square")); roundCap->setText(tr("Round")); flatCap->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); squareCap->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); roundCap->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); m_joinGroup = new QGroupBox(parent); m_joinGroup->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); QRadioButton *bevelJoin = new QRadioButton(m_joinGroup); QRadioButton *miterJoin = new QRadioButton(m_joinGroup); QRadioButton *roundJoin = new QRadioButton(m_joinGroup); m_joinGroup->setTitle(tr("Join Style")); bevelJoin->setText(tr("Bevel")); miterJoin->setText(tr("Miter")); roundJoin->setText(tr("Round")); m_styleGroup = new QGroupBox(parent); m_styleGroup->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); QRadioButton *solidLine = new QRadioButton(m_styleGroup); QRadioButton *dashLine = new QRadioButton(m_styleGroup); QRadioButton *dotLine = new QRadioButton(m_styleGroup); QRadioButton *dashDotLine = new QRadioButton(m_styleGroup); QRadioButton *dashDotDotLine = new QRadioButton(m_styleGroup); QRadioButton *customDashLine = new QRadioButton(m_styleGroup); m_styleGroup->setTitle(tr("Pen Style")); QPixmap line_solid(":res/images/line_solid.png"); solidLine->setIcon(line_solid); solidLine->setIconSize(line_solid.size()); QPixmap line_dashed(":res/images/line_dashed.png"); dashLine->setIcon(line_dashed); dashLine->setIconSize(line_dashed.size()); QPixmap line_dotted(":res/images/line_dotted.png"); dotLine->setIcon(line_dotted); dotLine->setIconSize(line_dotted.size()); QPixmap line_dash_dot(":res/images/line_dash_dot.png"); dashDotLine->setIcon(line_dash_dot); dashDotLine->setIconSize(line_dash_dot.size()); QPixmap line_dash_dot_dot(":res/images/line_dash_dot_dot.png"); dashDotDotLine->setIcon(line_dash_dot_dot); dashDotDotLine->setIconSize(line_dash_dot_dot.size()); customDashLine->setText(tr("Custom")); int fixedHeight = bevelJoin->sizeHint().height(); solidLine->setFixedHeight(fixedHeight); dashLine->setFixedHeight(fixedHeight); dotLine->setFixedHeight(fixedHeight); dashDotLine->setFixedHeight(fixedHeight); dashDotDotLine->setFixedHeight(fixedHeight); m_pathModeGroup = new QGroupBox(parent); m_pathModeGroup->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); QRadioButton *curveMode = new QRadioButton(m_pathModeGroup); QRadioButton *lineMode = new QRadioButton(m_pathModeGroup); m_pathModeGroup->setTitle(tr("Line Style")); curveMode->setText(tr("Curves")); lineMode->setText(tr("Lines")); // Layouts QVBoxLayout *capGroupLayout = new QVBoxLayout(m_capGroup); capGroupLayout->addWidget(flatCap); capGroupLayout->addWidget(squareCap); capGroupLayout->addWidget(roundCap); QVBoxLayout *joinGroupLayout = new QVBoxLayout(m_joinGroup); joinGroupLayout->addWidget(bevelJoin); joinGroupLayout->addWidget(miterJoin); joinGroupLayout->addWidget(roundJoin); QVBoxLayout *styleGroupLayout = new QVBoxLayout(m_styleGroup); styleGroupLayout->addWidget(solidLine); styleGroupLayout->addWidget(dashLine); styleGroupLayout->addWidget(dotLine); styleGroupLayout->addWidget(dashDotLine); styleGroupLayout->addWidget(dashDotDotLine); styleGroupLayout->addWidget(customDashLine); QVBoxLayout *pathModeGroupLayout = new QVBoxLayout(m_pathModeGroup); pathModeGroupLayout->addWidget(curveMode); pathModeGroupLayout->addWidget(lineMode); // Connections connect(flatCap, SIGNAL(clicked()), m_renderer, SLOT(setFlatCap())); connect(squareCap, SIGNAL(clicked()), m_renderer, SLOT(setSquareCap())); connect(roundCap, SIGNAL(clicked()), m_renderer, SLOT(setRoundCap())); connect(bevelJoin, SIGNAL(clicked()), m_renderer, SLOT(setBevelJoin())); connect(miterJoin, SIGNAL(clicked()), m_renderer, SLOT(setMiterJoin())); connect(roundJoin, SIGNAL(clicked()), m_renderer, SLOT(setRoundJoin())); connect(curveMode, SIGNAL(clicked()), m_renderer, SLOT(setCurveMode())); connect(lineMode, SIGNAL(clicked()), m_renderer, SLOT(setLineMode())); connect(solidLine, SIGNAL(clicked()), m_renderer, SLOT(setSolidLine())); connect(dashLine, SIGNAL(clicked()), m_renderer, SLOT(setDashLine())); connect(dotLine, SIGNAL(clicked()), m_renderer, SLOT(setDotLine())); connect(dashDotLine, SIGNAL(clicked()), m_renderer, SLOT(setDashDotLine())); connect(dashDotDotLine, SIGNAL(clicked()), m_renderer, SLOT(setDashDotDotLine())); connect(customDashLine, SIGNAL(clicked()), m_renderer, SLOT(setCustomDashLine())); // Set the defaults: flatCap->setChecked(true); bevelJoin->setChecked(true); curveMode->setChecked(true); solidLine->setChecked(true); }
GeneralPage::GeneralPage(QWidget* parent) : QWidget(parent) { QSettings settings("Pencil","Pencil"); QVBoxLayout* lay = new QVBoxLayout(); QGroupBox* windowOpacityBox = new QGroupBox(tr("Window opacity")); QGroupBox* backgroundBox = new QGroupBox(tr("Background")); QGroupBox* appearanceBox = new QGroupBox(tr("Appearance")); QGroupBox* displayBox = new QGroupBox(tr("Rendering")); QGroupBox* editingBox = new QGroupBox(tr("Editing")); QLabel* windowOpacityLabel = new QLabel(tr("Opacity")); QSlider* windowOpacityLevel = new QSlider(Qt::Horizontal); windowOpacityLevel->setMinimum(30); windowOpacityLevel->setMaximum(100); int value = settings.value("windowOpacity").toInt(); windowOpacityLevel->setValue( 100 - value ); QButtonGroup* backgroundButtons = new QButtonGroup(); QRadioButton* checkerBackgroundButton = new QRadioButton(); QRadioButton* whiteBackgroundButton = new QRadioButton(); QRadioButton* greyBackgroundButton = new QRadioButton(); QRadioButton* dotsBackgroundButton = new QRadioButton(); QRadioButton* weaveBackgroundButton = new QRadioButton(); QPixmap previewCheckerboard(32,32); QPixmap previewWhite(32,32); QPixmap previewGrey(32,32); QPixmap previewDots(32,32); QPixmap previewWeave(32,32); QPainter painter(&previewCheckerboard); painter.fillRect( QRect(0,0,32,32), ScribbleArea::getBackgroundBrush("checkerboard") ); painter.end(); painter.begin(&previewDots); painter.fillRect( QRect(0,0,32,32), ScribbleArea::getBackgroundBrush("dots") ); painter.end(); painter.begin(&previewWeave); painter.fillRect( QRect(0,0,32,32), ScribbleArea::getBackgroundBrush("weave") ); painter.end(); previewWhite.fill( Qt::white ); previewGrey.fill( Qt:: lightGray ); checkerBackgroundButton->setIcon( previewCheckerboard ); whiteBackgroundButton->setIcon( previewWhite ); greyBackgroundButton->setIcon( previewGrey ); dotsBackgroundButton->setIcon( previewDots ); dotsBackgroundButton->setIcon( previewWeave ); backgroundButtons->addButton(checkerBackgroundButton); backgroundButtons->addButton(whiteBackgroundButton); backgroundButtons->addButton(greyBackgroundButton); backgroundButtons->addButton(dotsBackgroundButton); backgroundButtons->addButton(weaveBackgroundButton); backgroundButtons->setId(checkerBackgroundButton, 1); backgroundButtons->setId(whiteBackgroundButton, 2); backgroundButtons->setId(greyBackgroundButton, 3); backgroundButtons->setId(dotsBackgroundButton, 4); backgroundButtons->setId(weaveBackgroundButton, 5); QHBoxLayout* backgroundLayout = new QHBoxLayout(); backgroundBox->setLayout(backgroundLayout); backgroundLayout->addWidget(checkerBackgroundButton); backgroundLayout->addWidget(whiteBackgroundButton); backgroundLayout->addWidget(greyBackgroundButton); backgroundLayout->addWidget(dotsBackgroundButton); backgroundLayout->addWidget(weaveBackgroundButton); if ( settings.value("background").toString() == "checkerboard" ) checkerBackgroundButton->setChecked(true); if ( settings.value("background").toString() == "white" ) whiteBackgroundButton->setChecked(true); if ( settings.value("background").toString() == "grey" ) greyBackgroundButton->setChecked(true); if ( settings.value("background").toString() == "dots" ) dotsBackgroundButton->setChecked(true); if ( settings.value("background").toString() == "weave" ) weaveBackgroundButton->setChecked(true); QCheckBox* shadowsBox = new QCheckBox(tr("Shadows")); shadowsBox->setChecked(false); // default if (settings.value("shadows").toString()=="true") shadowsBox->setChecked(true); QCheckBox* toolCursorsBox = new QCheckBox(tr("Tool Cursors")); toolCursorsBox->setChecked(true); // default if (settings.value("toolCursors").toString()=="false") toolCursorsBox->setChecked(false); QCheckBox* aquaBox = new QCheckBox(tr("Aqua Style")); aquaBox->setChecked(false); // default if (settings.value("style").toString()=="aqua") aquaBox->setChecked(true); QCheckBox* antialiasingBox = new QCheckBox(tr("Antialiasing")); antialiasingBox->setChecked(true); // default if (settings.value("antialiasing").toString()=="false") antialiasingBox->setChecked(false); QButtonGroup* gradientsButtons = new QButtonGroup(); QRadioButton* gradient1Button = new QRadioButton(tr("None")); QRadioButton* gradient2Button = new QRadioButton(tr("Quick")); QRadioButton* gradient3Button = new QRadioButton(tr("Gradient1")); QRadioButton* gradient4Button = new QRadioButton(tr("Gradient2")); gradientsButtons->addButton(gradient1Button); gradientsButtons->addButton(gradient2Button); gradientsButtons->addButton(gradient3Button); gradientsButtons->addButton(gradient4Button); gradientsButtons->setId(gradient1Button, 1); gradientsButtons->setId(gradient2Button, 2); gradientsButtons->setId(gradient3Button, 3); gradientsButtons->setId(gradient4Button, 4); QGroupBox* gradientsBox = new QGroupBox(tr("Gradients")); QHBoxLayout* gradientsLayout = new QHBoxLayout(); gradientsBox->setLayout(gradientsLayout); gradientsLayout->addWidget(gradient1Button); gradientsLayout->addWidget(gradient2Button); gradientsLayout->addWidget(gradient3Button); gradientsLayout->addWidget(gradient4Button); if ( settings.value("gradients").toString() == "1" ) gradient1Button->setChecked(true); if ( settings.value("gradients").toString() == "2" ) gradient2Button->setChecked(true); if ( settings.value("gradients").toString() == "" ) gradient2Button->setChecked(true); // default if ( settings.value("gradients").toString() == "3" ) gradient3Button->setChecked(true); if ( settings.value("gradients").toString() == "4" ) gradient4Button->setChecked(true); QGridLayout* windowOpacityLayout = new QGridLayout(); windowOpacityBox->setLayout(windowOpacityLayout); windowOpacityLayout->addWidget(windowOpacityLabel, 0, 0); windowOpacityLayout->addWidget(windowOpacityLevel, 0, 1); QVBoxLayout* appearanceLayout = new QVBoxLayout(); appearanceBox->setLayout(appearanceLayout); appearanceLayout->addWidget(shadowsBox); appearanceLayout->addWidget(toolCursorsBox); #ifdef Q_WS_MAC appearanceLayout->addWidget(aquaBox); #endif QGridLayout* displayLayout = new QGridLayout(); displayBox->setLayout(displayLayout); displayLayout->addWidget(antialiasingBox, 0, 0); displayLayout->addWidget(gradientsBox, 1, 0); QLabel* curveSmoothingLabel = new QLabel(tr("Vector curve smoothing")); QSlider* curveSmoothingLevel = new QSlider(Qt::Horizontal); curveSmoothingLevel->setMinimum(1); curveSmoothingLevel->setMaximum(100); value = settings.value("curveSmoothing").toInt(); curveSmoothingLevel->setValue( value ); QCheckBox* highResBox = new QCheckBox(tr("Tablet high-resolution position")); if (settings.value(SETTING_HIGH_RESOLUTION) == "true") { highResBox->setChecked(true); } else { highResBox->setChecked(false); } QGridLayout* editingLayout = new QGridLayout(); editingBox->setLayout(editingLayout); editingLayout->addWidget(curveSmoothingLabel, 0, 0); editingLayout->addWidget(curveSmoothingLevel, 1, 0); editingLayout->addWidget(highResBox, 2, 0); lay->addWidget(windowOpacityBox); lay->addWidget(appearanceBox); lay->addWidget(backgroundBox); lay->addWidget(displayBox); lay->addWidget(editingBox); connect(windowOpacityLevel, SIGNAL(valueChanged(int)), parent, SIGNAL(windowOpacityChange(int))); connect(backgroundButtons, SIGNAL(buttonClicked(int)), parent, SIGNAL(backgroundChange(int))); connect(gradientsButtons, SIGNAL(buttonClicked(int)), parent, SIGNAL(gradientsChange(int))); connect(shadowsBox, SIGNAL(stateChanged(int)), parent, SIGNAL(shadowsChange(int))); connect(toolCursorsBox, SIGNAL(stateChanged(int)), parent, SIGNAL(toolCursorsChange(int))); connect(aquaBox, SIGNAL(stateChanged(int)), parent, SIGNAL(styleChanged(int))); connect(antialiasingBox, SIGNAL(stateChanged(int)), parent, SIGNAL(antialiasingChange(int))); connect(curveSmoothingLevel, SIGNAL(valueChanged(int)), parent, SIGNAL(curveSmoothingChange(int))); connect(highResBox, SIGNAL(stateChanged(int)), parent, SIGNAL(highResPositionChange(int))); setLayout(lay); }
GeneralPage::GeneralPage(QWidget* parent) : QWidget(parent) { QSettings settings( PENCIL2D, PENCIL2D ); QVBoxLayout* lay = new QVBoxLayout(); QGroupBox* windowOpacityBox = new QGroupBox(tr("Window opacity")); QGroupBox* backgroundBox = new QGroupBox(tr("Background")); QGroupBox* appearanceBox = new QGroupBox(tr("Appearance")); QGroupBox* displayBox = new QGroupBox(tr("Rendering")); QGroupBox* editingBox = new QGroupBox(tr("Editing")); QLabel* windowOpacityLabel = new QLabel(tr("Opacity")); QSlider* windowOpacityLevel = new QSlider(Qt::Horizontal); windowOpacityLevel->setMinimum(30); windowOpacityLevel->setMaximum(100); int value = settings.value("windowOpacity").toInt(); windowOpacityLevel->setValue( 100 - value ); QButtonGroup* backgroundButtons = new QButtonGroup(); QRadioButton* checkerBackgroundButton = new QRadioButton(); QRadioButton* whiteBackgroundButton = new QRadioButton(); QRadioButton* greyBackgroundButton = new QRadioButton(); QRadioButton* dotsBackgroundButton = new QRadioButton(); QRadioButton* weaveBackgroundButton = new QRadioButton(); QPixmap previewCheckerboard(32,32); QPixmap previewWhite(32,32); QPixmap previewGrey(32,32); QPixmap previewDots(32,32); QPixmap previewWeave(32,32); QPainter painter(&previewCheckerboard); painter.fillRect( QRect(0,0,32,32), ScribbleArea::getBackgroundBrush("checkerboard") ); painter.end(); painter.begin(&previewDots); painter.fillRect( QRect(0,0,32,32), ScribbleArea::getBackgroundBrush("dots") ); painter.end(); painter.begin(&previewWeave); painter.fillRect( QRect(0,0,32,32), ScribbleArea::getBackgroundBrush("weave") ); painter.end(); previewWhite.fill( Qt::white ); previewGrey.fill( Qt:: lightGray ); checkerBackgroundButton->setIcon( previewCheckerboard ); whiteBackgroundButton->setIcon( previewWhite ); greyBackgroundButton->setIcon( previewGrey ); dotsBackgroundButton->setIcon( previewDots ); dotsBackgroundButton->setIcon( previewWeave ); backgroundButtons->addButton(checkerBackgroundButton); backgroundButtons->addButton(whiteBackgroundButton); backgroundButtons->addButton(greyBackgroundButton); backgroundButtons->addButton(dotsBackgroundButton); backgroundButtons->addButton(weaveBackgroundButton); backgroundButtons->setId(checkerBackgroundButton, 1); backgroundButtons->setId(whiteBackgroundButton, 2); backgroundButtons->setId(greyBackgroundButton, 3); backgroundButtons->setId(dotsBackgroundButton, 4); backgroundButtons->setId(weaveBackgroundButton, 5); QHBoxLayout* backgroundLayout = new QHBoxLayout(); backgroundBox->setLayout(backgroundLayout); backgroundLayout->addWidget(checkerBackgroundButton); backgroundLayout->addWidget(whiteBackgroundButton); backgroundLayout->addWidget(greyBackgroundButton); backgroundLayout->addWidget(dotsBackgroundButton); backgroundLayout->addWidget(weaveBackgroundButton); if ( settings.value("background").toString() == "checkerboard" ) checkerBackgroundButton->setChecked(true); if ( settings.value("background").toString() == "white" ) whiteBackgroundButton->setChecked(true); if ( settings.value("background").toString() == "grey" ) greyBackgroundButton->setChecked(true); if ( settings.value("background").toString() == "dots" ) dotsBackgroundButton->setChecked(true); if ( settings.value("background").toString() == "weave" ) weaveBackgroundButton->setChecked(true); mShadowsBox = new QCheckBox(tr("Shadows")); mToolCursorsBox = new QCheckBox(tr("Tool Cursors")); mAntialiasingBox = new QCheckBox(tr("Antialiasing")); mBlurryZoomBox = new QCheckBox(tr("Blurry Zoom")); QGridLayout* windowOpacityLayout = new QGridLayout(); windowOpacityBox->setLayout(windowOpacityLayout); windowOpacityLayout->addWidget(windowOpacityLabel, 0, 0); windowOpacityLayout->addWidget(windowOpacityLevel, 0, 1); QVBoxLayout* appearanceLayout = new QVBoxLayout(); appearanceBox->setLayout(appearanceLayout); appearanceLayout->addWidget(mShadowsBox); appearanceLayout->addWidget(mToolCursorsBox); QGridLayout* displayLayout = new QGridLayout(); displayBox->setLayout(displayLayout); displayLayout->addWidget(mAntialiasingBox, 0, 0); displayLayout->addWidget(mBlurryZoomBox, 1, 0); QLabel* curveSmoothingLabel = new QLabel(tr("Vector curve smoothing")); QSlider* curveSmoothingLevel = new QSlider(Qt::Horizontal); curveSmoothingLevel->setMinimum(1); curveSmoothingLevel->setMaximum(100); value = settings.value("curveSmoothing").toInt(); curveSmoothingLevel->setValue( value ); QCheckBox* highResBox = new QCheckBox(tr("Tablet high-resolution position")); if (settings.value(SETTING_HIGH_RESOLUTION) == "true") { highResBox->setChecked(true); } else { highResBox->setChecked(false); } QGridLayout* editingLayout = new QGridLayout(); editingBox->setLayout(editingLayout); editingLayout->addWidget(curveSmoothingLabel, 0, 0); editingLayout->addWidget(curveSmoothingLevel, 1, 0); editingLayout->addWidget(highResBox, 2, 0); lay->addWidget(windowOpacityBox); lay->addWidget(appearanceBox); lay->addWidget(backgroundBox); lay->addWidget(displayBox); lay->addWidget(editingBox); PreferencesDialog* preference = qobject_cast< PreferencesDialog* >( parent ); auto kButtonClicked = static_cast< void (QButtonGroup::* )( int ) >( &QButtonGroup::buttonClicked ); connect( windowOpacityLevel, &QSlider::valueChanged, preference, &PreferencesDialog::windowOpacityChange ); connect( backgroundButtons, kButtonClicked, preference, &PreferencesDialog::backgroundChange ); connect( mShadowsBox, &QCheckBox::stateChanged, preference, &PreferencesDialog::shadowsChange ); connect( mToolCursorsBox, &QCheckBox::stateChanged, this, &GeneralPage::toolCursorsCheckboxStateChanged ); connect( mAntialiasingBox, &QCheckBox::stateChanged, this, &GeneralPage::antiAliasCheckboxStateChanged ); connect( mBlurryZoomBox, &QCheckBox::stateChanged, this, &GeneralPage::blurryZoomCheckboxStateChanged ); connect( curveSmoothingLevel, &QSlider::valueChanged, preference, &PreferencesDialog::curveSmoothingChange ); connect( highResBox, &QCheckBox::stateChanged, preference, &PreferencesDialog::highResPositionChange ); setLayout(lay); }
StrokeDocker::StrokeDocker() : d( new Private() ) { setWindowTitle( i18n( "Stroke Properties" ) ); QWidget *mainWidget = new QWidget( this ); QGridLayout *mainLayout = new QGridLayout( mainWidget ); QLabel * styleLabel = new QLabel( i18n( "Style:" ), mainWidget ); mainLayout->addWidget( styleLabel, 0, 0 ); d->lineStyle = new KoLineStyleSelector( mainWidget ); mainLayout->addWidget( d->lineStyle, 0, 1, 1, 3 ); connect( d->lineStyle, SIGNAL(currentIndexChanged( int ) ), this, SLOT( styleChanged() ) ); QLabel* widthLabel = new QLabel( i18n ( "Width:" ), mainWidget ); mainLayout->addWidget( widthLabel, 1, 0 ); // set min/max/step and value in points, then set actual unit d->setLineWidth = new KoUnitDoubleSpinBox( mainWidget ); d->setLineWidth->setMinMaxStep( 0.0, 1000.0, 0.5 ); d->setLineWidth->setDecimals( 2 ); d->setLineWidth->setUnit( KoUnit(KoUnit::Point) ); d->setLineWidth->setToolTip( i18n( "Set line width of actual selection" ) ); mainLayout->addWidget( d->setLineWidth, 1, 1, 1, 3 ); connect( d->setLineWidth, SIGNAL( valueChangedPt( qreal ) ), this, SLOT( widthChanged() ) ); QLabel* capLabel = new QLabel( i18n ( "Cap:" ), mainWidget ); mainLayout->addWidget( capLabel, 2, 0 ); d->capGroup = new QButtonGroup( mainWidget ); d->capGroup->setExclusive( true ); d->capGroup->setExclusive( true ); QRadioButton *button = 0; button = new QRadioButton( mainWidget ); button->setIcon( SmallIcon( "cap_butt" ) ); button->setCheckable( true ); button->setToolTip( i18n( "Butt cap" ) ); d->capGroup->addButton( button, Qt::FlatCap ); mainLayout->addWidget( button, 2, 1 ); button = new QRadioButton( mainWidget ); button->setIcon( SmallIcon( "cap_round" ) ); button->setCheckable( true ); button->setToolTip( i18n( "Round cap" ) ); d->capGroup->addButton( button, Qt::RoundCap ); mainLayout->addWidget( button, 2, 2 ); button = new QRadioButton( mainWidget ); button->setIcon( SmallIcon( "cap_square" ) ); button->setCheckable( true ); button->setToolTip( i18n( "Square cap" ) ); d->capGroup->addButton( button, Qt::SquareCap ); mainLayout->addWidget( button, 2, 3 ); connect( d->capGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( slotCapChanged( int ) ) ); QLabel* joinLabel = new QLabel( i18n ( "Join:" ), mainWidget ); mainLayout->addWidget( joinLabel, 3, 0 ); d->joinGroup = new QButtonGroup( mainWidget ); d->joinGroup->setExclusive( true ); button = new QRadioButton( mainWidget ); button->setIcon( SmallIcon( "join_miter" ) ); button->setCheckable( true ); button->setToolTip( i18n( "Miter join" ) ); d->joinGroup->addButton( button, Qt::MiterJoin ); mainLayout->addWidget( button, 3, 1 ); button = new QRadioButton( mainWidget ); button->setIcon( SmallIcon( "join_round" ) ); button->setCheckable( true ); button->setToolTip( i18n( "Round join" ) ); d->joinGroup->addButton( button, Qt::RoundJoin ); mainLayout->addWidget( button, 3, 2 ); button = new QRadioButton( mainWidget ); button->setIcon( SmallIcon( "join_bevel" ) ); button->setCheckable( true ); button->setToolTip( i18n( "Bevel join" ) ); d->joinGroup->addButton( button, Qt::BevelJoin ); mainLayout->addWidget( button, 3, 3 ); connect( d->joinGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( slotJoinChanged( int ) ) ); QLabel* miterLabel = new QLabel( i18n ( "Miter limit:" ), mainWidget ); mainLayout->addWidget( miterLabel, 4, 0 ); // set min/max/step and value in points, then set actual unit d->miterLimit = new KoUnitDoubleSpinBox( mainWidget ); d->miterLimit->setMinMaxStep( 0.0, 1000.0, 0.5 ); d->miterLimit->setDecimals( 2 ); d->miterLimit->setUnit( KoUnit(KoUnit::Point) ); d->miterLimit->setToolTip( i18n( "Set miter limit" ) ); mainLayout->addWidget( d->miterLimit, 4, 1, 1, 3 ); connect( d->miterLimit, SIGNAL( valueChangedPt( qreal ) ), this, SLOT( miterLimitChanged() ) ); mainLayout->setRowStretch( 5, 1 ); mainLayout->setColumnStretch( 1, 1 ); mainLayout->setColumnStretch( 2, 1 ); mainLayout->setColumnStretch( 3, 1 ); setWidget( mainWidget ); updateControls(); }