Move category tab widgets to separate widget and hide history category when there is no history
This commit is contained in:
79
src/gui/CategoryListWidget.h
Normal file
79
src/gui/CategoryListWidget.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (C) 2017 KeePassXC Team
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 or (at your option)
|
||||
* version 3 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QWidget>
|
||||
#include <QStyledItemDelegate>
|
||||
|
||||
namespace Ui {
|
||||
class CategoryListWidget;
|
||||
}
|
||||
|
||||
class CategoryListWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CategoryListWidget(QWidget* parent = 0);
|
||||
~CategoryListWidget();
|
||||
|
||||
int currentCategory();
|
||||
void setCurrentCategory(int index);
|
||||
int addCategory(const QString& labelText, const QIcon& icon);
|
||||
void setCategoryHidden(int index, bool hidden);
|
||||
bool isCategoryHidden(int index);
|
||||
void removeCategory(int index);
|
||||
|
||||
signals:
|
||||
void categoryChanged(int index);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent* event) override;
|
||||
QSize sizeHint() const override;
|
||||
QSize minimumSizeHint() const override;
|
||||
|
||||
protected slots:
|
||||
void updateCategoryScrollButtons();
|
||||
void scrollCategoriesDown();
|
||||
void scrollCategoriesUp();
|
||||
void emitCategoryChanged(int index);
|
||||
|
||||
private:
|
||||
const QScopedPointer<Ui::CategoryListWidget> m_ui;
|
||||
|
||||
Q_DISABLE_COPY(CategoryListWidget)
|
||||
};
|
||||
|
||||
|
||||
/* =============================================================================================== */
|
||||
|
||||
|
||||
class CategoryListWidgetDelegate : public QStyledItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CategoryListWidgetDelegate(QWidget* parent = nullptr);
|
||||
|
||||
protected:
|
||||
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
|
||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||
|
||||
private:
|
||||
QSize m_size;
|
||||
|
||||
Q_DISABLE_COPY(CategoryListWidgetDelegate)
|
||||
};
|
||||
Reference in New Issue
Block a user