2015-12-10 05:06:13 +02:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
**
|
2019-06-03 13:38:02 +00:00
|
|
|
** This file is part of the Qt Designer of the Katie Toolkit.
|
2015-12-10 05:06:13 +02:00
|
|
|
**
|
|
|
|
** $QT_BEGIN_LICENSE:LGPL$
|
|
|
|
** Commercial License Usage
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
|
|
|
** information use the contact form at http://www.qt.io/contact-us.
|
|
|
|
**
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
**
|
|
|
|
** As a special exception, The Qt Company gives you certain additional
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
**
|
|
|
|
** GNU General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
** General Public License version 3.0 as published by the Free Software
|
|
|
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
** ensure the GNU General Public License version 3.0 requirements will be
|
|
|
|
** met: http://www.gnu.org/copyleft/gpl.html.
|
|
|
|
**
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "previewconfigurationwidget_p.h"
|
|
|
|
#include "ui_previewconfigurationwidget.h"
|
|
|
|
#include "previewmanager_p.h"
|
|
|
|
#include "abstractsettings_p.h"
|
|
|
|
#include "shared_settings_p.h"
|
|
|
|
|
|
|
|
#include <iconloader_p.h>
|
|
|
|
#include <stylesheeteditor_p.h>
|
|
|
|
|
|
|
|
#include <QtGui/QFileDialog>
|
|
|
|
#include <QtGui/QStyleFactory>
|
|
|
|
#include <QtGui/QFileDialog>
|
|
|
|
#include <QtGui/QMessageBox>
|
|
|
|
#include <QtCore/QPair>
|
|
|
|
#include <QtCore/QList>
|
|
|
|
#include <QtCore/QDebug>
|
|
|
|
#include <QtCore/QFileInfo>
|
|
|
|
#include <QtCore/QSharedData>
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
|
|
|
namespace qdesigner_internal {
|
|
|
|
|
|
|
|
// ------------- PreviewConfigurationWidgetPrivate
|
|
|
|
class PreviewConfigurationWidget::PreviewConfigurationWidgetPrivate {
|
|
|
|
public:
|
|
|
|
PreviewConfigurationWidgetPrivate(QDesignerFormEditorInterface *core, QGroupBox *g);
|
|
|
|
|
|
|
|
void slotEditAppStyleSheet();
|
|
|
|
|
|
|
|
void retrieveSettings();
|
|
|
|
void storeSettings() const;
|
|
|
|
|
|
|
|
QAbstractButton *appStyleSheetChangeButton() const { return m_ui.m_appStyleSheetChangeButton; }
|
|
|
|
|
|
|
|
QDesignerFormEditorInterface *m_core;
|
|
|
|
|
|
|
|
private:
|
|
|
|
PreviewConfiguration previewConfiguration() const;
|
|
|
|
void setPreviewConfiguration(const PreviewConfiguration &pc);
|
|
|
|
|
|
|
|
const QString m_defaultStyle;
|
|
|
|
QGroupBox *m_parent;
|
2016-08-26 18:05:03 +00:00
|
|
|
Ui_PreviewConfigurationWidget m_ui;
|
2015-12-10 05:06:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
PreviewConfigurationWidget::PreviewConfigurationWidgetPrivate::PreviewConfigurationWidgetPrivate(
|
|
|
|
QDesignerFormEditorInterface *core, QGroupBox *g) :
|
|
|
|
m_core(core),
|
|
|
|
m_defaultStyle(PreviewConfigurationWidget::tr("Default")),
|
2019-05-04 17:06:44 +00:00
|
|
|
m_parent(g)
|
2015-12-10 05:06:13 +02:00
|
|
|
{
|
|
|
|
m_ui.setupUi(g);
|
|
|
|
// styles
|
|
|
|
m_ui.m_styleCombo->setEditable(false);
|
|
|
|
QStringList styleItems(m_defaultStyle);
|
|
|
|
styleItems += QStyleFactory::keys();
|
|
|
|
m_ui.m_styleCombo->addItems(styleItems);
|
|
|
|
|
|
|
|
// sheet
|
|
|
|
m_ui.m_appStyleSheetLineEdit->setTextPropertyValidationMode(qdesigner_internal::ValidationStyleSheet);
|
|
|
|
m_ui.m_appStyleSheetClearButton->setIcon(qdesigner_internal::createIconSet(QString::fromUtf8("resetproperty.png")));
|
|
|
|
QObject::connect(m_ui.m_appStyleSheetClearButton, SIGNAL(clicked()), m_ui.m_appStyleSheetLineEdit, SLOT(clear()));
|
|
|
|
|
|
|
|
retrieveSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
PreviewConfiguration PreviewConfigurationWidget::PreviewConfigurationWidgetPrivate::previewConfiguration() const
|
|
|
|
{
|
|
|
|
PreviewConfiguration rc;
|
|
|
|
QString style = m_ui.m_styleCombo->currentText();
|
|
|
|
if (style == m_defaultStyle)
|
|
|
|
style.clear();
|
|
|
|
const QString applicationStyleSheet = m_ui.m_appStyleSheetLineEdit->text();
|
2019-05-04 17:06:44 +00:00
|
|
|
return PreviewConfiguration(style, applicationStyleSheet);
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewConfigurationWidget::PreviewConfigurationWidgetPrivate::setPreviewConfiguration(const PreviewConfiguration &pc)
|
|
|
|
{
|
|
|
|
int styleIndex = m_ui.m_styleCombo->findText(pc.style());
|
|
|
|
if (styleIndex == -1)
|
|
|
|
styleIndex = m_ui.m_styleCombo->findText(m_defaultStyle);
|
|
|
|
m_ui.m_styleCombo->setCurrentIndex(styleIndex);
|
|
|
|
m_ui.m_appStyleSheetLineEdit->setText(pc.applicationStyleSheet());
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewConfigurationWidget::PreviewConfigurationWidgetPrivate::slotEditAppStyleSheet()
|
|
|
|
{
|
|
|
|
StyleSheetEditorDialog dlg(m_core, m_parent, StyleSheetEditorDialog::ModeGlobal);
|
|
|
|
dlg.setText(m_ui.m_appStyleSheetLineEdit->text());
|
|
|
|
if (dlg.exec() == QDialog::Accepted)
|
|
|
|
m_ui.m_appStyleSheetLineEdit->setText(dlg.text());
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewConfigurationWidget::PreviewConfigurationWidgetPrivate::retrieveSettings()
|
|
|
|
{
|
|
|
|
QDesignerSharedSettings settings(m_core);
|
|
|
|
m_parent->setChecked(settings.isCustomPreviewConfigurationEnabled());
|
|
|
|
setPreviewConfiguration(settings.customPreviewConfiguration());
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewConfigurationWidget::PreviewConfigurationWidgetPrivate::storeSettings() const
|
|
|
|
{
|
|
|
|
QDesignerSharedSettings settings(m_core);
|
|
|
|
settings.setCustomPreviewConfigurationEnabled(m_parent->isChecked());
|
|
|
|
settings.setCustomPreviewConfiguration(previewConfiguration());
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------- PreviewConfigurationWidget
|
|
|
|
PreviewConfigurationWidget::PreviewConfigurationWidget(QDesignerFormEditorInterface *core,
|
|
|
|
QWidget *parent) :
|
|
|
|
QGroupBox(parent),
|
|
|
|
m_impl(new PreviewConfigurationWidgetPrivate(core, this))
|
|
|
|
{
|
|
|
|
connect(m_impl->appStyleSheetChangeButton(), SIGNAL(clicked()), this, SLOT(slotEditAppStyleSheet()));
|
|
|
|
|
|
|
|
m_impl->retrieveSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
PreviewConfigurationWidget::~PreviewConfigurationWidget()
|
|
|
|
{
|
|
|
|
delete m_impl;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewConfigurationWidget::saveState()
|
|
|
|
{
|
|
|
|
m_impl->storeSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewConfigurationWidget::slotEditAppStyleSheet()
|
|
|
|
{
|
|
|
|
m_impl->slotEditAppStyleSheet();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
#include <moc_previewconfigurationwidget_p.h>
|