diff --git a/YACReaderLibrary/images.qrc b/YACReaderLibrary/images.qrc index 8658670d..6ce0c2f7 100644 --- a/YACReaderLibrary/images.qrc +++ b/YACReaderLibrary/images.qrc @@ -38,5 +38,8 @@ ../images/db.png ../images/asignNumber.png ../images/defaultCover.png + ../images/server.png + ../images/iphoneConfig.png + ../images/qrMessage.png \ No newline at end of file diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index 03b9cdd9..ce53016b 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -34,6 +34,9 @@ void LibraryWindow::setupUI() libraryCreator = new LibraryCreator(); packageManager = new PackageManager(); + settings = new QSettings("YACReaderLibrary.ini",QSettings::IniFormat); //TODO unificar la creación del fichero de config con el servidor + settings->beginGroup("libraryConfig"); + doModels(); doDialogs(); doLayout(); @@ -51,8 +54,12 @@ void LibraryWindow::doLayout() QSplitter * sHorizontal = new QSplitter(Qt::Horizontal); //spliter principal //TODO: flowType is a global variable //CONFIG COMIC_FLOW-------------------------------------------------------- - comicFlow = new ComicFlowWidgetGL(0); - comicFlow->setFlowType(flowType); + if(settings->contains("useOpenGL") && settings->value("useOpenGL").toBool() == true) + comicFlow = new ComicFlowWidgetGL(0); + else + comicFlow = new ComicFlowWidgetSW(0); + //comicFlow->setFlowType(flowType); + comicFlow->updateConfig(settings); comicFlow->setFocusPolicy(Qt::StrongFocus); comicFlow->setShowMarks(true); QMatrix m; @@ -186,7 +193,7 @@ void LibraryWindow::doDialogs() importComicsInfoDialog = new ImportComicsInfoDialog(this); addLibraryDialog = new AddLibraryDialog(this); optionsDialog = new OptionsDialog(this); - optionsDialog->restoreOptions(); + optionsDialog->restoreOptions(settings); serverConfigDialog = new ServerConfigDialog(this); had = new HelpAboutDialog(this); //TODO load data. @@ -330,7 +337,7 @@ void LibraryWindow::createActions() serverConfigAction = new QAction(this); serverConfigAction->setToolTip(tr("Show comics server options dialog")); - serverConfigAction->setIcon(QIcon(":/images/options.png")); + serverConfigAction->setIcon(QIcon(":/images/server.png")); //disable actions updateLibraryAction->setEnabled(false); @@ -1262,7 +1269,8 @@ void LibraryWindow::importLibrary(QString clc,QString destPath,QString name) void LibraryWindow::reloadOptions() { - comicFlow->setFlowType(flowType); + //comicFlow->setFlowType(flowType); + comicFlow->updateConfig(settings); } //TODO esto sobra diff --git a/YACReaderLibrary/library_window.h b/YACReaderLibrary/library_window.h index f3857ceb..92fff750 100644 --- a/YACReaderLibrary/library_window.h +++ b/YACReaderLibrary/library_window.h @@ -157,6 +157,9 @@ private: void enableLibraryActions(); QString currentPath(); + + //settings + QSettings * settings; public: LibraryWindow(); public slots: diff --git a/YACReaderLibrary/options_dialog.cpp b/YACReaderLibrary/options_dialog.cpp index 0744b59f..a5f544df 100644 --- a/YACReaderLibrary/options_dialog.cpp +++ b/YACReaderLibrary/options_dialog.cpp @@ -8,13 +8,33 @@ #include #include #include +#include + +#include "custom_widgets.h" +#include "yacreader_flow_gl.h" PictureFlow::FlowType flowType = PictureFlow::Strip; OptionsDialog::OptionsDialog(QWidget * parent) :QDialog() { - QVBoxLayout * layout = new QVBoxLayout(this); + QVBoxLayout * layout = new QVBoxLayout; + QLayout * layout1 = setupLayoutSW(); + QLayout * layout2 = setupLayoutGL(); + + sw = new QWidget(this); + layout1->setContentsMargins(0,0,0,0); + sw->setLayout(layout1); + + gl = new QWidget(this); + layout2->setContentsMargins(0,0,0,0); + gl->setLayout(layout2); + + QHBoxLayout * switchFlowType = new QHBoxLayout; + switchFlowType->addStretch(); + switchFlowType->addWidget(useGL = new QCheckBox(tr("Use hardware acceleration (restart needed)"))); + + connect(useGL,SIGNAL(stateChanged(int)),this,SLOT(saveUseGL(int))); accept = new QPushButton(tr("Save")); cancel = new QPushButton(tr("Cancel")); @@ -22,127 +42,525 @@ OptionsDialog::OptionsDialog(QWidget * parent) connect(cancel,SIGNAL(clicked()),this,SLOT(restoreOptions())); connect(cancel,SIGNAL(clicked()),this,SLOT(close())); - QGroupBox *groupBox = new QGroupBox(tr("How to show covers:")); - - radio1 = new QRadioButton(tr("CoverFlow look")); - radio2 = new QRadioButton(tr("Stripe look")); - radio3 = new QRadioButton(tr("Overlapped Stripe look")); - - - QVBoxLayout *vbox = new QVBoxLayout; - QHBoxLayout * opt1 = new QHBoxLayout; - opt1->addWidget(radio1); - QLabel * lOpt1 = new QLabel(); - lOpt1->setPixmap(QPixmap(":/images/flow1.png")); - opt1->addStretch(); - opt1->addWidget(lOpt1); - vbox->addLayout(opt1); - - QHBoxLayout * opt2 = new QHBoxLayout; - opt2->addWidget(radio2); - QLabel * lOpt2 = new QLabel(); - lOpt2->setPixmap(QPixmap(":/images/flow2.png")); - opt2->addStretch(); - opt2->addWidget(lOpt2); - vbox->addLayout(opt2); - - QHBoxLayout * opt3 = new QHBoxLayout; - opt3->addWidget(radio3); - QLabel * lOpt3 = new QLabel(); - lOpt3->setPixmap(QPixmap(":/images/flow3.png")); - opt3->addStretch(); - opt3->addWidget(lOpt3); - vbox->addLayout(opt3); - - - //vbox->addStretch(1); - groupBox->setLayout(vbox); - QHBoxLayout * buttons = new QHBoxLayout(); buttons->addStretch(); buttons->addWidget(accept); buttons->addWidget(cancel); - layout->addWidget(groupBox); + layout->addWidget(sw); + layout->addWidget(gl); + layout->addLayout(switchFlowType); layout->addLayout(buttons); - setLayout(layout); + sw->hide(); - restoreOptions(); //load options - resize(200,0); + setLayout(layout); + //restoreOptions(settings); //load options + //resize(200,0); setModal (true); setWindowTitle("Options"); } -void OptionsDialog::findFolder() +QLayout * OptionsDialog::setupLayoutSW() { - QString s = QFileDialog::getExistingDirectory(0,tr("Comics directory"),"."); - if(!s.isEmpty()) - { - pathEdit->setText(s); - } + QVBoxLayout * layout = new QVBoxLayout(this); + + QGroupBox *groupBox = new QGroupBox(tr("How to show covers:")); + + radio1 = new QRadioButton(tr("CoverFlow look")); + radio2 = new QRadioButton(tr("Stripe look")); + radio3 = new QRadioButton(tr("Overlapped Stripe look")); + + + QVBoxLayout *vbox = new QVBoxLayout; + QHBoxLayout * opt1 = new QHBoxLayout; + opt1->addWidget(radio1); + QLabel * lOpt1 = new QLabel(); + lOpt1->setPixmap(QPixmap(":/images/flow1.png")); + opt1->addStretch(); + opt1->addWidget(lOpt1); + vbox->addLayout(opt1); + + QHBoxLayout * opt2 = new QHBoxLayout; + opt2->addWidget(radio2); + QLabel * lOpt2 = new QLabel(); + lOpt2->setPixmap(QPixmap(":/images/flow2.png")); + opt2->addStretch(); + opt2->addWidget(lOpt2); + vbox->addLayout(opt2); + + QHBoxLayout * opt3 = new QHBoxLayout; + opt3->addWidget(radio3); + QLabel * lOpt3 = new QLabel(); + lOpt3->setPixmap(QPixmap(":/images/flow3.png")); + opt3->addStretch(); + opt3->addWidget(lOpt3); + vbox->addLayout(opt3); + + + //vbox->addStretch(1); + groupBox->setLayout(vbox); + + layout->addWidget(groupBox); + + return layout; } +QLayout * OptionsDialog::setupLayoutGL() +{ + QVBoxLayout * layout = new QVBoxLayout(this); + + //PRESETS------------------------------------------------------------------ + QGroupBox *groupBox = new QGroupBox(tr("Presets:")); + + radioClassic = new QRadioButton(tr("Classic look")); + connect(radioClassic,SIGNAL(toggled(bool)),this,SLOT(setClassicConfig())); + + radioStripe = new QRadioButton(tr("Stripe look")); + connect(radioStripe,SIGNAL(toggled(bool)),this,SLOT(setStripeConfig())); + + radioOver = new QRadioButton(tr("Overlapped Stripe look")); + connect(radioOver,SIGNAL(toggled(bool)),this,SLOT(setOverlappedStripeConfig())); + + radionModern = new QRadioButton(tr("Modern look")); + connect(radionModern,SIGNAL(toggled(bool)),this,SLOT(setModernConfig())); + + radioDown = new QRadioButton(tr("Roulette look")); + connect(radioDown,SIGNAL(toggled(bool)),this,SLOT(setRouletteConfig())); + + QVBoxLayout *vbox = new QVBoxLayout; + QHBoxLayout * opt1 = new QHBoxLayout; + opt1->addWidget(radioClassic); + QLabel * lOpt1 = new QLabel(); + lOpt1->setPixmap(QPixmap(":/images/flow1.png")); + opt1->addStretch(); + opt1->addWidget(lOpt1); + vbox->addLayout(opt1); + + QHBoxLayout * opt2 = new QHBoxLayout; + opt2->addWidget(radioStripe); + QLabel * lOpt2 = new QLabel(); + lOpt2->setPixmap(QPixmap(":/images/flow2.png")); + opt2->addStretch(); + opt2->addWidget(lOpt2); + vbox->addLayout(opt2); + + QHBoxLayout * opt3 = new QHBoxLayout; + opt3->addWidget(radioOver); + QLabel * lOpt3 = new QLabel(); + lOpt3->setPixmap(QPixmap(":/images/flow3.png")); + opt3->addStretch(); + opt3->addWidget(lOpt3); + vbox->addLayout(opt3); + + QHBoxLayout * opt4 = new QHBoxLayout; + opt4->addWidget(radionModern); + QLabel * lOpt4 = new QLabel(); + lOpt4->setPixmap(QPixmap(":/images/flow3.png")); + opt4->addStretch(); + opt4->addWidget(lOpt4); + vbox->addLayout(opt4); + + QHBoxLayout * opt5 = new QHBoxLayout; + opt5->addWidget(radioDown); + QLabel * lOpt5 = new QLabel(); + lOpt5->setPixmap(QPixmap(":/images/flow3.png")); + opt5->addStretch(); + opt5->addWidget(lOpt5); + vbox->addLayout(opt5); + + groupBox->setLayout(vbox); + + //OPTIONS------------------------------------------------------------------ + QGroupBox *optionsGroupBox = new QGroupBox(tr("Custom:")); + + xRotation = new YACReaderSpinSliderWidget(this); + xRotation->setText(tr("View angle")); + xRotation->setRange(0,90); + connect(xRotation,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); + connect(xRotation,SIGNAL(valueChanged(int)),this,SLOT(saveXRotation(int))); + + yPosition = new YACReaderSpinSliderWidget(this); + yPosition->setText(tr("Position")); + yPosition->setRange(-100,100); + connect(yPosition,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); + connect(yPosition,SIGNAL(valueChanged(int)),this,SLOT(saveYPosition(int))); + + coverDistance = new YACReaderSpinSliderWidget(this); + coverDistance->setText(tr("Cover gap")); + coverDistance->setRange(0,150); + connect(coverDistance,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); + connect(coverDistance,SIGNAL(valueChanged(int)),this,SLOT(saveCoverDistance(int))); + + centralDistance = new YACReaderSpinSliderWidget(this); + centralDistance->setText(tr("Central gap")); + centralDistance->setRange(0,150); + connect(centralDistance,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); + connect(centralDistance,SIGNAL(valueChanged(int)),this,SLOT(saveCentralDistance(int))); + + zoomLevel = new YACReaderSpinSliderWidget(this); + zoomLevel->setText(tr("Zoom")); + zoomLevel->setRange(-20,0); + connect(zoomLevel,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); + connect(zoomLevel,SIGNAL(valueChanged(int)),this,SLOT(saveZoomLevel(int))); + + yCoverOffset = new YACReaderSpinSliderWidget(this); + yCoverOffset->setText(tr("Y offset")); + yCoverOffset->setRange(-50,50); + connect(yCoverOffset,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); + connect(yCoverOffset,SIGNAL(valueChanged(int)),this,SLOT(saveYCoverOffset(int))); + + zCoverOffset = new YACReaderSpinSliderWidget(this); + zCoverOffset->setText(tr("Z offset")); + zCoverOffset->setRange(-50,50); + connect(zCoverOffset,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); + connect(zCoverOffset,SIGNAL(valueChanged(int)),this,SLOT(saveZCoverOffset(int))); + + coverRotation = new YACReaderSpinSliderWidget(this); + coverRotation->setText(tr("Cover Angle")); + coverRotation->setRange(0,360); + connect(coverRotation,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); + connect(coverRotation,SIGNAL(valueChanged(int)),this,SLOT(saveCoverRotation(int))); + + fadeOutDist = new YACReaderSpinSliderWidget(this); + fadeOutDist->setText(tr("Visibility")); + fadeOutDist->setRange(0,10); + connect(fadeOutDist,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); + connect(fadeOutDist,SIGNAL(valueChanged(int)),this,SLOT(saveFadeOutDist(int))); + + lightStrength = new YACReaderSpinSliderWidget(this); + lightStrength->setText(tr("Light")); + lightStrength->setRange(-10,10); + connect(lightStrength,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); + connect(lightStrength,SIGNAL(valueChanged(int)),this,SLOT(saveLightStrength(int))); + + maxAngle = new YACReaderSpinSliderWidget(this); + maxAngle->setText(tr("Max angle")); + maxAngle->setRange(0,90); + connect(maxAngle,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); + connect(maxAngle,SIGNAL(valueChanged(int)),this,SLOT(saveMaxAngle(int))); + + QVBoxLayout *optionsLayoutStretch = new QVBoxLayout; + optionsLayoutStretch->setContentsMargins(0,0,0,0); + QGridLayout *optionsLayout = new QGridLayout; + optionsLayout->addWidget(xRotation,0,0); + optionsLayout->addWidget(yPosition,0,1); + optionsLayout->addWidget(coverDistance,1,0); + optionsLayout->addWidget(centralDistance,1,1); + optionsLayout->addWidget(zoomLevel,2,0); + optionsLayout->addWidget(yCoverOffset,2,1); + optionsLayout->addWidget(zCoverOffset,3,0); + optionsLayout->addWidget(coverRotation,3,1); + optionsLayout->addWidget(fadeOutDist,4,0); + optionsLayout->addWidget(lightStrength,4,1); + optionsLayout->addWidget(maxAngle,5,0); + + optionsLayoutStretch->addLayout(optionsLayout); + optionsLayoutStretch->addStretch(); + + optionsGroupBox->setLayout(optionsLayoutStretch); + + QHBoxLayout * groupBoxesLayout = new QHBoxLayout; + groupBoxesLayout->addWidget(groupBox); + groupBoxesLayout->addWidget(optionsGroupBox); + + QHBoxLayout * performance = new QHBoxLayout; + performance->addWidget(new QLabel(tr("Low Performance"))); + performance->addWidget(performanceSlider = new QSlider(Qt::Horizontal)); + performance->addWidget(new QLabel(tr("High Performance"))); + + performanceSlider->setMinimum(0); + performanceSlider->setMaximum(3); + performanceSlider->setSingleStep(1); + performanceSlider->setPageStep(1); + performanceSlider->setTickInterval(1); + performanceSlider->setTickPosition(QSlider::TicksRight); + + connect(performanceSlider, SIGNAL(valueChanged(int)),this,SLOT(savePerformance(int))); + connect(performanceSlider, SIGNAL(valueChanged(int)),this,SLOT(optionsChanged())); + + + layout->addLayout(groupBoxesLayout); + layout->addLayout(performance); + + return layout; +} + +void OptionsDialog::savePerformance(int value) +{ + settings->setValue("performance",value); +} + +void OptionsDialog::saveUseGL(int b) +{ + if(Qt::Checked == b) + { + sw->setVisible(false); + gl->setVisible(true); + } + else + { + gl->setVisible(false); + sw->setVisible(true); + } + resize(0,0); + settings->setValue("useOpenGL",b); +} + +void OptionsDialog::saveXRotation(int value) +{ + settings->setValue("flowType",PictureFlow::Custom); + settings->setValue("xRotation",xRotation->getValue()); +} +void OptionsDialog::saveYPosition(int value) +{ + settings->setValue("flowType",PictureFlow::Custom); + settings->setValue("yPosition",yPosition->getValue()); +} +void OptionsDialog::saveCoverDistance(int value) +{ + settings->setValue("flowType",PictureFlow::Custom); + settings->setValue("coverDistance",coverDistance->getValue()); +} +void OptionsDialog::saveCentralDistance(int value) +{ + settings->setValue("flowType",PictureFlow::Custom); + settings->setValue("centralDistance",centralDistance->getValue()); +} +void OptionsDialog::saveZoomLevel(int value) +{ + settings->setValue("flowType",PictureFlow::Custom); + settings->setValue("zoomLevel",zoomLevel->getValue()); +} +void OptionsDialog::saveYCoverOffset(int value) +{ + settings->setValue("flowType",PictureFlow::Custom); + settings->setValue("yCoverOffset",yCoverOffset->getValue()); +} +void OptionsDialog::saveZCoverOffset(int value) +{ + settings->setValue("flowType",PictureFlow::Custom); + settings->setValue("zCoverOffset",zCoverOffset->getValue()); +} +void OptionsDialog::saveCoverRotation(int value) +{ + settings->setValue("flowType",PictureFlow::Custom); + settings->setValue("coverRotation",coverRotation->getValue()); +} +void OptionsDialog::saveFadeOutDist(int value) +{ + settings->setValue("flowType",PictureFlow::Custom); + settings->setValue("fadeOutDist",fadeOutDist->getValue()); +} +void OptionsDialog::saveLightStrength(int value) +{ + settings->setValue("flowType",PictureFlow::Custom); + settings->setValue("lightStrength",lightStrength->getValue()); +} + +void OptionsDialog::saveMaxAngle(int value) +{ + settings->setValue("flowType",PictureFlow::Custom); + settings->setValue("maxAngle",maxAngle->getValue()); +} + void OptionsDialog::saveOptions() { - QFile f(QCoreApplication::applicationDirPath()+"/YACReaderLibrary.conf"); - if(!f.open(QIODevice::WriteOnly)) - { - QMessageBox::critical(NULL,tr("Saving config file...."),tr("There was a problem saving YACReaderLibrary configuration. Please, check if you have enough permissions in the YACReader root folder.")); - } - else - { - QTextStream txtS(&f); - if(radio1->isChecked()) - { - txtS << "FLOW_TYPE" << "\n" << (int)PictureFlow::CoverFlowLike << "\n"; - flowType = PictureFlow::CoverFlowLike; - } - if(radio2->isChecked()) - { - txtS << "FLOW_TYPE" << "\n" << (int)PictureFlow::Strip << "\n"; - flowType = PictureFlow::Strip; - } - if(radio3->isChecked()) - { - txtS << "FLOW_TYPE" << "\n" << (int)PictureFlow::StripOverlapped << "\n"; - flowType = PictureFlow::StripOverlapped; - } - f.close(); - close(); emit(optionsChanged()); - } + close(); } -void OptionsDialog::restoreOptions() +void OptionsDialog::restoreOptions(QSettings * settings) { - QFile f(QCoreApplication::applicationDirPath()+"/YACReaderLibrary.conf"); - if(f.exists()) + this->settings = settings; + + if(settings->contains("useOpenGL") && settings->value("useOpenGL").toInt() == Qt::Checked) { - f.open(QIODevice::ReadOnly); - QTextStream txtS(&f); - QString content = txtS.readAll(); + sw->setVisible(false); + gl->setVisible(true); + useGL->setChecked(true); + } + else + { + gl->setVisible(false); + sw->setVisible(true); + useGL->setChecked(false); + } + + + if(!settings->contains("flowType")) + { + setClassicConfig(); + radioClassic->setChecked(true); + performanceSlider->setValue(1); + return; + } + + performanceSlider->setValue(settings->value("performance").toInt()); + PictureFlow::FlowType flowType; + switch(settings->value("flowType").toInt()) + { + case 0: + flowType = PictureFlow::CoverFlowLike; + break; + case 1: + flowType = PictureFlow::Strip; + break; + case 2: + flowType = PictureFlow::StripOverlapped; + break; + case 3: + flowType = PictureFlow::Modern; + break; + case 4: + flowType = PictureFlow::Roulette; + break; + case 5: + flowType = PictureFlow::Custom; + break; + } - QStringList lines = content.split('\n'); - if(lines.count()>0){ - QString name = lines.at(1); - switch(flowType=(PictureFlow::FlowType)name.toInt()){ - case PictureFlow::CoverFlowLike: - radio1->setChecked(true); - break; - case PictureFlow::Strip: - radio2->setChecked(true); - break; - case PictureFlow::StripOverlapped: - radio3->setChecked(true); - break; + if(flowType == PictureFlow::Custom) + { + loadConfig(); + return; } - } - else - flowType=PictureFlow::Strip; - } - else - flowType=PictureFlow::Strip; + if(flowType == PictureFlow::CoverFlowLike) + { + setClassicConfig(); + radioClassic->setChecked(true); + return; + } + + if(flowType == PictureFlow::Strip) + { + setStripeConfig(); + radioStripe->setChecked(true); + return; + } + + if(flowType == PictureFlow::StripOverlapped) + { + setOverlappedStripeConfig(); + radioOver->setChecked(true); + return; + } + + if(flowType == PictureFlow::Modern) + { + setModernConfig(); + radionModern->setChecked(true); + return; + } + + if(flowType == PictureFlow::Roulette) + { + setRouletteConfig(); + radioDown->setChecked(true); + return; + } +} + +void OptionsDialog::loadConfig() +{ + + xRotation->setValue(settings->value("xRotation").toInt()); + yPosition->setValue(settings->value("yPosition").toInt()); + coverDistance->setValue(settings->value("coverDistance").toInt()); + centralDistance->setValue(settings->value("centralDistance").toInt()); + zoomLevel->setValue(settings->value("zoomLevel").toInt()); + yCoverOffset->setValue(settings->value("yCoverOffset").toInt()); + zCoverOffset->setValue(settings->value("zCoverOffset").toInt()); + coverRotation->setValue(settings->value("coverRotation").toInt()); + fadeOutDist->setValue(settings->value("fadeOutDist").toInt()); + lightStrength->setValue(settings->value("lightStrength").toInt()); + maxAngle->setValue(settings->value("maxAngle").toInt()); +} +void OptionsDialog::setClassicConfig() +{ + + settings->setValue("flowType",PictureFlow::CoverFlowLike); + + xRotation->setValue(presetYACReaderFlowClassicConfig.cfRX); + yPosition->setValue(presetYACReaderFlowClassicConfig.cfY*100); + coverDistance->setValue(presetYACReaderFlowClassicConfig.xDistance*100); + centralDistance->setValue(presetYACReaderFlowClassicConfig.centerDistance*100); + zoomLevel->setValue(presetYACReaderFlowClassicConfig.cfZ); + yCoverOffset->setValue(presetYACReaderFlowClassicConfig.yDistance*100); + zCoverOffset->setValue(presetYACReaderFlowClassicConfig.zDistance*100); + coverRotation->setValue(presetYACReaderFlowClassicConfig.rotation*-1); + fadeOutDist->setValue(presetYACReaderFlowClassicConfig.animationFadeOutDist); + lightStrength->setValue(presetYACReaderFlowClassicConfig.viewRotateLightStrenght); + maxAngle->setValue(presetYACReaderFlowClassicConfig.viewAngle); +} + +void OptionsDialog::setStripeConfig() +{ + + settings->setValue("flowType",PictureFlow::Strip); + + xRotation->setValue(presetYACReaderFlowStripeConfig.cfRX); + yPosition->setValue(presetYACReaderFlowStripeConfig.cfY*100); + coverDistance->setValue(presetYACReaderFlowStripeConfig.xDistance*100); + centralDistance->setValue(presetYACReaderFlowStripeConfig.centerDistance*100); + zoomLevel->setValue(presetYACReaderFlowStripeConfig.cfZ); + yCoverOffset->setValue(presetYACReaderFlowStripeConfig.yDistance*100); + zCoverOffset->setValue(presetYACReaderFlowStripeConfig.zDistance*100); + coverRotation->setValue(presetYACReaderFlowStripeConfig.rotation*-1); + fadeOutDist->setValue(presetYACReaderFlowStripeConfig.animationFadeOutDist); + lightStrength->setValue(presetYACReaderFlowStripeConfig.viewRotateLightStrenght); + maxAngle->setValue(presetYACReaderFlowStripeConfig.viewAngle); +} + +void OptionsDialog::setOverlappedStripeConfig() +{ + settings->setValue("flowType",PictureFlow::StripOverlapped); + + xRotation->setValue(presetYACReaderFlowOverlappedStripeConfig.cfRX); + yPosition->setValue(presetYACReaderFlowOverlappedStripeConfig.cfY*100); + coverDistance->setValue(presetYACReaderFlowOverlappedStripeConfig.xDistance*100); + centralDistance->setValue(presetYACReaderFlowOverlappedStripeConfig.centerDistance*100); + zoomLevel->setValue(presetYACReaderFlowOverlappedStripeConfig.cfZ); + yCoverOffset->setValue(presetYACReaderFlowOverlappedStripeConfig.yDistance*100); + zCoverOffset->setValue(presetYACReaderFlowOverlappedStripeConfig.zDistance*100); + coverRotation->setValue(presetYACReaderFlowOverlappedStripeConfig.rotation*-1); + fadeOutDist->setValue(presetYACReaderFlowOverlappedStripeConfig.animationFadeOutDist); + lightStrength->setValue(presetYACReaderFlowOverlappedStripeConfig.viewRotateLightStrenght); + maxAngle->setValue(presetYACReaderFlowOverlappedStripeConfig.viewAngle); +} + +void OptionsDialog::setModernConfig() +{ + settings->setValue("flowType",PictureFlow::Modern); + + xRotation->setValue(defaultYACReaderFlowConfig.cfRX); + yPosition->setValue(defaultYACReaderFlowConfig.cfY*100); + coverDistance->setValue(defaultYACReaderFlowConfig.xDistance*100); + centralDistance->setValue(defaultYACReaderFlowConfig.centerDistance*100); + zoomLevel->setValue(defaultYACReaderFlowConfig.cfZ); + yCoverOffset->setValue(defaultYACReaderFlowConfig.yDistance*100); + zCoverOffset->setValue(defaultYACReaderFlowConfig.zDistance*100); + coverRotation->setValue(defaultYACReaderFlowConfig.rotation*-1); + fadeOutDist->setValue(defaultYACReaderFlowConfig.animationFadeOutDist); + lightStrength->setValue(defaultYACReaderFlowConfig.viewRotateLightStrenght); + maxAngle->setValue(defaultYACReaderFlowConfig.viewAngle); +} + +void OptionsDialog::setRouletteConfig() +{ + settings->setValue("flowType",PictureFlow::Roulette); + + xRotation->setValue(pressetYACReaderFlowDownConfig.cfRX); + yPosition->setValue(pressetYACReaderFlowDownConfig.cfY*100); + coverDistance->setValue(pressetYACReaderFlowDownConfig.xDistance*100); + centralDistance->setValue(pressetYACReaderFlowDownConfig.centerDistance*100); + zoomLevel->setValue(pressetYACReaderFlowDownConfig.cfZ); + yCoverOffset->setValue(pressetYACReaderFlowDownConfig.yDistance*100); + zCoverOffset->setValue(pressetYACReaderFlowDownConfig.zDistance*100); + coverRotation->setValue(pressetYACReaderFlowDownConfig.rotation*-1); + fadeOutDist->setValue(pressetYACReaderFlowDownConfig.animationFadeOutDist); + lightStrength->setValue(pressetYACReaderFlowDownConfig.viewRotateLightStrenght); + maxAngle->setValue(pressetYACReaderFlowDownConfig.viewAngle); } diff --git a/YACReaderLibrary/options_dialog.h b/YACReaderLibrary/options_dialog.h index 36fe2d6a..4d631a15 100644 --- a/YACReaderLibrary/options_dialog.h +++ b/YACReaderLibrary/options_dialog.h @@ -8,8 +8,12 @@ #include #include #include +#include +#include #include "pictureflow.h" +#include "custom_widgets.h" + extern PictureFlow::FlowType flowType; class OptionsDialog : public QDialog @@ -18,32 +22,74 @@ Q_OBJECT public: OptionsDialog(QWidget * parent = 0); private: - QLabel * pathLabel; - QLineEdit * pathEdit; - QPushButton * pathFindButton; - - QLabel * magGlassSizeLabel; - - QLabel * zoomLevel; - - QLabel * slideSizeLabel; - QSlider * slideSize; - + QPushButton * accept; QPushButton * cancel; + QCheckBox * useGL; + //SW......................... QRadioButton *radio1; QRadioButton *radio2; QRadioButton *radio3; + //GL......................... + QRadioButton *radioClassic; + QRadioButton *radioStripe; + QRadioButton *radioOver; + QRadioButton *radionModern; + QRadioButton *radioDown; + + YACReaderSpinSliderWidget * xRotation; + YACReaderSpinSliderWidget * yPosition; + YACReaderSpinSliderWidget * coverDistance; + YACReaderSpinSliderWidget * centralDistance; + YACReaderSpinSliderWidget * zoomLevel; + YACReaderSpinSliderWidget * yCoverOffset; + YACReaderSpinSliderWidget * zCoverOffset; + YACReaderSpinSliderWidget * coverRotation; + YACReaderSpinSliderWidget * fadeOutDist; + YACReaderSpinSliderWidget * lightStrength; + YACReaderSpinSliderWidget * maxAngle; + + QSlider * performanceSlider; + + QWidget * sw; + QWidget * gl; + + QLayout * setupLayoutSW(); + QLayout * setupLayoutGL(); + + QSettings * settings; + QSettings * previousSettings; + + private slots: + void savePerformance(int value); + void saveUseGL(int b); + void saveXRotation(int value); + void saveYPosition(int value); + void saveCoverDistance(int value); + void saveCentralDistance(int value); + void saveZoomLevel(int value); + void saveYCoverOffset(int value); + void saveZCoverOffset(int value); + void saveCoverRotation(int value); + void saveFadeOutDist(int value); + void saveLightStrength(int value); + void saveMaxAngle(int value); + void loadConfig(); + void setClassicConfig(); + void setStripeConfig(); + void setOverlappedStripeConfig(); + void setModernConfig(); + void setRouletteConfig(); public slots: void saveOptions(); - void restoreOptions(); - void findFolder(); - + void restoreOptions(QSettings * settings); signals: void optionsChanged(); + + }; diff --git a/YACReaderLibrary/server/startup.cpp b/YACReaderLibrary/server/startup.cpp index 2cb3a60e..b8599dc7 100644 --- a/YACReaderLibrary/server/startup.cpp +++ b/YACReaderLibrary/server/startup.cpp @@ -16,16 +16,16 @@ #define APPNAME "YACReaderLibrary" /** Publisher of this application */ -#define ORGANISATION "Butterfly" +#define ORGANISATION "YACReader" /** Short description of this application */ -#define DESCRIPTION "Web service based on Qt" +#define DESCRIPTION "Comic reader and organizer" void Startup::start() { // Initialize the core application QCoreApplication* app = QApplication::instance(); app->setApplicationName(APPNAME); - //app->setOrganizationName(ORGANISATION); + app->setOrganizationName(ORGANISATION); QString configFileName=Static::getConfigDir()+"/"+QCoreApplication::applicationName()+".ini"; // Configure logging into files diff --git a/YACReaderLibrary/server_config_dialog.cpp b/YACReaderLibrary/server_config_dialog.cpp index d374a230..32036e87 100644 --- a/YACReaderLibrary/server_config_dialog.cpp +++ b/YACReaderLibrary/server_config_dialog.cpp @@ -17,12 +17,60 @@ ServerConfigDialog::ServerConfigDialog(QWidget * parent) qrCodeImage = new QPixmap(); qrCode = new QLabel("xxxx",this); - QGridLayout * mainLayout = new QGridLayout; - mainLayout->addWidget(accept,0,0); - mainLayout->addWidget(qrCode,0,1); + + + + + QGridLayout * gridEdits = new QGridLayout; + gridEdits->addWidget(new QLabel(tr("IP")),0,0); + gridEdits->addWidget(new QLabel(tr("Port")),0,1); + ip = new QLineEdit(". . ."); + gridEdits->addWidget(ip,1,0); + port = new QLineEdit("8080"); + port->setMaximumWidth(50); + gridEdits->addWidget(port,1,1); + gridEdits->setColumnStretch(0,1); + gridEdits->setColumnStretch(1,0); + + QHBoxLayout * codeLayout = new QHBoxLayout; + codeLayout->addStretch(); + QLabel * qrMessage = new QLabel(); + qrMessage->setPixmap(QPixmap(":/images/qrMessage.png")); + codeLayout->addWidget(qrMessage); + codeLayout->addWidget(qrCode); + + QVBoxLayout * configLayout = new QVBoxLayout; + configLayout->addLayout(gridEdits); + configLayout->addLayout(codeLayout); + configLayout->addStretch(); + configLayout->setSpacing(5); + + QHBoxLayout * elementsLayout = new QHBoxLayout; + + QLabel * iphone = new QLabel(); + iphone->setPixmap(QPixmap(":/images/iphoneConfig.png")); + elementsLayout->setSpacing(40); + elementsLayout->addWidget(iphone); + elementsLayout->addStretch(); + elementsLayout->addLayout(configLayout); + + QHBoxLayout * buttons = new QHBoxLayout; + buttons->addStretch(); + buttons->addWidget(accept); + + QVBoxLayout * mainLayout = new QVBoxLayout; + mainLayout->addLayout(elementsLayout); + mainLayout->addLayout(buttons); + //mainLayout->addWidget(qrCode,0,1); this->setLayout(mainLayout); generateQR(); + + QPalette Pal(palette()); + // set black background + Pal.setColor(QPalette::Background, Qt::white); + setAutoFillBackground(true); + setPalette(Pal); } void ServerConfigDialog::generateQR() @@ -50,12 +98,17 @@ void ServerConfigDialog::generateQR() } } if(!dir.isEmpty()) + { generateQR(dir+":"+s->getPort()); + ip->setText(dir); + port->setText(s->getPort()); + } else { } //qrCode->setText(dir+":8080"); + } @@ -63,7 +116,7 @@ void ServerConfigDialog::generateQR(const QString & serverAddress) { qrGenerator = new QProcess(); QStringList attributes; - attributes << "-o" << QCoreApplication::applicationDirPath()+"/utils/tmp.png" << "-s" << "8" << "-l" << "H" << serverAddress; + attributes << "-o" << "-" /*QCoreApplication::applicationDirPath()+"/utils/tmp.png"*/ << "-s" << "8" << "-l" << "H" << serverAddress; connect(qrGenerator,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(updateImage(void))); connect(qrGenerator,SIGNAL(error(QProcess::ProcessError)),this,SLOT(openingError(QProcess::ProcessError))); qrGenerator->start(QCoreApplication::applicationDirPath()+"/utils/qrencode",attributes); @@ -71,17 +124,20 @@ void ServerConfigDialog::generateQR(const QString & serverAddress) void ServerConfigDialog::updateImage() { - //QByteArray imgBinary = qrGenerator->readAllStandardOutput(); + QByteArray imgBinary = qrGenerator->readAllStandardOutput(); //imgBinary = imgBinary.replace(0x0D0A,0x0A); - //qrCodeImage->loadFromData(imgBinary); - //if(imgBinary.isEmpty()) - // qrCode->setText("yyyyy"); - //else - // qrCode->setText("") - //delete qrGenerator; - qrCodeImage->load(QCoreApplication::applicationDirPath()+"/utils/tmp.png"); + if(!qrCodeImage->loadFromData(imgBinary)) + qrCode->setText(tr("QR generator error!")); + else + qrCode->setPixmap(*qrCodeImage); + + delete qrGenerator; + + + +/* qrCodeImage->load(QCoreApplication::applicationDirPath()+"/utils/tmp.png"); qrCode->setPixmap(*qrCodeImage); - delete qrGenerator; + delete qrGenerator;*/ } \ No newline at end of file diff --git a/YACReaderLibrary/server_config_dialog.h b/YACReaderLibrary/server_config_dialog.h index 87d3084e..a6171182 100644 --- a/YACReaderLibrary/server_config_dialog.h +++ b/YACReaderLibrary/server_config_dialog.h @@ -15,9 +15,8 @@ Q_OBJECT public: ServerConfigDialog(QWidget * parent = 0); private: - QLabel * ipLabel; - QLabel * portLabel; - QLineEdit * portEdit; + QLineEdit * ip; + QLineEdit * port; QPushButton * close; QPushButton * accept; QLabel * qrCode; diff --git a/common/comic_flow_widget.cpp b/common/comic_flow_widget.cpp index e0891027..364bad47 100644 --- a/common/comic_flow_widget.cpp +++ b/common/comic_flow_widget.cpp @@ -111,8 +111,10 @@ void ComicFlowWidgetSW::mouseDoubleClickEvent(QMouseEvent* event) { flow->mouseDoubleClickEvent(event); } - - +void ComicFlowWidgetSW::updateConfig(QSettings * settings) +{ + //flow->setFlowType(flowType); +} ////////////////////////////////////////////////////////////////////////// @@ -131,6 +133,7 @@ ComicFlowWidgetGL::ComicFlowWidgetGL(QWidget * parent) QVBoxLayout * l = new QVBoxLayout; l->addWidget(flow); + l->setContentsMargins(0,0,0,0); setLayout(l); //TODO eleminar "padding" @@ -232,4 +235,77 @@ void ComicFlowWidgetGL::resizeEvent(QResizeEvent* event) void ComicFlowWidgetGL::mouseDoubleClickEvent(QMouseEvent* event) { flow->mouseDoubleClickEvent(event); -} \ No newline at end of file +} + +void ComicFlowWidgetGL::updateConfig(QSettings * settings) +{ + Performance performance = medium; + + switch (settings->value("performance").toInt()) + { + case 0: + performance = low; + break; + case 1: + performance = medium; + break; + case 2: + performance = high; + break; + case 3: + performance = ultraHigh; + break; + } + + flow->setPerformance(performance); + + switch (settings->value("flowType").toInt()) + { + case 0: + flow->setPreset(presetYACReaderFlowClassicConfig); + return; + case 1: + flow->setPreset(presetYACReaderFlowStripeConfig); + return; + case 2: + flow->setPreset(presetYACReaderFlowOverlappedStripeConfig); + return; + case 3: + flow->setPreset(defaultYACReaderFlowConfig); + return; + case 4: + flow->setPreset(pressetYACReaderFlowDownConfig); + return; + } + + + //custom config + + flow->setCF_RX(settings->value("xRotation").toInt()); + flow->setCF_Y(settings->value("yPosition").toInt()); + flow->setX_Distance(settings->value("coverDistance").toInt()); + flow->setCenter_Distance(settings->value("centralDistance").toInt()); + flow->setCF_Z(settings->value("zoomLevel").toInt()); + flow->setY_Distance(settings->value("yCoverOffset").toInt()); + flow->setZ_Distance(settings->value("zCoverOffset").toInt()); + flow->setRotation(settings->value("coverRotation").toInt()); + flow->setFadeOutDist(settings->value("fadeOutDist").toInt()); + flow->setLightStrenght(settings->value("lightStrength").toInt()); + flow->setMaxAngle(settings->value("maxAngle").toInt()); + +/* flow->setVisibility(settings->value("visibilityDistance").toInt()); + flow->setLightStrenght(settings->value("lightStrength").toInt())*/; + +} + +//void ComicFlowWidgetGL::setCF_RX(int value){ flow->setCF_RX(value);} +//void ComicFlowWidgetGL::setCF_RY(int value){ flow->setCF_RY(value);} +//void ComicFlowWidgetGL::setCF_RZ(int value){ flow->setCF_RZ(value);} +//void ComicFlowWidgetGL::setZoom(int zoom){ flow->setZoom(zoom);} +//void ComicFlowWidgetGL::setRotation(int angle){ flow->setRotation(angle);} +//void ComicFlowWidgetGL::setX_Distance(int distance){ flow->setX_Distance(distance);} +//void ComicFlowWidgetGL::setCenter_Distance(int distance){ flow->setCenter_Distance(distance);} +//void ComicFlowWidgetGL::setZ_Distance(int distance){ flow->setZ_Distance(distance);} +//void ComicFlowWidgetGL::setCF_Y(int value){ flow->setCF_Y(value);} +//void ComicFlowWidgetGL::setY_Distance(int value){ flow->setY_Distance(value);} +//void ComicFlowWidgetGL::setPreset(const Preset & p){ flow->setPreset(p);} \ No newline at end of file diff --git a/common/comic_flow_widget.h b/common/comic_flow_widget.h index d6d53f8b..5709e675 100644 --- a/common/comic_flow_widget.h +++ b/common/comic_flow_widget.h @@ -27,6 +27,7 @@ public slots: virtual void updateMarks() = 0; virtual void setFlowType(PictureFlow::FlowType flowType) = 0; virtual void render() = 0; + virtual void updateConfig(QSettings * settings) = 0; signals: void centerIndexChanged(int); void selected(unsigned int); @@ -55,6 +56,7 @@ public: void updateMarks(); void setFlowType(PictureFlow::FlowType flowType); void render(); + void updateConfig(QSettings * settings); protected: void keyPressEvent(QKeyEvent* event); void paintEvent(QPaintEvent *event); @@ -87,6 +89,25 @@ public: void updateMarks(); void setFlowType(PictureFlow::FlowType flowType); void render(); + void updateConfig(QSettings * settings); +//public slots: +// void setCF_RX(int value); +// //the Y Rotation of the Coverflow +// void setCF_RY(int value); +// //the Z Rotation of the Coverflow +// void setCF_RZ(int value); +// //perspective +// void setZoom(int zoom); +// void setRotation(int angle); +// //sets the distance between the covers +// void setX_Distance(int distance); +// //sets the distance between the centered and the non centered covers +// void setCenter_Distance(int distance); +// //sets the pushback amount +// void setZ_Distance(int distance); +// void setCF_Y(int value); +// void setY_Distance(int value); +// void setPreset(const Preset & p); protected: void keyPressEvent(QKeyEvent* event); void paintEvent(QPaintEvent *event); diff --git a/common/custom_widgets.cpp b/common/custom_widgets.cpp index ad33b663..9a9ed301 100644 --- a/common/custom_widgets.cpp +++ b/common/custom_widgets.cpp @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include "qnaturalsorting.h" @@ -462,4 +464,55 @@ void YACReaderFieldPlainTextEdit::setDisabled(bool disabled) if(disabled) setPlainText(tr("Click to overwrite")); QPlainTextEdit::setDisabled(disabled); -} \ No newline at end of file +} + + +YACReaderSpinSliderWidget::YACReaderSpinSliderWidget(QWidget * parent) + :QWidget(parent) +{ + QHBoxLayout * layout = new QHBoxLayout; + layout->addWidget(label = new QLabel(this)); + layout->addStretch(); + spinBox = new QSpinBox(this); + layout->addWidget(spinBox); + slider = new QSlider(Qt::Horizontal,this); + layout->addWidget(slider); + + connect(spinBox, SIGNAL(valueChanged(int)), slider, SLOT(setValue(int))); + connect(slider, SIGNAL(valueChanged(int)), spinBox, SLOT(setValue(int))); + + connect(spinBox, SIGNAL(valueChanged(int)), this, SIGNAL(valueChanged(int))); + + setLayout(layout); +} + +void YACReaderSpinSliderWidget::setRange(int lowValue, int topValue, int step) +{ + spinBox->setMinimum(lowValue); + spinBox->setMaximum(topValue); + spinBox->setSingleStep(step); + + slider->setMinimum(lowValue); + slider->setMaximum(topValue); + slider->setSingleStep(step); +} + +void YACReaderSpinSliderWidget::setValue(int value) +{ + spinBox->setValue(value); +} + +void YACReaderSpinSliderWidget::setText(const QString & text) +{ + label->setText(text); +} + +int YACReaderSpinSliderWidget::getValue() +{ + return spinBox->value(); +} + +QSize YACReaderSpinSliderWidget::minimumSizeHint() const +{ + return QSize(220, 25); +} diff --git a/common/custom_widgets.h b/common/custom_widgets.h index d2e0d75a..12f9ded6 100644 --- a/common/custom_widgets.h +++ b/common/custom_widgets.h @@ -21,6 +21,9 @@ #include #include #include +#include +#include +#include #include "pictureflow.h" @@ -184,6 +187,26 @@ private: // } //}; +class YACReaderSpinSliderWidget : public QWidget +{ + Q_OBJECT +private: + QLabel * label; + QSpinBox * spinBox; + QSlider * slider; +public: + YACReaderSpinSliderWidget(QWidget * parent = 0); +public slots: + void setRange(int lowValue, int topValue, int step=1); + void setValue(int value); + void setText(const QString & text); + int getValue(); + QSize minimumSizeHint() const; +signals: + void valueChanged(int); + +}; + #endif diff --git a/common/pictureflow.h b/common/pictureflow.h index 8e7b6664..a1da0c6b 100644 --- a/common/pictureflow.h +++ b/common/pictureflow.h @@ -1,191 +1,194 @@ -/* - PictureFlow - animated image show widget - http://pictureflow.googlecode.com - - Copyright (C) 2008 Ariya Hidayat (ariya@kde.org) - Copyright (C) 2007 Ariya Hidayat (ariya@kde.org) - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. -*/ - -#ifndef PICTUREFLOW_H -#define PICTUREFLOW_H - -#include - -class PictureFlowPrivate; - -/*! - Class PictureFlow implements an image show widget with animation effect - like Apple's CoverFlow (in iTunes and iPod). Images are arranged in form - of slides, one main slide is shown at the center with few slides on - the left and right sides of the center slide. When the next or previous - slide is brought to the front, the whole slides flow to the right or - the right with smooth animation effect; until the new slide is finally - placed at the center. - - */ -class PictureFlow : public QWidget -{ -Q_OBJECT - - Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor) - Q_PROPERTY(QSize slideSize READ slideSize WRITE setSlideSize) - Q_PROPERTY(int slideCount READ slideCount) - Q_PROPERTY(int centerIndex READ centerIndex WRITE setCenterIndex) - -public: - - enum ReflectionEffect - { - NoReflection, - PlainReflection, - BlurredReflection - }; - - enum FlowType - { - CoverFlowLike, - Strip, - StripOverlapped - }; - - /*! - Creates a new PictureFlow widget. - */ - PictureFlow(QWidget* parent = 0, FlowType flowType = CoverFlowLike); - - /*! - Destroys the widget. - */ - ~PictureFlow(); - - /*! - Returns the background color. - */ - QColor backgroundColor() const; - - /*! - Sets the background color. By default it is black. - */ - void setBackgroundColor(const QColor& c); - - /*! - Returns the dimension of each slide (in pixels). - */ - QSize slideSize() const; - - /*! - Sets the dimension of each slide (in pixels). - */ - void setSlideSize(QSize size); - - /*! - Returns the total number of slides. - */ - int slideCount() const; - - /*! - Returns QImage of specified slide. - */ - QImage slide(int index) const; - - /*! - Returns the index of slide currently shown in the middle of the viewport. - */ - int centerIndex() const; - - /*! - Returns the effect applied to the reflection. - */ - ReflectionEffect reflectionEffect() const; - - /*! - Sets the effect applied to the reflection. The default is PlainReflection. - */ - void setReflectionEffect(ReflectionEffect effect); - - -public slots: - - /*! - Adds a new slide. - */ - void addSlide(const QImage& image); - - /*! - Adds a new slide. - */ - void addSlide(const QPixmap& pixmap); - - /*! - Sets an image for specified slide. If the slide already exists, - it will be replaced. - */ - void setSlide(int index, const QImage& image); - - /*! - Sets a pixmap for specified slide. If the slide already exists, - it will be replaced. - */ - void setSlide(int index, const QPixmap& pixmap); - - /*! - Sets slide to be shown in the middle of the viewport. No animation - effect will be produced, unlike using showSlide. - */ - void setCenterIndex(int index); - - /*! - Clears all slides. - */ - void clear(); - - /*! - Shows previous slide using animation effect. - */ - void showPrevious(); - - /*! - Shows next slide using animation effect. - */ - void showNext(); - - /*! - Go to specified slide using animation effect. - */ - void showSlide(int index); - - /*! - Rerender the widget. Normally this function will be automatically invoked - whenever necessary, e.g. during the transition animation. - */ - void render(); - - /*! - Schedules a rendering update. Unlike render(), this function does not cause - immediate rendering. - */ - void triggerRender(); - - void setFlowType(FlowType flowType); - +/* + PictureFlow - animated image show widget + http://pictureflow.googlecode.com + + Copyright (C) 2008 Ariya Hidayat (ariya@kde.org) + Copyright (C) 2007 Ariya Hidayat (ariya@kde.org) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +#ifndef PICTUREFLOW_H +#define PICTUREFLOW_H + +#include + +class PictureFlowPrivate; + +/*! + Class PictureFlow implements an image show widget with animation effect + like Apple's CoverFlow (in iTunes and iPod). Images are arranged in form + of slides, one main slide is shown at the center with few slides on + the left and right sides of the center slide. When the next or previous + slide is brought to the front, the whole slides flow to the right or + the right with smooth animation effect; until the new slide is finally + placed at the center. + + */ +class PictureFlow : public QWidget +{ +Q_OBJECT + + Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor) + Q_PROPERTY(QSize slideSize READ slideSize WRITE setSlideSize) + Q_PROPERTY(int slideCount READ slideCount) + Q_PROPERTY(int centerIndex READ centerIndex WRITE setCenterIndex) + +public: + + enum ReflectionEffect + { + NoReflection, + PlainReflection, + BlurredReflection + }; + + enum FlowType + { + CoverFlowLike, + Strip, + StripOverlapped, + Modern, + Roulette, + Custom + }; + + /*! + Creates a new PictureFlow widget. + */ + PictureFlow(QWidget* parent = 0, FlowType flowType = CoverFlowLike); + + /*! + Destroys the widget. + */ + ~PictureFlow(); + + /*! + Returns the background color. + */ + QColor backgroundColor() const; + + /*! + Sets the background color. By default it is black. + */ + void setBackgroundColor(const QColor& c); + + /*! + Returns the dimension of each slide (in pixels). + */ + QSize slideSize() const; + + /*! + Sets the dimension of each slide (in pixels). + */ + void setSlideSize(QSize size); + + /*! + Returns the total number of slides. + */ + int slideCount() const; + + /*! + Returns QImage of specified slide. + */ + QImage slide(int index) const; + + /*! + Returns the index of slide currently shown in the middle of the viewport. + */ + int centerIndex() const; + + /*! + Returns the effect applied to the reflection. + */ + ReflectionEffect reflectionEffect() const; + + /*! + Sets the effect applied to the reflection. The default is PlainReflection. + */ + void setReflectionEffect(ReflectionEffect effect); + + +public slots: + + /*! + Adds a new slide. + */ + void addSlide(const QImage& image); + + /*! + Adds a new slide. + */ + void addSlide(const QPixmap& pixmap); + + /*! + Sets an image for specified slide. If the slide already exists, + it will be replaced. + */ + void setSlide(int index, const QImage& image); + + /*! + Sets a pixmap for specified slide. If the slide already exists, + it will be replaced. + */ + void setSlide(int index, const QPixmap& pixmap); + + /*! + Sets slide to be shown in the middle of the viewport. No animation + effect will be produced, unlike using showSlide. + */ + void setCenterIndex(int index); + + /*! + Clears all slides. + */ + void clear(); + + /*! + Shows previous slide using animation effect. + */ + void showPrevious(); + + /*! + Shows next slide using animation effect. + */ + void showNext(); + + /*! + Go to specified slide using animation effect. + */ + void showSlide(int index); + + /*! + Rerender the widget. Normally this function will be automatically invoked + whenever necessary, e.g. during the transition animation. + */ + void render(); + + /*! + Schedules a rendering update. Unlike render(), this function does not cause + immediate rendering. + */ + void triggerRender(); + + void setFlowType(FlowType flowType); + void setMarkImage(const QImage & mark); void markSlide(int index); @@ -200,25 +203,25 @@ public slots: QVector getMarks(); - -signals: - void centerIndexChanged(int index); - -public: - void paintEvent(QPaintEvent *event); - void keyPressEvent(QKeyEvent* event); - void mousePressEvent(QMouseEvent* event); - void resizeEvent(QResizeEvent* event); - -private slots: - void updateAnimation(); - -private: - PictureFlowPrivate* d; - QImage mark; - QVector marks; - int framesSkip; -}; - -#endif // PICTUREFLOW_H - + +signals: + void centerIndexChanged(int index); + +public: + void paintEvent(QPaintEvent *event); + void keyPressEvent(QKeyEvent* event); + void mousePressEvent(QMouseEvent* event); + void resizeEvent(QResizeEvent* event); + +private slots: + void updateAnimation(); + +private: + PictureFlowPrivate* d; + QImage mark; + QVector marks; + int framesSkip; +}; + +#endif // PICTUREFLOW_H + diff --git a/common/yacreader_flow_gl.cpp b/common/yacreader_flow_gl.cpp index a9d2feb9..0abe288a 100644 --- a/common/yacreader_flow_gl.cpp +++ b/common/yacreader_flow_gl.cpp @@ -25,7 +25,7 @@ struct Preset defaultYACReaderFlowConfig = { 0, //CF_X the X Position of the Coverflow 0, //CF_Y the Y Position of the Coverflow - -10, //CF_Z the Z Position of the Coverflow + -12, //CF_Z the Z Position of the Coverflow 15, //CF_RX the X Rotation of the Coverflow 0, //CF_RY the Y Rotation of the Coverflow @@ -35,7 +35,9 @@ struct Preset defaultYACReaderFlowConfig = { 0.18, //X_Distance sets the distance between the covers 1, //Center_Distance sets the distance between the centered and the non centered covers 0.1, //Z_Distance sets the pushback amount - 0.0 //Y_Distance sets the elevation amount + 0.0, //Y_Distance sets the elevation amount + + 30 //zoom level }; @@ -63,7 +65,9 @@ struct Preset presetYACReaderFlowClassicConfig = { 0.18, //X_Distance sets the distance between the covers 1, //Center_Distance sets the distance between the centered and the non centered covers 0.1, //Z_Distance sets the pushback amount - 0.0 //Y_Distance sets the elevation amount + 0.0, //Y_Distance sets the elevation amount + + 22 //zoom level }; @@ -91,7 +95,9 @@ struct Preset presetYACReaderFlowStripeConfig = { 1.1, //X_Distance sets the distance between the covers 0.2, //Center_Distance sets the distance between the centered and the non centered covers 0.01, //Z_Distance sets the pushback amount - 0.0 //Y_Distance sets the elevation amount + 0.0, //Y_Distance sets the elevation amount + + 22 //zoom level }; @@ -119,7 +125,9 @@ struct Preset presetYACReaderFlowOverlappedStripeConfig = { 0.18, //X_Distance sets the distance between the covers 1, //Center_Distance sets the distance between the centered and the non centered covers 0.1, //Z_Distance sets the pushback amount - 0.0 //Y_Distance sets the elevation amount + 0.0, //Y_Distance sets the elevation amount + + 22 //zoom level }; @@ -133,7 +141,7 @@ struct Preset pressetYACReaderFlowUpConfig = { 3, //View_rotate_light_strenght sets the light strenght on rotation 0.08, //View_rotate_add sets the speed of the rotation 0.08, //View_rotate_sub sets the speed of reversing the rotation - 30, //View_angle sets the maximum view angle + 5, //View_angle sets the maximum view angle 0, //CF_X the X Position of the Coverflow -0.2, //CF_Y the Y Position of the Coverflow @@ -147,7 +155,9 @@ struct Preset pressetYACReaderFlowUpConfig = { 0.18, //X_Distance sets the distance between the covers 1, //Center_Distance sets the distance between the centered and the non centered covers 0.1, //Z_Distance sets the pushback amount - -0.1 //Y_Distance sets the elevation amount + -0.1, //Y_Distance sets the elevation amount + + 22 //zoom level }; @@ -161,7 +171,7 @@ struct Preset pressetYACReaderFlowDownConfig = { 3, //View_rotate_light_strenght sets the light strenght on rotation 0.08, //View_rotate_add sets the speed of the rotation 0.08, //View_rotate_sub sets the speed of reversing the rotation - 30, //View_angle sets the maximum view angle + 5, //View_angle sets the maximum view angle 0, //CF_X the X Position of the Coverflow -0.2, //CF_Y the Y Position of the Coverflow @@ -175,11 +185,13 @@ struct Preset pressetYACReaderFlowDownConfig = { 0.18, //X_Distance sets the distance between the covers 1, //Center_Distance sets the distance between the centered and the non centered covers 0.1, //Z_Distance sets the pushback amount - 0.1 //Y_Distance sets the elevation amount + 0.1, //Y_Distance sets the elevation amount + + 22 //zoom level }; /*Constructor*/ YACReaderFlowGL::YACReaderFlowGL(QWidget *parent,struct Preset p) - :QGLWidget(QGLFormat(QGL::DoubleBuffer), parent),numObjects(0),lazyPopulateObjects(-1) + :QGLWidget(QGLFormat(QGL::SampleBuffers), parent),numObjects(0),lazyPopulateObjects(-1) { updateCount = 0; config = p; @@ -217,7 +229,6 @@ YACReaderFlowGL::YACReaderFlowGL(QWidget *parent,struct Preset p) loaderThread->start();*/ timerId = startTimer(16); - } void YACReaderFlowGL::timerEvent(QTimerEvent * event) @@ -257,19 +268,9 @@ void YACReaderFlowGL::initializeGL() defaultTexture = bindTexture(QImage(":/images/defaultCover.png"),GL_TEXTURE_2D,GL_RGBA,QGLContext::LinearFilteringBindOption | QGLContext::MipmapBindOption); markTexture = bindTexture(QImage(":/images/setRead.png"),GL_TEXTURE_2D,GL_RGBA,QGLContext::LinearFilteringBindOption | QGLContext::MipmapBindOption); + if(lazyPopulateObjects!=-1) populate(lazyPopulateObjects); //TODO esto es responsabilidad del usuario de la clase - - //float x = 0.5; - //int i; - //int n = 20; - //for(i = 0;iInsert("cover", cover, x, y); - //} - } void YACReaderFlowGL::paintGL() @@ -600,7 +601,8 @@ void YACReaderFlowGL::updatePositions() if(!viewRotateActive){ viewRotate += (0-viewRotate)*config.viewRotateSub; } - if(viewRotate < 0.2) + + if(abs (cfImages[currentSelected].current.x - cfImages[currentSelected].animEnd.x) < 1)//viewRotate < 0.2) { if(updateCount >= 0) //TODO parametrizar { @@ -677,6 +679,7 @@ void YACReaderFlowGL::replace(char *name, GLuint Tex, float x, float y,int item) void YACReaderFlowGL::populate(int n) { + emit centerIndexChanged(0); float x = 1; float y = 1 * (700/480.0); int i; @@ -696,13 +699,14 @@ void YACReaderFlowGL::populate(int n) loaded = QVector(n,false); marks = QVector(n,false); - emit centerIndexChanged(0); + //worker->start(); } void YACReaderFlowGL::reset() { + currentSelected = 0; loaded.clear(); for(int i = 0;i0) delete[] cfImages; numObjects = 0; - currentSelected = 0; + } //slots @@ -771,16 +775,54 @@ void YACReaderFlowGL::setCF_Y(int value) config.cfY = value/100.0; } +void YACReaderFlowGL::setCF_Z(int value) +{ + config.cfZ = value; +} + void YACReaderFlowGL::setY_Distance(int value) { config.yDistance = value / 100.0; } +void YACReaderFlowGL::setFadeOutDist(int value) +{ + config.animationFadeOutDist = value; +} + +void YACReaderFlowGL::setLightStrenght(int value) +{ + config.viewRotateLightStrenght = value; +} + +void YACReaderFlowGL::setMaxAngle(int value) +{ + config.viewAngle = value; +} + void YACReaderFlowGL::setPreset(const Preset & p) { config = p; } +void YACReaderFlowGL::setPerformance(Performance performance) +{ + this->performance = performance; + + //if(performance = ultraHigh) + //{ + // QGLFormat f = format(); + // f.setSwapInterval(1); + // setFormat(f); + //} + //else + //{ + // QGLFormat f = format(); + // f.setSwapInterval(0); + // setFormat(f); + //} +} + void YACReaderFlowGL::setShowMarks(bool value) { showMarks = value; @@ -954,7 +996,11 @@ void YACReaderComicFlowGL::updateImageData() { float x = 1; QImage img = worker->result(); - GLuint cover = bindTexture(img, GL_TEXTURE_2D,GL_RGB,QGLContext::LinearFilteringBindOption); + GLuint cover; + if(performance == high || performance == ultraHigh) + cover = bindTexture(img, GL_TEXTURE_2D,GL_RGB,QGLContext::LinearFilteringBindOption | QGLContext::MipmapBindOption); + else + cover = bindTexture(img, GL_TEXTURE_2D,GL_RGB,QGLContext::LinearFilteringBindOption); float y = 1 * (float(img.height())/img.width()); replace("cover", cover, x, y,idx); /*CFImages[idx].width = x; @@ -968,16 +1014,31 @@ void YACReaderComicFlowGL::updateImageData() // try to load only few images on the left and right side // i.e. all visible ones plus some extra -#define COUNT 8 - int indexes[2*COUNT+1]; + int count=8; + switch(performance) + { + case low: + count = 8; + break; + case medium: + count = 10; + break; + case high: + count = 12; + break; + case ultraHigh: + count = 14; + break; + } + int * indexes = new int[2*count+1]; int center = currentSelected; indexes[0] = center; - for(int j = 0; j < COUNT; j++) + for(int j = 0; j < count; j++) { indexes[j*2+1] = center+j+1; indexes[j*2+2] = center-j-1; } - for(int c = 0; c < 2*COUNT+1; c++) + for(int c = 0; c < 2*count+1; c++) { int i = indexes[c]; if((i >= 0) && (i < numObjects)) @@ -993,6 +1054,7 @@ void YACReaderComicFlowGL::updateImageData() worker->generate(i, fname); } + delete[] indexes; return; } } @@ -1026,7 +1088,11 @@ void YACReaderPageFlowGL::updateImageData() { float x = 1; QImage img = worker->result(); - GLuint cover = bindTexture(img, GL_TEXTURE_2D,GL_RGB,QGLContext::LinearFilteringBindOption | QGLContext::MipmapBindOption); + GLuint cover; + if(performance == high || performance == ultraHigh) + cover = bindTexture(img, GL_TEXTURE_2D,GL_RGB,QGLContext::LinearFilteringBindOption | QGLContext::MipmapBindOption); + else + cover = bindTexture(img, GL_TEXTURE_2D,GL_RGB,QGLContext::LinearFilteringBindOption); float y = 1 * (float(img.height())/img.width()); replace("cover", cover, x, y,idx); /*CFImages[idx].width = x; @@ -1040,16 +1106,31 @@ void YACReaderPageFlowGL::updateImageData() // try to load only few images on the left and right side // i.e. all visible ones plus some extra -#define COUNT 8 - int indexes[2*COUNT+1]; + int count=8; + switch(performance) + { + case low: + count = 8; + break; + case medium: + count = 10; + break; + case high: + count = 12; + break; + case ultraHigh: + count = 14; + break; + } + int * indexes = new int[2*count+1]; int center = currentSelected; indexes[0] = center; - for(int j = 0; j < COUNT; j++) + for(int j = 0; j < count; j++) { indexes[j*2+1] = center+j+1; indexes[j*2+2] = center-j-1; } - for(int c = 0; c < 2*COUNT+1; c++) + for(int c = 0; c < 2*count+1; c++) { int i = indexes[c]; if((i >= 0) && (i < numObjects)) @@ -1065,6 +1146,7 @@ void YACReaderPageFlowGL::updateImageData() worker->generate(i, rawImages.at(i)); + delete[] indexes; return; } } @@ -1096,8 +1178,19 @@ QImage ImageLoaderGL::loadImage(const QString& fileName) //resultTexture = flow->bindTexture(image,GL_TEXTURE_2D); //TODO parametrizar - image = image.scaledToWidth(256,Qt::SmoothTransformation); - + switch(flow->performance) + { + case low: + image = image.scaledToWidth(200,Qt::SmoothTransformation); + break; + case medium: + image = image.scaledToWidth(256,Qt::SmoothTransformation); + break; + case high: + image = image.scaledToWidth(320,Qt::SmoothTransformation); + break; + + } if(!result) return QImage(); diff --git a/common/yacreader_flow_gl.h b/common/yacreader_flow_gl.h index 7fa5dd3a..e00cccf9 100644 --- a/common/yacreader_flow_gl.h +++ b/common/yacreader_flow_gl.h @@ -18,6 +18,14 @@ class QGLContext; class WidgetLoader; class ImageLoaderByteArrayGL; +typedef enum Performance +{ + low=0, + medium, + high, + ultraHigh +}; + //Cover Vector typedef struct RVect{ float x; @@ -84,6 +92,8 @@ struct Preset{ float zDistance; //sets the elevation amount float yDistance; + + float zoom; }; extern struct Preset defaultYACReaderFlowConfig; @@ -118,9 +128,7 @@ protected: void initializeGL(); void paintGL(); void timerEvent(QTimerEvent *); - -public: //number of Covers int numObjects; int lazyPopulateObjects; @@ -130,6 +138,8 @@ public: QList paths; CFImage * cfImages; + Performance performance; + /*** Animation Settings ***/ Preset config; @@ -150,9 +160,12 @@ public: /*** System info ***/ float viewRotate; + +public: + /*Constructor*/ - YACReaderFlowGL(QWidget *parent = 0,struct Preset p = defaultYACReaderFlowConfig); + YACReaderFlowGL(QWidget *parent = 0,struct Preset p = pressetYACReaderFlowDownConfig); ~YACReaderFlowGL(); //size; @@ -207,11 +220,22 @@ public: void setZ_Distance(int distance); void setCF_Y(int value); + void setCF_Z(int value); void setY_Distance(int value); + void setFadeOutDist(int value); + + void setLightStrenght(int value); + + void setMaxAngle(int value); + void setPreset(const Preset & p); + void setPerformance(Performance performance); + + + virtual void updateImageData() = 0; void reset(); @@ -237,6 +261,8 @@ public: void wheelEvent(QWheelEvent * event); void keyPressEvent(QKeyEvent *event); void resizeGL(int width, int height); + friend class ImageLoaderGL; + friend class ImageLoaderByteArrayGL; signals: void centerIndexChanged(int); @@ -260,7 +286,7 @@ public: YACReaderComicFlowGL(QWidget *parent = 0,struct Preset p = defaultYACReaderFlowConfig); void setImagePaths(QStringList paths); void updateImageData(); - + friend class ImageLoaderGL; private: ImageLoaderGL * worker; @@ -275,6 +301,7 @@ public: QVector imagesReady; QVector rawImages; QVector imagesSetted; + friend class ImageLoaderByteArrayGL; private: ImageLoaderByteArrayGL * worker; }; diff --git a/images/iphoneConfig.png b/images/iphoneConfig.png new file mode 100644 index 00000000..c5b4797c Binary files /dev/null and b/images/iphoneConfig.png differ diff --git a/images/qrMessage.png b/images/qrMessage.png new file mode 100644 index 00000000..0a3a4f13 Binary files /dev/null and b/images/qrMessage.png differ diff --git a/images/server.png b/images/server.png new file mode 100644 index 00000000..bbc11134 Binary files /dev/null and b/images/server.png differ