diff --git a/src/konqhistorydialog.cpp b/src/konqhistorydialog.cpp index 62e7b3386..80d792f7c 100644 --- a/src/konqhistorydialog.cpp +++ b/src/konqhistorydialog.cpp @@ -1,120 +1,122 @@ /* This file is part of the KDE project Copyright 2009 Pino Toscano 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; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "konqhistorydialog.h" #include "konqhistoryview.h" #include "konqhistory.h" #include "konqmainwindow.h" #include "konqmainwindowfactory.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include -#include KonqHistoryDialog::KonqHistoryDialog(KonqMainWindow *parent) - : KDialog(parent), m_mainWindow(parent) + : QDialog(parent), m_mainWindow(parent) { - setCaption(i18nc("@title:window", "History")); - setButtons(KDialog::Close); + setWindowTitle(i18nc("@title:window", "History")); - QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget()); - mainLayout->setContentsMargins(0, 0, 0, 0); + QVBoxLayout *mainLayout = new QVBoxLayout(this); - m_historyView = new KonqHistoryView(mainWidget()); + m_historyView = new KonqHistoryView(this); connect(m_historyView->treeView(), SIGNAL(doubleClicked(QModelIndex)), this, SLOT(slotOpenWindowForIndex(QModelIndex))); connect(m_historyView, &KonqHistoryView::openUrlInNewWindow, this, &KonqHistoryDialog::slotOpenWindow); connect(m_historyView, &KonqHistoryView::openUrlInNewTab, this, &KonqHistoryDialog::slotOpenTab); KActionCollection *collection = m_historyView->actionCollection(); - QToolBar *toolBar = new QToolBar(mainWidget()); + QToolBar *toolBar = new QToolBar(this); toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); QToolButton *sortButton = new QToolButton(toolBar); sortButton->setText(i18nc("@action:inmenu Parent of 'By Name' and 'By Date'", "Sort")); sortButton->setIcon(QIcon::fromTheme(QStringLiteral("view-sort-ascending"))); sortButton->setPopupMode(QToolButton::InstantPopup); sortButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); QMenu *sortMenu = new QMenu(sortButton); sortMenu->addAction(collection->action(QStringLiteral("byName"))); sortMenu->addAction(collection->action(QStringLiteral("byDate"))); sortButton->setMenu(sortMenu); toolBar->addWidget(sortButton); toolBar->addSeparator(); toolBar->addAction(collection->action(QStringLiteral("preferences"))); mainLayout->addWidget(toolBar); mainLayout->addWidget(m_historyView); - create(); + QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close); + connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); + connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); + mainLayout->addWidget(buttonBox); + + create(); // required by windowHandle() KWindowConfig::restoreWindowSize(windowHandle(), KSharedConfig::openConfig()->group("History Dialog")); // give focus to the search line edit when opening the dialog (#240513) m_historyView->lineEdit()->setFocus(); } KonqHistoryDialog::~KonqHistoryDialog() { KConfigGroup group(KSharedConfig::openConfig(), "History Dialog"); KWindowConfig::saveWindowSize(windowHandle(), group); } QSize KonqHistoryDialog::sizeHint() const { return QSize(500, 400); } void KonqHistoryDialog::slotOpenWindow(const QUrl &url) { KonqMainWindow *mw = KonqMainWindowFactory::createNewWindow(url); mw->show(); } void KonqHistoryDialog::slotOpenTab(const QUrl &url) { m_mainWindow->openMultiURL(QList() << url); } // Called when double-clicking on a row void KonqHistoryDialog::slotOpenWindowForIndex(const QModelIndex &index) { const QUrl url = m_historyView->urlForIndex(index); if (url.isValid()) { slotOpenWindow(url); // should we call slotOpenTab instead? } } diff --git a/src/konqhistorydialog.h b/src/konqhistorydialog.h index 589d37ce1..6a0f2653d 100644 --- a/src/konqhistorydialog.h +++ b/src/konqhistorydialog.h @@ -1,50 +1,50 @@ /* This file is part of the KDE project Copyright 2009 Pino Toscano 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; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KONQ_HISTORYDIALOG_H #define KONQ_HISTORYDIALOG_H -#include +#include class KonqMainWindow; class KonqHistoryView; class QModelIndex; class QUrl; -class KonqHistoryDialog : public KDialog +class KonqHistoryDialog : public QDialog { Q_OBJECT public: KonqHistoryDialog(KonqMainWindow *parent = nullptr); ~KonqHistoryDialog() override; QSize sizeHint() const override; private Q_SLOTS: void slotOpenWindow(const QUrl &url); void slotOpenTab(const QUrl &url); void slotOpenWindowForIndex(const QModelIndex &index); private: KonqHistoryView *m_historyView; KonqMainWindow *m_mainWindow; }; #endif // KONQ_HISTORYDIALOG_H