//------------------------------------------------------------------------------ void MainDialog::slotOpenExample() { QAction *t = (QAction*) QObject::sender(); QString t_path = ":/examples/examples/" + t->text().replace(" ", "").toLower() + ".qss"; QFile t_file(t_path); t_file.open(QIODevice::ReadOnly); QString t_text = QTextStream(&t_file).readAll(); t_file.close(); ui->TECode->setText(t_text); slotUpdatePreview(); }
//------------------------------------------------------------------------------ void MainDialog::slotLoadExample() { QFileDialog::Options options; QString selectedFilter; QString fileName = QFileDialog::getOpenFileName(this, tr("Open QSS style"), "", tr("Qt Style Sheets (*.qss)"), &selectedFilter, options); if (!fileName.isEmpty()) { QFile t_file(fileName); t_file.open(QIODevice::ReadOnly); QString t_text = QTextStream(&t_file).readAll(); t_file.close(); ui->TECode->setText(t_text); slotUpdatePreview(); } }
OrganizeCollectionDialog::OrganizeCollectionDialog( const Meta::TrackList &tracks, const QStringList &folders, const QString &targetExtension, QWidget *parent, const char *name, bool modal, const QString &caption, QFlags<KDialog::ButtonCode> buttonMask ) : KDialog( parent ) , ui( new Ui::OrganizeCollectionDialogBase ) , m_detailed( true ) , m_schemeModified( false ) , m_conflict( false ) { Q_UNUSED( name ) setCaption( caption ); setModal( modal ); setButtons( buttonMask ); showButtonSeparator( true ); m_targetFileExtension = targetExtension; if( tracks.size() > 0 ) m_allTracks = tracks; KVBox *mainVBox = new KVBox( this ); setMainWidget( mainVBox ); QWidget *mainContainer = new QWidget( mainVBox ); ui->setupUi( mainContainer ); m_trackOrganizer = new TrackOrganizer( m_allTracks, this ); ui->folderCombo->insertItems( 0, folders ); if( ui->folderCombo->contains( AmarokConfig::organizeDirectory() ) ) ui->folderCombo->setCurrentItem( AmarokConfig::organizeDirectory() ); else ui->folderCombo->setCurrentIndex( 0 ); //TODO possible bug: assumes folder list is not empty. ui->overwriteCheck->setChecked( AmarokConfig::overwriteFiles() ); ui->optionsWidget->setReplaceSpaces( AmarokConfig::replaceSpace() ); ui->optionsWidget->setPostfixThe( AmarokConfig::ignoreThe() ); ui->optionsWidget->setVfatCompatible( AmarokConfig::vfatCompatible() ); ui->optionsWidget->setAsciiOnly( AmarokConfig::asciiOnly() ); ui->optionsWidget->setRegexpText( AmarokConfig::replacementRegexp() ); ui->optionsWidget->setReplaceText( AmarokConfig::replacementString() ); ui->previewTableWidget->horizontalHeader()->setResizeMode( QHeaderView::ResizeToContents ); ui->conflictLabel->setText(""); QPalette p = ui->conflictLabel->palette(); KColorScheme::adjustForeground( p, KColorScheme::NegativeText ); // TODO this isn't working, the color is still normal ui->conflictLabel->setPalette( p ); ui->previewTableWidget->sortItems( 0, Qt::AscendingOrder ); // only show the options when the Options button is checked connect( ui->optionsButton, SIGNAL(toggled(bool)), ui->organizeCollectionWidget, SLOT(setVisible(bool)) ); connect( ui->optionsButton, SIGNAL(toggled(bool)), ui->optionsWidget, SLOT(setVisible(bool)) ); ui->organizeCollectionWidget->hide(); ui->optionsWidget->hide(); connect( ui->folderCombo, SIGNAL(currentIndexChanged(QString)), SLOT(slotUpdatePreview()) ); connect( ui->organizeCollectionWidget, SIGNAL(schemeChanged()), SLOT(slotUpdatePreview()) ); connect( ui->optionsWidget, SIGNAL(optionsChanged()), SLOT(slotUpdatePreview())); // to show the conflict error connect( ui->overwriteCheck, SIGNAL(stateChanged(int)), SLOT(slotOverwriteModeChanged()) ); connect( this, SIGNAL(finished(int)), ui->organizeCollectionWidget, SLOT(slotSaveFormatList()) ); connect( this, SIGNAL(accepted()), ui->organizeCollectionWidget, SLOT(onAccept()) ); connect( this, SIGNAL(accepted()), SLOT(slotDialogAccepted()) ); connect( ui->folderCombo, SIGNAL(currentIndexChanged(QString)), SLOT(slotEnableOk(QString)) ); slotEnableOk( ui->folderCombo->currentText() ); restoreDialogSize( Amarok::config( "OrganizeCollectionDialog" ) ); QTimer::singleShot( 0, this, SLOT(slotUpdatePreview()) ); }
InsertTextTool::InsertTextTool(QObject* const parent) : EditorTool(parent), d(new Private) { setObjectName(QLatin1String("inserttext")); // ------------------------------------------------------------- QFrame* const frame = new QFrame(nullptr); frame->setFrameStyle(QFrame::Panel|QFrame::Sunken); QVBoxLayout* const l = new QVBoxLayout(frame); d->previewWidget = new InsertTextWidget(480, 320, frame); l->addWidget(d->previewWidget); d->previewWidget->setWhatsThis(i18n("This previews the text inserted in the image. " "You can use the mouse to move the text to the right location.")); setToolView(frame); // ------------------------------------------------------------- d->gboxSettings = new EditorToolSettings(nullptr); d->textEdit = new QTextEdit(); d->textEdit->setWordWrapMode(QTextOption::NoWrap); d->textEdit->setWhatsThis( i18n("Here, enter the text you want to insert in your image.")); // ------------------------------------------------------------- d->fontChooserWidget = new DFontProperties(nullptr, DFontProperties::NoDisplayFlags); d->fontChooserWidget->setSampleBoxVisible(false); d->fontChooserWidget->setWhatsThis(i18n("Here you can choose the font to be used.")); // ------------------------------------------------------------- QWidget* const alignBox = new QWidget(); QHBoxLayout* const hlay = new QHBoxLayout(alignBox); d->alignButtonGroup = new QButtonGroup(alignBox); d->alignButtonGroup->setExclusive(true); QToolButton* const alignLeft = new QToolButton(alignBox); d->alignButtonGroup->addButton(alignLeft, InsertTextWidget::ALIGN_LEFT); alignLeft->setIcon(QIcon::fromTheme(QLatin1String("format-justify-left"))); alignLeft->setCheckable(true); alignLeft->setToolTip(i18n("Align text to the left")); QToolButton* const alignRight = new QToolButton(alignBox); d->alignButtonGroup->addButton(alignRight, InsertTextWidget::ALIGN_RIGHT); alignRight->setIcon(QIcon::fromTheme(QLatin1String("format-justify-right"))); alignRight->setCheckable(true); alignRight->setToolTip(i18n("Align text to the right")); QToolButton* const alignCenter = new QToolButton(alignBox); d->alignButtonGroup->addButton(alignCenter, InsertTextWidget::ALIGN_CENTER); alignCenter->setIcon(QIcon::fromTheme(QLatin1String("format-justify-center"))); alignCenter->setCheckable(true); alignCenter->setToolTip(i18n("Align text to center")); QToolButton* alignBlock = new QToolButton(alignBox); d->alignButtonGroup->addButton(alignBlock, InsertTextWidget::ALIGN_BLOCK); alignBlock->setIcon(QIcon::fromTheme(QLatin1String("format-justify-fill"))); alignBlock->setCheckable(true); alignBlock->setToolTip(i18n("Align text to a block")); hlay->setContentsMargins(QMargins()); hlay->setSpacing(0); hlay->addStretch(); hlay->addWidget(alignLeft); hlay->addWidget(alignRight); hlay->addWidget(alignCenter); hlay->addWidget(alignBlock); hlay->addStretch(); // ------------------------------------------------------------- QLabel* const label1 = new QLabel(i18n("Rotation:")); d->textRotation = new QComboBox(); d->textRotation->addItem(i18nc("no rotation", "None")); d->textRotation->addItem(i18n("90 Degrees")); d->textRotation->addItem(i18n("180 Degrees")); d->textRotation->addItem(i18n("270 Degrees")); d->textRotation->setWhatsThis(i18n("Select the text rotation to use here.")); // ------------------------------------------------------------- QLabel* const label2 = new QLabel(i18nc("font color", "Color:")); d->fontColorButton = new DColorSelector(); d->fontColorButton->setColor(Qt::black); d->fontColorButton->setWhatsThis(i18n("Set here the font color to use.")); // ------------------------------------------------------------- QLabel* const label3 = new QLabel(i18nc("text opacity", "Opacity:")); d->textOpacity = new DIntNumInput(); d->textOpacity->setRange(0, 100, 1); d->textOpacity->setDefaultValue(100); d->textOpacity->setSuffix(QLatin1String("%")); d->textOpacity->setWhatsThis(i18n("Select the text opacity to use here.")); // ------------------------------------------------------------- d->borderText = new QCheckBox(i18n("Add border")); d->borderText->setToolTip(i18n("Add a solid border around text using current text color")); d->transparentText = new QCheckBox(i18n("Semi-transparent")); d->transparentText->setToolTip(i18n("Use semi-transparent text background under image")); // ------------------------------------------------------------- const int spacing = d->gboxSettings->spacingHint(); QGridLayout* const mainLayout = new QGridLayout(); mainLayout->addWidget(d->textEdit, 0, 0, 3, -1); mainLayout->addWidget(d->fontChooserWidget, 3, 0, 1, -1); mainLayout->addWidget(alignBox, 4, 0, 1, -1); mainLayout->addWidget(label1, 5, 0, 1, 1); mainLayout->addWidget(d->textRotation, 5, 1, 1, 1); mainLayout->addWidget(label2, 6, 0, 1, 1); mainLayout->addWidget(d->fontColorButton, 6, 1, 1, 1); mainLayout->addWidget(label3, 7, 0, 1, 1); mainLayout->addWidget(d->textOpacity, 7, 1, 1, 1); mainLayout->addWidget(d->borderText, 8, 0, 1, -1); mainLayout->addWidget(d->transparentText, 9, 0, 1, -1); mainLayout->setRowStretch(10, 10); mainLayout->setColumnStretch(1, 5); mainLayout->setColumnStretch(2, 10); mainLayout->setContentsMargins(spacing, spacing, spacing, spacing); mainLayout->setSpacing(spacing); d->gboxSettings->plainPage()->setLayout(mainLayout); // ------------------------------------------------------------- setToolSettings(d->gboxSettings); // ------------------------------------------------------------- connect(d->fontChooserWidget, SIGNAL(fontSelected(QFont)), this, SLOT(slotFontPropertiesChanged(QFont))); connect(d->fontColorButton, SIGNAL(signalColorSelected(QColor)), this, SLOT(slotUpdatePreview())); connect(d->textOpacity, SIGNAL(valueChanged(int)), this, SLOT(slotUpdatePreview())); connect(d->textEdit, SIGNAL(textChanged()), this, SLOT(slotUpdatePreview())); connect(d->alignButtonGroup, SIGNAL(buttonReleased(int)), this, SLOT(slotAlignModeChanged(int))); connect(d->borderText, SIGNAL(toggled(bool)), this, SLOT(slotUpdatePreview())); connect(d->transparentText, SIGNAL(toggled(bool)), this, SLOT(slotUpdatePreview())); connect(d->textRotation, SIGNAL(activated(int)), this, SLOT(slotUpdatePreview())); connect(this, SIGNAL(signalUpdatePreview()), this, SLOT(slotUpdatePreview())); // ------------------------------------------------------------- slotUpdatePreview(); }
void OrganizeCollectionDialog::init() { slotUpdatePreview(); }
//------------------------------------------------------------------------------ void MainDialog::slotAdvancedSave() { ui->widgetView->setStyleSheet(ui->TECode->toPlainText()); slotUpdatePreview(); }