Display a Close button for history items.

Previously we had Ok and Cancel with the same action.
This commit is contained in:
Felix Geyer 2015-05-03 18:59:19 +02:00
parent b9c9c56059
commit f3d956ceed
3 changed files with 22 additions and 0 deletions

View File

@ -23,6 +23,7 @@ EditWidget::EditWidget(QWidget* parent)
, m_ui(new Ui::EditWidget()) , m_ui(new Ui::EditWidget())
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
setReadOnly(false);
QFont headerLabelFont = m_ui->headerLabel->font(); QFont headerLabelFont = m_ui->headerLabel->font();
headerLabelFont.setBold(true); headerLabelFont.setBold(true);
@ -68,3 +69,20 @@ QLabel* EditWidget::headlineLabel()
{ {
return m_ui->headerLabel; return m_ui->headerLabel;
} }
void EditWidget::setReadOnly(bool readOnly)
{
m_readOnly = readOnly;
if (readOnly) {
m_ui->buttonBox->setStandardButtons(QDialogButtonBox::Close);
}
else {
m_ui->buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
}
}
bool EditWidget::readOnly() const
{
return m_readOnly;
}

View File

@ -41,6 +41,8 @@ public:
void setCurrentRow(int index); void setCurrentRow(int index);
void setHeadline(const QString& text); void setHeadline(const QString& text);
QLabel* headlineLabel(); QLabel* headlineLabel();
void setReadOnly(bool readOnly);
bool readOnly() const;
Q_SIGNALS: Q_SIGNALS:
void accepted(); void accepted();
@ -48,6 +50,7 @@ Q_SIGNALS:
private: private:
const QScopedPointer<Ui::EditWidget> m_ui; const QScopedPointer<Ui::EditWidget> m_ui;
bool m_readOnly;
Q_DISABLE_COPY(EditWidget) Q_DISABLE_COPY(EditWidget)
}; };

View File

@ -277,6 +277,7 @@ void EditEntryWidget::loadEntry(Entry* entry, bool create, bool history, const Q
} }
setForms(entry); setForms(entry);
setReadOnly(m_history);
setCurrentRow(0); setCurrentRow(0);
setRowHidden(m_historyWidget, m_history); setRowHidden(m_historyWidget, m_history);