/* 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 "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); 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); mTab->addTab(pathWidget, tr("Directories")); //misc tab QWidget *miscWidget = new QWidget; QVBoxLayout *miscLayout = new QVBoxLayout; miscLayout->setAlignment(Qt::AlignTop); //misc - icons QGroupBox *iconBox = new QGroupBox(tr("Icon for folders")); QHBoxLayout *iconLayout = new QHBoxLayout; mIconForFolder = new QComboBox; 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); } mIconForFolder->setModel(mIconModel); iconLayout->addWidget(mIconForFolder); iconBox->setLayout(iconLayout); //misc - hover QGroupBox *hoverBox = new QGroupBox(tr("Hover options")); QVBoxLayout *hoverLayout = new QVBoxLayout; mHoverPics = new QCheckBox(tr("Show picture when hovering")); hoverLayout->addWidget(mHoverPics); mHoverArchive = new QCheckBox(tr("Show further information when hovering over archive")); hoverLayout->addWidget(mHoverArchive); mHoverOpacity = new QSpinBox; mHoverOpacity->setMinimum(1); mHoverOpacity->setMaximum(10); mHoverMovies = new QCheckBox(tr("Show frame when hovering over movie")); connect(mHoverMovies, SIGNAL(clicked(bool)), this, SLOT(setGrabFrameEnabled(bool))); hoverLayout->addWidget(mHoverMovies); QGridLayout *miscInputGrid = new QGridLayout; QLabel *miscl6 = new QLabel(tr("Opacity of hover window")); miscInputGrid->addWidget(miscl6, 0, 0); miscInputGrid->addWidget(mHoverOpacity, 0, 1); QLabel *miscl7 = new QLabel(tr("Grab frame at ([hh:mm:ss])")); mGrabFrameFrom = new QLineEdit; QRegExp frameValid("\\d{2}:\\d{2}:\\d{2}"); QRegExpValidator *frameValidator = new QRegExpValidator(frameValid, this); mGrabFrameFrom->setValidator(frameValidator); miscInputGrid->addWidget(miscl7, 1, 0); miscInputGrid->addWidget(mGrabFrameFrom, 1, 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); //misc - assemble miscLayout->addWidget(iconBox); miscLayout->addWidget(hoverBox); miscLayout->addWidget(archiveBox); miscWidget->setLayout(miscLayout); mTab->addTab(miscWidget, tr("Misc. settings")); // 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); movieWidget->setLayout(movieWidgetLayout); mTab->addTab(movieWidget, tr("Movies")); //picture viewer - info item QGroupBox *picInfoBox = new QGroupBox(tr("Picture info item")); mInfoPositionBox = new QComboBox; createPositionMap(); fillPositions(mInfoPositionBox); mInfoPositionBox->removeItem(mInfoPositionBox->findData(SideBySide)); QFormLayout *pvInfoL = new QFormLayout; pvInfoL->addRow(tr("Picture info position"), mInfoPositionBox); mShowInfoItem = new QCheckBox(tr("Show info item")); connect(mShowInfoItem, SIGNAL(toggled(bool)), mInfoPositionBox, SLOT(setEnabled(bool))); pvInfoL->addRow(QString(), mShowInfoItem); picInfoBox->setLayout(pvInfoL); //picture viewer - mapping item QGroupBox *picMapBox = new QGroupBox(tr("Picture mappings")); mMapPositionBox = new QComboBox; fillPositions(mMapPositionBox); QFormLayout *pvMapL = new QFormLayout; pvMapL->addRow(tr("Picture mapping position"), mMapPositionBox); mShowMapItem = new QCheckBox(tr("Show mapping item")); connect(mShowMapItem, SIGNAL(toggled(bool)), mMapPositionBox, SLOT(setEnabled(bool))); pvMapL->addRow(QString(), mShowMapItem); picMapBox->setLayout(pvMapL); //picture viewer - layout QWidget *picWidget = new QWidget; QVBoxLayout *picLayout = new QVBoxLayout; picLayout->addWidget(picInfoBox); picLayout->addWidget(picMapBox); picWidget->setLayout(picLayout); picLayout->addStretch(); 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); QWidget *dbWidget = new QWidget; QVBoxLayout *dbWidgetLayout = new QVBoxLayout; dbWidgetLayout->addWidget(dbBox); dbWidget->setLayout(dbWidgetLayout); mTab->addTab(dbWidget, tr("Database")); //colors tab QWidget *colorsWidget = new QWidget; QGridLayout *colorGrid = new QGridLayout; QSignalMapper *colorMapper = new QSignalMapper(this); QLabel *colorl1 = new QLabel(tr("Files marked as seen")); mSeenColor = new QLabel; mSeenColor->setFrameStyle(QFrame::Sunken | QFrame::Panel); mSeenColor->setScaledContents(true); mSeenButton = new QPushButton(tr("Choose...")); colorGrid->addWidget(colorl1, 0, 0); colorGrid->addWidget(mSeenColor, 0, 1); colorGrid->addWidget(mSeenButton, 0, 2); colorMapper->setMapping(mSeenButton, mSeenColor); connect(mSeenButton, SIGNAL(clicked()), colorMapper, SLOT(map())); 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::setGrabFrameEnabled(bool enabled){ mGrabFrameFrom->setEnabled(enabled); } void ConfigurationDialog::readSettings(){ QSettings s; //read misc QString icon = s.value("ui/foldericon", "Dildo").toString(); int pos = mIconForFolder->findText(icon); if(pos != -1){ mIconForFolder->setCurrentIndex(pos); } mHoverPics->setChecked(s.value("ui/hoverpics", false).toBool()); mHoverArchive->setChecked(s.value("ui/hoverarchive", false).toBool()); mHoverMovies->setChecked(s.value("ui/hovermovies", false).toBool()); mHoverOpacity->setValue(s.value("ui/hoveropacity", 10).toInt()); mGrabFrameFrom->setText(s.value("ui/grabframe", "00:00:00").toString()); mGrabFrameFrom->setEnabled(s.value("ui/hovermovies", false).toBool()); 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()); //read paths mArchiveDir->setText(s.value("paths/archivedir").toString()); mBurnDir->setText(s.value("paths/burn").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()); //read pictures mShowInfoItem->setChecked(s.value("ui/showinfoitem", true).toBool()); mInfoPositionBox->setCurrentIndex(mInfoPositionBox->findData(s.value("ui/infoposition", TopLeft).toInt())); mInfoPositionBox->setEnabled(mShowInfoItem->checkState()); mShowMapItem->setChecked(s.value("ui/showmapitem", true).toBool()); mMapPositionBox->setCurrentIndex(mMapPositionBox->findData(s.value("ui/mappingposition", TopRight).toInt())); mMapPositionBox->setEnabled(mShowMapItem->checkState()); //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 seen = s.value("ui/seencolor", Qt::red); mColors.insert(mSeenColor, seen.value()); QVariant clip = s.value("ui/clipcolor", 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", Qt::darkBlue); mColors.insert(mLocalColor, local.value()); QVariant archived = s.value("ui/archivedcolor", Qt::black); mColors.insert(mArchivedColor, archived.value()); QVariant favorite = s.value("ui/favoritecolor", Qt::red); mColors.insert(mFavoriteColor, favorite.value()); QVariant pvbackground = s.value("ui/pvbgcolor", 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()); 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/folderIcon", mIconForFolder->currentText()); s.setValue("ui/hoverpics", (mHoverPics->checkState() == Qt::Checked)); s.setValue("ui/hoverarchive", (mHoverArchive->checkState() == Qt::Checked)); s.setValue("ui/hoveropacity", mHoverOpacity->value()); s.setValue("ui/hovermovies", (mHoverMovies->checkState() == Qt::Checked)); s.setValue("ui/grabframe", mGrabFrameFrom->text()); s.setValue("ui/autoaddcovers", (mAutoAddCovers->checkState() == Qt::Checked)); s.setValue("ui/iconizecovers", (mIconizeCovers->checkState() == Qt::Checked)); s.setValue("ui/cursoroffset", mCursorOffset->value()); //write pictures s.setValue("ui/showinfoitem", (mShowInfoItem->checkState() == Qt::Checked)); QString curPos = mInfoPositionBox->currentText(); s.setValue("ui/infoposition", mPositionMap.value(curPos)); s.setValue("ui/showmapitem", (mShowMapItem->checkState() == Qt::Checked)); curPos = mMapPositionBox->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/seencolor", mColors.value(mSeenColor)); 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::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("Side by side"), SideBySide); mPositionMap.insert(tr("Freely moveable"), Moveable);; } void ConfigurationDialog::fillPositions(QComboBox *cb){ for(QMap::const_iterator it = mPositionMap.constBegin(); it != mPositionMap.constEnd(); ++it){ cb->addItem(it.key(), it.value()); } }