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* 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); }
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); }