mirror of
https://github.com/YACReader/yacreader
synced 2025-07-19 05:24:57 -04:00
a?adido nuevo widget que sustituye al combo box de las bibliotecas
This commit is contained in:
@ -101,5 +101,8 @@
|
||||
<file>../images/collapsed_branch_osx.png</file>
|
||||
<file>../images/expanded_branch_osx.png</file>
|
||||
<file>../images/folder_macosx.png</file>
|
||||
<file>../images/libraryIcon.png</file>
|
||||
<file>../images/libraryIconSelected.png</file>
|
||||
<file>../images/libraryOptions.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include "yacreader_sidebar.h"
|
||||
|
||||
#include "comics_remover.h"
|
||||
#include "yacreader_library_list_widget.h"
|
||||
|
||||
//#include "yacreader_social_dialog.h"
|
||||
//
|
||||
@ -188,7 +189,8 @@ void LibraryWindow::doLayout()
|
||||
#endif
|
||||
sideBar = new YACReaderSideBar;
|
||||
QVBoxLayout * l = new QVBoxLayout;
|
||||
selectedLibrary = new QComboBox;
|
||||
selectedLibrary = new YACReaderLibraryListWidget;
|
||||
selectedLibrary->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
selectedLibrary->setAttribute(Qt::WA_MacShowFocusRect,false);
|
||||
selectedLibrary->setFocusPolicy(Qt::NoFocus);
|
||||
l->setContentsMargins(sHorizontal->handleWidth(),0,0,0);
|
||||
@ -351,17 +353,17 @@ void LibraryWindow::createActions()
|
||||
importLibraryAction->setToolTip(tr("Unpack a catalog"));
|
||||
importLibraryAction->setIcon(QIcon(":/images/importLibrary.png"));
|
||||
|
||||
updateLibraryAction = new QAction(this);
|
||||
updateLibraryAction = new QAction(tr("Update library"),this);
|
||||
updateLibraryAction->setToolTip(tr("Update current library"));
|
||||
updateLibraryAction->setShortcut(Qt::Key_U);
|
||||
updateLibraryAction->setIcon(QIcon(":/images/updateLibrary.png"));
|
||||
|
||||
renameLibraryAction = new QAction(this);
|
||||
renameLibraryAction = new QAction(tr("Rename library"),this);
|
||||
renameLibraryAction->setToolTip(tr("Rename current library"));
|
||||
renameLibraryAction->setShortcut(Qt::Key_R);
|
||||
renameLibraryAction->setIcon(QIcon(":/images/edit.png"));
|
||||
|
||||
removeLibraryAction = new QAction(this);
|
||||
removeLibraryAction = new QAction(tr("Remove library"),this);
|
||||
removeLibraryAction->setToolTip(tr("Remove current library from your collection"));
|
||||
removeLibraryAction->setIcon(QIcon(":/images/removeLibrary.png"));
|
||||
|
||||
@ -617,6 +619,30 @@ void LibraryWindow::createMenus()
|
||||
{
|
||||
comicView->addAction(openContainingFolderComicAction);
|
||||
foldersView->addAction(openContainingFolderAction);
|
||||
|
||||
selectedLibrary->addAction(updateLibraryAction);
|
||||
selectedLibrary->addAction(renameLibraryAction);
|
||||
selectedLibrary->addAction(removeLibraryAction);
|
||||
|
||||
{
|
||||
QAction *act = new QAction(this);
|
||||
act->setSeparator(true);
|
||||
selectedLibrary->addAction(act);
|
||||
}
|
||||
|
||||
selectedLibrary->addAction(exportComicsInfo);
|
||||
selectedLibrary->addAction(importComicsInfo);
|
||||
|
||||
{
|
||||
QAction *act = new QAction(this);
|
||||
act->setSeparator(true);
|
||||
selectedLibrary->addAction(act);
|
||||
}
|
||||
|
||||
selectedLibrary->addAction(exportLibraryAction);
|
||||
selectedLibrary->addAction(importLibraryAction);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void LibraryWindow::createConnections()
|
||||
|
@ -45,6 +45,7 @@ class QSettings;
|
||||
class LibraryItem;
|
||||
class YACReaderTableView;
|
||||
class YACReaderSideBar;
|
||||
class YACReaderLibraryListWidget;
|
||||
#include "comic_db.h"
|
||||
|
||||
class LibraryWindow : public QMainWindow
|
||||
@ -87,7 +88,7 @@ private:
|
||||
QWidget *comics;
|
||||
YACReaderTableView * comicView;
|
||||
QTreeView * foldersView;
|
||||
QComboBox * selectedLibrary;
|
||||
YACReaderLibraryListWidget * selectedLibrary;
|
||||
TreeModel * dm;
|
||||
QItemSelectionModel * sm;
|
||||
TableModel * dmCV;
|
||||
|
@ -16,7 +16,9 @@ HEADERS += $$PWD/help_about_dialog.h \
|
||||
$$PWD/yacreader_deleting_progress.h \
|
||||
$$PWD/yacreader_table_view.h \
|
||||
$$PWD/yacreader_social_dialog.h \
|
||||
$$PWD/yacreader_sidebar.h
|
||||
$$PWD/yacreader_sidebar.h \
|
||||
$$PWD/yacreader_library_list_widget.h \
|
||||
$$PWD/yacreader_library_item_widget.h \
|
||||
|
||||
|
||||
SOURCES += $$PWD/help_about_dialog.cpp \
|
||||
@ -34,4 +36,6 @@ SOURCES += $$PWD/help_about_dialog.cpp \
|
||||
$$PWD/yacreader_deleting_progress.cpp \
|
||||
$$PWD/yacreader_table_view.cpp \
|
||||
$$PWD/yacreader_social_dialog.cpp \
|
||||
$$PWD/yacreader_sidebar.cpp
|
||||
$$PWD/yacreader_sidebar.cpp \
|
||||
$$PWD/yacreader_library_list_widget.cpp \
|
||||
$$PWD/yacreader_library_item_widget.cpp \
|
137
custom_widgets/yacreader_library_item_widget.cpp
Normal file
137
custom_widgets/yacreader_library_item_widget.cpp
Normal file
@ -0,0 +1,137 @@
|
||||
#include "yacreader_library_item_widget.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QToolButton>
|
||||
#include <QMouseEvent>
|
||||
|
||||
YACReaderLibraryItemWidget::YACReaderLibraryItemWidget(QString n/*ame*/, QString p/*ath*/, QWidget *parent) :
|
||||
QWidget(parent),name(n),path(p),isSelected(false)
|
||||
{
|
||||
QHBoxLayout * mainLayout = new QHBoxLayout;
|
||||
mainLayout->setMargin(0);
|
||||
mainLayout->setSpacing(0);
|
||||
|
||||
//installEventFilter(this);
|
||||
|
||||
QPixmap iconPixmap(":/images/libraryIcon.png");
|
||||
icon = new QLabel(this);
|
||||
icon->setAutoFillBackground(true);
|
||||
icon->setPixmap(iconPixmap);
|
||||
nameLabel = new QLabel(name,this);
|
||||
|
||||
options = new QToolButton(this);
|
||||
options->setIcon(QIcon(":/images/libraryOptions.png"));
|
||||
options->setHidden(true);
|
||||
options->setFixedWidth(18);
|
||||
options->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Minimum);
|
||||
options->setStyleSheet("QToolButton {border:none;}");
|
||||
/*up = new QToolButton(this);
|
||||
up->setIcon(QIcon(":/images/libraryUp.png"));
|
||||
up->setHidden(true);
|
||||
up->setFixedWidth(18);
|
||||
up->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Minimum);
|
||||
|
||||
down = new QToolButton(this);
|
||||
down->setIcon(QIcon(":/images/libraryDown.png"));
|
||||
down->setHidden(true);
|
||||
down->setFixedWidth(18);
|
||||
down->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Minimum);*/
|
||||
|
||||
|
||||
mainLayout->addWidget(icon);
|
||||
mainLayout->addWidget(nameLabel,Qt::AlignLeft);
|
||||
mainLayout->addStretch();
|
||||
mainLayout->addWidget(options);
|
||||
/*mainLayout->addWidget(up);
|
||||
mainLayout->addWidget(down);*/
|
||||
|
||||
setLayout(mainLayout);
|
||||
|
||||
//QString styleSheet = " background-color:#454545; border-top: 1px solid #454545;border-bottom: 1px solid #454545;";
|
||||
//setStyleSheet(styleSheet);
|
||||
|
||||
|
||||
QString iconStyleSheet = "QLabel {padding:0 0 0 24px; margin:0px}";
|
||||
icon->setStyleSheet(iconStyleSheet);
|
||||
|
||||
QString nameLabelStyleSheet = "QLabel {padding:0 0 0 3px; margin:0px;}";
|
||||
nameLabel->setStyleSheet(nameLabelStyleSheet);
|
||||
|
||||
setMinimumHeight(20);
|
||||
}
|
||||
|
||||
void YACReaderLibraryItemWidget::showUpDownButtons(bool show)
|
||||
{
|
||||
up->setHidden(!show);
|
||||
down->setHidden(!show);
|
||||
}
|
||||
|
||||
/*
|
||||
bool YACReaderLibraryItemWidget::eventFilter(QObject *object, QEvent *event){
|
||||
if(!isSelected && object==this && (event->type()==QEvent::Enter))
|
||||
{
|
||||
QString styleSheet = "background-color:#5E5E5E; border-top: 1px solid #5E5E5E;border-bottom: 1px solid #5E5E5E; ";
|
||||
setStyleSheet(styleSheet);
|
||||
|
||||
up->setHidden(false);
|
||||
down->setHidden(false);
|
||||
options->setHidden(false);
|
||||
|
||||
return true;
|
||||
}
|
||||
if(!isSelected && object==this && (event->type()==QEvent::Leave))
|
||||
{
|
||||
QString styleSheet = "background-color:#454545; border-top: 1px solid #454545;border-bottom: 1px solid #454545;";
|
||||
setStyleSheet(styleSheet);
|
||||
|
||||
up->setHidden(true);
|
||||
down->setHidden(true);
|
||||
options->setHidden(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if(object==this && (event->type()==QEvent::MouseButtonRelease))
|
||||
{
|
||||
QString styleSheet = "background-color:#2E2E2E; border-top: 1px solid #1F1F1F;border-bottom: 1px solid #636363; padding-top:1px; padding-bottom:1px;";
|
||||
setStyleSheet(styleSheet);
|
||||
emit(selected(name,path));
|
||||
isSelected = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
void YACReaderLibraryItemWidget::deselect()
|
||||
{
|
||||
QString styleSheet = "background-color:transparent;";
|
||||
setStyleSheet(styleSheet);
|
||||
|
||||
QPixmap iconPixmap(":/images/libraryIcon.png");
|
||||
icon->setPixmap(iconPixmap);
|
||||
|
||||
/*up->setHidden(true);
|
||||
down->setHidden(true);*/
|
||||
options->setHidden(true);
|
||||
|
||||
isSelected = false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void YACReaderLibraryItemWidget::select()
|
||||
{
|
||||
QString styleSheet = "color: white; background-color:#BBBBBB; font-weight:bold;";
|
||||
setStyleSheet(styleSheet);
|
||||
|
||||
options->setHidden(false);
|
||||
|
||||
QPixmap iconPixmap(":/images/libraryIconSelected.png");
|
||||
icon->setPixmap(iconPixmap);
|
||||
|
||||
isSelected = true;
|
||||
}
|
42
custom_widgets/yacreader_library_item_widget.h
Normal file
42
custom_widgets/yacreader_library_item_widget.h
Normal file
@ -0,0 +1,42 @@
|
||||
#ifndef YACREADER_LIBRARY_ITEM_WIDGET_H
|
||||
#define YACREADER_LIBRARY_ITEM_WIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QLabel;
|
||||
class QToolButton;
|
||||
class QMouseEvent;
|
||||
class QEvent;
|
||||
|
||||
class YACReaderLibraryItemWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
YACReaderLibraryItemWidget(QString name, QString path, QWidget *parent = 0);
|
||||
QString name;
|
||||
QString path;
|
||||
|
||||
signals:
|
||||
void selected(QString,QString);
|
||||
public slots:
|
||||
void showUpDownButtons(bool show);
|
||||
|
||||
//bool eventFilter(QObject *object, QEvent *event);
|
||||
void select();
|
||||
void deselect();
|
||||
|
||||
private:
|
||||
|
||||
QLabel * icon;
|
||||
QLabel * nameLabel;
|
||||
|
||||
QToolButton * options;
|
||||
QToolButton * up;
|
||||
QToolButton * down;
|
||||
|
||||
bool isSelected;
|
||||
|
||||
};
|
||||
|
||||
#endif // YACREADER_LIBRARY_ITEM_WIDGET_H
|
97
custom_widgets/yacreader_library_list_widget.cpp
Normal file
97
custom_widgets/yacreader_library_list_widget.cpp
Normal file
@ -0,0 +1,97 @@
|
||||
#include "yacreader_library_list_widget.h"
|
||||
|
||||
#include "yacreader_library_item_widget.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QMouseEvent>
|
||||
|
||||
YACReaderLibraryListWidget::YACReaderLibraryListWidget(QWidget *parent) :
|
||||
QWidget(parent),currentLibraryIndex(0)
|
||||
{
|
||||
QVBoxLayout * mainLayout = new QVBoxLayout;
|
||||
mainLayout->setSpacing(0);
|
||||
mainLayout->setMargin(0);
|
||||
|
||||
this->setLayout(mainLayout);
|
||||
}
|
||||
|
||||
void YACReaderLibraryListWidget::addItem(QString name, QString path)
|
||||
{
|
||||
QVBoxLayout * mainLayout = dynamic_cast<QVBoxLayout *>(layout());
|
||||
|
||||
YACReaderLibraryItemWidget * library = new YACReaderLibraryItemWidget(name,path,this);
|
||||
librariesList.append(library);
|
||||
|
||||
connect(library,SIGNAL(selected(QString,QString)),this,SIGNAL(librarySelected(QString,QString)));
|
||||
connect(library,SIGNAL(selected(QString,QString)),this,SLOT(updateLibraries(QString,QString)));
|
||||
|
||||
mainLayout->addWidget(library);
|
||||
|
||||
//first item added
|
||||
if(librariesList.count()==1)
|
||||
{
|
||||
library->select();
|
||||
emit currentIndexChanged(name);
|
||||
}
|
||||
}
|
||||
|
||||
QString YACReaderLibraryListWidget::currentText()
|
||||
{
|
||||
return librariesList.at(currentLibraryIndex)->name;
|
||||
}
|
||||
int YACReaderLibraryListWidget::findText(QString text)
|
||||
{
|
||||
for(int i=0;i<librariesList.count();i++)
|
||||
{
|
||||
if(librariesList.at(i)->name == text)
|
||||
return i;
|
||||
}
|
||||
}
|
||||
void YACReaderLibraryListWidget::setCurrentIndex(int index)
|
||||
{
|
||||
if(index>=0 && index < librariesList.count())
|
||||
{
|
||||
librariesList.at(index)->select();
|
||||
currentLibraryIndex = index;
|
||||
deselectAllBut(index);
|
||||
}
|
||||
}
|
||||
|
||||
int YACReaderLibraryListWidget::currentIndex()
|
||||
{
|
||||
return currentLibraryIndex;
|
||||
}
|
||||
void YACReaderLibraryListWidget::removeItem(int index)
|
||||
{
|
||||
YACReaderLibraryItemWidget * itemWidget = librariesList.at(index);
|
||||
this->layout()->removeWidget(itemWidget);
|
||||
librariesList.removeAt(index);
|
||||
if(librariesList.count()>0)
|
||||
{
|
||||
setCurrentIndex(0);
|
||||
emit currentIndexChanged(librariesList.at(0)->name);
|
||||
}
|
||||
delete itemWidget;
|
||||
}
|
||||
|
||||
void YACReaderLibraryListWidget::mousePressEvent ( QMouseEvent * event )
|
||||
{
|
||||
if(librariesList.count()>0)
|
||||
{
|
||||
int h = librariesList.at(0)->height();
|
||||
int item = event->pos().y() / h;
|
||||
//deselectAllBut(item);
|
||||
setCurrentIndex(item);
|
||||
emit currentIndexChanged(librariesList.at(item)->name);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void YACReaderLibraryListWidget::deselectAllBut(int index)
|
||||
{
|
||||
for(int i=0;i<librariesList.count();i++)
|
||||
{
|
||||
if(i!=index)
|
||||
librariesList.at(i)->deselect();
|
||||
}
|
||||
}
|
35
custom_widgets/yacreader_library_list_widget.h
Normal file
35
custom_widgets/yacreader_library_list_widget.h
Normal file
@ -0,0 +1,35 @@
|
||||
#ifndef YACREADER_LIBRARY_LIST_WIDGET_H
|
||||
#define YACREADER_LIBRARY_LIST_WIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class YACReaderLibraryItemWidget;
|
||||
class QMouseEvent;
|
||||
|
||||
class YACReaderLibraryListWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit YACReaderLibraryListWidget(QWidget *parent = 0);
|
||||
|
||||
signals:
|
||||
void currentIndexChanged(QString text);
|
||||
|
||||
public slots:
|
||||
QString currentText();
|
||||
int findText(QString text);
|
||||
void setCurrentIndex(int index);
|
||||
void addItem(QString name, QString path);
|
||||
int currentIndex();
|
||||
void removeItem(int index);
|
||||
protected:
|
||||
void mousePressEvent ( QMouseEvent * event );
|
||||
private:
|
||||
int currentLibraryIndex;
|
||||
QList < YACReaderLibraryItemWidget* > librariesList;
|
||||
void deselectAllBut(int index);
|
||||
|
||||
};
|
||||
|
||||
#endif // YACREADER_LIBRARY_LIST_WIDGET_H
|
||||
|
@ -12,10 +12,13 @@ YACReaderSideBar::YACReaderSideBar(QWidget *parent) :
|
||||
|
||||
void YACReaderSideBar::paintEvent(QPaintEvent * event)
|
||||
{
|
||||
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
QPainter painter(this);
|
||||
|
||||
|
||||
QLinearGradient lG(0,0,0,height());
|
||||
|
||||
lG.setColorAt(0,QColor("#E8ECF1"));
|
||||
lG.setColorAt(1,QColor("#D1D8E0"));
|
||||
|
||||
@ -24,6 +27,8 @@ void YACReaderSideBar::paintEvent(QPaintEvent * event)
|
||||
QWidget::paintEvent(event);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//QPixmap shadow(":/images/side_bar/shadow.png");
|
||||
//painter.drawPixmap(width()-shadow.width(),0,shadow.width(),height(),shadow);
|
||||
|
||||
|
BIN
images/libraryIcon.png
Normal file
BIN
images/libraryIcon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 164 B |
BIN
images/libraryIconSelected.png
Normal file
BIN
images/libraryIconSelected.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 152 B |
BIN
images/libraryOptions.png
Normal file
BIN
images/libraryOptions.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 206 B |
Reference in New Issue
Block a user