From 1763b16ccd4dd1ac5d6d8c15877c20e1a91e3634 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Wed, 21 Aug 2013 13:26:49 +0200 Subject: [PATCH] added drag&drop for image files --- CHANGELOG.txt | 2 ++ YACReader/comic.cpp | 2 -- YACReader/comic.h | 3 +- YACReader/main_window_viewer.cpp | 44 +++++++++++++++++++++++-- YACReader/main_window_viewer.h | 1 + custom_widgets/yacreader_table_view.cpp | 2 +- 6 files changed, 47 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 86988ae8..f4b79e3b 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -3,6 +3,8 @@ Corregido bug que causaba un cierre inesperado despu Corregido bug que causaba que la toolbar en el visor no se pudiese ocultar/mostrar sin un cómic abierto Mejorada la gestión de errores al abrir cómics Corregidos algunos bugs relacionados con la apertura de cómics +Añadido función de rating +El visor ahora puede abrir archivos de imagen directamente. Si se abre un archivo de imagen se abre el directorio que lo contiene con todas las imágenes. 6.7 (No pública) Añadidos nuevos campos en la base de datos para almacenar información adicional sobre cómics: rating, página actual, bookmarks y configuración de imagen diff --git a/YACReader/comic.cpp b/YACReader/comic.cpp index 203c5012..a3e69b2b 100644 --- a/YACReader/comic.cpp +++ b/YACReader/comic.cpp @@ -11,8 +11,6 @@ #include "compressed_archive.h" #include "comic_db.h" -#define EXTENSIONS << "*.jpg" << "*.jpeg" << "*.png" << "*.gif" << "*.tiff" << "*.tif" << "*.bmp" -#define EXTENSIONS_LITERAL << ".jpg" << ".jpeg" << ".png" << ".gif" << ".tiff" << ".tif" << ".bmp" //----------------------------------------------------------------------------- Comic::Comic() :_pages(),_index(0),_path(),_loaded(false),bm(new Bookmarks()),_loadedPages(),_isPDF(false) diff --git a/YACReader/comic.h b/YACReader/comic.h index e231c459..ce4e449c 100644 --- a/YACReader/comic.h +++ b/YACReader/comic.h @@ -13,7 +13,8 @@ #include "poppler-qt4.h" class ComicDB; - +#define EXTENSIONS << "*.jpg" << "*.jpeg" << "*.png" << "*.gif" << "*.tiff" << "*.tif" << "*.bmp" +#define EXTENSIONS_LITERAL << ".jpg" << ".jpeg" << ".png" << ".gif" << ".tiff" << ".tif" << ".bmp" class Comic : public QObject { Q_OBJECT diff --git a/YACReader/main_window_viewer.cpp b/YACReader/main_window_viewer.cpp index b1b5e4c5..4ea06733 100644 --- a/YACReader/main_window_viewer.cpp +++ b/YACReader/main_window_viewer.cpp @@ -657,7 +657,38 @@ void MainWindowViewer::openFolderFromPath(QString pathDir) enableActions(); viewer->open(pathDir); - +} + +void MainWindowViewer::openFolderFromPath(QString pathDir, QString atFileName) +{ + currentDirectory = pathDir; //TODO ?? + QFileInfo fi(pathDir); + getSiblingComics(fi.absolutePath(),fi.fileName()); + + setWindowTitle("YACReader - " + fi.fileName()); + + enableActions(); + + QDir d(pathDir); + d.setFilter(QDir::Files|QDir::NoDotAndDotDot); + d.setNameFilters(QStringList() EXTENSIONS); + d.setSorting(QDir::Name|QDir::IgnoreCase|QDir::LocaleAware); + QStringList list = d.entryList(); + + qSort(list.begin(),list.end(),naturalSortLessThanCI); + int i = 0; + foreach(QString path,list) + { + if(path.endsWith(atFileName)) + break; + i++; + } + + int index = 0; + if(i < list.count()) + index = i; + + viewer->open(pathDir,i); } void MainWindowViewer::saveImage() @@ -977,12 +1008,19 @@ void MainWindowViewer::dropEvent(QDropEvent *event) { urlList = event->mimeData()->urls(); - if ( urlList.size() > 0) + if ( urlList.size() > 0 ) { fName = urlList[0].toLocalFile(); // convert first QUrl to local path info.setFile( fName ); // information about file if (info.isFile()) - openComicFromPath(fName); // if is file, setText + { + QStringList imageSuffixs; + imageSuffixs EXTENSIONS_LITERAL; + if(imageSuffixs.contains("."+info.suffix())) //image dropped + openFolderFromPath(info.absoluteDir().absolutePath(),info.fileName()); + else + openComicFromPath(fName); // if is file, setText + } else if(info.isDir()) openFolderFromPath(fName); diff --git a/YACReader/main_window_viewer.h b/YACReader/main_window_viewer.h index 2d0185fd..0c3ec9f6 100644 --- a/YACReader/main_window_viewer.h +++ b/YACReader/main_window_viewer.h @@ -43,6 +43,7 @@ class YACReaderSliderAction; void openNextComic(); void openComicFromPath(QString pathFile); void openFolderFromPath(QString pathDir); + void openFolderFromPath(QString pathFile, QString atFileName); void alwaysOnTopSwitch(); void adjustToFullSizeSwitch(); void reloadOptions(); diff --git a/custom_widgets/yacreader_table_view.cpp b/custom_widgets/yacreader_table_view.cpp index 0ec8101a..05e84684 100644 --- a/custom_widgets/yacreader_table_view.cpp +++ b/custom_widgets/yacreader_table_view.cpp @@ -130,7 +130,7 @@ void YACReaderRatingDelegate::paint(QPainter *painter, const QStyleOptionViewIte QStyledItemDelegate::paint(painter, option, index); - if(option.state | QStyle::State_Editing) + if(!(option.state & QStyle::State_Editing)) { if (option.state & QStyle::State_Selected) starRating.paintSelected(painter, option.rect, option.palette,