2006-03-05 17:24:44 +00:00
|
|
|
/**
|
2007-04-26 03:53:02 +00:00
|
|
|
* \file Qt2BC.cpp
|
2006-03-05 17:24:44 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Allan Rae
|
|
|
|
* \author Angus Leeming
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "Qt2BC.h"
|
2007-09-01 20:44:14 +00:00
|
|
|
#include "BCView.h"
|
|
|
|
#include "ButtonPolicy.h"
|
|
|
|
#include "debug.h"
|
2007-09-01 21:05:31 +00:00
|
|
|
#include "qt_helpers.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2007-09-01 20:44:14 +00:00
|
|
|
|
|
|
|
Qt2BC::Qt2BC(ButtonController const & parent)
|
|
|
|
: BCView(parent), okay_(0), apply_(0), cancel_(0), restore_(0)
|
2006-03-05 17:24:44 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
2007-09-01 20:44:14 +00:00
|
|
|
void Qt2BC::refresh() const
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2007-09-01 20:44:14 +00:00
|
|
|
lyxerr[Debug::GUI] << "Calling BC refresh()" << std::endl;
|
|
|
|
|
|
|
|
bool const all_valid = checkWidgets();
|
|
|
|
|
|
|
|
if (okay_) {
|
|
|
|
bool const enabled =
|
|
|
|
all_valid && bp().buttonStatus(ButtonPolicy::OKAY);
|
|
|
|
okay_->setEnabled(enabled);
|
|
|
|
}
|
|
|
|
if (apply_) {
|
|
|
|
bool const enabled =
|
|
|
|
all_valid && bp().buttonStatus(ButtonPolicy::APPLY);
|
|
|
|
apply_->setEnabled(enabled);
|
|
|
|
}
|
|
|
|
if (restore_) {
|
|
|
|
bool const enabled =
|
|
|
|
all_valid && bp().buttonStatus(ButtonPolicy::RESTORE);
|
|
|
|
restore_->setEnabled(enabled);
|
|
|
|
}
|
|
|
|
if (cancel_) {
|
|
|
|
bool const enabled = bp().buttonStatus(ButtonPolicy::CANCEL);
|
|
|
|
if (enabled)
|
|
|
|
cancel_->setText(toqstr(_("Cancel")));
|
|
|
|
else
|
|
|
|
cancel_->setText(toqstr(_("Close")));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Qt2BC::refreshReadOnly() const
|
|
|
|
{
|
|
|
|
if (read_only_.empty()) return;
|
|
|
|
|
|
|
|
bool const enable = !bp().isReadOnly();
|
|
|
|
|
|
|
|
Widgets::const_iterator end = read_only_.end();
|
|
|
|
Widgets::const_iterator iter = read_only_.begin();
|
|
|
|
for (; iter != end; ++iter) {
|
|
|
|
setWidgetEnabled(*iter, enable);
|
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Qt2BC::setWidgetEnabled(QWidget * obj, bool enabled) const
|
|
|
|
{
|
2007-04-25 16:39:21 +00:00
|
|
|
if (QLineEdit * le = qobject_cast<QLineEdit*>(obj))
|
2006-03-05 17:24:44 +00:00
|
|
|
le->setReadOnly(!enabled);
|
2007-04-25 16:39:21 +00:00
|
|
|
else
|
2006-03-05 17:24:44 +00:00
|
|
|
obj->setEnabled(enabled);
|
|
|
|
|
2007-04-25 16:39:21 +00:00
|
|
|
obj->setFocusPolicy(enabled ? Qt::StrongFocus : Qt::NoFocus);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|