/* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "configurationdialog.h" #include "programconfigurator.h" #include "smglobals.h" #include "helper.h" ConfigurationDialog::ConfigurationDialog(QWidget *parent, Qt::WindowFlags f) : SmDialog(parent, f) { //setup mTab = new QTabWidget; QDirModel *model = new QDirModel(this); QCompleter *fsCompleter = new QCompleter(this); fsCompleter->setModel(model); fsCompleter->setCompletionMode(QCompleter::PopupCompletion); //directories tab //directories QWidget *pathWidget = new QWidget; QGroupBox *pathBox = new QGroupBox(tr("Paths")); QFormLayout *pathL = new QFormLayout; mArchiveDir = new QLineEdit; mArchiveDir->setCompleter(fsCompleter); pathL->addRow(tr("Archive directory"), mArchiveDir); mBurnDir = new QLineEdit; mBurnDir->setCompleter(fsCompleter); pathL->addRow(tr("Burn directory"), mBurnDir); mUSBDir = new QLineEdit; mUSBDir->setCompleter(fsCompleter); pathL->addRow(tr("USB directory"), mUSBDir); mFfProbePath = new QLineEdit; mFfProbePath->setCompleter(fsCompleter); pathL->addRow(tr("Path to ffprobe"), mFfProbePath); mFfMpegPath = new QLineEdit; mFfMpegPath->setCompleter(fsCompleter); pathL->addRow(tr("Path to ffmpeg"), mFfMpegPath); mDvdMountPath = new QLineEdit; pathL->addRow(tr("DVD mount directory"), mDvdMountPath); mCoverPath = new QLineEdit; mCoverPath->setCompleter(fsCompleter); pathL->addRow(tr("Cover directory"), mCoverPath); pathBox->setLayout(pathL); QVBoxLayout *pathLayout = new QVBoxLayout; pathLayout->addWidget(pathBox); pathWidget->setLayout(pathLayout); //copy path options QGroupBox *copyBox = new QGroupBox(tr("Copy path options")); QFormLayout *copyL = new QFormLayout; mWindowsDrive = new QLineEdit; QRegExp pathValid("[a-z]{1}:"); pathValid.setCaseSensitivity(Qt::CaseInsensitive); QRegExpValidator *pathValidator = new QRegExpValidator(pathValid, this); mWindowsDrive->setValidator(pathValidator); copyL->addRow(tr("Windows drive"), mWindowsDrive); mStripPath = new QLineEdit; copyL->addRow(tr("Strip from path"), mStripPath); copyBox->setLayout(copyL); pathLayout->addWidget(copyBox); //expensive option QGroupBox *expensiveBox = new QGroupBox(tr("Expensive file operations")); QHBoxLayout *expensiveL = new QHBoxLayout; mExpensive = new QCheckBox(tr("Do expenive file operations")); expensiveL->addWidget(mExpensive); expensiveBox->setLayout(expensiveL); pathLayout->addWidget(expensiveBox); pathLayout->addStretch(Qt::Vertical); mTab->addTab(pathWidget, tr("Files")); //misc tab QWidget *miscWidget = new QWidget; QVBoxLayout *miscLayout = new QVBoxLayout; miscLayout->setAlignment(Qt::AlignTop); //misc - hover QGroupBox *hoverBox = new QGroupBox(tr("Hover options")); QVBoxLayout *hoverLayout = new QVBoxLayout; mHoverPics = new QCheckBox(tr("Show picture when hovering")); hoverLayout->addWidget(mHoverPics); mHoverOpacity = new QSpinBox; mHoverOpacity->setMinimum(1); mHoverOpacity->setMaximum(10); QGridLayout *miscInputGrid = new QGridLayout; QLabel *miscl6 = new QLabel(tr("Opacity of hover window")); miscInputGrid->addWidget(miscl6, 0, 0); miscInputGrid->addWidget(mHoverOpacity, 0, 1); QLabel *miscl8 = new QLabel(tr("Y cursor offset (hover)")); mCursorOffset = new QSpinBox; mCursorOffset->setMinimum(-100); mCursorOffset->setMaximum(100); miscInputGrid->addWidget(miscl8, 2, 0); miscInputGrid->addWidget(mCursorOffset, 2, 1); hoverLayout->addLayout(miscInputGrid); hoverBox->setLayout(hoverLayout); //misc - archiving movies QGroupBox *archiveBox = new QGroupBox(tr("Archiving options")); QVBoxLayout *archiveLayout = new QVBoxLayout; mAutoAddCovers = new QCheckBox(tr("Automatically add covers")); archiveLayout->addWidget(mAutoAddCovers); mIconizeCovers = new QCheckBox(tr("Iconize covers")); archiveLayout->addWidget(mIconizeCovers); archiveBox->setLayout(archiveLayout); //auto refresh QGroupBox *autoRefreshBox = new QGroupBox(tr("Auto Refresh")); QVBoxLayout *autoRefreshLayout = new QVBoxLayout; mAutoRefresh = new QCheckBox(tr("Automatically refresh directory")); autoRefreshLayout->addWidget(mAutoRefresh); QLabel *refreshL1 = new QLabel(tr("Refresh every (s)")); mAutoRefreshValue = new QSpinBox; mAutoRefreshValue->setMinimum(5); mAutoRefreshValue->setValue(5); QHBoxLayout *autoSpinLayout = new QHBoxLayout; autoSpinLayout->addWidget(refreshL1); autoSpinLayout->addWidget(mAutoRefreshValue); QVBoxLayout *autoRefreshBoxL = new QVBoxLayout; autoRefreshBoxL->addWidget(mAutoRefresh); autoRefreshBoxL->addLayout(autoSpinLayout); autoRefreshBox->setLayout(autoRefreshBoxL); //misc - clear wizard? QGroupBox *clearWizardBox = new QGroupBox(tr("New movie Wizard")); QVBoxLayout *clearWizardLayout = new QVBoxLayout; mClearNewMovieWizard = new QCheckBox(tr("Clear new movie Wizard")); mClearNewMovieWizard->setChecked(false); clearWizardLayout->addWidget(mClearNewMovieWizard); clearWizardBox->setLayout(clearWizardLayout); //misc - assemble miscLayout->addWidget(hoverBox); miscLayout->addWidget(archiveBox); miscLayout->addWidget(autoRefreshBox); miscLayout->addWidget(clearWizardBox); miscWidget->setLayout(miscLayout); mTab->addTab(miscWidget, tr("Misc. settings")); // icons mIconModel = new QStandardItemModel; const QHash icons = SmGlobals::instance()->icons(); for(QHash::const_iterator it = icons.constBegin(); it != icons.constEnd(); ++it){ QStandardItem *item = new QStandardItem(QIcon(it.value()), it.key()); mIconModel->appendRow(item); } QGroupBox *folderIconBox = new QGroupBox(tr("Icon for folders")); QHBoxLayout *folderIconLayout = new QHBoxLayout; mIconForFolder = new QComboBox; mIconForFolder->setModel(mIconModel); folderIconLayout->addWidget(mIconForFolder); folderIconBox->setLayout(folderIconLayout); QGroupBox *fileIconBox = new QGroupBox(tr("Icon for files")); QHBoxLayout *fileIconLayout = new QHBoxLayout; mIconForFile = new QComboBox; mIconForFile->setModel(mIconModel); fileIconLayout->addWidget(mIconForFile); fileIconBox->setLayout(fileIconLayout); QGroupBox *seriesIconBox = new QGroupBox(tr("Icon for series")); QHBoxLayout *seriesIconLayout = new QHBoxLayout; mIconForSeries= new QComboBox; mIconForSeries->setModel(mIconModel); seriesIconLayout->addWidget(mIconForSeries); seriesIconBox->setLayout(seriesIconLayout); QGroupBox *actorIconBox = new QGroupBox(tr("Icon for actors")); QHBoxLayout *actorIconLayout = new QHBoxLayout; mIconForActor = new QComboBox; mIconForActor->setModel(mIconModel); actorIconLayout->addWidget(mIconForActor); actorIconBox->setLayout(actorIconLayout); QGroupBox *genreIconBox = new QGroupBox(tr("Icon for genres")); QHBoxLayout *genreIconLayout = new QHBoxLayout; mIconForGenre = new QComboBox; mIconForGenre->setModel(mIconModel); genreIconLayout->addWidget(mIconForGenre); genreIconBox->setLayout(genreIconLayout); QGroupBox *metaIconBox = new QGroupBox(tr("Icon for metadata")); QHBoxLayout *metaIconLayout = new QHBoxLayout; mIconForMeta = new QComboBox; mIconForMeta->setModel(mIconModel); metaIconLayout->addWidget(mIconForMeta); metaIconBox->setLayout(metaIconLayout); QVBoxLayout *iconWidgetLayout = new QVBoxLayout; iconWidgetLayout->addWidget(folderIconBox); iconWidgetLayout->addWidget(fileIconBox); iconWidgetLayout->addWidget(seriesIconBox); iconWidgetLayout->addWidget(actorIconBox); iconWidgetLayout->addWidget(genreIconBox); iconWidgetLayout->addWidget(metaIconBox); iconWidgetLayout->addStretch(); QWidget *iconWidget = new QWidget; iconWidget->setLayout(iconWidgetLayout); mTab->addTab(iconWidget, tr("Icons")); // movie viewer QGroupBox *movieBox = new QGroupBox(tr("Movie viewer")); QHBoxLayout *movieBoxLayout = new QHBoxLayout; mMovieConfig = new ProgramConfigurator("movieviewer", "Movie viewer"); movieBoxLayout->addWidget(mMovieConfig); movieBox->setLayout(movieBoxLayout); QWidget *movieWidget = new QWidget; QVBoxLayout *movieWidgetLayout = new QVBoxLayout; movieWidgetLayout->addWidget(movieBox); QGroupBox *reasonBox = new QGroupBox(tr("Reencode reasons")); QLabel *rbl1 = new QLabel(tr("Reasons")); mReasonsBox = new QComboBox; QStringList reasons = SmGlobals::instance()->reencReasons(); mReasonsBox->addItems(reasons); QPushButton *editRBtn = new QPushButton(tr("Edit...")); connect(editRBtn, SIGNAL(clicked()), this, SLOT(editReason())); QPushButton *newRBtn = new QPushButton(tr("Add...")); connect(newRBtn, SIGNAL(clicked()), this, SLOT(addReason())); QPushButton *delRBtn = new QPushButton(tr("Delete...")); connect(delRBtn, SIGNAL(clicked()), this, SLOT(delReason())); QVBoxLayout *reasonL = new QVBoxLayout; QHBoxLayout *reasonCBL = new QHBoxLayout; reasonCBL->addWidget(rbl1); reasonCBL->addWidget(mReasonsBox); reasonCBL->setStretch(1, 3); QHBoxLayout *reasonBL = new QHBoxLayout; reasonBL->addStretch(); reasonBL->addWidget(newRBtn); reasonBL->addWidget(editRBtn); reasonBL->addWidget(delRBtn); reasonL->addLayout(reasonCBL); reasonL->addLayout(reasonBL); reasonBox->setLayout(reasonL); movieWidgetLayout->addWidget(reasonBox); movieWidgetLayout->addStretch(); movieWidget->setLayout(movieWidgetLayout); mTab->addTab(movieWidget, tr("Movies")); //picture viewer - information createPositionMap(); QFormLayout *pvInfoL = new QFormLayout; QGroupBox *picInfoBox = new QGroupBox(tr("Show additional info")); mInfoBox = new QComboBox; fillPositions(mInfoBox); pvInfoL->addRow(tr("Picture information position"), mInfoBox); mMapBox = new QComboBox; fillPositions(mMapBox); pvInfoL->addRow(tr("Picture mapping information"), mMapBox); picInfoBox->setLayout(pvInfoL); //picture viewer - size QFormLayout *pvSizeWHL = new QFormLayout; QVBoxLayout *pvSizeL = new QVBoxLayout; pvSizeL->addLayout(pvSizeWHL); //picture viewer - layout QWidget *picWidget = new QWidget; QVBoxLayout *picLayout = new QVBoxLayout; picLayout->addWidget(picInfoBox); picLayout->addStretch(); picWidget->setLayout(picLayout); mTab->addTab(picWidget, tr("Pictures")); //database tab QFormLayout *dbFormL = new QFormLayout; mDatabaseHost = new QLineEdit; dbFormL->addRow(tr("Database &host"), mDatabaseHost); mDatabaseName = new QLineEdit; dbFormL->addRow(tr("Database &name"), mDatabaseName); mDatabaseUsername = new QLineEdit; dbFormL->addRow(tr("Database &user"), mDatabaseUsername); mDatabasePassword = new QLineEdit; mDatabasePassword->setEchoMode(QLineEdit::Password); dbFormL->addRow(tr("Database &password"), mDatabasePassword); QGroupBox *dbBox = new QGroupBox(tr("Database connection")); dbBox->setLayout(dbFormL); QVBoxLayout *dbWidgetLayout = new QVBoxLayout; dbWidgetLayout->addWidget(dbBox); dbWidgetLayout->addStretch(); QWidget *dbWidget = new QWidget; dbWidget->setLayout(dbWidgetLayout); mTab->addTab(dbWidget, tr("Database")); //colors tab QWidget *colorsWidget = new QWidget; QGridLayout *colorGrid = new QGridLayout; QSignalMapper *colorMapper = new QSignalMapper(this); QLabel *colorl2 = new QLabel(tr("Files in clipboard")); mClipboardColor = new QLabel; mClipboardColor->setFrameStyle(QFrame::Sunken | QFrame::Panel); mClipboardColor->setScaledContents(true); mClipboardButton = new QPushButton(tr("Choose...")); colorGrid->addWidget(colorl2, 1, 0); colorGrid->addWidget(mClipboardColor, 1, 1); colorGrid->addWidget(mClipboardButton, 1, 2); colorMapper->setMapping(mClipboardButton, mClipboardColor); connect(mClipboardButton, SIGNAL(clicked()), colorMapper, SLOT(map())); QLabel *colorl3 = new QLabel(tr("Base color for rows")); mBaseColor = new QLabel; mBaseColor->setFrameStyle(QFrame::Sunken | QFrame::Panel); mBaseColor->setScaledContents(true); mBaseButton = new QPushButton(tr("Choose...")); colorGrid->addWidget(colorl3, 2, 0); colorGrid->addWidget(mBaseColor, 2, 1); colorGrid->addWidget(mBaseButton, 2, 2); colorMapper->setMapping(mBaseButton, mBaseColor); connect(mBaseButton, SIGNAL(clicked()), colorMapper, SLOT(map())); QLabel *colorl4 = new QLabel(tr("Alternate base for rows")); mAlternateBaseColor = new QLabel; mAlternateBaseColor->setFrameStyle(QFrame::Sunken | QFrame::Panel); mAlternateBaseColor->setScaledContents(true); mAlternateBaseButton = new QPushButton(tr("Choose...")); colorGrid->addWidget(colorl4, 3, 0); colorGrid->addWidget(mAlternateBaseColor, 3, 1); colorGrid->addWidget(mAlternateBaseButton, 3, 2); colorMapper->setMapping(mAlternateBaseButton, mAlternateBaseColor); connect(mAlternateBaseButton, SIGNAL(clicked()), colorMapper, SLOT(map())); QLabel *colorl5 = new QLabel(tr("Font color")); mFontColor = new QLabel; mFontColor->setFrameStyle(QFrame::Sunken | QFrame::Panel); mFontColor->setScaledContents(true); mFontColorButton = new QPushButton(tr("Choose...")); colorGrid->addWidget(colorl5, 4, 0); colorGrid->addWidget(mFontColor, 4, 1); colorGrid->addWidget(mFontColorButton, 4, 2); colorMapper->setMapping(mFontColorButton, mFontColor); connect(mFontColorButton, SIGNAL(clicked()), colorMapper, SLOT(map())); QLabel *colorl6 = new QLabel(tr("Local files")); mLocalColor = new QLabel; mLocalColor->setFrameStyle(QFrame::Sunken | QFrame::Panel); mLocalColor->setScaledContents(true); mLocalColorButton = new QPushButton(tr("Choose...")); colorGrid->addWidget(colorl6, 5, 0); colorGrid->addWidget(mLocalColor, 5, 1); colorGrid->addWidget(mLocalColorButton, 5, 2); colorMapper->setMapping(mLocalColorButton, mLocalColor); connect(mLocalColorButton, SIGNAL(clicked()), colorMapper, SLOT(map())); QLabel *colorl7 = new QLabel(tr("Archived Files")); mArchivedColor = new QLabel; mArchivedColor->setFrameStyle(QFrame::Sunken | QFrame::Panel); mArchivedColor->setScaledContents(true); mArchivedColorButton = new QPushButton(tr("Choose...")); colorGrid->addWidget(colorl7, 6, 0); colorGrid->addWidget(mArchivedColor, 6, 1); colorGrid->addWidget(mArchivedColorButton, 6, 2); colorMapper->setMapping(mArchivedColorButton, mArchivedColor); connect(mArchivedColorButton, SIGNAL(clicked()), colorMapper, SLOT(map())); QLabel *colorl8 = new QLabel(tr("Favorites")); mFavoriteColor = new QLabel; mFavoriteColor->setFrameStyle(QFrame::Sunken | QFrame::Panel); mFavoriteColor->setScaledContents(true); mFavoriteColorButton = new QPushButton(tr("Choose...")); colorGrid->addWidget(colorl8, 7, 0); colorGrid->addWidget(mFavoriteColor, 7, 1); colorGrid->addWidget(mFavoriteColorButton, 7, 2); colorMapper->setMapping(mFavoriteColorButton, mFavoriteColor); connect(mFavoriteColorButton, SIGNAL(clicked()), colorMapper, SLOT(map())); mAlternateColors = new QCheckBox(tr("Use alternating row colors")); mAlternateColors->setTristate(false); connect(mAlternateColors, SIGNAL(stateChanged(int)), this, SLOT(alternateColorsChanged(int))); colorGrid->addWidget(mAlternateColors, 8, 1, 1, 2, Qt::AlignLeft); colorsWidget->setLayout(colorGrid); QLabel *color9 = new QLabel(tr("PicViewer Background")); mPVBgColor = new QLabel; mPVBgColor->setFrameStyle(QFrame::Sunken | QFrame::Panel); mPVBgColor->setScaledContents(true); mPVBgButton = new QPushButton(tr("Choose...")); QGridLayout *pvGrid = new QGridLayout; pvGrid->addWidget(color9, 0, 0); pvGrid->addWidget(mPVBgColor, 0, 1); pvGrid->addWidget(mPVBgButton, 0, 2); colorMapper->setMapping(mPVBgButton, mPVBgColor); connect(mPVBgButton, SIGNAL(clicked()), colorMapper, SLOT(map())); mPVGradient = new QCheckBox(tr("Use random gradient as background")); mPVGradient->setTristate(false); connect(mPVGradient, SIGNAL(stateChanged(int)), this, SLOT(randomGradientChanged(int))); pvGrid->addWidget(mPVGradient, 1, 1, 1, 2, Qt::AlignLeft); connect(colorMapper, SIGNAL(mapped(QWidget*)), this, SLOT(chooseColor(QWidget*))); QGroupBox *treeGB = new QGroupBox(tr("Treeview colors")); treeGB->setLayout(colorGrid); QGroupBox *pvGB = new QGroupBox(tr("PicViewer colors")); pvGB->setLayout(pvGrid); QVBoxLayout *colorLayout = new QVBoxLayout; colorLayout->addWidget(treeGB); colorLayout->addWidget(pvGB); colorsWidget->setLayout(colorLayout); mTab->addTab(colorsWidget, tr("Colors")); //main layout mOk = new QPushButton(tr("Ok")); connect(mOk, SIGNAL(clicked()), this, SLOT(accept())); mCancel = new QPushButton(tr("Cancel")); connect(mCancel, SIGNAL(clicked()), this, SLOT(reject())); QHBoxLayout *mainButtonLayout = new QHBoxLayout; mainButtonLayout->addStretch(); mainButtonLayout->addWidget(mOk); mainButtonLayout->addWidget(mCancel); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(mTab); mainLayout->addLayout(mainButtonLayout); setLayout(mainLayout); QString winTitle = QString(tr("%1 - Configure")).arg(qApp->applicationName()); setWindowTitle(winTitle); readSettings(); } void ConfigurationDialog::accept(){ writeSettings(); QDialog::accept(); } void ConfigurationDialog::readSettings(){ QSettings s; //read icons QString iconText = s.value("ui/foldericon", "Dildo").toString(); int pos = mIconForFolder->findText(iconText); pos = pos > -1 ? pos : 0; mIconForFolder->setCurrentIndex(pos); iconText = s.value("ui/fileicon", "Dildo").toString(); pos = mIconForFile->findText(iconText); pos = pos > -1 ? pos : 0; mIconForFile->setCurrentIndex(pos); iconText = s.value("ui/seriesicon", "Dildo").toString(); pos = mIconForSeries->findText(iconText); pos = pos > -1 ? pos : 0; mIconForSeries->setCurrentIndex(pos); iconText = s.value("ui/actoricon", "Dildo").toString(); pos = mIconForActor->findText(iconText); pos = pos > -1 ? pos : 0; mIconForActor->setCurrentIndex(pos); iconText = s.value("ui/genreicon", "Dildo").toString(); pos = mIconForGenre->findText(iconText); pos = pos > -1 ? pos : 0; mIconForGenre->setCurrentIndex(pos); iconText = s.value("ui/metaicon", "Dildo").toString(); pos = mIconForMeta->findText(iconText); pos = pos > -1 ? pos : 0; mIconForMeta->setCurrentIndex(pos); // read misc mHoverPics->setChecked(s.value("ui/hoverpics", false).toBool()); mHoverOpacity->setValue(s.value("ui/hoveropacity", 10).toInt()); mAutoAddCovers->setChecked(s.value("ui/autoaddcovers", false).toBool()); mIconizeCovers->setChecked(s.value("ui/iconizecovers", false).toBool()); mCursorOffset->setValue(s.value("ui/cursoroffset", SmGlobals::instance()->cursorSize().height()).toInt()); mAutoRefresh->setChecked(s.value("ui/autorefresh", false).toBool()); mAutoRefreshValue->setValue(s.value("ui/autorefreshvalue", 5).toInt()); mClearNewMovieWizard->setChecked(s.value("ui/clearnewmoviewizard", false).toBool()); //read paths mArchiveDir->setText(s.value("paths/archivedir").toString()); mBurnDir->setText(s.value("paths/burn").toString()); mUSBDir->setText(s.value("paths/usb").toString()); mFfProbePath->setText(s.value("paths/ffprobe").toString()); mFfMpegPath->setText(s.value("paths/ffmpeg").toString()); mDvdMountPath->setText(s.value("paths/dvdmount").toString()); mCoverPath->setText(s.value("paths/coverpath").toString()); mWindowsDrive->setText(s.value("paths/windowsdrive").toString()); mStripPath->setText(s.value("paths/strippath").toString()); mExpensive->setChecked(s.value("ui/expensiveops", true).toBool()); //read pictures mInfoBox->setCurrentIndex(mInfoBox->findData(s.value("ui/infoposition", TopLeft).toInt())); mMapBox->setCurrentIndex(mMapBox->findData(s.value("ui/mappingposition", TopRight).toInt())); //read database mDatabaseHost->setText(s.value("database/hostname").toString()); mDatabaseName->setText(s.value("database/dbname").toString()); mDatabaseUsername->setText(s.value("database/dbuser").toString()); mDatabasePassword->setText(s.value("database/dbpass").toString()); //read colors QVariant clip = s.value("ui/clipcolor", QVariant(QColor(Qt::darkBlue))); mColors.insert(mClipboardColor, clip.value()); QVariant base = s.value("ui/basecolor", qApp->palette().base().color()); mColors.insert(mBaseColor, base.value()); QVariant alternate = s.value("ui/alternatecolor", qApp->palette().alternateBase().color()); mColors.insert(mAlternateBaseColor, alternate.value()); QVariant font = s.value("ui/fontcolor", qApp->palette().foreground().color()); mColors.insert(mFontColor, font.value()); QVariant local = s.value("ui/localcolor", QVariant(QColor(Qt::darkBlue))); mColors.insert(mLocalColor, local.value()); QVariant archived = s.value("ui/archivedcolor", QVariant(QColor(Qt::black))); mColors.insert(mArchivedColor, archived.value()); QVariant favorite = s.value("ui/favoritecolor", QVariant(QColor(Qt::red))); mColors.insert(mFavoriteColor, favorite.value()); QVariant pvbackground = s.value("ui/pvbgcolor", QVariant(QColor(Qt::red))); mColors.insert(mPVBgColor, pvbackground.value()); QHash::const_iterator it; for(it = mColors.constBegin(); it != mColors.constEnd(); ++it){ setColor(it.key()); } bool allowAlternate = s.value("ui/allowalternate", true).toBool(); mAlternateColors->setChecked(allowAlternate); alternateColorsChanged(mAlternateColors->checkState()); bool useGradient = s.value("ui/pvgradient", false).toBool(); mPVGradient->setChecked(useGradient); randomGradientChanged(mPVGradient->checkState()); } void ConfigurationDialog::writeSettings(){ QSettings s; //write paths s.setValue("paths/archivedir", mArchiveDir->text()); s.setValue("paths/burn", mBurnDir->text()); s.setValue("paths/usb", mUSBDir->text()); QString ffprobe = mFfProbePath->text(); QFileInfo ffProbeInfo(ffprobe); if(ffProbeInfo.exists() && ffProbeInfo.isExecutable()){ s.setValue("paths/ffprobe", ffprobe); } QString ffmpeg = mFfMpegPath->text(); QFileInfo ffMpegInfo(ffmpeg); if(ffMpegInfo.exists() && ffMpegInfo.isExecutable()){ s.setValue("paths/ffmpeg", ffmpeg); } if(checkDvdPath()){ s.setValue("paths/dvdmount", mDvdMountPath->text()); } s.setValue("paths/windowsdrive", mWindowsDrive->text()); s.setValue("paths/strippath", mStripPath->text()); s.setValue("paths/coverpath", mCoverPath->text()); s.setValue("ui/expensiveops", (mExpensive->checkState() == Qt::Checked)); //write icons s.setValue("ui/foldericon", mIconForFolder->currentText()); s.setValue("ui/fileicon", mIconForFile->currentText()); s.setValue("ui/seriesicon", mIconForSeries->currentText()); s.setValue("ui/actoricon", mIconForActor->currentText()); s.setValue("ui/genreicon", mIconForGenre->currentText()); s.setValue("ui/metaicon", mIconForMeta->currentText()); //write misc s.setValue("ui/hoverpics", (mHoverPics->checkState() == Qt::Checked)); s.setValue("ui/hoveropacity", mHoverOpacity->value()); s.setValue("ui/autoaddcovers", (mAutoAddCovers->checkState() == Qt::Checked)); s.setValue("ui/iconizecovers", (mIconizeCovers->checkState() == Qt::Checked)); s.setValue("ui/cursoroffset", mCursorOffset->value()); s.setValue("ui/autorefresh", (mAutoRefresh->checkState() == Qt::Checked)); s.setValue("ui/autorefreshvalue", mAutoRefreshValue->value()); s.setValue("ui/clearnewmoviewizard", (mClearNewMovieWizard->checkState() == Qt::Checked)); //write pictures QString curPos = mInfoBox->currentText(); s.setValue("ui/infoposition", mPositionMap.value(curPos)); curPos = mMapBox->currentText(); s.setValue("ui/mappingposition", mPositionMap.value(curPos)); //write database s.setValue("database/hostname", mDatabaseHost->text()); s.setValue("database/dbname", mDatabaseName->text()); s.setValue("database/dbuser", mDatabaseUsername->text()); s.setValue("database/dbpass", mDatabasePassword->text()); //write movies mMovieConfig->writeSettings(); //write colors s.setValue("ui/clipcolor", mColors.value(mClipboardColor)); s.setValue("ui/basecolor", mColors.value(mBaseColor)); s.setValue("ui/alternatecolor", mColors.value(mAlternateBaseColor)); s.setValue("ui/fontcolor", mColors.value(mFontColor)); s.setValue("ui/localcolor", mColors.value(mLocalColor)); s.setValue("ui/archivedcolor", mColors.value(mArchivedColor)); s.setValue("ui/favoritecolor", mColors.value(mFavoriteColor)); s.setValue("ui/pvbgcolor", mColors.value(mPVBgColor)); s.setValue("ui/allowalternate", mAlternateColors->isChecked()); s.setValue("ui/pvgradient", mPVGradient->isChecked()); } bool ConfigurationDialog::checkDvdPath(){ QString path = mDvdMountPath->text(); if(path.isEmpty()){ return true; } QFileInfo mountInfo(path); if(!mountInfo.exists() || !mountInfo.isDir()){ QString message = QString(tr("%1 does not exist or is not a directory. Ignoring.")).arg(path); mountError(message); return false; } QFile fstab("/etc/fstab"); if(!fstab.exists() || !fstab.open(QFile::ReadOnly)){ mountError(QString()); return true; } QTextStream fStream(&fstab); QString line; bool ok = false; do { line = fStream.readLine(); if(line.contains(path)){ QStringList fsParts = line.split(QRegExp("\\s+")); if(fsParts.isEmpty() || (fsParts.size() < 4)){ continue; } QStringList options = fsParts.at(3).split(','); foreach(QString opt, options){ if(opt.toLower().trimmed() == "user"){ ok = true; break; } } } } while(!line.isNull()); if(!ok){ QString message = QString(tr("Didn't find %1 in fstab or it isn't user mountable. Ignoring.")).arg(path); mountError(message); return false; } return true; } void ConfigurationDialog::mountError(const QString &error){ if(!error.isEmpty()){ QMessageBox::critical(this, tr("Mount Path Error"), error); } QSettings s; s.setValue("paths/dvdmount", QString()); } void ConfigurationDialog::chooseColor(QWidget *label){ QColor newColor = QColorDialog::getColor(mColors.value(label), this); if(newColor.isValid()){ mColors[label] = newColor; setColor(label); } } void ConfigurationDialog::alternateColorsChanged(int state){ mBaseButton->setEnabled(state == Qt::Checked); mBaseColor->setEnabled(state == Qt::Checked); mAlternateBaseButton->setEnabled(state == Qt::Checked); mAlternateBaseColor->setEnabled(state == Qt::Checked); } void ConfigurationDialog::randomGradientChanged(int state){ mPVBgButton->setEnabled(state == Qt::Unchecked); mPVBgColor->setEnabled(state == Qt::Unchecked); } void ConfigurationDialog::editReason(){ QString curReason = mReasonsBox->currentText(); if(curReason.isEmpty()){ return; } QString newReason = QInputDialog::getText(this, tr("Edit reason..."), tr("Reason"), QLineEdit::Normal, curReason); if(!newReason.isEmpty()){ QStringList r = SmGlobals::instance()->reencReasons(); r.removeAll(curReason); r.append(newReason); SmGlobals::instance()->setReencReasons(r); r = SmGlobals::instance()->reencReasons(); mReasonsBox->clear(); mReasonsBox->addItems(r); mReasonsBox->setCurrentText(newReason); } } void ConfigurationDialog::addReason(){ QString newReason = QInputDialog::getText(this, tr("Add reason..."), tr("Reason")); if(!newReason.isEmpty()){ QStringList r = SmGlobals::instance()->reencReasons(); if(r.contains(newReason)){ mReasonsBox->setCurrentText(newReason); return; } r.append(newReason); SmGlobals::instance()->setReencReasons(r); mReasonsBox->clear(); r = SmGlobals::instance()->reencReasons(); mReasonsBox->addItems(r); mReasonsBox->setCurrentText(newReason); } } void ConfigurationDialog::delReason(){ QString curReason = mReasonsBox->currentText(); QStringList r = SmGlobals::instance()->reencReasons(); r.removeAll(curReason); SmGlobals::instance()->setReencReasons(r); r = SmGlobals::instance()->reencReasons(); mReasonsBox->clear(); mReasonsBox->addItems(r); if(!r.isEmpty()){ mReasonsBox->setCurrentIndex(0); } } void ConfigurationDialog::setColor(QWidget *label){ QLabel *curLabel = qobject_cast(label); if(!curLabel){ return; } QColor curColor = mColors.value(label); QPixmap pm(curLabel->sizeHint()); pm.fill(curColor); curLabel->setPixmap(pm); } void ConfigurationDialog::createPositionMap(){ mPositionMap.insert(tr("Top left"), TopLeft); mPositionMap.insert(tr("Top right"), TopRight); mPositionMap.insert(tr("Bottom left"), BottomLeft); mPositionMap.insert(tr("Bottom right"), BottomRigth); mPositionMap.insert(tr("Freely moveable"), Moveable); mPositionMap.insert(tr("Do not show"), NoDisplay); } void ConfigurationDialog::fillPositions(QComboBox *cb){ for(QMap::const_iterator it = mPositionMap.constBegin(); it != mPositionMap.constEnd(); ++it){ cb->addItem(it.key(), it.value()); } }