Commit c4c0da04 authored by Michael Pyne's avatar Michael Pyne

Port from KVBox and KDialog in the file renamer U/I.

parent 9844462a
......@@ -31,12 +31,13 @@
#include <klineedit.h>
#include <klocale.h>
#include <kmessagebox.h>
#include <kvbox.h>
#include <QFile>
#include <QTimer>
#include <QCheckBox>
#include <QDir>
#include <QDialog>
#include <QDialogButtonBox>
#include <QUrl>
#include <QLabel>
#include <QSignalMapper>
......@@ -55,30 +56,30 @@
#include "coverinfo.h"
#include "juk_debug.h"
class ConfirmationDialog : public KDialog
class ConfirmationDialog : public QDialog
{
public:
ConfirmationDialog(const QMap<QString, QString> &files,
QWidget *parent = 0, const char *name = 0)
: KDialog(parent)
QWidget *parent = nullptr)
: QDialog(parent)
{
setObjectName( QLatin1String( name ) );
setModal(true);
setCaption(i18nc("warning about mass file rename", "Warning"));
setButtons(Ok | Cancel);
setWindowTitle(i18nc("warning about mass file rename", "Warning"));
KVBox *vbox = new KVBox(this);
setMainWidget(vbox);
KVBox *hbox = new KVBox(vbox);
auto vboxLayout = new QVBoxLayout(this);
auto hbox = new QWidget(this);
auto hboxVLayout = new QVBoxLayout(hbox);
vboxLayout->addWidget(hbox);
QLabel *l = new QLabel(hbox);
l->setPixmap(SmallIcon("dialog-warning", 32));
hboxVLayout->addWidget(l);
l = new QLabel(i18n("You are about to rename the following files. "
"Are you sure you want to continue?"), hbox);
hbox->setStretchFactor(l, 1);
hboxVLayout->addWidget(l, 1);
QTreeWidget *lv = new QTreeWidget(vbox);
QTreeWidget *lv = new QTreeWidget(this);
QStringList headers;
headers << i18n("Original Name");
......@@ -86,6 +87,12 @@ public:
lv->setHeaderLabels(headers);
lv->setRootIsDecorated(false);
vboxLayout->addWidget(lv);
auto buttonBox = new QDialogButtonBox(this);
vboxLayout->addWidget(buttonBox);
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
int lvHeight = 0;
......@@ -107,6 +114,7 @@ public:
lvHeight += lv->horizontalScrollBar()->height() + lv->header()->height();
lv->setMinimumHeight(qMin(lvHeight, 400));
resize(qMin(width(), 500), qMin(minimumHeight(), 400));
show();
......
......@@ -15,8 +15,8 @@
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef FILERENAMER_H
#define FILERENAMER_H
#ifndef JUK_FILERENAMER_H
#define JUK_FILERENAMER_H
#include <QString>
#include <QVector>
......@@ -543,6 +543,6 @@ private:
bool moveFile(const QString &src, const QString &dest);
};
#endif /* FILERENAMER_H */
#endif /* JUK_FILERENAMER_H */
// vim: set et sw=4 tw=0 sta:
......@@ -22,10 +22,10 @@
#include "juk_debug.h"
FileRenamerTagOptions::FileRenamerTagOptions(QWidget *parent,
const TagRenamerOptions &options) :
QWidget(parent),
Ui::FileRenamerTagOptionsBase(),
m_options(options)
const TagRenamerOptions &options)
: QWidget(parent)
, Ui::FileRenamerTagOptionsBase()
, m_options(options)
{
setupUi(this);
......@@ -96,7 +96,6 @@ void FileRenamerTagOptions::slotTrackWidthChanged()
void FileRenamerTagOptions::slotEmptyActionChanged()
{
m_options.setEmptyText(m_emptyTagValue->text());
m_options.setEmptyAction(TagRenamerOptions::IgnoreEmptyTag);
if(m_useValueButton->isChecked())
......@@ -107,21 +106,26 @@ void FileRenamerTagOptions::slotEmptyActionChanged()
TagOptionsDialog::TagOptionsDialog(QWidget *parent,
const TagRenamerOptions &options,
unsigned categoryNumber) :
KDialog(parent, 0),
m_options(options),
m_categoryNumber(categoryNumber)
unsigned categoryNumber)
: QDialog(parent)
, m_options(options)
, m_categoryNumber(categoryNumber)
{
setModal(true);
setCaption(i18n("File Renamer"));
setButtons(Ok|Cancel);
setWindowTitle(i18n("File Renamer"));
loadConfig();
m_widget = new FileRenamerTagOptions(this, m_options);
m_widget->setMinimumSize(400, 200);
setMainWidget(m_widget);
connect(m_widget->dlgButtonBox, &QDialogButtonBox::accepted,
this, &QDialog::accept);
connect(m_widget->dlgButtonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject);
auto boxLayout = new QVBoxLayout(this);
boxLayout->addWidget(m_widget);
}
void TagOptionsDialog::accept()
......@@ -129,7 +133,7 @@ void TagOptionsDialog::accept()
m_options = m_widget->options();
saveConfig();
KDialog::accept();
QDialog::accept();
}
void TagOptionsDialog::loadConfig()
......
......@@ -14,10 +14,11 @@
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef FILERENAMEROPTIONS_H
#define FILERENAMEROPTIONS_H
#ifndef JUK_FILERENAMEROPTIONS_H
#define JUK_FILERENAMEROPTIONS_H
#include <QDialog>
#include <kdialog.h>
#include "ui_filerenameroptionsbase.h"
#include "tagrenameroptions.h"
......@@ -31,7 +32,6 @@ class FileRenamerTagOptions : public QWidget, public Ui::FileRenamerTagOptionsBa
Q_OBJECT
public:
FileRenamerTagOptions(QWidget *parent, const TagRenamerOptions &options);
virtual ~FileRenamerTagOptions() {}
const TagRenamerOptions &options() const { return m_options; }
......@@ -49,7 +49,7 @@ private:
*
* @author Michael Pyne <mpyne@kde.org>
*/
class TagOptionsDialog : public KDialog
class TagOptionsDialog : public QDialog
{
Q_OBJECT
......@@ -75,6 +75,6 @@ private:
unsigned m_categoryNumber;
};
#endif /* FILERENAMEROPTIONS_H */
#endif /* JUK_FILERENAMEROPTIONS_H */
// vim: set et sw=4 tw=0 sta:
......@@ -328,6 +328,13 @@
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="dlgButtonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment