mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
estilo de la sidebar en windows y linux actualizado
movido c?digo espec?fico a las clases sidebar y yacreadertreeview
This commit is contained in:
parent
ebdb21f5a2
commit
49da26e2bc
@ -108,5 +108,7 @@
|
||||
<file>../images/branch-closed.png</file>
|
||||
<file>../images/expanded_branch_selected.png</file>
|
||||
<file>../images/collapsed_branch_selected.png</file>
|
||||
<file>../images/newLibraryIcon.png</file>
|
||||
<file>../images/openLibraryIcon.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -54,12 +54,13 @@
|
||||
|
||||
#include "comics_remover.h"
|
||||
#include "yacreader_library_list_widget.h"
|
||||
#include "yacreader_treeview.h"
|
||||
|
||||
//#include "yacreader_social_dialog.h"
|
||||
//
|
||||
|
||||
LibraryWindow::LibraryWindow()
|
||||
:QMainWindow(),fullscreen(false),fetching(false)
|
||||
:QMainWindow(),fullscreen(false),fetching(false),previousFilter("")
|
||||
{
|
||||
setupUI();
|
||||
loadLibraries();
|
||||
@ -177,82 +178,23 @@ void LibraryWindow::doLayout()
|
||||
|
||||
//SIDEBAR-----------------------------------------------------------------------
|
||||
//---------------------------------------------------------------------------
|
||||
foldersView = new QTreeView;
|
||||
foldersView->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
foldersView->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
foldersView->header()->hide();
|
||||
foldersView->setUniformRowHeights(true);
|
||||
foldersView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
foldersView->setAttribute(Qt::WA_MacShowFocusRect,false);
|
||||
#ifdef Q_OS_MAC
|
||||
foldersView->setStyleSheet("QTreeView {background-color:transparent; border: none;}"
|
||||
"QTreeView::item:selected {background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6BAFE4, stop: 1 #3984D2); border-top: 2px solid qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #5EA3DF, stop: 1 #73B8EA); border-left:none;border-right:none;border-bottom:1px solid #3577C2;}"
|
||||
"QTreeView::branch:selected {background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6BAFE4, stop: 1 #3984D2); border-top: 2px solid qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #5EA3DF, stop: 1 #73B8EA); border-left:none;border-right:none;border-bottom:1px solid #3577C2;}"
|
||||
"QTreeView::branch:open:selected:has-children {image: url(':/images/expanded_branch_osx.png');}"
|
||||
"QTreeView::branch:closed:selected:has-children {image: url(':/images/collapsed_branch_osx.png');}");
|
||||
#else
|
||||
foldersView->setStyleSheet("QTreeView {background-color:transparent; border: none; color:#DDDFDF; outline:0;}"
|
||||
"QTreeView::item:selected {background-color: #2E2E2E; color:white; font:bold;}"
|
||||
"QTreeView::item:hover {background-color:#2E2E2E; color:white; font:bold;}"
|
||||
"QTreeView::branch:selected {background-color:#2E2E2E;}"
|
||||
|
||||
|
||||
"QScrollBar:vertical { border: none; background: #222222; width: 7px; margin: 0 3px 0 0; }"
|
||||
"QScrollBar::handle:vertical { background: #DDDDDD; width: 7px; min-height: 20px; }"
|
||||
"QScrollBar::add-line:vertical { border: none; background: #222222; height: 10px; subcontrol-position: bottom; subcontrol-origin: margin; margin: 0 3px 0 0;}"
|
||||
|
||||
"QScrollBar::sub-line:vertical { border: none; background: #222222; height: 10px; subcontrol-position: top; subcontrol-origin: margin; margin: 0 3px 0 0;}"
|
||||
"QScrollBar::up-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-up.png') center top no-repeat;}"
|
||||
"QScrollBar::down-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-down.png') center top no-repeat;}"
|
||||
|
||||
"QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {background: none; }"
|
||||
|
||||
"QTreeView::branch:has-children:!has-siblings:closed,QTreeView::branch:closed:has-children:has-siblings {border-image: none;image: url(':/images/branch-closed.png');}"
|
||||
"QTreeView::branch:has-children:selected:!has-siblings:closed,QTreeView::branch:closed:selected:has-children:has-siblings {border-image: none;image: url(':/images/collapsed_branch_selected.png');}"
|
||||
|
||||
"QTreeView::branch:open:has-children:!has-siblings,QTreeView::branch:open:has-children:has-siblings {border-image: none;image: url(':/images/branch-open.png');}"
|
||||
"QTreeView::branch:open:has-children:selected:!has-siblings,QTreeView::branch:open:has-children:selected:has-siblings {border-image: none;image: url(':/images/expanded_branch_selected.png');}"
|
||||
|
||||
|
||||
);
|
||||
#endif
|
||||
sideBar = new YACReaderSideBar;
|
||||
QVBoxLayout * l = new QVBoxLayout;
|
||||
selectedLibrary = new YACReaderLibraryListWidget;
|
||||
selectedLibrary->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
selectedLibrary->setAttribute(Qt::WA_MacShowFocusRect,false);
|
||||
selectedLibrary->setFocusPolicy(Qt::NoFocus);
|
||||
|
||||
l->setContentsMargins(0,0,0,0);
|
||||
foldersView = sideBar->foldersView;
|
||||
selectedLibrary = sideBar->selectedLibrary;
|
||||
foldersFilter = sideBar->foldersFilter;
|
||||
|
||||
YACReaderTitledToolBar * librariesTitle = new YACReaderTitledToolBar(tr("LIBRARIES"));
|
||||
YACReaderTitledToolBar * librariesTitle = sideBar->librariesTitle;
|
||||
|
||||
l->addWidget(librariesTitle);
|
||||
l->addWidget(selectedLibrary);
|
||||
|
||||
YACReaderTitledToolBar * foldersTitle = new YACReaderTitledToolBar(tr("FOLDERS"));
|
||||
YACReaderTitledToolBar * foldersTitle = sideBar->foldersTitle;
|
||||
|
||||
foldersTitle->addAction(setRootIndexAction);
|
||||
librariesTitle->addAction(createLibraryAction);
|
||||
librariesTitle->addAction(openLibraryAction);
|
||||
|
||||
foldersTitle->addAction(setRootIndexAction);
|
||||
foldersTitle->addAction(expandAllNodesAction);
|
||||
foldersTitle->addAction(colapseAllNodesAction);
|
||||
|
||||
l->addWidget(foldersTitle);
|
||||
l->addWidget(foldersView);
|
||||
|
||||
QVBoxLayout * searchLayout = new QVBoxLayout;
|
||||
|
||||
QHBoxLayout * filter = new QHBoxLayout;
|
||||
filter->addWidget(foldersFilter = new YACReaderSearchLineEdit());
|
||||
foldersFilter->setAttribute(Qt::WA_MacShowFocusRect,false);
|
||||
foldersFilter->setPlaceholderText(tr("Search folders and comics"));
|
||||
previousFilter = "";
|
||||
|
||||
searchLayout->addLayout(filter);
|
||||
|
||||
l->addLayout(searchLayout);
|
||||
l->setSpacing(0);
|
||||
sideBar->setLayout(l);
|
||||
|
||||
//FINAL LAYOUT-------------------------------------------------------------
|
||||
sVertical->addWidget(comicFlow);
|
||||
comics = new QWidget;
|
||||
@ -360,12 +302,12 @@ void LibraryWindow::createActions()
|
||||
createLibraryAction = new QAction(this);
|
||||
createLibraryAction->setToolTip(tr("Create a new library"));
|
||||
createLibraryAction->setShortcut(Qt::Key_A);
|
||||
createLibraryAction->setIcon(QIcon(":/images/new.png"));
|
||||
createLibraryAction->setIcon(QIcon(":/images/newLibraryIcon.png"));
|
||||
|
||||
openLibraryAction = new QAction(this);
|
||||
openLibraryAction->setToolTip(tr("Open an existing library"));
|
||||
openLibraryAction->setShortcut(Qt::Key_O);
|
||||
openLibraryAction->setIcon(QIcon(":/images/openLibrary.png"));
|
||||
openLibraryAction->setIcon(QIcon(":/images/openLibraryIcon.png"));
|
||||
|
||||
exportComicsInfo = new QAction(tr("Export comics info"),this);
|
||||
exportComicsInfo->setToolTip(tr("Export comics info"));
|
||||
|
@ -46,6 +46,7 @@ class LibraryItem;
|
||||
class YACReaderTableView;
|
||||
class YACReaderSideBar;
|
||||
class YACReaderLibraryListWidget;
|
||||
class YACReaderTreeView;
|
||||
#include "comic_db.h"
|
||||
|
||||
class LibraryWindow : public QMainWindow
|
||||
@ -87,7 +88,7 @@ private:
|
||||
//-------------
|
||||
QWidget *comics;
|
||||
YACReaderTableView * comicView;
|
||||
QTreeView * foldersView;
|
||||
YACReaderTreeView * foldersView;
|
||||
YACReaderLibraryListWidget * selectedLibrary;
|
||||
TreeModel * dm;
|
||||
QItemSelectionModel * sm;
|
||||
|
@ -19,6 +19,7 @@ HEADERS += $$PWD/help_about_dialog.h \
|
||||
$$PWD/yacreader_sidebar.h \
|
||||
$$PWD/yacreader_library_list_widget.h \
|
||||
$$PWD/yacreader_library_item_widget.h \
|
||||
$$PWD/yacreader_treeview.h \
|
||||
|
||||
|
||||
SOURCES += $$PWD/help_about_dialog.cpp \
|
||||
@ -38,4 +39,5 @@ SOURCES += $$PWD/help_about_dialog.cpp \
|
||||
$$PWD/yacreader_social_dialog.cpp \
|
||||
$$PWD/yacreader_sidebar.cpp \
|
||||
$$PWD/yacreader_library_list_widget.cpp \
|
||||
$$PWD/yacreader_library_item_widget.cpp \
|
||||
$$PWD/yacreader_library_item_widget.cpp \
|
||||
$$PWD/yacreader_treeview.cpp \
|
@ -3,10 +3,91 @@
|
||||
#include <QPainter>
|
||||
#include <QLayout>
|
||||
|
||||
#include "yacreader_treeview.h"
|
||||
#include "yacreader_library_list_widget.h"
|
||||
#include "yacreader_search_line_edit.h"
|
||||
#include "yacreader_titled_toolbar.h"
|
||||
|
||||
YACReaderSideBar::YACReaderSideBar(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Minimum);
|
||||
|
||||
//widgets
|
||||
foldersView = new YACReaderTreeView;
|
||||
selectedLibrary = new YACReaderLibraryListWidget;
|
||||
foldersFilter = new YACReaderSearchLineEdit();
|
||||
|
||||
librariesTitle = new YACReaderTitledToolBar(tr("LIBRARIES"));
|
||||
|
||||
foldersTitle = new YACReaderTitledToolBar(tr("FOLDERS"));
|
||||
|
||||
selectedLibrary->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
selectedLibrary->setAttribute(Qt::WA_MacShowFocusRect,false);
|
||||
selectedLibrary->setFocusPolicy(Qt::NoFocus);
|
||||
|
||||
foldersFilter->setAttribute(Qt::WA_MacShowFocusRect,false);
|
||||
foldersFilter->setPlaceholderText(tr("Search folders and comics"));
|
||||
|
||||
//layout
|
||||
QVBoxLayout * l = new QVBoxLayout;
|
||||
|
||||
l->setContentsMargins(0,0,0,0);
|
||||
#ifndef Q_OS_MAC
|
||||
l->addSpacing(5);
|
||||
#endif
|
||||
|
||||
l->addWidget(librariesTitle);
|
||||
|
||||
#ifndef Q_OS_MAC
|
||||
{QWidget * w = new QWidget();
|
||||
w->setStyleSheet("QWidget {border:none; border-bottom:1px solid #636363;border-top:1px solid #292929;}");
|
||||
w->setMinimumHeight(2);
|
||||
|
||||
l->addSpacing(4);
|
||||
|
||||
l->addWidget(w);}
|
||||
|
||||
l->addSpacing(3);
|
||||
#endif
|
||||
|
||||
l->addWidget(selectedLibrary);
|
||||
|
||||
#ifndef Q_OS_MAC
|
||||
l->addSpacing(6);
|
||||
|
||||
{QWidget * w = new QWidget();
|
||||
w->setStyleSheet("QWidget {border:none; border-bottom:1px solid #636363;border-top:1px solid #292929;}");
|
||||
w->setMinimumHeight(2);
|
||||
|
||||
l->addSpacing(5);
|
||||
|
||||
l->addWidget(w);}
|
||||
|
||||
l->addSpacing(4);
|
||||
#endif
|
||||
|
||||
l->addWidget(foldersTitle);
|
||||
|
||||
#ifndef Q_OS_MAC
|
||||
{QWidget * w = new QWidget();
|
||||
w->setStyleSheet("QWidget {border:none; border-bottom:1px solid #636363;border-top:1px solid #292929;}");
|
||||
w->setMinimumHeight(2);
|
||||
|
||||
l->addSpacing(4);
|
||||
|
||||
l->addWidget(w);}
|
||||
|
||||
|
||||
l->addSpacing(4);
|
||||
#endif
|
||||
|
||||
l->addWidget(foldersView);
|
||||
|
||||
l->addWidget(foldersFilter);
|
||||
|
||||
l->setSpacing(0);
|
||||
setLayout(l);
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,12 +3,24 @@
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class YACReaderTreeView;
|
||||
class YACReaderLibraryListWidget;
|
||||
class YACReaderSearchLineEdit;
|
||||
class YACReaderTitledToolBar;
|
||||
class YACReaderTitledToolBar;
|
||||
|
||||
class YACReaderSideBar : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit YACReaderSideBar(QWidget *parent = 0);
|
||||
QSize sizeHint() const;
|
||||
|
||||
YACReaderTreeView * foldersView;
|
||||
YACReaderLibraryListWidget * selectedLibrary;
|
||||
YACReaderSearchLineEdit * foldersFilter;
|
||||
YACReaderTitledToolBar * librariesTitle;
|
||||
YACReaderTitledToolBar * foldersTitle;
|
||||
|
||||
signals:
|
||||
|
||||
|
46
custom_widgets/yacreader_treeview.cpp
Normal file
46
custom_widgets/yacreader_treeview.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
#include "yacreader_treeview.h"
|
||||
|
||||
#include <QHeaderView>
|
||||
|
||||
YACReaderTreeView::YACReaderTreeView(QWidget *parent) :
|
||||
QTreeView(parent)
|
||||
{
|
||||
setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
header()->hide();
|
||||
setUniformRowHeights(true);
|
||||
setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
setAttribute(Qt::WA_MacShowFocusRect,false);
|
||||
#ifdef Q_OS_MAC
|
||||
setStyleSheet("QTreeView {background-color:transparent; border: none;}"
|
||||
"QTreeView::item:selected {background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6BAFE4, stop: 1 #3984D2); border-top: 2px solid qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #5EA3DF, stop: 1 #73B8EA); border-left:none;border-right:none;border-bottom:1px solid #3577C2;}"
|
||||
"QTreeView::branch:selected {background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6BAFE4, stop: 1 #3984D2); border-top: 2px solid qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #5EA3DF, stop: 1 #73B8EA); border-left:none;border-right:none;border-bottom:1px solid #3577C2;}"
|
||||
"QTreeView::branch:open:selected:has-children {image: url(':/images/expanded_branch_osx.png');}"
|
||||
"QTreeView::branch:closed:selected:has-children {image: url(':/images/collapsed_branch_osx.png');}");
|
||||
#else
|
||||
setStyleSheet("QTreeView {background-color:transparent; border: none; color:#DDDFDF; outline:0; show-decoration-selected: 0;}"
|
||||
"QTreeView::item:selected {background-color: #2E2E2E; color:white; font:bold;}"
|
||||
"QTreeView::item:hover {background-color:#2E2E2E; color:white; font:bold;}"
|
||||
"QTreeView::branch:selected {background-color:#2E2E2E;}"
|
||||
|
||||
|
||||
"QScrollBar:vertical { border: none; background: #404040; width: 7px; margin: 0 3px 0 0; }"
|
||||
"QScrollBar::handle:vertical { background: #DDDDDD; width: 7px; min-height: 20px; }"
|
||||
"QScrollBar::add-line:vertical { border: none; background: #404040; height: 10px; subcontrol-position: bottom; subcontrol-origin: margin; margin: 0 3px 0 0;}"
|
||||
|
||||
"QScrollBar::sub-line:vertical { border: none; background: #404040; height: 10px; subcontrol-position: top; subcontrol-origin: margin; margin: 0 3px 0 0;}"
|
||||
"QScrollBar::up-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-up.png') center top no-repeat;}"
|
||||
"QScrollBar::down-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-down.png') center top no-repeat;}"
|
||||
|
||||
"QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {background: none; }"
|
||||
|
||||
"QTreeView::branch:has-children:!has-siblings:closed,QTreeView::branch:closed:has-children:has-siblings {border-image: none;image: url(':/images/branch-closed.png');}"
|
||||
"QTreeView::branch:has-children:selected:!has-siblings:closed,QTreeView::branch:closed:selected:has-children:has-siblings {border-image: none;image: url(':/images/collapsed_branch_selected.png');}"
|
||||
|
||||
"QTreeView::branch:open:has-children:!has-siblings,QTreeView::branch:open:has-children:has-siblings {border-image: none;image: url(':/images/branch-open.png');}"
|
||||
"QTreeView::branch:open:has-children:selected:!has-siblings,QTreeView::branch:open:has-children:selected:has-siblings {border-image: none;image: url(':/images/expanded_branch_selected.png');}"
|
||||
|
||||
|
||||
);
|
||||
#endif
|
||||
}
|
18
custom_widgets/yacreader_treeview.h
Normal file
18
custom_widgets/yacreader_treeview.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef YACREADER_TREEVIEW_H
|
||||
#define YACREADER_TREEVIEW_H
|
||||
|
||||
#include <QTreeView>
|
||||
|
||||
class YACReaderTreeView : public QTreeView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit YACReaderTreeView(QWidget *parent = 0);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
};
|
||||
|
||||
#endif // YACREADER_TREEVIEW_H
|
BIN
images/newLibraryIcon.png
Normal file
BIN
images/newLibraryIcon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 212 B |
BIN
images/openLibraryIcon.png
Normal file
BIN
images/openLibraryIcon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 298 B |
Loading…
Reference in New Issue
Block a user