summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--newmoviewizard.cpp43
-rw-r--r--newmoviewizard.h4
-rw-r--r--smglobals.cpp21
-rw-r--r--smglobals.h2
4 files changed, 64 insertions, 6 deletions
diff --git a/newmoviewizard.cpp b/newmoviewizard.cpp
index f5fe333..99c2f8d 100644
--- a/newmoviewizard.cpp
+++ b/newmoviewizard.cpp
@@ -21,6 +21,7 @@
#include <QCheckBox>
#include <QMessageBox>
#include <QFile>
+#include <QSettings>
#include "newmoviewizard.h"
#include "smtreeitem.h"
@@ -31,6 +32,7 @@
#include "mappingtablemodel.h"
#include "filestreemodel.h"
#include "helper.h"
+#include "pictureviewer.h"
NewMovieWizard::NewMovieWizard(QWidget *parent) : QWizard(parent){
mInfoPage = new MovieInfoPage;
@@ -115,6 +117,10 @@ void NewMovieWizard::accept(){
MappingTableModel *genreModel = static_cast<MappingTableModel*>(SmGlobals::instance()->model("genres"));
genreModel->setMappings(genres, seriesPartId);
+ //make picviewer setting persistent
+ QSettings s;
+ s.setValue("ui/archiveusepicviewer", field("usePicViewer"));
+
//done
emit seriesAdded(series, seriesno);
QDialog::accept();
@@ -122,6 +128,8 @@ void NewMovieWizard::accept(){
MovieInfoPage::MovieInfoPage(QWidget *parent) : QWizardPage(parent){
setupGui();
+ mPicViewer = SmGlobals::instance()->pictureViewer();
+ connect(mFileView, SIGNAL(clicked(QModelIndex)), this, SLOT(itemClicked(QModelIndex)));
}
void MovieInfoPage::setupGui(){
@@ -214,12 +222,22 @@ void MovieInfoPage::setupGui(){
mDvdNo->setEnabled(false);
mNextDvdNo->setEnabled(false);
+ //picviewer
+ QHBoxLayout *picViewerLayout = new QHBoxLayout;
+ picViewerLayout->setAlignment(Qt::AlignRight | Qt::AlignHCenter);
+ mUsePicViewer = new QCheckBox(tr("Use picture viewer when selecting item"));
+ picViewerLayout->addWidget(mUsePicViewer);
+ QSettings s;
+ bool usePicViewer = s.value("ui/archiveusepicviewer", false).toBool();
+ mUsePicViewer->setChecked(usePicViewer);
+
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(mFileView);
mainLayout->addLayout(fileButtonLayout);
mainLayout->addLayout(movieTitleLayout);
mainLayout->addLayout(numberLayout);
mainLayout->addLayout(dvdLayout);
+ mainLayout->addLayout(picViewerLayout);
setLayout(mainLayout);
//expose data
@@ -229,6 +247,7 @@ void MovieInfoPage::setupGui(){
registerField("quality", mQuality);
registerField("dvdNo", mDvdNo);
registerField("onDvd", mOnDvd);
+ registerField("usePicViewer", mUsePicViewer);
}
void MovieInfoPage::initializePage(){
@@ -376,6 +395,30 @@ void MovieInfoPage::fileSelectionChanged(const QModelIndex &current, const QMode
}
}
+void MovieInfoPage::itemClicked(const QModelIndex &index){
+ if(!field("usePicViewer").toBool()){
+ return;
+ }
+ int type = index.data(WizardTreeModel::FileTypeRole).toInt();
+ switch(type){
+ case WizardTreeModel::Movie:{
+ QString framePath = SmGlobals::instance()->frameCache()->entryPath(index.data(WizardTreeModel::FullPathRole).toString(), QString());
+ mPicViewer->showPic(framePath, false);
+ break;
+ }
+ case WizardTreeModel::FrontCover:
+ case WizardTreeModel::BackCover:
+ case WizardTreeModel::GeneralCover:
+ mPicViewer->showPic(index.data(WizardTreeModel::FullPathRole).toString(), false);
+ break;
+ default:
+ mPicViewer->setVisible(false);
+ return;
+ }
+ mPicViewer->setVisible(true);
+ mPicViewer->raise();
+}
+
MovieMappingPage::MovieMappingPage(const QString &table, QWidget *parent) : QWizardPage(parent){
QString title = QString(tr("Edit %1")).arg(table);
QString subTitle = QString(tr("Edit %1 by adding them from the text field below")).arg(table);
diff --git a/newmoviewizard.h b/newmoviewizard.h
index 93da626..abcf977 100644
--- a/newmoviewizard.h
+++ b/newmoviewizard.h
@@ -26,6 +26,7 @@ class WizardTreeModel;
class SmTreeItem;
class MovieInfoPage;
class MovieMappingPage;
+class PictureViewer;
class NewMovieWizard : public QWizard {
Q_OBJECT
@@ -63,6 +64,7 @@ class MovieInfoPage : public QWizardPage {
void setNextDvdNo();
void initModel();
void fileSelectionChanged(const QModelIndex &current, const QModelIndex &previous);
+ void itemClicked(const QModelIndex &index);
private:
void setupGui();
@@ -76,10 +78,12 @@ class MovieInfoPage : public QWizardPage {
QPushButton *mRemoveFile;
QComboBox *mFileType;
QCheckBox *mOnDvd;
+ QCheckBox *mUsePicViewer;
QPushButton *mNextDvdNo;
WizardTreeModel *mFileModel;
SmTreeItem *mMoviesItem;
SmTreeItem *mCoversItem;
+ PictureViewer *mPicViewer;
};
class MovieMappingPage : public QWizardPage {
diff --git a/smglobals.cpp b/smglobals.cpp
index 52b3805..c21cea4 100644
--- a/smglobals.cpp
+++ b/smglobals.cpp
@@ -164,15 +164,24 @@ void SmGlobals::FrameCache::readConfig(){
}
const QPixmap SmGlobals::FrameCache::entry(const QString &sourcePath, const QString &when){
- QString realWhen = when;
- if(realWhen.isEmpty()){
- realWhen = mWhen;
+ const QPair<QString, QString> source = prepFrame(sourcePath, when);
+ return QPixmap(mFrameCache.value(source));
+}
+
+const QString SmGlobals::FrameCache::entryPath(const QString &sourcePath, const QString &when){
+ const QPair<QString, QString> source = prepFrame(sourcePath, when);
+ return mFrameCache.value(source);
+}
+
+const QPair<QString, QString> SmGlobals::FrameCache::prepFrame(const QString &sourceFile, QString when){
+ if(when.isEmpty()){
+ when = mWhen;
}
- const QPair<QString, QString> source(sourcePath, realWhen);
+ const QPair<QString, QString> source(sourceFile, when);
if(!mFrameCache.contains(source)){
- grabFrame(sourcePath, realWhen);
+ grabFrame(sourceFile, when);
}
- return QPixmap(mFrameCache.value(source));
+ return source;
}
void SmGlobals::FrameCache::grabFrame(const QString &sourceFile, QString when){
diff --git a/smglobals.h b/smglobals.h
index e86493c..9324b85 100644
--- a/smglobals.h
+++ b/smglobals.h
@@ -25,10 +25,12 @@ class SmGlobals : public QObject {
~FrameCache();
void readConfig();
const QPixmap entry(const QString &sourcePath, const QString &when = QString());
+ const QString entryPath(const QString &sourcePath, const QString &when = QString());
private:
void readCache();
void grabFrame(const QString &sourceFile, QString when);
+ const QPair<QString, QString> prepFrame(const QString &sourceFile, QString when);
QHash<QPair<QString, QString>, QString> mFrameCache;
const qint32 mMagic;
const QString mCacheSubDir;