2018-10-19 19:10:22 +02:00
|
|
|
/*
|
|
|
|
* Strawberry Music Player
|
|
|
|
* This file was part of Clementine.
|
|
|
|
* Copyright 2018, Vikram Ambrose <ambroseworks@gmail.com>
|
|
|
|
* Copyright 2018, Jonas Kvinge <jonas@jkvinge.net>
|
|
|
|
*
|
|
|
|
* Strawberry 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 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
#ifndef FANCYTABWIDGET_H
|
|
|
|
#define FANCYTABWIDGET_H
|
|
|
|
|
2020-02-12 00:07:05 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
2020-02-09 02:29:35 +01:00
|
|
|
#include <QObject>
|
2018-10-19 19:10:22 +02:00
|
|
|
#include <QTabWidget>
|
2019-07-08 22:27:45 +02:00
|
|
|
#include <QMap>
|
2019-04-27 22:32:39 +02:00
|
|
|
#include <QString>
|
|
|
|
#include <QIcon>
|
2018-10-19 19:10:22 +02:00
|
|
|
#include <QPixmap>
|
|
|
|
#include <QSize>
|
2020-02-09 02:29:35 +01:00
|
|
|
#include <QColor>
|
2018-05-01 00:41:33 +02:00
|
|
|
|
2019-07-08 22:27:45 +02:00
|
|
|
class QMenu;
|
|
|
|
class QActionGroup;
|
2020-02-09 02:29:35 +01:00
|
|
|
class QContextMenuEvent;
|
|
|
|
class QPaintEvent;
|
2019-04-27 22:32:39 +02:00
|
|
|
class TabData;
|
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
namespace Core {
|
|
|
|
namespace Internal {
|
|
|
|
|
2018-10-19 19:10:22 +02:00
|
|
|
class FancyTabWidget : public QTabWidget {
|
2018-02-27 18:06:05 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
2020-06-15 21:55:05 +02:00
|
|
|
public:
|
|
|
|
explicit FancyTabWidget(QWidget *parent = nullptr);
|
2019-04-27 22:32:39 +02:00
|
|
|
|
2020-07-18 15:52:36 +02:00
|
|
|
void AddTab(QWidget *widget_view, const QString &name, const QIcon &icon, const QString &label);
|
2020-06-15 21:55:05 +02:00
|
|
|
bool EnableTab(QWidget *widget_view);
|
|
|
|
bool DisableTab(QWidget *widget_view);
|
|
|
|
int insertTab(const int idx, QWidget *page, const QIcon &icon, const QString &label);
|
|
|
|
void addBottomWidget(QWidget* widget_view);
|
2020-07-18 15:52:36 +02:00
|
|
|
int IndexOfTab(QWidget *widget);
|
2018-10-19 19:10:22 +02:00
|
|
|
|
2020-06-15 21:55:05 +02:00
|
|
|
void setBackgroundPixmap(const QPixmap& pixmap);
|
|
|
|
void addSpacer();
|
2018-10-19 19:10:22 +02:00
|
|
|
|
2020-06-15 21:55:05 +02:00
|
|
|
void Load(const QString &kSettingsGroup);
|
|
|
|
void SaveSettings(const QString &kSettingsGroup);
|
|
|
|
void ReloadSettings();
|
2018-10-19 19:10:22 +02:00
|
|
|
|
2020-06-15 21:55:05 +02:00
|
|
|
// Values are persisted - only add to the end
|
|
|
|
enum Mode {
|
|
|
|
Mode_None = 0,
|
|
|
|
Mode_LargeSidebar,
|
|
|
|
Mode_SmallSidebar,
|
|
|
|
Mode_Tabs,
|
|
|
|
Mode_IconOnlyTabs,
|
|
|
|
Mode_PlainSidebar,
|
|
|
|
};
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-07-13 18:29:48 +02:00
|
|
|
static const int TabSize_LargeSidebarMinWidth;
|
2020-06-29 03:03:04 +02:00
|
|
|
static const int IconSize_LargeSidebar;
|
|
|
|
static const int IconSize_SmallSidebar;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-06-29 03:03:04 +02:00
|
|
|
Mode mode() const { return mode_; }
|
2020-07-12 21:02:29 +02:00
|
|
|
int iconsize_smallsidebar() const { return iconsize_smallsidebar_; }
|
2020-06-29 03:03:04 +02:00
|
|
|
int iconsize_largesidebar() const { return iconsize_largesidebar_; }
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2018-10-19 19:10:22 +02:00
|
|
|
signals:
|
2020-06-15 21:55:05 +02:00
|
|
|
void ModeChanged(FancyTabWidget::Mode mode);
|
|
|
|
void CurrentChanged(int);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2018-10-19 19:10:22 +02:00
|
|
|
public slots:
|
2020-06-15 21:55:05 +02:00
|
|
|
void setCurrentIndex(int idx);
|
|
|
|
void SetMode(Mode mode);
|
|
|
|
// Mapper mapped signal needs this convenience function
|
|
|
|
void SetMode(int mode) { SetMode(Mode(mode)); }
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2018-10-19 19:10:22 +02:00
|
|
|
private slots:
|
2020-06-15 21:55:05 +02:00
|
|
|
void tabBarUpdateGeometry();
|
|
|
|
void currentTabChanged(int);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2018-10-19 19:10:22 +02:00
|
|
|
protected:
|
2020-06-15 21:55:05 +02:00
|
|
|
void paintEvent(QPaintEvent*) override;
|
|
|
|
void contextMenuEvent(QContextMenuEvent* e) override;
|
|
|
|
|
2018-10-19 19:10:22 +02:00
|
|
|
private:
|
2020-06-15 21:55:05 +02:00
|
|
|
void addMenuItem(QActionGroup* group, const QString& text, Mode mode);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-06-15 21:55:05 +02:00
|
|
|
QPixmap background_pixmap_;
|
2020-07-18 15:52:36 +02:00
|
|
|
QMenu *menu_;
|
2020-06-15 21:55:05 +02:00
|
|
|
Mode mode_;
|
|
|
|
QWidget *bottom_widget_;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-07-18 15:52:36 +02:00
|
|
|
QMap<QWidget*, TabData*> tabs_;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-06-15 21:55:05 +02:00
|
|
|
bool bg_color_system_;
|
|
|
|
bool bg_gradient_;
|
|
|
|
QColor bg_color_;
|
2020-07-12 21:02:29 +02:00
|
|
|
int iconsize_smallsidebar_;
|
2020-06-29 03:03:04 +02:00
|
|
|
int iconsize_largesidebar_;
|
2019-08-08 23:16:45 +02:00
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
} // namespace Core
|
|
|
|
|
|
|
|
using Core::Internal::FancyTabWidget;
|
|
|
|
|
|
|
|
#endif // FANCYTABWIDGET_H
|