diff --git a/src/kdefrontend/HistoryDialog.cpp b/src/kdefrontend/HistoryDialog.cpp index f717e4e77..04a270f95 100644 --- a/src/kdefrontend/HistoryDialog.cpp +++ b/src/kdefrontend/HistoryDialog.cpp @@ -1,84 +1,102 @@ /*************************************************************************** File : HistoryDialog.cpp Project : LabPlot Description : history dialog -------------------------------------------------------------------- Copyright : (C) 2012-2016 by Alexander Semke (alexander.semke@web.de) ***************************************************************************/ /*************************************************************************** * * * This program 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 2 of the License, or * * (at your option) any later version. * * * * This program 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 this program; if not, write to the Free Software * * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * ***************************************************************************/ #include "HistoryDialog.h" #include #include #include #include +#include +#include +#include #include - /*! \class HistoryDialog \brief Display the content of project's undo stack. \ingroup kdefrontend */ -HistoryDialog::HistoryDialog(QWidget* parent, QUndoStack* stack, const QString& emptyLabel) : KDialog(parent), m_undoStack(stack) { +HistoryDialog::HistoryDialog(QWidget* parent, QUndoStack* stack, const QString& emptyLabel) : QDialog(parent), + m_undoStack(stack), m_clearUndoStackButton(nullptr) { QUndoView* undoView = new QUndoView(stack, this); undoView->setCleanIcon( QIcon::fromTheme("edit-clear-history") ); undoView->setEmptyLabel(emptyLabel); undoView->setMinimumWidth(350); undoView->setWhatsThis(i18n("List of all performed steps/actions.\n" "Select an item in the list to navigate to the corresponding step.")); - setMainWidget(undoView); setWindowIcon( QIcon::fromTheme("view-history") ); setWindowTitle(i18n("Undo/Redo History")); - showButtonSeparator(true); setAttribute(Qt::WA_DeleteOnClose); + QDialogButtonBox* btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + + m_okButton = btnBox->button(QDialogButtonBox::Ok); + QPushButton* cancelButton = btnBox->button(QDialogButtonBox::Cancel); + + connect(cancelButton, SIGNAL(clicked(bool)), this, SLOT(close())); if (stack->count()) { - setButtons( KDialog::Ok | KDialog::User1 | KDialog::Cancel ); - setButtonToolTip(KDialog::User1, i18n("Clears the undo history. Commands are not undone or redone; the state of the project remains unchanged.")); - setButtonIcon(KDialog::User1, QIcon::fromTheme("edit-clear")); - setButtonText(KDialog::User1, i18n("Clear")); - connect(this,SIGNAL(user1Clicked()), this, SLOT(clearUndoStack())); - } else - setButtons( KDialog::Ok | KDialog::Cancel ); + m_clearUndoStackButton = new QPushButton; + btnBox->addButton(m_clearUndoStackButton, QDialogButtonBox::ActionRole); + m_clearUndoStackButton->setText(i18n("&Clear")); + m_clearUndoStackButton->setToolTip(i18n("Clears the undo history. Commands are not undone or redone; the state of the project remains unchanged.")); + m_clearUndoStackButton->setIcon(QIcon::fromTheme("edit-clear")); + connect(m_clearUndoStackButton, SIGNAL(clicked(bool)), this, SLOT(clearUndoStack())); + } + + QFrame* line = new QFrame; + line->setFrameShape(QFrame::HLine); + line->setFrameShadow(QFrame::Sunken); + + QVBoxLayout* layout = new QVBoxLayout; + + layout->addWidget(undoView); + layout->addWidget(line); + layout->addWidget(btnBox); + setLayout(layout); //restore saved dialog size if available KConfigGroup conf(KSharedConfig::openConfig(), "HistoryDialog"); if (conf.exists()) KWindowConfig::restoreWindowSize(windowHandle(), conf); else resize( QSize(500, 300).expandedTo(minimumSize()) ); } HistoryDialog::~HistoryDialog() { //save dialog size KConfigGroup conf(KSharedConfig::openConfig(), "HistoryDialog"); KWindowConfig::saveWindowSize(windowHandle(), conf); } void HistoryDialog::clearUndoStack() { if (KMessageBox::questionYesNo( this, i18n("Do you really want to clear the undo history?"), i18n("Clear history") ) == KMessageBox::Yes) m_undoStack->clear(); } diff --git a/src/kdefrontend/HistoryDialog.h b/src/kdefrontend/HistoryDialog.h index b9886c51d..01cce3d06 100644 --- a/src/kdefrontend/HistoryDialog.h +++ b/src/kdefrontend/HistoryDialog.h @@ -1,50 +1,53 @@ /*************************************************************************** File : HistoryDialog.h Project : LabPlot Description : history dialog -------------------------------------------------------------------- Copyright : (C) 2012-2016 by Alexander Semke (alexander.semke@web.de) ***************************************************************************/ /*************************************************************************** * * * This program 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 2 of the License, or * * (at your option) any later version. * * * * This program 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 this program; if not, write to the Free Software * * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * ***************************************************************************/ #ifndef HISTORYDIALOG_H #define HISTORYDIALOG_H -#include +#include class QUndoStack; +class QPushButton; -class HistoryDialog: public KDialog { +class HistoryDialog: public QDialog { Q_OBJECT public: HistoryDialog(QWidget*, QUndoStack*, const QString&); ~HistoryDialog(); private: QUndoStack* m_undoStack; + QPushButton* m_okButton; + QPushButton* m_clearUndoStackButton; private slots: void clearUndoStack(); }; #endif