diff --git a/YACReader/YACReader.pro b/YACReader/YACReader.pro index d63cc501..b48c3508 100644 --- a/YACReader/YACReader.pro +++ b/YACReader/YACReader.pro @@ -6,7 +6,8 @@ TARGET = DEPENDPATH += . \ release INCLUDEPATH += . -INCLUDEPATH += ../common +INCLUDEPATH += ../common \ + ../custom_widgets win32 { INCLUDEPATH += ../dependencies/poppler/include @@ -88,7 +89,9 @@ SOURCES += comic.cpp \ ../common/qnaturalsorting.cpp \ ../common/yacreader_flow_gl.cpp \ ../common/onstart_flow_selection_dialog.cpp - + +include(../custom_widgets/custom_widgets.pri) + RESOURCES += images.qrc \ files.qrc RC_FILE = icon.rc diff --git a/YACReader/goto_flow.cpp b/YACReader/goto_flow.cpp index 24c7513d..2ffb9abd 100644 --- a/YACReader/goto_flow.cpp +++ b/YACReader/goto_flow.cpp @@ -1,7 +1,6 @@ #include "goto_flow.h" #include "configuration.h" #include "comic.h" -#include "custom_widgets.h" #include #include @@ -11,6 +10,19 @@ #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "yacreader_flow.h" + #include "goto_flow_toolbar.h" #include "goto_flow_decorationbar.h" diff --git a/YACReader/goto_flow.h b/YACReader/goto_flow.h index 0b48b824..7fb101b2 100644 --- a/YACReader/goto_flow.h +++ b/YACReader/goto_flow.h @@ -1,22 +1,27 @@ #ifndef __GOTO_FLOW_H #define __GOTO_FLOW_H -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "custom_widgets.h" #include "goto_flow_widget.h" -class Comic; +#include +#include + +class QLineEdit; +class QPushButton; +class QPixmap; +class QThread; +class QSize; +class QIntValidator; +class QWaitCondition; +class QEvent; +class QLabel; + + +class Comic; class SlideInitializer; class PageLoader; +class YACReaderFlow; +class PictureFlow; class GoToFlow : public GoToFlowWidget { @@ -71,6 +76,7 @@ private: //----------------------------------------------------------------------------- //PageLoader //----------------------------------------------------------------------------- + class PageLoader : public QThread { public: diff --git a/YACReader/main_window_viewer.cpp b/YACReader/main_window_viewer.cpp index be160bcc..7e50a73b 100644 --- a/YACReader/main_window_viewer.cpp +++ b/YACReader/main_window_viewer.cpp @@ -10,6 +10,8 @@ #include "shortcuts_dialog.h" #include "width_slider.h" #include "qnaturalsorting.h" +#include "help_about_dialog.h" +#include "yacreader_tool_bar_stretch.h" #include #include diff --git a/YACReader/options_dialog.cpp b/YACReader/options_dialog.cpp index 2969ba1e..086bdbc6 100644 --- a/YACReader/options_dialog.cpp +++ b/YACReader/options_dialog.cpp @@ -6,7 +6,15 @@ #include #include #include +#include +#include +#include +#include +#include +#include "yacreader_spin_slider_widget.h" +#include "yacreader_flow_config_widget.h" +#include "yacreader_gl_flow_config_widget.h" OptionsDialog::OptionsDialog(QWidget * parent) :YACReaderOptionsDialog(parent) diff --git a/YACReader/options_dialog.h b/YACReader/options_dialog.h index 395be78c..e0f504dd 100644 --- a/YACReader/options_dialog.h +++ b/YACReader/options_dialog.h @@ -1,16 +1,18 @@ #ifndef __OPTIONS_DIALOG_H #define __OPTIONS_DIALOG_H -#include -#include -#include -#include -#include -#include -#include -#include +#include "yacreader_options_dialog.h" + +class QDialog; +class QLabel; +class QLineEdit; +class QPushButton; +class QSlider; +class QPushButton; +class QRadioButton; +class QColorDialog; +class YACReaderSpinSliderWidget; -#include "custom_widgets.h" class OptionsDialog : public YACReaderOptionsDialog { diff --git a/YACReaderLibrary/YACReaderLibrary.pro b/YACReaderLibrary/YACReaderLibrary.pro index ad0040f5..9a9ba5e6 100644 --- a/YACReaderLibrary/YACReaderLibrary.pro +++ b/YACReaderLibrary/YACReaderLibrary.pro @@ -9,7 +9,8 @@ INCLUDEPATH += . INCLUDEPATH += ../common \ ./server \ ./db \ - ../YACReader + ../YACReader \ + ../custom_widgets DEFINES += SERVER_RELEASE @@ -37,8 +38,6 @@ CONFIG += release CONFIG -= flat QT += sql network opengl - - # Input HEADERS += comic_flow.h \ create_library_dialog.h \ @@ -73,8 +72,8 @@ HEADERS += comic_flow.h \ ../common/yacreader_flow_gl.h \ ../common/yacreader_global.h \ ../common/onstart_flow_selection_dialog.h \ - no_libraries_widget.h \ - import_widget.h + no_libraries_widget.h \ + import_widget.h SOURCES += comic_flow.cpp \ create_library_dialog.cpp \ @@ -109,11 +108,12 @@ SOURCES += comic_flow.cpp \ ../common/qnaturalsorting.cpp \ ../common/yacreader_flow_gl.cpp \ ../common/onstart_flow_selection_dialog.cpp \ - no_libraries_widget.cpp \ - import_widget.cpp + no_libraries_widget.cpp \ + import_widget.cpp \ + include(./server/server.pri) - +include(../custom_widgets/custom_widgets.pri) RESOURCES += images.qrc files.qrc RC_FILE = icon.rc diff --git a/YACReaderLibrary/comic_flow.cpp b/YACReaderLibrary/comic_flow.cpp index f1f9f4f6..7c013a7e 100644 --- a/YACReaderLibrary/comic_flow.cpp +++ b/YACReaderLibrary/comic_flow.cpp @@ -1,9 +1,13 @@ #include "comic_flow.h" #include "qnaturalsorting.h" +#include "yacreader_global.h" + +#include + #include #include -#include +#include ComicFlow::ComicFlow(QWidget* parent,FlowType flowType) :YACReaderFlow(parent,flowType) diff --git a/YACReaderLibrary/comic_flow.h b/YACReaderLibrary/comic_flow.h index e4448de2..6332af38 100644 --- a/YACReaderLibrary/comic_flow.h +++ b/YACReaderLibrary/comic_flow.h @@ -1,7 +1,8 @@ #ifndef __COMICFLOW_H #define __COMICFLOW_H -#include "custom_widgets.h" +#include "yacreader_flow.h" + #include #include #include diff --git a/YACReaderLibrary/db/tableitem.h b/YACReaderLibrary/db/tableitem.h index 3911889f..a25616ac 100644 --- a/YACReaderLibrary/db/tableitem.h +++ b/YACReaderLibrary/db/tableitem.h @@ -3,7 +3,6 @@ #include #include -#include "comic_db.h" //! [0] class TableItem diff --git a/YACReaderLibrary/db/tablemodel.cpp b/YACReaderLibrary/db/tablemodel.cpp index 8b055a7c..d651235d 100644 --- a/YACReaderLibrary/db/tablemodel.cpp +++ b/YACReaderLibrary/db/tablemodel.cpp @@ -6,6 +6,7 @@ #include "tablemodel.h" #include "data_base_management.h" #include "qnaturalsorting.h" +#include "comic_db.h" //ci.number,ci.title,c.fileName,ci.numPages,c.id,c.parentId,c.path,ci.hash,ci.read #define NUMBER 0 diff --git a/YACReaderLibrary/db/tablemodel.h b/YACReaderLibrary/db/tablemodel.h index da29c83a..5cff3f11 100644 --- a/YACReaderLibrary/db/tablemodel.h +++ b/YACReaderLibrary/db/tablemodel.h @@ -7,7 +7,7 @@ #include #include -#include "comic_db.h" +class ComicDB; class TableItem; diff --git a/YACReaderLibrary/db_helper.h b/YACReaderLibrary/db_helper.h index e248d1b6..9d1520ca 100644 --- a/YACReaderLibrary/db_helper.h +++ b/YACReaderLibrary/db_helper.h @@ -3,7 +3,7 @@ class QString; class LibraryItem; -class ComicDB; +#include "comic_db.h" #include #include diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index 8394f7cc..e47ded10 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -14,6 +14,8 @@ #include #include #include +#include +#include #include #include @@ -24,6 +26,26 @@ #include "no_libraries_widget.h" #include "import_widget.h" +#include "yacreader_search_line_edit.h" +#include "comic_db.h" +#include "library_creator.h" +#include "package_manager.h" +#include "comic_flow_widget.h" +#include "create_library_dialog.h" +#include "rename_library_dialog.h" +#include "properties_dialog.h" +#include "export_library_dialog.h" +#include "import_library_dialog.h" +#include "export_comics_info_dialog.h" +#include "import_comics_info_dialog.h" +#include "add_library_dialog.h" +#include "options_dialog.h" +#include "help_about_dialog.h" +#include "server_config_dialog.h" +#include "tablemodel.h" +#include "yacreader_tool_bar_stretch.h" + + // LibraryWindow::LibraryWindow() @@ -181,7 +203,7 @@ void LibraryWindow::doLayout() QVBoxLayout * searchLayout = new QVBoxLayout; QHBoxLayout * filter = new QHBoxLayout; - filter->addWidget(foldersFilter = new YACReaderLineEdit()); + filter->addWidget(foldersFilter = new YACReaderSearchLineEdit()); foldersFilter->setPlaceholderText(tr("Search folders and comics")); previousFilter = ""; //filter->addWidget(clearFoldersFilter = new QPushButton(tr("Clear"))); diff --git a/YACReaderLibrary/library_window.h b/YACReaderLibrary/library_window.h index 5a4bfe1a..a60f5344 100644 --- a/YACReaderLibrary/library_window.h +++ b/YACReaderLibrary/library_window.h @@ -2,38 +2,49 @@ #define __LIBRARYWINDOW_H #include -#include -#include +#include #include -#include -#include -#include -#include -#include -#include -#include +#include -//TODO cambiar por class XXXXX -#include "create_library_dialog.h" -#include "add_library_dialog.h" -#include "library_creator.h" -//#include "comic_flow.h" -#include "comic_flow_widget.h" -#include "custom_widgets.h" -#include "rename_library_dialog.h" -#include "properties_dialog.h" -#include "options_dialog.h" -#include "export_comics_info_dialog.h" -#include "import_comics_info_dialog.h" -#include "export_library_dialog.h" -#include "import_library_dialog.h" -#include "package_manager.h" -#include "treemodel.h" -#include "tablemodel.h" -#include "treeitem.h" -#include "server_config_dialog.h" -#include "no_libraries_widget.h" -#include "import_widget.h" +class QTableView; +class QTreeView; +class QDirModel; +class QAction; +class QToolBar; +class QComboBox; +class QThread; +class QStackedWidget; +class YACReaderSearchLineEdit; +class CreateLibraryDialog; +class UpdateLibraryDialog; +class ExportLibraryDialog; +class ImportLibraryDialog; +class ExportComicsInfoDialog; +class ImportComicsInfoDialog; +class AddLibraryDialog; +class LibraryCreator; +class HelpAboutDialog; +class RenameLibraryDialog; +class PropertiesDialog; +class PackageManager; +class ComicFlowWidget; +class QCheckBox; +class QPushButton; +class TableModel; +class QSplitter; +class TreeItem; +class TreeModel; +class QItemSelectionModel; +class QString; +class QLabel; +class NoLibrariesWidget; +class OptionsDialog; +class ServerConfigDialog; +class QCloseEvent; +class ImportWidget; +class QSettings; +class LibraryItem; +#include "comic_db.h" class LibraryWindow : public QMainWindow { @@ -64,7 +75,7 @@ private: QSize slideSizeW; QSize slideSizeF; //search filter - YACReaderLineEdit * foldersFilter; + YACReaderSearchLineEdit * foldersFilter; TreeItem * index; //index al que hay que hacer scroll después de pulsar sobre un folder filtrado int column; QString previousFilter; @@ -81,7 +92,6 @@ private: //QStringList paths; QMap libraries; QLabel * fullScreenToolTip; - YACReaderIconProvider fip; QStackedWidget * mainWidget; NoLibrariesWidget * noLibrariesWidget; diff --git a/YACReaderLibrary/main.cpp b/YACReaderLibrary/main.cpp index 9767c070..fc39c24f 100644 --- a/YACReaderLibrary/main.cpp +++ b/YACReaderLibrary/main.cpp @@ -1,6 +1,11 @@ #include "library_window.h" #include +#include +#include +#include + +#include "yacreader_global.h" #include "startup.h" #define PICTUREFLOW_QT4 1 diff --git a/YACReaderLibrary/options_dialog.cpp b/YACReaderLibrary/options_dialog.cpp index 05571f62..328b0e0d 100644 --- a/YACReaderLibrary/options_dialog.cpp +++ b/YACReaderLibrary/options_dialog.cpp @@ -1,4 +1,9 @@ #include "options_dialog.h" + +#include "yacreader_flow_gl.h" +#include "yacreader_flow_config_widget.h" +#include "yacreader_gl_flow_config_widget.h" + #include #include #include @@ -10,9 +15,6 @@ #include #include -#include "custom_widgets.h" -#include "yacreader_flow_gl.h" - FlowType flowType = Strip; OptionsDialog::OptionsDialog(QWidget * parent) diff --git a/YACReaderLibrary/options_dialog.h b/YACReaderLibrary/options_dialog.h index 1eca3db2..85e9305d 100644 --- a/YACReaderLibrary/options_dialog.h +++ b/YACReaderLibrary/options_dialog.h @@ -1,18 +1,9 @@ #ifndef __OPTIONS_DIALOG_H #define __OPTIONS_DIALOG_H -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "pictureflow.h" +#include "yacreader_options_dialog.h" -#include "custom_widgets.h" +#include "yacreader_global.h" extern FlowType flowType; diff --git a/YACReaderLibrary/properties_dialog.cpp b/YACReaderLibrary/properties_dialog.cpp index d89cecee..470a709f 100644 --- a/YACReaderLibrary/properties_dialog.cpp +++ b/YACReaderLibrary/properties_dialog.cpp @@ -1,4 +1,10 @@ #include "properties_dialog.h" + +#include "data_base_management.h" +#include "library_creator.h" +#include "yacreader_field_edit.h" +#include "yacreader_field_plain_text_edit.h" + #include #include #include @@ -8,9 +14,6 @@ #include #include -#include "data_base_management.h" -#include "library_creator.h" - PropertiesDialog::PropertiesDialog(QWidget * parent) :QDialog(parent) { diff --git a/YACReaderLibrary/properties_dialog.h b/YACReaderLibrary/properties_dialog.h index 1952223f..d0e76f4c 100644 --- a/YACReaderLibrary/properties_dialog.h +++ b/YACReaderLibrary/properties_dialog.h @@ -2,18 +2,20 @@ #define __PROPERTIES_DIALOG_H #include -#include -#include -#include -#include -#include -#include -#include -#include + #include +class QGridLayout; +class QTabWidget; +class QGroupBox; +class QLabel; +class QScrollArea; +class QWidget; +class YACReaderFieldEdit; +class YACReaderFieldPlainTextEdit; +class QDialogButtonBox; +class QCheckBox; #include "comic_db.h" -#include "custom_widgets.h" class PropertiesDialog : public QDialog { diff --git a/common/custom_widgets.cpp b/common/custom_widgets.cpp index 7906f63f..b5b96cfb 100644 --- a/common/custom_widgets.cpp +++ b/common/custom_widgets.cpp @@ -1,92 +1,8 @@ #include "custom_widgets.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include -#include "qnaturalsorting.h" - - - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -HelpAboutDialog::HelpAboutDialog(QWidget * parent) -:QDialog(parent) -{ - QVBoxLayout * layout = new QVBoxLayout(); - - tabWidget = new QTabWidget(); - - tabWidget->addTab(aboutText = new QTextBrowser(), tr("About")); - aboutText->setOpenExternalLinks(true); - aboutText->setFont(QFont("Comic Sans MS", 10)); //purisa - tabWidget->addTab(helpText = new QTextBrowser(), tr("Help")); - helpText->setOpenExternalLinks(true); - helpText->setFont(QFont("Comic Sans MS", 10)); - //helpText->setDisabled(true); - //tabWidget->addTab(,"About Qt"); - - layout->addWidget(tabWidget); - layout->setContentsMargins(1,3,1,1); - - setLayout(layout); - resize(500, QApplication::desktop()->availableGeometry().height()*0.83); -} - -HelpAboutDialog::HelpAboutDialog(const QString & pathAbout,const QString & pathHelp,QWidget * parent) -:QDialog(parent) -{ - loadAboutInformation(pathAbout); - loadHelp(pathHelp); -} - -void HelpAboutDialog::loadAboutInformation(const QString & path) -{ - aboutText->insertHtml(fileToString(path)); - aboutText->moveCursor(QTextCursor::Start); -} - -void HelpAboutDialog::loadHelp(const QString & path) -{ - helpText->insertHtml(fileToString(path)); - helpText->moveCursor(QTextCursor::Start); -} - -QString HelpAboutDialog::fileToString(const QString & path) -{ - QFile f(path); - f.open(QIODevice::ReadOnly); - QTextStream txtS(&f); - - txtS.setCodec(QTextCodec::codecForName("UTF-8")); - - QString content = txtS.readAll(); - f.close(); - - return content; -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// void delTree(QDir dir) { dir.setFilter(QDir::AllDirs|QDir::Files|QDir::Hidden|QDir::NoDotAndDotDot); @@ -106,1190 +22,3 @@ void delTree(QDir dir) } } } - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -YACReaderIconProvider::YACReaderIconProvider() -:QFileIconProvider() -{ -} - -QIcon YACReaderIconProvider::icon(IconType type) const -{ - switch(type) - { - case Folder: - return QIcon(":/images/folder.png"); - break; - case File: - return QIcon(":/images/icon.png"); - break; - default: - return QFileIconProvider::icon(type); - } -} -QIcon YACReaderIconProvider::icon(const QFileInfo & info) const -{ - if(info.isDir()) - return QIcon(":/images/folder.png"); - if(info.isFile()) - return QIcon(":/images/icon.png"); - - return QFileIconProvider::icon(info); -} -QString YACReaderIconProvider::type(const QFileInfo & info) const -{ - return QFileIconProvider::type(info); -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -YACReaderFlow::YACReaderFlow(QWidget * parent,FlowType flowType) : PictureFlow(parent,flowType) {} - -void YACReaderFlow::mousePressEvent(QMouseEvent* event) -{ - if(event->x() > (width()+slideSize().width())/2) - showNext(); - else - if(event->x() < (width()-slideSize().width())/2) - showPrevious(); - //else (centered cover space) -} - -void YACReaderFlow::mouseDoubleClickEvent(QMouseEvent* event) -{ - if((event->x() > (width()-slideSize().width())/2)&&(event->x() < (width()+slideSize().width())/2)) - emit selected(centerIndex()); -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -YACReaderComicDirModel::YACReaderComicDirModel( const QStringList & nameFilters, QDir::Filters filters, QDir::SortFlags sort, QObject * parent ) -:QDirModel(nameFilters,filters,sort,parent) -{ - -} - -//this method isn't used to show fileName on QListView -QString YACReaderComicDirModel::fileName ( const QModelIndex & index ) const -{ - QString fileName = QDirModel::fileName(index); - return fileName.remove(fileName.size()-4,4); -} - -QFileInfo YACReaderComicDirModel::fileInfo ( const QModelIndex & index ) const -{ - QFileInfo fileInfo = QDirModel::fileInfo(index); - QString path = QDir::cleanPath(filePath(index)).remove("/.yacreaderlibrary"); - path.remove(path.size()-4,4); - fileInfo.setFile(path); - return fileInfo; -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -YACReaderComicViewDelegate::YACReaderComicViewDelegate(QObject * parent) -:QItemDelegate(parent) -{ -} - -void YACReaderComicViewDelegate::paint ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const -{ - QStyleOptionViewItemV4 opt = setOptions(index, option); - - const QStyleOptionViewItemV2 *v2 = qstyleoption_cast(&option); - opt.features = v2 ? v2->features - : QStyleOptionViewItemV2::ViewItemFeatures(QStyleOptionViewItemV2::None); - const QStyleOptionViewItemV3 *v3 = qstyleoption_cast(&option); - opt.locale = v3 ? v3->locale : QLocale(); - opt.widget = v3 ? v3->widget : 0; - - // prepare - painter->save(); - painter->setClipRect(opt.rect); - - // get the data and the rectangles - - QVariant value; - - QPixmap pixmap; - QRect decorationRect; - QIcon icon; - value = index.data(Qt::DecorationRole); - if (value.isValid()) { - // ### we need the pixmap to call the virtual function - pixmap = decoration(opt, value); - if (value.type() == QVariant::Icon) { - icon = qvariant_cast(value); - const QSize size = icon.actualSize(option.decorationSize); - decorationRect = QRect(QPoint(0, 0), size); - } else { - icon = QIcon(); - decorationRect = QRect(QPoint(0, 0), pixmap.size()); - } - } else { - icon = QIcon(); - decorationRect = QRect(); - } - - QString text; - QRect displayRect; - value = index.data(Qt::DisplayRole); - if (value.isValid() && !value.isNull()) { - text = value.toString(); - text.remove(text.size()-4,4); - displayRect = textRectangle(painter, textLayoutBounds(opt), opt.font, text); - } - - QRect checkRect; - Qt::CheckState checkState = Qt::Unchecked; - value = index.data(Qt::CheckStateRole); - if (value.isValid()) { - checkState = static_cast(value.toInt()); - checkRect = check(opt, opt.rect, value); - } - - // do the layout - - doLayout(opt, &checkRect, &decorationRect, &displayRect, false); - - // draw the item - - drawBackground(painter, opt, index); - drawCheck(painter, opt, checkRect, checkState); - drawDecoration(painter, opt, decorationRect, pixmap); - drawDisplay(painter, opt, displayRect, text); - drawFocus(painter, opt, displayRect); - - // done - painter->restore(); -} - -QRect YACReaderComicViewDelegate::textLayoutBounds(const QStyleOptionViewItemV2 &option) const -{ - QRect rect = option.rect; - const bool wrapText = option.features & QStyleOptionViewItemV2::WrapText; - switch (option.decorationPosition) { - case QStyleOptionViewItem::Left: - case QStyleOptionViewItem::Right: - rect.setWidth(wrapText && rect.isValid() ? rect.width() : (1000)); - break; - case QStyleOptionViewItem::Top: - case QStyleOptionViewItem::Bottom: - rect.setWidth(wrapText ? option.decorationSize.width() : (1000)); - break; - } - - return rect; -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -YACReaderTreeSearch::YACReaderTreeSearch(QObject * parent) -:QSortFilterProxyModel(parent),cache(new ModelIndexCache()) -{ - this->setFilterCaseSensitivity(Qt::CaseInsensitive); -} - -bool YACReaderTreeSearch::containsFiles(QString path,const QRegExp &exp) const -{ - QDir dir(path); - QStringList list = dir.entryList(QStringList() << "*"+exp.pattern()+"*",QDir::Files | QDir::NoDotAndDotDot); - return list.size()>0; -} - -bool YACReaderTreeSearch::itemMatchesExpression(const QModelIndex &index, const QRegExp &exp) const -{ - - QString name = ((QFileSystemModel *)sourceModel())->filePath(index); - ModelIndexCache::CacheData cd = cache->getCacheData(name); - bool v = false; - if(!cd.visited || cd.acepted) - { - v = name.contains(exp);// || containsFiles(name,exp); // TODO : complete path? - int numChildren = sourceModel()->rowCount(index); - for(int i=0; iindex(i,0,index), exp); - } - cd.visited = true; - cd.acepted = v; - cache->setModelIndex(name,cd); - } - - return cd.acepted; -} - -bool YACReaderTreeSearch::filterAcceptsRow ( int sourceRow, const QModelIndex & sourceParent ) const -{ - QString name = sourceModel()->data(sourceModel()->index(sourceRow, 0, sourceParent),Qt::DisplayRole ).toString(); - QFileSystemModel * dm = (QFileSystemModel *)sourceModel(); - if(!dm->isDir(dm->index(sourceRow, 0, sourceParent))) - //if(name.endsWith(".jpg")||name.endsWith(".db")) //TODO: if is not a dir - return false; - if(filterRegExp().isEmpty()) - return true; - if(name.contains("yacreader")) - return true; - QString path = dm->filePath(dm->index(sourceRow, 0, sourceParent)); - if(path.contains("yacreaderlibrary")) - return itemMatchesExpression(sourceModel()->index(sourceRow, 0, sourceParent), filterRegExp()); - else - return true; -} - -void YACReaderTreeSearch::reset() -{ - //invalidateFilter(); - cache->clear(); -} - -void YACReaderTreeSearch::softReset() -{ - //invalidateFilter(); -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -ModelIndexCache::ModelIndexCache() -:cache() -{ -} - -void ModelIndexCache::setModelIndex(const QString & index, const CacheData & cd) -{ - cache.insert(index,cd); -} -ModelIndexCache::CacheData ModelIndexCache::getCacheData(const QString & index) const -{ - if(cache.contains(index)) - return cache.value(index); - else - { - CacheData cd; - cd.visited = false; - cd.acepted = true; - return cd; - } -} - -void ModelIndexCache::clear() -{ - cache.clear(); -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -YACReaderSortComics::YACReaderSortComics(QObject * parent) -:QSortFilterProxyModel(parent) -{ - -} - -bool YACReaderSortComics::lessThan(const QModelIndex &left, const QModelIndex &right) const -{ - QVariant leftData = sourceModel()->data(left); - QVariant rightData = sourceModel()->data(right); - - QString leftString = leftData.toString(); - QString rightString = rightData.toString(); - - return naturalSortLessThanCI(leftString,rightString); -} - - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -YACReaderFieldEdit::YACReaderFieldEdit(QWidget * parent) - :QLineEdit(parent) -{ - setPlaceholderText(tr("Click to overwrite")); - setModified(false); - restore = new QAction(tr("Restore to default"),this); - this->addAction(restore); - //this->setContextMenuPolicy(Qt::ActionsContextMenu); -} - -void YACReaderFieldEdit::focusInEvent(QFocusEvent* e) -{ - if (e->reason() == Qt::MouseFocusReason) - { - setModified(true); - setPlaceholderText(""); - } - - QLineEdit::focusInEvent(e); -} - -void YACReaderFieldEdit::clear() -{ - setPlaceholderText(tr("Click to overwrite")); - QLineEdit::clear(); - QLineEdit::setModified(false); -} - -void YACReaderFieldEdit::setDisabled(bool disabled) -{ - if(disabled) - setPlaceholderText(""); - QLineEdit::setDisabled(disabled); -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -YACReaderFieldPlainTextEdit::YACReaderFieldPlainTextEdit(QWidget * parent) - :QPlainTextEdit(parent) -{ - document()->setModified(false); - setPlainText(tr("Click to overwrite")); - restore = new QAction(tr("Restore to default"),this); - this->addAction(restore); - //this->setContextMenuPolicy(Qt::ActionsContextMenu); -} - -void YACReaderFieldPlainTextEdit::focusInEvent(QFocusEvent* e) -{ - if (e->reason() == Qt::MouseFocusReason || e->reason() == Qt::TabFocusReason) - { - document()->setModified(true); - if(toPlainText()==tr("Click to overwrite")) - setPlainText(""); - } - - QPlainTextEdit::focusInEvent(e); -} - -void YACReaderFieldPlainTextEdit::focusOutEvent(QFocusEvent* e) -{ - /*if (e->reason() == Qt::MouseFocusReason || e->reason() == Qt::TabFocusReason) - { - if(toPlainText().isEmpty()) - { - setPlainText(tr("Click to overwrite")); - document()->setModified(false); - } - } - */ - QPlainTextEdit::focusOutEvent(e); -} - -void YACReaderFieldPlainTextEdit::clear() -{ - QPlainTextEdit::clear(); - document()->setModified(false); - setPlainText(tr("Click to overwrite")); -} - -void YACReaderFieldPlainTextEdit::setDisabled(bool disabled) -{ - if(disabled) - setPlainText(tr("Click to overwrite")); - QPlainTextEdit::setDisabled(disabled); -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -YACReaderSpinSliderWidget::YACReaderSpinSliderWidget(QWidget * parent,bool strechableSlider) - :QWidget(parent),tracking(true) -{ - QHBoxLayout * layout = new QHBoxLayout; - layout->addWidget(label = new QLabel(this),1); - if(!strechableSlider) - layout->addStretch(); - spinBox = new QSpinBox(this); - layout->addWidget(spinBox); - slider = new QSlider(Qt::Horizontal,this); - layout->addWidget(slider); - if(strechableSlider) - { - layout->setStretchFactor(slider,0.85); - layout->setStretchFactor(spinBox,0); - layout->setStretchFactor(label,0.15); - } - - connect(spinBox, SIGNAL(valueChanged(int)), slider, SLOT(setValue(int))); - connect(slider, SIGNAL(valueChanged(int)), spinBox, SLOT(setValue(int))); - - connect(slider, SIGNAL(valueChanged(int)), this, SLOT(valueWillChange(int))); - connect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(valueWillChangeFromSpinBox(int))); - - connect(slider, SIGNAL(sliderReleased()), this, SLOT(sliderRelease())); - - setLayout(layout); -} -void YACReaderSpinSliderWidget::valueWillChange(int v) -{ - if(tracking) - emit valueChanged(spinBox->value()); -} - -void YACReaderSpinSliderWidget::valueWillChangeFromSpinBox(int v) -{ - if(!tracking && !slider->isSliderDown()) - emit valueChanged(spinBox->value()); -} - -void YACReaderSpinSliderWidget::sliderRelease() -{ - if(!tracking) - emit valueChanged(spinBox->value()); -} - -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) -{ - disconnect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(valueWillChange(int))); - spinBox->setValue(value); - connect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(valueWillChange(int))); -} - -void YACReaderSpinSliderWidget::setText(const QString & text) -{ - label->setText(text); -} - -int YACReaderSpinSliderWidget::getValue() -{ - return spinBox->value(); -} - -QSize YACReaderSpinSliderWidget::minimumSizeHint() const -{ - return QSize(270, 25); -} - -void YACReaderSpinSliderWidget::setTracking(bool b) -{ - tracking = b; - //slider->setTracking(b); -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -YACReaderOptionsDialog::YACReaderOptionsDialog(QWidget * parent) - :QDialog(parent) -{ - - sw = new YACReaderFlowConfigWidget(this); - gl = new YACReaderGLFlowConfigWidget(this); - - accept = new QPushButton(tr("Save")); - cancel = new QPushButton(tr("Cancel")); - - cancel->setDefault(true); - - connect(accept,SIGNAL(clicked()),this,SLOT(saveOptions())); - connect(cancel,SIGNAL(clicked()),this,SLOT(restoreOptions())); - connect(cancel,SIGNAL(clicked()),this,SLOT(close())); - - useGL = new QCheckBox(tr("Use hardware acceleration (restart needed)")); - connect(useGL,SIGNAL(stateChanged(int)),this,SLOT(saveUseGL(int))); - - //sw CONNECTIONS - connect(sw->radio1,SIGNAL(toggled(bool)),this,SLOT(setClassicConfigSW())); - connect(sw->radio2,SIGNAL(toggled(bool)),this,SLOT(setStripeConfigSW())); - connect(sw->radio3,SIGNAL(togg+led(bool)),this,SLOT(setOverlappedStripeConfigSW())); - - //gl CONNECTIONS - connect(gl->radioClassic,SIGNAL(toggled(bool)),this,SLOT(setClassicConfig())); - connect(gl->radioStripe,SIGNAL(toggled(bool)),this,SLOT(setStripeConfig())); - connect(gl->radioOver,SIGNAL(toggled(bool)),this,SLOT(setOverlappedStripeConfig())); - connect(gl->radionModern,SIGNAL(toggled(bool)),this,SLOT(setModernConfig())); - connect(gl->radioDown,SIGNAL(toggled(bool)),this,SLOT(setRouletteConfig())); - - connect(gl->radioClassic,SIGNAL(toggled(bool)),this,SIGNAL(optionsChanged())); - connect(gl->radioStripe,SIGNAL(toggled(bool)),this,SIGNAL(optionsChanged())); - connect(gl->radioOver,SIGNAL(toggled(bool)),this,SIGNAL(optionsChanged())); - connect(gl->radionModern,SIGNAL(toggled(bool)),this,SIGNAL(optionsChanged())); - connect(gl->radioDown,SIGNAL(toggled(bool)),this,SIGNAL(optionsChanged())); - - connect(gl->xRotation,SIGNAL(valueChanged(int)),this,SLOT(saveXRotation(int))); - connect(gl->xRotation,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); - - connect(gl->yPosition,SIGNAL(valueChanged(int)),this,SLOT(saveYPosition(int))); - connect(gl->yPosition,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); - - connect(gl->coverDistance,SIGNAL(valueChanged(int)),this,SLOT(saveCoverDistance(int))); - connect(gl->coverDistance,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); - - connect(gl->centralDistance,SIGNAL(valueChanged(int)),this,SLOT(saveCentralDistance(int))); - connect(gl->centralDistance,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); - - connect(gl->zoomLevel,SIGNAL(valueChanged(int)),this,SLOT(saveZoomLevel(int))); - connect(gl->zoomLevel,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); - - connect(gl->yCoverOffset,SIGNAL(valueChanged(int)),this,SLOT(saveYCoverOffset(int))); - connect(gl->yCoverOffset,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); - - connect(gl->zCoverOffset,SIGNAL(valueChanged(int)),this,SLOT(saveZCoverOffset(int))); - connect(gl->zCoverOffset,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); - - connect(gl->coverRotation,SIGNAL(valueChanged(int)),this,SLOT(saveCoverRotation(int))); - connect(gl->coverRotation,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); - - connect(gl->fadeOutDist,SIGNAL(valueChanged(int)),this,SLOT(saveFadeOutDist(int))); - connect(gl->fadeOutDist,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); - - connect(gl->lightStrength,SIGNAL(valueChanged(int)),this,SLOT(saveLightStrength(int))); - connect(gl->lightStrength,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); - - connect(gl->maxAngle,SIGNAL(valueChanged(int)),this,SLOT(saveMaxAngle(int))); - connect(gl->maxAngle,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); - - connect(gl->performanceSlider, SIGNAL(valueChanged(int)),this,SLOT(savePerformance(int))); - connect(gl->performanceSlider, SIGNAL(valueChanged(int)),this,SLOT(optionsChanged())); - - connect(gl->vSyncCheck,SIGNAL(stateChanged(int)),this,SLOT(saveUseVSync(int))); -} - -void YACReaderOptionsDialog::savePerformance(int value) -{ - settings->setValue(PERFORMANCE,value); -} - -void YACReaderOptionsDialog::saveUseVSync(int b) -{ - settings->setValue(V_SYNC,b); -} - -void YACReaderOptionsDialog::saveFlowParameters() -{ - settings->setValue(X_ROTATION,gl->xRotation->getValue()); - settings->setValue(Y_POSITION,gl->yPosition->getValue()); - settings->setValue(COVER_DISTANCE,gl->coverDistance->getValue()); - settings->setValue(CENTRAL_DISTANCE,gl->centralDistance->getValue()); - settings->setValue(ZOOM_LEVEL,gl->zoomLevel->getValue()); - settings->setValue(Y_COVER_OFFSET,gl->yCoverOffset->getValue()); - settings->setValue(Z_COVER_OFFSET,gl->zCoverOffset->getValue()); - settings->setValue(COVER_ROTATION,gl->coverRotation->getValue()); - settings->setValue(FADE_OUT_DIST,gl->fadeOutDist->getValue()); - settings->setValue(LIGHT_STRENGTH,gl->lightStrength->getValue()); - settings->setValue(MAX_ANGLE,gl->maxAngle->getValue()); -} - -void YACReaderOptionsDialog::saveOptions() -{ - emit(optionsChanged()); - close(); -} - -void YACReaderOptionsDialog::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(USE_OPEN_GL,b); - -} - -void YACReaderOptionsDialog::saveXRotation(int value) -{ - settings->setValue(FLOW_TYPE_GL,Custom); - settings->setValue(X_ROTATION,value); -} -void YACReaderOptionsDialog::saveYPosition(int value) -{ - settings->setValue(FLOW_TYPE_GL,Custom); - settings->setValue(Y_POSITION,value); -} -void YACReaderOptionsDialog::saveCoverDistance(int value) -{ - settings->setValue(FLOW_TYPE_GL,Custom); - settings->setValue(COVER_DISTANCE,value); -} -void YACReaderOptionsDialog::saveCentralDistance(int value) -{ - settings->setValue(FLOW_TYPE_GL,Custom); - settings->setValue(CENTRAL_DISTANCE,value); -} -void YACReaderOptionsDialog::saveZoomLevel(int value) -{ - settings->setValue(FLOW_TYPE_GL,Custom); - settings->setValue(ZOOM_LEVEL,value); -} -void YACReaderOptionsDialog::saveYCoverOffset(int value) -{ - settings->setValue(FLOW_TYPE_GL,Custom); - settings->setValue(Y_COVER_OFFSET,value); -} -void YACReaderOptionsDialog::saveZCoverOffset(int value) -{ - settings->setValue(FLOW_TYPE_GL,Custom); - settings->setValue(Z_COVER_OFFSET,value); -} -void YACReaderOptionsDialog::saveCoverRotation(int value) -{ - settings->setValue(FLOW_TYPE_GL,Custom); - settings->setValue(COVER_ROTATION,value); -} -void YACReaderOptionsDialog::saveFadeOutDist(int value) -{ - settings->setValue(FLOW_TYPE_GL,Custom); - settings->setValue(FADE_OUT_DIST,value); -} -void YACReaderOptionsDialog::saveLightStrength(int value) -{ - settings->setValue(FLOW_TYPE_GL,Custom); - settings->setValue(LIGHT_STRENGTH,value); -} - -void YACReaderOptionsDialog::saveMaxAngle(int value) -{ - settings->setValue(FLOW_TYPE_GL,Custom); - settings->setValue(MAX_ANGLE,value); -} - -void YACReaderOptionsDialog::restoreOptions(QSettings * settings) -{ - this->settings = settings; - - //FLOW CONFIG - - if(settings->contains(USE_OPEN_GL) && settings->value(USE_OPEN_GL).toInt() == Qt::Checked) - { - sw->setVisible(false); - gl->setVisible(true); - useGL->setChecked(true); - } - else - { - gl->setVisible(false); - sw->setVisible(true); - useGL->setChecked(false); - } - - - if(!settings->contains(FLOW_TYPE_GL)) - { - setClassicConfig(); - gl->radioClassic->setChecked(true); - gl->performanceSlider->setValue(1); - return; - } - - if(settings->contains(V_SYNC) && settings->value(V_SYNC).toInt() == Qt::Checked) - gl->vSyncCheck->setChecked(true); - else - gl->vSyncCheck->setChecked(false); - - gl->performanceSlider->setValue(settings->value(PERFORMANCE).toInt()); - - FlowType flowType; - switch(settings->value(FLOW_TYPE_GL).toInt()) - { - case 0: - flowType = CoverFlowLike; - break; - case 1: - flowType = Strip; - break; - case 2: - flowType = StripOverlapped; - break; - case 3: - flowType = Modern; - break; - case 4: - flowType = Roulette; - break; - case 5: - flowType = Custom; - break; - } - - - if(flowType == Custom) - { - loadConfig(); - return; - } - - if(flowType == CoverFlowLike) - { - setClassicConfig(); - gl->radioClassic->setChecked(true); - return; - } - - if(flowType == Strip) - { - setStripeConfig(); - gl->radioStripe->setChecked(true); - return; - } - - if(flowType == StripOverlapped) - { - setOverlappedStripeConfig(); - gl->radioOver->setChecked(true); - return; - } - - if(flowType == Modern) - { - setModernConfig(); - gl->radionModern->setChecked(true); - return; - } - - if(flowType == Roulette) - { - setRouletteConfig(); - gl->radioDown->setChecked(true); - return; - } - - //END FLOW CONFIG -} - -void YACReaderOptionsDialog::loadConfig() -{ - gl->xRotation->setValue(settings->value(X_ROTATION).toInt()); - gl->yPosition->setValue(settings->value(Y_POSITION).toInt()); - gl->coverDistance->setValue(settings->value(COVER_DISTANCE).toInt()); - gl->centralDistance->setValue(settings->value(CENTRAL_DISTANCE).toInt()); - gl->zoomLevel->setValue(settings->value(ZOOM_LEVEL).toInt()); - gl->yCoverOffset->setValue(settings->value(Y_COVER_OFFSET).toInt()); - gl->zCoverOffset->setValue(settings->value(Z_COVER_OFFSET).toInt()); - gl->coverRotation->setValue(settings->value(COVER_ROTATION).toInt()); - gl->fadeOutDist->setValue(settings->value(FADE_OUT_DIST).toInt()); - gl->lightStrength->setValue(settings->value(LIGHT_STRENGTH).toInt()); - gl->maxAngle->setValue(settings->value(MAX_ANGLE).toInt()); -} - -void YACReaderOptionsDialog::setClassicConfigSW() -{ - settings->setValue(FLOW_TYPE_SW,CoverFlowLike); -} - -void YACReaderOptionsDialog::setStripeConfigSW() -{ - settings->setValue(FLOW_TYPE_SW,Strip); -} - -void YACReaderOptionsDialog::setOverlappedStripeConfigSW() -{ - settings->setValue(FLOW_TYPE_SW,StripOverlapped); -} - -void YACReaderOptionsDialog::setClassicConfig() -{ - settings->setValue(FLOW_TYPE_GL,CoverFlowLike); - - gl->setValues(presetYACReaderFlowClassicConfig); - - saveFlowParameters(); -} - -void YACReaderOptionsDialog::setStripeConfig() -{ - settings->setValue(FLOW_TYPE_GL,Strip); - - gl->setValues(presetYACReaderFlowStripeConfig); - - saveFlowParameters(); -} - -void YACReaderOptionsDialog::setOverlappedStripeConfig() -{ - settings->setValue(FLOW_TYPE_GL,StripOverlapped); - - gl->setValues(presetYACReaderFlowOverlappedStripeConfig); - - saveFlowParameters(); -} - -void YACReaderOptionsDialog::setModernConfig() -{ - settings->setValue(FLOW_TYPE_GL,Modern); - - gl->setValues(defaultYACReaderFlowConfig); - - saveFlowParameters(); -} - -void YACReaderOptionsDialog::setRouletteConfig() -{ - settings->setValue(FLOW_TYPE_GL,Roulette); - - gl->setValues(pressetYACReaderFlowDownConfig); - - saveFlowParameters(); -} - - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -YACReaderGLFlowConfigWidget::YACReaderGLFlowConfigWidget(QWidget * parent /* = 0 */) - :QWidget(parent) -{ - 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/flow4.png")); - opt4->addStretch(); - opt4->addWidget(lOpt4); - vbox->addLayout(opt4); - - QHBoxLayout * opt5 = new QHBoxLayout; - opt5->addWidget(radioDown); - QLabel * lOpt5 = new QLabel(); - lOpt5->setPixmap(QPixmap(":/images/flow5.png")); - opt5->addStretch(); - opt5->addWidget(lOpt5); - vbox->addLayout(opt5); - - showAdvancedOptions = new QPushButton(tr("Show advanced settings")); - showAdvancedOptions->setCheckable(true); - connect(showAdvancedOptions,SIGNAL(toggled(bool)),this,SLOT(avancedOptionToogled(bool))); - - vbox->addWidget(showAdvancedOptions,0,Qt::AlignRight); - - groupBox->setLayout(vbox); - - //OPTIONS------------------------------------------------------------------ - 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(0,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); - - optionsGroupBox->hide(); - - QHBoxLayout * performanceSliderLayout = new QHBoxLayout; - performanceSliderLayout->addWidget(new QLabel(tr("Low Performance"))); - performanceSliderLayout->addWidget(performanceSlider = new QSlider(Qt::Horizontal)); - performanceSliderLayout->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); - - QHBoxLayout * vSyncLayout = new QHBoxLayout; - - vSyncCheck = new QCheckBox(tr("Use VSync (improve the image quality in fullscreen mode, worse performance)")); - vSyncLayout->addStretch(); - vSyncLayout->addWidget(vSyncCheck); - - QVBoxLayout * performanceLayout = new QVBoxLayout; - performanceLayout->addLayout(performanceSliderLayout); - performanceLayout->addLayout(vSyncLayout); - - QGroupBox *performanceGroupBox = new QGroupBox(tr("Performance:")); - - //connect(performanceSlider, SIGNAL(valueChanged(int)),this,SLOT(savePerformance(int))); - //connect(performanceSlider, SIGNAL(valueChanged(int)),this,SLOT(optionsChanged())); - - performanceGroupBox->setLayout(performanceLayout); - - layout->addLayout(groupBoxesLayout); - layout->addWidget(performanceGroupBox); - - layout->setContentsMargins(0,0,0,0); - - setLayout(layout); - - -} - -void YACReaderGLFlowConfigWidget::avancedOptionToogled(bool show) -{ - if(show) - optionsGroupBox->show(); - else - optionsGroupBox->hide(); -} - -void YACReaderGLFlowConfigWidget::setValues(Preset preset) -{ - xRotation->setValue(preset.cfRX); - yPosition->setValue(preset.cfY*100); - coverDistance->setValue(preset.xDistance*100); - centralDistance->setValue(preset.centerDistance*100); - zoomLevel->setValue(preset.cfZ); - yCoverOffset->setValue(preset.yDistance*100); - zCoverOffset->setValue(preset.zDistance*100); - coverRotation->setValue(preset.rotation*-1); - fadeOutDist->setValue(preset.animationFadeOutDist); - lightStrength->setValue(preset.viewRotateLightStrenght); - maxAngle->setValue(preset.viewAngle); -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -YACReaderFlowConfigWidget::YACReaderFlowConfigWidget(QWidget * parent ) - :QWidget(parent) -{ - 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); - - layout->setContentsMargins(0,0,0,0); - - setLayout(layout); -} - -///////////////////////////////////////////////////////////////////////////////////////// -#include -#include -#include - -YACReaderLineEdit::YACReaderLineEdit(QWidget *parent) - : QLineEdit(parent) -{ - clearButton = new QToolButton(this); - searchLabel = new QLabel(this); - - QPixmap pixmap(":/images/clearSearch.png"); - QPixmap pixmapIcon(":/images/iconSearch.png"); - - searchLabel->setStyleSheet("QLabel { border: none; padding: 0px; }"); - searchLabel->setPixmap(pixmapIcon); - - clearButton->setIcon(QIcon(pixmap)); - clearButton->setIconSize(pixmap.size()); - clearButton->setCursor(Qt::ArrowCursor); - clearButton->setStyleSheet("QToolButton { border: none; padding: 0px; }"); - clearButton->hide(); - connect(clearButton, SIGNAL(clicked()), this, SLOT(clear())); - connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(updateCloseButton(const QString&))); - int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); - setStyleSheet(QString("QLineEdit { padding-left: %1px; padding-right: %2px; padding-bottom: 1px; margin-bottom: 1px;} ").arg(searchLabel->sizeHint().width() + frameWidth + 2).arg(clearButton->sizeHint().width() + frameWidth + 2)); - QSize msz = minimumSizeHint(); - setMinimumSize(qMax(msz.width(), clearButton->sizeHint().height() + frameWidth * 2 + 2), - qMax(msz.height(), clearButton->sizeHint().height() + frameWidth * 2 + 2)); -} - -void YACReaderLineEdit::resizeEvent(QResizeEvent *) -{ - QSize sz = clearButton->sizeHint(); - int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); - clearButton->move(rect().right() - frameWidth - sz.width(), - (rect().bottom() + 1 - sz.height())/2); - - QSize szl = searchLabel->sizeHint(); - searchLabel->move(3,(rect().bottom() + 1 - szl.height())/2); -} - -void YACReaderLineEdit::updateCloseButton(const QString& text) -{ - clearButton->setVisible(!text.isEmpty()); -} \ No newline at end of file diff --git a/common/custom_widgets.h b/common/custom_widgets.h index f1b4b8a7..3ca6d5f3 100644 --- a/common/custom_widgets.h +++ b/common/custom_widgets.h @@ -1,406 +1,11 @@ #ifndef __CUSTOM_WIDGETS_H #define __CUSTOM_WIDGETS_H -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +class QDir; -#include "yacreader_global.h" - -#include "pictureflow.h" - -#include "yacreader_flow_gl.h" - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -class QToolBarStretch : public QWidget -{ -public: - QToolBarStretch(QWidget * parent=0):QWidget(parent) - { - QHBoxLayout * l= new QHBoxLayout(); - l->addStretch(); - setLayout(l); - } -}; - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -class HelpAboutDialog : public QDialog -{ -Q_OBJECT -public: - HelpAboutDialog(QWidget * parent=0); - HelpAboutDialog(const QString & pathAbout,const QString & pathHelp,QWidget * parent =0); -public slots: - void loadAboutInformation(const QString & path); - void loadHelp(const QString & path); - -private: - QTabWidget *tabWidget; - QTextBrowser *aboutText; - QTextBrowser *helpText; - QString fileToString(const QString & path); -}; - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -class YACReaderIconProvider : public QFileIconProvider -{ -public: - YACReaderIconProvider(); - virtual QIcon icon ( IconType type ) const; - virtual QIcon icon ( const QFileInfo & info ) const; - virtual QString type ( const QFileInfo & info ) const; -}; - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -class YACReaderFlow : public PictureFlow -{ -Q_OBJECT -public: - YACReaderFlow(QWidget * parent,FlowType flowType = CoverFlowLike); - - void mousePressEvent(QMouseEvent* event); - void mouseDoubleClickEvent(QMouseEvent* event); - -signals: - void selected(unsigned int centerIndex); -}; - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -class YACReaderComicDirModel : public QDirModel -{ -Q_OBJECT - public: - YACReaderComicDirModel( const QStringList & nameFilters, QDir::Filters filters, QDir::SortFlags sort, QObject * parent = 0 ); - QString fileName ( const QModelIndex & index ) const; - QFileInfo fileInfo ( const QModelIndex & index ) const; -}; - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -class YACReaderComicViewDelegate : public QItemDelegate -{ - Q_OBJECT - public: - YACReaderComicViewDelegate(QObject * parent = 0); - virtual void paint ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const; - QRect textLayoutBounds(const QStyleOptionViewItemV2 &option) const; -}; - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -class ModelIndexCache -{ - -public: - struct CacheData{ - bool visited; - bool acepted; - }; - ModelIndexCache(); - void setModelIndex(const QString & index, const CacheData & cd); - CacheData getCacheData(const QString & index) const; - void clear(); - - -private: - QHash cache; -}; - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -class YACReaderTreeSearch : public QSortFilterProxyModel -{ - Q_OBJECT - public: - YACReaderTreeSearch(QObject * parent = 0); -protected: - virtual bool filterAcceptsRow ( int sourceRow, const QModelIndex & source_parent ) const; - bool itemMatchesExpression(const QModelIndex &index, const QRegExp &exp) const; - bool containsFiles(QString path,const QRegExp &exp) const; - public slots: - void reset(); - void softReset(); -private: - ModelIndexCache * cache; -}; - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -class YACReaderSortComics : public QSortFilterProxyModel -{ - Q_OBJECT - public: - YACReaderSortComics(QObject * parent = 0); - protected: - bool lessThan(const QModelIndex &left, const QModelIndex &right) const; -}; -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// void delTree(QDir dir); -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -class YACReaderFieldEdit : public QLineEdit -{ - Q_OBJECT - public: - YACReaderFieldEdit(QWidget * parent = 0); - void clear(); - void setDisabled(bool disabled); - protected: - void focusInEvent(QFocusEvent* e); -private: - QAction * restore; -}; - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -class YACReaderFieldPlainTextEdit : public QPlainTextEdit -{ - Q_OBJECT - public: - YACReaderFieldPlainTextEdit(QWidget * parent = 0); - void clear(); - void setDisabled(bool disabled); - protected: - void focusInEvent(QFocusEvent* e); - void focusOutEvent(QFocusEvent* e); -private: - QAction * restore; - -}; - - -//class YACReaderTableView : public QTableView -//{ -// Q_OBJECT -//public: -// YACReaderTableView(QWidget *parent = 0) -// : QTableView(parent) {} -// -//protected: -// bool viewportEvent ( QEvent * event ) -// { -// resizeColumnsToContents(); -// return QTableView::viewportEvent(event); -// } -//}; - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -class YACReaderSpinSliderWidget : public QWidget -{ - Q_OBJECT -private: - QLabel * label; - QSpinBox * spinBox; - QSlider * slider; - bool tracking; -public: - YACReaderSpinSliderWidget(QWidget * parent = 0,bool strechableSlider = false); -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; - void setTracking(bool b); - void valueWillChange(int); - void valueWillChangeFromSpinBox(int); - void sliderRelease(); -signals: - void valueChanged(int); - -}; - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -class YACReaderFlowConfigWidget : public QWidget -{ - Q_OBJECT -public: - QRadioButton *radio1; - QRadioButton *radio2; - QRadioButton *radio3; - - YACReaderFlowConfigWidget(QWidget * parent = 0); -}; - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -class YACReaderGLFlowConfigWidget : public QWidget -{ - Q_OBJECT -public: - YACReaderGLFlowConfigWidget(QWidget * parent = 0); - - //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; - QCheckBox * vSyncCheck; - - QPushButton * showAdvancedOptions; - QGroupBox *optionsGroupBox; - -public slots: - void setValues(Preset preset); - void avancedOptionToogled(bool show); -}; - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -class YACReaderOptionsDialog : public QDialog -{ - Q_OBJECT -protected: - YACReaderFlowConfigWidget * sw; - YACReaderGLFlowConfigWidget * gl; - QCheckBox * useGL; - - QPushButton * accept; - QPushButton * cancel; - - QSettings * settings; - QSettings * previousSettings; - -public: - YACReaderOptionsDialog(QWidget * parent); -public slots: - virtual void restoreOptions(QSettings * settings); - virtual void saveOptions(); -protected slots: - virtual void savePerformance(int value); - virtual void saveUseVSync(int b); - virtual void saveUseGL(int b); - virtual void saveXRotation(int value); - virtual void saveYPosition(int value); - virtual void saveCoverDistance(int value); - virtual void saveCentralDistance(int value); - virtual void saveZoomLevel(int value); - virtual void saveYCoverOffset(int value); - virtual void saveZCoverOffset(int value); - virtual void saveCoverRotation(int value); - virtual void saveFadeOutDist(int value); - virtual void saveLightStrength(int value); - virtual void saveMaxAngle(int value); - virtual void loadConfig(); - virtual void setClassicConfig(); - virtual void setStripeConfig(); - virtual void setOverlappedStripeConfig(); - virtual void setModernConfig(); - virtual void setRouletteConfig(); - virtual void setClassicConfigSW(); - virtual void setStripeConfigSW(); - virtual void setOverlappedStripeConfigSW(); - virtual void saveFlowParameters(); - -signals: - void optionsChanged(); -}; - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -#include - -class QToolButton; -class QLabel; - -class YACReaderLineEdit : public QLineEdit -{ - Q_OBJECT - -public: - YACReaderLineEdit(QWidget *parent = 0); - -protected: - void resizeEvent(QResizeEvent *); - -private slots: - void updateCloseButton(const QString &text); - -private: - QToolButton *clearButton; - QLabel * searchLabel; -}; #endif diff --git a/custom_widgets/custom_widgets.pri b/custom_widgets/custom_widgets.pri new file mode 100644 index 00000000..68e0deae --- /dev/null +++ b/custom_widgets/custom_widgets.pri @@ -0,0 +1,24 @@ +INCLUDEPATH += $$PWD +DEPENDPATH += $$PWD + +HEADERS += $$PWD/help_about_dialog.h \ + $$PWD/yacreader_field_edit.h yacreader_search_line_edit.cpp \ + $$PWD/yacreader_field_plain_text_edit.h \ + $$PWD/yacreader_flow.h \ + $$PWD/yacreader_flow_config_widget.h \ + $$PWD/yacreader_gl_flow_config_widget.h \ + $$PWD/yacreader_options_dialog.h \ + $$PWD/yacreader_search_line_edit.h \ + $$PWD/yacreader_spin_slider_widget.h \ + $$PWD/yacreader_tool_bar_stretch.h \ + +SOURCES += $$PWD/help_about_dialog.cpp \ + $$PWD/yacreader_field_edit.cpp yacreader_search_line_edit.cpp \ + $$PWD/yacreader_field_plain_text_edit.cpp \ + $$PWD/yacreader_flow.cpp \ + $$PWD/yacreader_flow_config_widget.cpp \ + $$PWD/yacreader_gl_flow_config_widget.cpp \ + $$PWD/yacreader_options_dialog.cpp \ + $$PWD/yacreader_search_line_edit.cpp \ + $$PWD/yacreader_spin_slider_widget.cpp \ + $$PWD/yacreader_tool_bar_stretch.cpp \ \ No newline at end of file diff --git a/custom_widgets/help_about_dialog.cpp b/custom_widgets/help_about_dialog.cpp new file mode 100644 index 00000000..9f3a245d --- /dev/null +++ b/custom_widgets/help_about_dialog.cpp @@ -0,0 +1,66 @@ +#include "help_about_dialog.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +HelpAboutDialog::HelpAboutDialog(QWidget * parent) +:QDialog(parent) +{ + QVBoxLayout * layout = new QVBoxLayout(); + + tabWidget = new QTabWidget(); + + tabWidget->addTab(aboutText = new QTextBrowser(), tr("About")); + aboutText->setOpenExternalLinks(true); + aboutText->setFont(QFont("Comic Sans MS", 10)); //purisa + tabWidget->addTab(helpText = new QTextBrowser(), tr("Help")); + helpText->setOpenExternalLinks(true); + helpText->setFont(QFont("Comic Sans MS", 10)); + //helpText->setDisabled(true); + //tabWidget->addTab(,"About Qt"); + + layout->addWidget(tabWidget); + layout->setContentsMargins(1,3,1,1); + + setLayout(layout); + resize(500, QApplication::desktop()->availableGeometry().height()*0.83); +} + +HelpAboutDialog::HelpAboutDialog(const QString & pathAbout,const QString & pathHelp,QWidget * parent) +:QDialog(parent) +{ + loadAboutInformation(pathAbout); + loadHelp(pathHelp); +} + +void HelpAboutDialog::loadAboutInformation(const QString & path) +{ + aboutText->insertHtml(fileToString(path)); + aboutText->moveCursor(QTextCursor::Start); +} + +void HelpAboutDialog::loadHelp(const QString & path) +{ + helpText->insertHtml(fileToString(path)); + helpText->moveCursor(QTextCursor::Start); +} + +QString HelpAboutDialog::fileToString(const QString & path) +{ + QFile f(path); + f.open(QIODevice::ReadOnly); + QTextStream txtS(&f); + + txtS.setCodec(QTextCodec::codecForName("UTF-8")); + + QString content = txtS.readAll(); + f.close(); + + return content; +} \ No newline at end of file diff --git a/custom_widgets/help_about_dialog.h b/custom_widgets/help_about_dialog.h new file mode 100644 index 00000000..14eb0f7b --- /dev/null +++ b/custom_widgets/help_about_dialog.h @@ -0,0 +1,27 @@ +#ifndef HELP_ABOUT_DIALOG_H +#define HELP_ABOUT_DIALOG_H + +#include + +class QTabWidget; +class QTextBrowser; + +class HelpAboutDialog : public QDialog +{ +Q_OBJECT +public: + HelpAboutDialog(QWidget * parent=0); + HelpAboutDialog(const QString & pathAbout,const QString & pathHelp,QWidget * parent =0); +public slots: + void loadAboutInformation(const QString & path); + void loadHelp(const QString & path); + +private: + QTabWidget *tabWidget; + QTextBrowser *aboutText; + QTextBrowser *helpText; + QString fileToString(const QString & path); +}; + + +#endif // HELP_ABOUT_DIALOG_H \ No newline at end of file diff --git a/custom_widgets/yacreader_field_edit.cpp b/custom_widgets/yacreader_field_edit.cpp new file mode 100644 index 00000000..55c6e2aa --- /dev/null +++ b/custom_widgets/yacreader_field_edit.cpp @@ -0,0 +1,39 @@ +#include "yacreader_field_edit.h" + +#include +#include + +YACReaderFieldEdit::YACReaderFieldEdit(QWidget * parent) + :QLineEdit(parent) +{ + setPlaceholderText(tr("Click to overwrite")); + setModified(false); + restore = new QAction(tr("Restore to default"),this); + this->addAction(restore); + //this->setContextMenuPolicy(Qt::ActionsContextMenu); +} + +void YACReaderFieldEdit::focusInEvent(QFocusEvent* e) +{ + if (e->reason() == Qt::MouseFocusReason) + { + setModified(true); + setPlaceholderText(""); + } + + QLineEdit::focusInEvent(e); +} + +void YACReaderFieldEdit::clear() +{ + setPlaceholderText(tr("Click to overwrite")); + QLineEdit::clear(); + QLineEdit::setModified(false); +} + +void YACReaderFieldEdit::setDisabled(bool disabled) +{ + if(disabled) + setPlaceholderText(""); + QLineEdit::setDisabled(disabled); +} \ No newline at end of file diff --git a/custom_widgets/yacreader_field_edit.h b/custom_widgets/yacreader_field_edit.h new file mode 100644 index 00000000..b7baf0f1 --- /dev/null +++ b/custom_widgets/yacreader_field_edit.h @@ -0,0 +1,23 @@ +#ifndef YACREADER_FIELD_EDIT_H +#define YACREADER_FIELD_EDIT_H + +#include + +class QAction; +class QFocusEvent; + +class YACReaderFieldEdit : public QLineEdit +{ + Q_OBJECT + public: + YACReaderFieldEdit(QWidget * parent = 0); + void clear(); + void setDisabled(bool disabled); + protected: + void focusInEvent(QFocusEvent* e); +private: + QAction * restore; + +}; + +#endif // YACREADER_FIELD_EDIT_H \ No newline at end of file diff --git a/custom_widgets/yacreader_field_plain_text_edit.cpp b/custom_widgets/yacreader_field_plain_text_edit.cpp new file mode 100644 index 00000000..66bc187d --- /dev/null +++ b/custom_widgets/yacreader_field_plain_text_edit.cpp @@ -0,0 +1,53 @@ +#include "yacreader_field_plain_text_edit.h" + +#include + +YACReaderFieldPlainTextEdit::YACReaderFieldPlainTextEdit(QWidget * parent) + :QPlainTextEdit(parent) +{ + document()->setModified(false); + setPlainText(tr("Click to overwrite")); + restore = new QAction(tr("Restore to default"),this); + this->addAction(restore); + //this->setContextMenuPolicy(Qt::ActionsContextMenu); +} + +void YACReaderFieldPlainTextEdit::focusInEvent(QFocusEvent* e) +{ + if (e->reason() == Qt::MouseFocusReason || e->reason() == Qt::TabFocusReason) + { + document()->setModified(true); + if(toPlainText()==tr("Click to overwrite")) + setPlainText(""); + } + + QPlainTextEdit::focusInEvent(e); +} + +void YACReaderFieldPlainTextEdit::focusOutEvent(QFocusEvent* e) +{ + /*if (e->reason() == Qt::MouseFocusReason || e->reason() == Qt::TabFocusReason) + { + if(toPlainText().isEmpty()) + { + setPlainText(tr("Click to overwrite")); + document()->setModified(false); + } + } + */ + QPlainTextEdit::focusOutEvent(e); +} + +void YACReaderFieldPlainTextEdit::clear() +{ + QPlainTextEdit::clear(); + document()->setModified(false); + setPlainText(tr("Click to overwrite")); +} + +void YACReaderFieldPlainTextEdit::setDisabled(bool disabled) +{ + if(disabled) + setPlainText(tr("Click to overwrite")); + QPlainTextEdit::setDisabled(disabled); +} diff --git a/custom_widgets/yacreader_field_plain_text_edit.h b/custom_widgets/yacreader_field_plain_text_edit.h new file mode 100644 index 00000000..0d02493c --- /dev/null +++ b/custom_widgets/yacreader_field_plain_text_edit.h @@ -0,0 +1,25 @@ +#ifndef YACREADER_FIELD_PLAIN_TEXT_EDIT_H +#define YACREADER_FIELD_PLAIN_TEXT_EDIT_H + +#include + +class QAction; +class QFocusEvent; + + +class YACReaderFieldPlainTextEdit : public QPlainTextEdit +{ + Q_OBJECT + public: + YACReaderFieldPlainTextEdit(QWidget * parent = 0); + void clear(); + void setDisabled(bool disabled); + protected: + void focusInEvent(QFocusEvent* e); + void focusOutEvent(QFocusEvent* e); +private: + QAction * restore; + +}; + +#endif // YACREADER_FIELD_PLAIN_TEXT_EDIT_H \ No newline at end of file diff --git a/custom_widgets/yacreader_flow.cpp b/custom_widgets/yacreader_flow.cpp new file mode 100644 index 00000000..e40507d3 --- /dev/null +++ b/custom_widgets/yacreader_flow.cpp @@ -0,0 +1,23 @@ +#include "yacreader_flow.h" + +#include + + +YACReaderFlow::YACReaderFlow(QWidget * parent,FlowType flowType) : PictureFlow(parent,flowType) {} + +void YACReaderFlow::mousePressEvent(QMouseEvent* event) +{ + if(event->x() > (width()+slideSize().width())/2) + showNext(); + else + if(event->x() < (width()-slideSize().width())/2) + showPrevious(); + //else (centered cover space) +} + +void YACReaderFlow::mouseDoubleClickEvent(QMouseEvent* event) +{ + if((event->x() > (width()-slideSize().width())/2)&&(event->x() < (width()+slideSize().width())/2)) + emit selected(centerIndex()); +} + diff --git a/custom_widgets/yacreader_flow.h b/custom_widgets/yacreader_flow.h new file mode 100644 index 00000000..174abaf8 --- /dev/null +++ b/custom_widgets/yacreader_flow.h @@ -0,0 +1,21 @@ +#ifndef YACREADER_FLOW_H +#define YACREADER_FLOW_H + +#include "pictureflow.h" + +class QMouseEvent; + +class YACReaderFlow : public PictureFlow +{ +Q_OBJECT +public: + YACReaderFlow(QWidget * parent,FlowType flowType = CoverFlowLike); + + void mousePressEvent(QMouseEvent* event); + void mouseDoubleClickEvent(QMouseEvent* event); + +signals: + void selected(unsigned int centerIndex); +}; + +#endif // YACREADER_FLOW_H \ No newline at end of file diff --git a/custom_widgets/yacreader_flow_config_widget.cpp b/custom_widgets/yacreader_flow_config_widget.cpp new file mode 100644 index 00000000..8fd3ba94 --- /dev/null +++ b/custom_widgets/yacreader_flow_config_widget.cpp @@ -0,0 +1,54 @@ +#include "yacreader_flow_config_widget.h" + +#include +#include +#include +#include + +YACReaderFlowConfigWidget::YACReaderFlowConfigWidget(QWidget * parent ) + :QWidget(parent) +{ + 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); + + layout->setContentsMargins(0,0,0,0); + + setLayout(layout); +} \ No newline at end of file diff --git a/custom_widgets/yacreader_flow_config_widget.h b/custom_widgets/yacreader_flow_config_widget.h new file mode 100644 index 00000000..b5dee55d --- /dev/null +++ b/custom_widgets/yacreader_flow_config_widget.h @@ -0,0 +1,19 @@ +#ifndef YACREADER_FLOW_CONFIG_WIDGET_H +#define YACREADER_FLOW_CONFIG_WIDGET_H + +#include + +class QRadioButton; + +class YACReaderFlowConfigWidget : public QWidget +{ + Q_OBJECT +public: + QRadioButton *radio1; + QRadioButton *radio2; + QRadioButton *radio3; + + YACReaderFlowConfigWidget(QWidget * parent = 0); +}; + +#endif // YACREADER_FLOW_CONFIG_WIDGET_H \ No newline at end of file diff --git a/custom_widgets/yacreader_gl_flow_config_widget.cpp b/custom_widgets/yacreader_gl_flow_config_widget.cpp new file mode 100644 index 00000000..aa283ffc --- /dev/null +++ b/custom_widgets/yacreader_gl_flow_config_widget.cpp @@ -0,0 +1,240 @@ +#include "yacreader_gl_flow_config_widget.h" + +#include "yacreader_spin_slider_widget.h" +#include "yacreader_flow_gl.h" //TODO + +#include +#include +#include +#include +#include + + +YACReaderGLFlowConfigWidget::YACReaderGLFlowConfigWidget(QWidget * parent /* = 0 */) + :QWidget(parent) +{ + 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/flow4.png")); + opt4->addStretch(); + opt4->addWidget(lOpt4); + vbox->addLayout(opt4); + + QHBoxLayout * opt5 = new QHBoxLayout; + opt5->addWidget(radioDown); + QLabel * lOpt5 = new QLabel(); + lOpt5->setPixmap(QPixmap(":/images/flow5.png")); + opt5->addStretch(); + opt5->addWidget(lOpt5); + vbox->addLayout(opt5); + + showAdvancedOptions = new QPushButton(tr("Show advanced settings")); + showAdvancedOptions->setCheckable(true); + connect(showAdvancedOptions,SIGNAL(toggled(bool)),this,SLOT(avancedOptionToogled(bool))); + + vbox->addWidget(showAdvancedOptions,0,Qt::AlignRight); + + groupBox->setLayout(vbox); + + //OPTIONS------------------------------------------------------------------ + 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(0,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); + + optionsGroupBox->hide(); + + QHBoxLayout * performanceSliderLayout = new QHBoxLayout; + performanceSliderLayout->addWidget(new QLabel(tr("Low Performance"))); + performanceSliderLayout->addWidget(performanceSlider = new QSlider(Qt::Horizontal)); + performanceSliderLayout->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); + + QHBoxLayout * vSyncLayout = new QHBoxLayout; + + vSyncCheck = new QCheckBox(tr("Use VSync (improve the image quality in fullscreen mode, worse performance)")); + vSyncLayout->addStretch(); + vSyncLayout->addWidget(vSyncCheck); + + QVBoxLayout * performanceLayout = new QVBoxLayout; + performanceLayout->addLayout(performanceSliderLayout); + performanceLayout->addLayout(vSyncLayout); + + QGroupBox *performanceGroupBox = new QGroupBox(tr("Performance:")); + + //connect(performanceSlider, SIGNAL(valueChanged(int)),this,SLOT(savePerformance(int))); + //connect(performanceSlider, SIGNAL(valueChanged(int)),this,SLOT(optionsChanged())); + + performanceGroupBox->setLayout(performanceLayout); + + layout->addLayout(groupBoxesLayout); + layout->addWidget(performanceGroupBox); + + layout->setContentsMargins(0,0,0,0); + + setLayout(layout); + + +} + +void YACReaderGLFlowConfigWidget::avancedOptionToogled(bool show) +{ + if(show) + optionsGroupBox->show(); + else + optionsGroupBox->hide(); +} + +void YACReaderGLFlowConfigWidget::setValues(Preset preset) +{ + xRotation->setValue(preset.cfRX); + yPosition->setValue(preset.cfY*100); + coverDistance->setValue(preset.xDistance*100); + centralDistance->setValue(preset.centerDistance*100); + zoomLevel->setValue(preset.cfZ); + yCoverOffset->setValue(preset.yDistance*100); + zCoverOffset->setValue(preset.zDistance*100); + coverRotation->setValue(preset.rotation*-1); + fadeOutDist->setValue(preset.animationFadeOutDist); + lightStrength->setValue(preset.viewRotateLightStrenght); + maxAngle->setValue(preset.viewAngle); +} \ No newline at end of file diff --git a/custom_widgets/yacreader_gl_flow_config_widget.h b/custom_widgets/yacreader_gl_flow_config_widget.h new file mode 100644 index 00000000..83ded28d --- /dev/null +++ b/custom_widgets/yacreader_gl_flow_config_widget.h @@ -0,0 +1,51 @@ +#ifndef YACREADER_GL_FLOW_CONFIG_WIDGET_H +#define YACREADER_GL_FLOW_CONFIG_WIDGET_H + +#include "yacreader_flow_gl.h" //TODO +#include + +class QRadioButton; +class YACReaderSpinSliderWidget; +class QSlider; +class QCheckBox; +class QPushButton; +class QGroupBox; + +class YACReaderGLFlowConfigWidget : public QWidget +{ + Q_OBJECT +public: + YACReaderGLFlowConfigWidget(QWidget * parent = 0); + + //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; + QCheckBox * vSyncCheck; + + QPushButton * showAdvancedOptions; + QGroupBox *optionsGroupBox; + +public slots: + void setValues(Preset preset); + void avancedOptionToogled(bool show); +}; + + +#endif // YACREADER_GL_FLOW_CONFIG_WIDGET_H \ No newline at end of file diff --git a/custom_widgets/yacreader_options_dialog.cpp b/custom_widgets/yacreader_options_dialog.cpp new file mode 100644 index 00000000..3858ecff --- /dev/null +++ b/custom_widgets/yacreader_options_dialog.cpp @@ -0,0 +1,372 @@ +#include "yacreader_options_dialog.h" + +#include "yacreader_flow_config_widget.h" +#include "yacreader_gl_flow_config_widget.h" +#include "yacreader_spin_slider_widget.h" +#include "yacreader_global.h" + +#include +#include +#include +#include +#include + +YACReaderOptionsDialog::YACReaderOptionsDialog(QWidget * parent) + :QDialog(parent) +{ + + sw = new YACReaderFlowConfigWidget(this); + gl = new YACReaderGLFlowConfigWidget(this); + + accept = new QPushButton(tr("Save")); + cancel = new QPushButton(tr("Cancel")); + + cancel->setDefault(true); + + connect(accept,SIGNAL(clicked()),this,SLOT(saveOptions())); + connect(cancel,SIGNAL(clicked()),this,SLOT(restoreOptions())); + connect(cancel,SIGNAL(clicked()),this,SLOT(close())); + + useGL = new QCheckBox(tr("Use hardware acceleration (restart needed)")); + connect(useGL,SIGNAL(stateChanged(int)),this,SLOT(saveUseGL(int))); + + //sw CONNECTIONS + connect(sw->radio1,SIGNAL(toggled(bool)),this,SLOT(setClassicConfigSW())); + connect(sw->radio2,SIGNAL(toggled(bool)),this,SLOT(setStripeConfigSW())); + connect(sw->radio3,SIGNAL(togg+led(bool)),this,SLOT(setOverlappedStripeConfigSW())); + + //gl CONNECTIONS + connect(gl->radioClassic,SIGNAL(toggled(bool)),this,SLOT(setClassicConfig())); + connect(gl->radioStripe,SIGNAL(toggled(bool)),this,SLOT(setStripeConfig())); + connect(gl->radioOver,SIGNAL(toggled(bool)),this,SLOT(setOverlappedStripeConfig())); + connect(gl->radionModern,SIGNAL(toggled(bool)),this,SLOT(setModernConfig())); + connect(gl->radioDown,SIGNAL(toggled(bool)),this,SLOT(setRouletteConfig())); + + connect(gl->radioClassic,SIGNAL(toggled(bool)),this,SIGNAL(optionsChanged())); + connect(gl->radioStripe,SIGNAL(toggled(bool)),this,SIGNAL(optionsChanged())); + connect(gl->radioOver,SIGNAL(toggled(bool)),this,SIGNAL(optionsChanged())); + connect(gl->radionModern,SIGNAL(toggled(bool)),this,SIGNAL(optionsChanged())); + connect(gl->radioDown,SIGNAL(toggled(bool)),this,SIGNAL(optionsChanged())); + + connect(gl->xRotation,SIGNAL(valueChanged(int)),this,SLOT(saveXRotation(int))); + connect(gl->xRotation,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); + + connect(gl->yPosition,SIGNAL(valueChanged(int)),this,SLOT(saveYPosition(int))); + connect(gl->yPosition,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); + + connect(gl->coverDistance,SIGNAL(valueChanged(int)),this,SLOT(saveCoverDistance(int))); + connect(gl->coverDistance,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); + + connect(gl->centralDistance,SIGNAL(valueChanged(int)),this,SLOT(saveCentralDistance(int))); + connect(gl->centralDistance,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); + + connect(gl->zoomLevel,SIGNAL(valueChanged(int)),this,SLOT(saveZoomLevel(int))); + connect(gl->zoomLevel,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); + + connect(gl->yCoverOffset,SIGNAL(valueChanged(int)),this,SLOT(saveYCoverOffset(int))); + connect(gl->yCoverOffset,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); + + connect(gl->zCoverOffset,SIGNAL(valueChanged(int)),this,SLOT(saveZCoverOffset(int))); + connect(gl->zCoverOffset,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); + + connect(gl->coverRotation,SIGNAL(valueChanged(int)),this,SLOT(saveCoverRotation(int))); + connect(gl->coverRotation,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); + + connect(gl->fadeOutDist,SIGNAL(valueChanged(int)),this,SLOT(saveFadeOutDist(int))); + connect(gl->fadeOutDist,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); + + connect(gl->lightStrength,SIGNAL(valueChanged(int)),this,SLOT(saveLightStrength(int))); + connect(gl->lightStrength,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); + + connect(gl->maxAngle,SIGNAL(valueChanged(int)),this,SLOT(saveMaxAngle(int))); + connect(gl->maxAngle,SIGNAL(valueChanged(int)),this,SIGNAL(optionsChanged())); + + connect(gl->performanceSlider, SIGNAL(valueChanged(int)),this,SLOT(savePerformance(int))); + connect(gl->performanceSlider, SIGNAL(valueChanged(int)),this,SLOT(optionsChanged())); + + connect(gl->vSyncCheck,SIGNAL(stateChanged(int)),this,SLOT(saveUseVSync(int))); +} + +void YACReaderOptionsDialog::savePerformance(int value) +{ + settings->setValue(PERFORMANCE,value); +} + +void YACReaderOptionsDialog::saveUseVSync(int b) +{ + settings->setValue(V_SYNC,b); +} + +void YACReaderOptionsDialog::saveFlowParameters() +{ + settings->setValue(X_ROTATION,gl->xRotation->getValue()); + settings->setValue(Y_POSITION,gl->yPosition->getValue()); + settings->setValue(COVER_DISTANCE,gl->coverDistance->getValue()); + settings->setValue(CENTRAL_DISTANCE,gl->centralDistance->getValue()); + settings->setValue(ZOOM_LEVEL,gl->zoomLevel->getValue()); + settings->setValue(Y_COVER_OFFSET,gl->yCoverOffset->getValue()); + settings->setValue(Z_COVER_OFFSET,gl->zCoverOffset->getValue()); + settings->setValue(COVER_ROTATION,gl->coverRotation->getValue()); + settings->setValue(FADE_OUT_DIST,gl->fadeOutDist->getValue()); + settings->setValue(LIGHT_STRENGTH,gl->lightStrength->getValue()); + settings->setValue(MAX_ANGLE,gl->maxAngle->getValue()); +} + +void YACReaderOptionsDialog::saveOptions() +{ + emit(optionsChanged()); + close(); +} + +void YACReaderOptionsDialog::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(USE_OPEN_GL,b); + +} + +void YACReaderOptionsDialog::saveXRotation(int value) +{ + settings->setValue(FLOW_TYPE_GL,Custom); + settings->setValue(X_ROTATION,value); +} +void YACReaderOptionsDialog::saveYPosition(int value) +{ + settings->setValue(FLOW_TYPE_GL,Custom); + settings->setValue(Y_POSITION,value); +} +void YACReaderOptionsDialog::saveCoverDistance(int value) +{ + settings->setValue(FLOW_TYPE_GL,Custom); + settings->setValue(COVER_DISTANCE,value); +} +void YACReaderOptionsDialog::saveCentralDistance(int value) +{ + settings->setValue(FLOW_TYPE_GL,Custom); + settings->setValue(CENTRAL_DISTANCE,value); +} +void YACReaderOptionsDialog::saveZoomLevel(int value) +{ + settings->setValue(FLOW_TYPE_GL,Custom); + settings->setValue(ZOOM_LEVEL,value); +} +void YACReaderOptionsDialog::saveYCoverOffset(int value) +{ + settings->setValue(FLOW_TYPE_GL,Custom); + settings->setValue(Y_COVER_OFFSET,value); +} +void YACReaderOptionsDialog::saveZCoverOffset(int value) +{ + settings->setValue(FLOW_TYPE_GL,Custom); + settings->setValue(Z_COVER_OFFSET,value); +} +void YACReaderOptionsDialog::saveCoverRotation(int value) +{ + settings->setValue(FLOW_TYPE_GL,Custom); + settings->setValue(COVER_ROTATION,value); +} +void YACReaderOptionsDialog::saveFadeOutDist(int value) +{ + settings->setValue(FLOW_TYPE_GL,Custom); + settings->setValue(FADE_OUT_DIST,value); +} +void YACReaderOptionsDialog::saveLightStrength(int value) +{ + settings->setValue(FLOW_TYPE_GL,Custom); + settings->setValue(LIGHT_STRENGTH,value); +} + +void YACReaderOptionsDialog::saveMaxAngle(int value) +{ + settings->setValue(FLOW_TYPE_GL,Custom); + settings->setValue(MAX_ANGLE,value); +} + +void YACReaderOptionsDialog::restoreOptions(QSettings * settings) +{ + this->settings = settings; + + //FLOW CONFIG + + if(settings->contains(USE_OPEN_GL) && settings->value(USE_OPEN_GL).toInt() == Qt::Checked) + { + sw->setVisible(false); + gl->setVisible(true); + useGL->setChecked(true); + } + else + { + gl->setVisible(false); + sw->setVisible(true); + useGL->setChecked(false); + } + + + if(!settings->contains(FLOW_TYPE_GL)) + { + setClassicConfig(); + gl->radioClassic->setChecked(true); + gl->performanceSlider->setValue(1); + return; + } + + if(settings->contains(V_SYNC) && settings->value(V_SYNC).toInt() == Qt::Checked) + gl->vSyncCheck->setChecked(true); + else + gl->vSyncCheck->setChecked(false); + + gl->performanceSlider->setValue(settings->value(PERFORMANCE).toInt()); + + FlowType flowType; + switch(settings->value(FLOW_TYPE_GL).toInt()) + { + case 0: + flowType = CoverFlowLike; + break; + case 1: + flowType = Strip; + break; + case 2: + flowType = StripOverlapped; + break; + case 3: + flowType = Modern; + break; + case 4: + flowType = Roulette; + break; + case 5: + flowType = Custom; + break; + } + + + if(flowType == Custom) + { + loadConfig(); + return; + } + + if(flowType == CoverFlowLike) + { + setClassicConfig(); + gl->radioClassic->setChecked(true); + return; + } + + if(flowType == Strip) + { + setStripeConfig(); + gl->radioStripe->setChecked(true); + return; + } + + if(flowType == StripOverlapped) + { + setOverlappedStripeConfig(); + gl->radioOver->setChecked(true); + return; + } + + if(flowType == Modern) + { + setModernConfig(); + gl->radionModern->setChecked(true); + return; + } + + if(flowType == Roulette) + { + setRouletteConfig(); + gl->radioDown->setChecked(true); + return; + } + + //END FLOW CONFIG +} + +void YACReaderOptionsDialog::loadConfig() +{ + gl->xRotation->setValue(settings->value(X_ROTATION).toInt()); + gl->yPosition->setValue(settings->value(Y_POSITION).toInt()); + gl->coverDistance->setValue(settings->value(COVER_DISTANCE).toInt()); + gl->centralDistance->setValue(settings->value(CENTRAL_DISTANCE).toInt()); + gl->zoomLevel->setValue(settings->value(ZOOM_LEVEL).toInt()); + gl->yCoverOffset->setValue(settings->value(Y_COVER_OFFSET).toInt()); + gl->zCoverOffset->setValue(settings->value(Z_COVER_OFFSET).toInt()); + gl->coverRotation->setValue(settings->value(COVER_ROTATION).toInt()); + gl->fadeOutDist->setValue(settings->value(FADE_OUT_DIST).toInt()); + gl->lightStrength->setValue(settings->value(LIGHT_STRENGTH).toInt()); + gl->maxAngle->setValue(settings->value(MAX_ANGLE).toInt()); +} + +void YACReaderOptionsDialog::setClassicConfigSW() +{ + settings->setValue(FLOW_TYPE_SW,CoverFlowLike); +} + +void YACReaderOptionsDialog::setStripeConfigSW() +{ + settings->setValue(FLOW_TYPE_SW,Strip); +} + +void YACReaderOptionsDialog::setOverlappedStripeConfigSW() +{ + settings->setValue(FLOW_TYPE_SW,StripOverlapped); +} + +void YACReaderOptionsDialog::setClassicConfig() +{ + settings->setValue(FLOW_TYPE_GL,CoverFlowLike); + + gl->setValues(presetYACReaderFlowClassicConfig); + + saveFlowParameters(); +} + +void YACReaderOptionsDialog::setStripeConfig() +{ + settings->setValue(FLOW_TYPE_GL,Strip); + + gl->setValues(presetYACReaderFlowStripeConfig); + + saveFlowParameters(); +} + +void YACReaderOptionsDialog::setOverlappedStripeConfig() +{ + settings->setValue(FLOW_TYPE_GL,StripOverlapped); + + gl->setValues(presetYACReaderFlowOverlappedStripeConfig); + + saveFlowParameters(); +} + +void YACReaderOptionsDialog::setModernConfig() +{ + settings->setValue(FLOW_TYPE_GL,Modern); + + gl->setValues(defaultYACReaderFlowConfig); + + saveFlowParameters(); +} + +void YACReaderOptionsDialog::setRouletteConfig() +{ + settings->setValue(FLOW_TYPE_GL,Roulette); + + gl->setValues(pressetYACReaderFlowDownConfig); + + saveFlowParameters(); +} diff --git a/custom_widgets/yacreader_options_dialog.h b/custom_widgets/yacreader_options_dialog.h new file mode 100644 index 00000000..67a08230 --- /dev/null +++ b/custom_widgets/yacreader_options_dialog.h @@ -0,0 +1,61 @@ +#ifndef YACREADER_OPTIONS_DIALOG_H +#define YACREADER_OPTIONS_DIALOG_H + +#include + +class YACReaderFlowConfigWidget; +class YACReaderGLFlowConfigWidget; +class QCheckBox; +class QPushButton; +class QSettings; + +class YACReaderOptionsDialog : public QDialog +{ + Q_OBJECT +protected: + YACReaderFlowConfigWidget * sw; + YACReaderGLFlowConfigWidget * gl; + QCheckBox * useGL; + + QPushButton * accept; + QPushButton * cancel; + + QSettings * settings; + QSettings * previousSettings; + +public: + YACReaderOptionsDialog(QWidget * parent); +public slots: + virtual void restoreOptions(QSettings * settings); + virtual void saveOptions(); +protected slots: + virtual void savePerformance(int value); + virtual void saveUseVSync(int b); + virtual void saveUseGL(int b); + virtual void saveXRotation(int value); + virtual void saveYPosition(int value); + virtual void saveCoverDistance(int value); + virtual void saveCentralDistance(int value); + virtual void saveZoomLevel(int value); + virtual void saveYCoverOffset(int value); + virtual void saveZCoverOffset(int value); + virtual void saveCoverRotation(int value); + virtual void saveFadeOutDist(int value); + virtual void saveLightStrength(int value); + virtual void saveMaxAngle(int value); + virtual void loadConfig(); + virtual void setClassicConfig(); + virtual void setStripeConfig(); + virtual void setOverlappedStripeConfig(); + virtual void setModernConfig(); + virtual void setRouletteConfig(); + virtual void setClassicConfigSW(); + virtual void setStripeConfigSW(); + virtual void setOverlappedStripeConfigSW(); + virtual void saveFlowParameters(); + +signals: + void optionsChanged(); +}; + +#endif // YACREADER_OPTIONS_DIALOG_H \ No newline at end of file diff --git a/custom_widgets/yacreader_search_line_edit.cpp b/custom_widgets/yacreader_search_line_edit.cpp new file mode 100644 index 00000000..33f030f8 --- /dev/null +++ b/custom_widgets/yacreader_search_line_edit.cpp @@ -0,0 +1,47 @@ +#include "yacreader_search_line_edit.h" + +#include +#include +#include + +YACReaderSearchLineEdit::YACReaderSearchLineEdit(QWidget *parent) + : QLineEdit(parent) +{ + clearButton = new QToolButton(this); + searchLabel = new QLabel(this); + + QPixmap pixmap(":/images/clearSearch.png"); + QPixmap pixmapIcon(":/images/iconSearch.png"); + + searchLabel->setStyleSheet("QLabel { border: none; padding: 0px; }"); + searchLabel->setPixmap(pixmapIcon); + + clearButton->setIcon(QIcon(pixmap)); + clearButton->setIconSize(pixmap.size()); + clearButton->setCursor(Qt::ArrowCursor); + clearButton->setStyleSheet("QToolButton { border: none; padding: 0px; }"); + clearButton->hide(); + connect(clearButton, SIGNAL(clicked()), this, SLOT(clear())); + connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(updateCloseButton(const QString&))); + int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); + setStyleSheet(QString("QLineEdit { padding-left: %1px; padding-right: %2px; padding-bottom: 1px; margin-bottom: 1px;} ").arg(searchLabel->sizeHint().width() + frameWidth + 6).arg(clearButton->sizeHint().width() + frameWidth + 2)); + QSize msz = minimumSizeHint(); + setMinimumSize(qMax(msz.width(), clearButton->sizeHint().height() + frameWidth * 2 + 2), + qMax(msz.height(), clearButton->sizeHint().height() + frameWidth * 2 + 2)); +} + +void YACReaderSearchLineEdit::resizeEvent(QResizeEvent *) +{ + QSize sz = clearButton->sizeHint(); + int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); + clearButton->move(rect().right() - frameWidth - sz.width(), + (rect().bottom() + 1 - sz.height())/2); + + QSize szl = searchLabel->sizeHint(); + searchLabel->move(6,(rect().bottom() + 1 - szl.height())/2); +} + +void YACReaderSearchLineEdit::updateCloseButton(const QString& text) +{ + clearButton->setVisible(!text.isEmpty()); +} \ No newline at end of file diff --git a/custom_widgets/yacreader_search_line_edit.h b/custom_widgets/yacreader_search_line_edit.h new file mode 100644 index 00000000..19de3b47 --- /dev/null +++ b/custom_widgets/yacreader_search_line_edit.h @@ -0,0 +1,29 @@ +#ifndef YACREADER_SEARCH_LINE_EDIT_H +#define YACREADER_SEARCH_LINE_EDIT_H + +#include + +class QToolButton; +class QLabel; + +class YACReaderSearchLineEdit : public QLineEdit +{ + Q_OBJECT + +public: + YACReaderSearchLineEdit(QWidget *parent = 0); + +protected: + void resizeEvent(QResizeEvent *); + +private slots: + void updateCloseButton(const QString &text); + +private: + QToolButton *clearButton; + QLabel * searchLabel; +}; + + + +#endif // YACREADER_SEARCH_LINE_EDIT_H diff --git a/custom_widgets/yacreader_spin_slider_widget.cpp b/custom_widgets/yacreader_spin_slider_widget.cpp new file mode 100644 index 00000000..a6a360f0 --- /dev/null +++ b/custom_widgets/yacreader_spin_slider_widget.cpp @@ -0,0 +1,91 @@ +#include "yacreader_spin_slider_widget.h" + +#include +#include +#include +#include + +YACReaderSpinSliderWidget::YACReaderSpinSliderWidget(QWidget * parent,bool strechableSlider) + :QWidget(parent),tracking(true) +{ + QHBoxLayout * layout = new QHBoxLayout; + layout->addWidget(label = new QLabel(this),1); + if(!strechableSlider) + layout->addStretch(); + spinBox = new QSpinBox(this); + layout->addWidget(spinBox); + slider = new QSlider(Qt::Horizontal,this); + layout->addWidget(slider); + if(strechableSlider) + { + layout->setStretchFactor(slider,0.85); + layout->setStretchFactor(spinBox,0); + layout->setStretchFactor(label,0.15); + } + + connect(spinBox, SIGNAL(valueChanged(int)), slider, SLOT(setValue(int))); + connect(slider, SIGNAL(valueChanged(int)), spinBox, SLOT(setValue(int))); + + connect(slider, SIGNAL(valueChanged(int)), this, SLOT(valueWillChange(int))); + connect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(valueWillChangeFromSpinBox(int))); + + connect(slider, SIGNAL(sliderReleased()), this, SLOT(sliderRelease())); + + setLayout(layout); +} +void YACReaderSpinSliderWidget::valueWillChange(int v) +{ + if(tracking) + emit valueChanged(spinBox->value()); +} + +void YACReaderSpinSliderWidget::valueWillChangeFromSpinBox(int v) +{ + if(!tracking && !slider->isSliderDown()) + emit valueChanged(spinBox->value()); +} + +void YACReaderSpinSliderWidget::sliderRelease() +{ + if(!tracking) + emit valueChanged(spinBox->value()); +} + +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) +{ + disconnect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(valueWillChange(int))); + spinBox->setValue(value); + connect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(valueWillChange(int))); +} + +void YACReaderSpinSliderWidget::setText(const QString & text) +{ + label->setText(text); +} + +int YACReaderSpinSliderWidget::getValue() +{ + return spinBox->value(); +} + +QSize YACReaderSpinSliderWidget::minimumSizeHint() const +{ + return QSize(270, 25); +} + +void YACReaderSpinSliderWidget::setTracking(bool b) +{ + tracking = b; + //slider->setTracking(b); +} diff --git a/custom_widgets/yacreader_spin_slider_widget.h b/custom_widgets/yacreader_spin_slider_widget.h new file mode 100644 index 00000000..8be271b0 --- /dev/null +++ b/custom_widgets/yacreader_spin_slider_widget.h @@ -0,0 +1,35 @@ +#ifndef YACREADER_SPIN_SLIDER_WIDGET_H +#define YACREADER_SPIN_SLIDER_WIDGET_H + +#include + +class QLabel; +class QSpinBox; +class QSlider; + +class YACReaderSpinSliderWidget : public QWidget +{ + Q_OBJECT +private: + QLabel * label; + QSpinBox * spinBox; + QSlider * slider; + bool tracking; +public: + YACReaderSpinSliderWidget(QWidget * parent = 0,bool strechableSlider = false); +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; + void setTracking(bool b); + void valueWillChange(int); + void valueWillChangeFromSpinBox(int); + void sliderRelease(); +signals: + void valueChanged(int); + +}; + +#endif // YACREADER_SPIN_SLIDER_WIDGET_H \ No newline at end of file diff --git a/custom_widgets/yacreader_tool_bar_stretch.cpp b/custom_widgets/yacreader_tool_bar_stretch.cpp new file mode 100644 index 00000000..e69de29b diff --git a/custom_widgets/yacreader_tool_bar_stretch.h b/custom_widgets/yacreader_tool_bar_stretch.h new file mode 100644 index 00000000..bcfa5df3 --- /dev/null +++ b/custom_widgets/yacreader_tool_bar_stretch.h @@ -0,0 +1,19 @@ +#ifndef YACREADER_TOOL_BAR_STRETCH_H +#define YACREADER_TOOL_BAR_STRETCH_H + +#include + +class QHBoxLayout; + +class QToolBarStretch : public QWidget +{ +public: + QToolBarStretch(QWidget * parent=0):QWidget(parent) + { + QHBoxLayout * l= new QHBoxLayout(); + l->addStretch(); + setLayout(l); + } +}; + +#endif // YACREADER_TOOL_BAR_STRETCH_H \ No newline at end of file