Ejemplo n.º 1
0
TabSwitcherWidget::TabSwitcherWidget(MainWindow *parent) : QWidget(parent),
	m_mainWindow(parent),
	m_model(new QStandardItemModel(this)),
	m_tabsView(new ItemViewWidget(this)),
	m_previewLabel(new QLabel(this)),
	m_spinnerAnimation(nullptr),
	m_reason(KeyboardReason),
	m_isIgnoringMinimizedTabs(SettingsManager::getOption(SettingsManager::TabSwitcher_IgnoreMinimizedTabsOption).toBool())
{
	QFrame *frame(new QFrame(this));
	QHBoxLayout *mainLayout(new QHBoxLayout(this));
	mainLayout->addWidget(frame, 0, Qt::AlignCenter);

	setLayout(mainLayout);
	setAutoFillBackground(false);

	QHBoxLayout *frameLayout(new QHBoxLayout(frame));
	frameLayout->addWidget(m_tabsView, 1);
	frameLayout->addWidget(m_previewLabel, 0, Qt::AlignCenter);

	m_model->setSortRole(OrderRole);

	frame->setLayout(frameLayout);
	frame->setAutoFillBackground(true);
	frame->setMinimumWidth(600);
	frame->setObjectName(QLatin1String("tabSwitcher"));
	frame->setStyleSheet(QStringLiteral("#tabSwitcher {background:%1;border:1px solid #B3B3B3;border-radius:4px;}").arg(palette().color(QPalette::Base).name()));

	m_tabsView->setModel(m_model);
	m_tabsView->setStyleSheet(QLatin1String("border:0;"));
	m_tabsView->header()->hide();
	m_tabsView->header()->setStretchLastSection(true);
	m_tabsView->viewport()->installEventFilter(this);

	m_previewLabel->setFixedSize(260, 170);
	m_previewLabel->setAlignment(Qt::AlignCenter);
	m_previewLabel->setStyleSheet(QLatin1String("border:1px solid gray;"));

	connect(m_tabsView, &ItemViewWidget::clicked, this, &TabSwitcherWidget::handleIndexClicked);
	connect(m_tabsView->selectionModel(), &QItemSelectionModel::currentChanged, this, &TabSwitcherWidget::handleCurrentTabChanged);
}
Ejemplo n.º 2
0
TabSwitcherWidget::TabSwitcherWidget(WindowsManager *manager, QWidget *parent) : QWidget(parent),
    m_windowsManager(manager),
    m_model(new QStandardItemModel(this)),
    m_frame(new QFrame(this)),
    m_tabsView(new ItemViewWidget(m_frame)),
    m_previewLabel(new QLabel(m_frame)),
    m_loadingMovie(nullptr),
    m_reason(KeyboardReason)
{
    QHBoxLayout *mainLayout(new QHBoxLayout(this));
    mainLayout->addWidget(m_frame, 0, Qt::AlignCenter);

    setLayout(mainLayout);
    setAutoFillBackground(false);

    QHBoxLayout *frameLayout(new QHBoxLayout(m_frame));
    frameLayout->addWidget(m_tabsView, 1);
    frameLayout->addWidget(m_previewLabel, 0, Qt::AlignCenter);

    m_model->setSortRole(Qt::UserRole);

    m_frame->setLayout(frameLayout);
    m_frame->setAutoFillBackground(true);
    m_frame->setMinimumWidth(600);
    m_frame->setObjectName(QLatin1String("tabSwitcher"));
    m_frame->setStyleSheet(QStringLiteral("#tabSwitcher {background:%1;border:1px solid #B3B3B3;border-radius:4px;}").arg(palette().color(QPalette::Base).name()));

    m_tabsView->setModel(m_model);
    m_tabsView->setStyleSheet(QLatin1String("border:0;"));
    m_tabsView->header()->hide();
    m_tabsView->header()->setStretchLastSection(true);
    m_tabsView->viewport()->installEventFilter(this);

    m_previewLabel->setFixedSize(260, 170);
    m_previewLabel->setAlignment(Qt::AlignCenter);
    m_previewLabel->setStyleSheet(QLatin1String("border:1px solid gray;"));

    connect(m_tabsView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(currentTabChanged(QModelIndex)));
}