diff --git a/YACReaderLibrary/images.qrc b/YACReaderLibrary/images.qrc
index 084c020b..5bb0e507 100644
--- a/YACReaderLibrary/images.qrc
+++ b/YACReaderLibrary/images.qrc
@@ -101,5 +101,8 @@
../images/collapsed_branch_osx.png
../images/expanded_branch_osx.png
../images/folder_macosx.png
+ ../images/libraryIcon.png
+ ../images/libraryIconSelected.png
+ ../images/libraryOptions.png
diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp
index 1c896b20..668b8945 100644
--- a/YACReaderLibrary/library_window.cpp
+++ b/YACReaderLibrary/library_window.cpp
@@ -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()
diff --git a/YACReaderLibrary/library_window.h b/YACReaderLibrary/library_window.h
index 6a99db17..2274306c 100644
--- a/YACReaderLibrary/library_window.h
+++ b/YACReaderLibrary/library_window.h
@@ -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;
diff --git a/custom_widgets/custom_widgets.pri b/custom_widgets/custom_widgets.pri
index a70d81ce..86d7aafa 100644
--- a/custom_widgets/custom_widgets.pri
+++ b/custom_widgets/custom_widgets.pri
@@ -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
\ No newline at end of file
+ $$PWD/yacreader_sidebar.cpp \
+ $$PWD/yacreader_library_list_widget.cpp \
+ $$PWD/yacreader_library_item_widget.cpp \
\ No newline at end of file
diff --git a/custom_widgets/yacreader_library_item_widget.cpp b/custom_widgets/yacreader_library_item_widget.cpp
new file mode 100644
index 00000000..a93e31fe
--- /dev/null
+++ b/custom_widgets/yacreader_library_item_widget.cpp
@@ -0,0 +1,137 @@
+#include "yacreader_library_item_widget.h"
+
+#include
+#include
+#include
+#include
+
+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;
+}
\ No newline at end of file
diff --git a/custom_widgets/yacreader_library_item_widget.h b/custom_widgets/yacreader_library_item_widget.h
new file mode 100644
index 00000000..eee15a13
--- /dev/null
+++ b/custom_widgets/yacreader_library_item_widget.h
@@ -0,0 +1,42 @@
+#ifndef YACREADER_LIBRARY_ITEM_WIDGET_H
+#define YACREADER_LIBRARY_ITEM_WIDGET_H
+
+#include
+
+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
diff --git a/custom_widgets/yacreader_library_list_widget.cpp b/custom_widgets/yacreader_library_list_widget.cpp
new file mode 100644
index 00000000..2ad0f7ed
--- /dev/null
+++ b/custom_widgets/yacreader_library_list_widget.cpp
@@ -0,0 +1,97 @@
+#include "yacreader_library_list_widget.h"
+
+#include "yacreader_library_item_widget.h"
+#include
+#include
+
+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(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;iname == 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;ideselect();
+ }
+}
\ No newline at end of file
diff --git a/custom_widgets/yacreader_library_list_widget.h b/custom_widgets/yacreader_library_list_widget.h
new file mode 100644
index 00000000..550cc8c5
--- /dev/null
+++ b/custom_widgets/yacreader_library_list_widget.h
@@ -0,0 +1,35 @@
+#ifndef YACREADER_LIBRARY_LIST_WIDGET_H
+#define YACREADER_LIBRARY_LIST_WIDGET_H
+
+#include
+
+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
+
diff --git a/custom_widgets/yacreader_sidebar.cpp b/custom_widgets/yacreader_sidebar.cpp
index d741384c..1cbc0973 100644
--- a/custom_widgets/yacreader_sidebar.cpp
+++ b/custom_widgets/yacreader_sidebar.cpp
@@ -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);
diff --git a/images/libraryIcon.png b/images/libraryIcon.png
new file mode 100644
index 00000000..d2cc7112
Binary files /dev/null and b/images/libraryIcon.png differ
diff --git a/images/libraryIconSelected.png b/images/libraryIconSelected.png
new file mode 100644
index 00000000..ecd31b01
Binary files /dev/null and b/images/libraryIconSelected.png differ
diff --git a/images/libraryOptions.png b/images/libraryOptions.png
new file mode 100644
index 00000000..761b5826
Binary files /dev/null and b/images/libraryOptions.png differ