From 423670fc310b8c853c471a3c272db13e38edd8db Mon Sep 17 00:00:00 2001 From: Arno Date: Sat, 13 Oct 2018 03:18:29 +0200 Subject: Implement layout for CopyDialog Does nothing yet except close. This was harder than it should be: To keep a GridLayout expanding its cells vertically, you have to set the Alignment in the *parent* Layout. Took me a while to figure out... --- BeetPlayer.pro | 6 ++++-- collectiondatesview.cpp | 6 ++++++ collectiondatesview.h | 1 + copydialog.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ copydialog.h | 20 +++++++++++++++++++ playerwidget.cpp | 7 +++++++ 6 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 copydialog.cpp create mode 100644 copydialog.h diff --git a/BeetPlayer.pro b/BeetPlayer.pro index 37d9542..d222745 100644 --- a/BeetPlayer.pro +++ b/BeetPlayer.pro @@ -42,7 +42,8 @@ SOURCES += main.cpp\ collectionfavoritesview.cpp \ collectionwebradioview.cpp \ collectionfoldersview.cpp \ - collectionwidgetproxy.cpp + collectionwidgetproxy.cpp \ + copydialog.cpp HEADERS += beetplayer.h \ configurationdialog.h \ @@ -61,7 +62,8 @@ HEADERS += beetplayer.h \ collectionfavoritesview.h \ collectionwebradioview.h \ collectionfoldersview.h \ - collectionwidgetproxy.h + collectionwidgetproxy.h \ + copydialog.h LIBS += -ltag diff --git a/collectiondatesview.cpp b/collectiondatesview.cpp index 17856c7..83a7c3f 100644 --- a/collectiondatesview.cpp +++ b/collectiondatesview.cpp @@ -4,6 +4,7 @@ #include #include "collectiondatesview.h" +#include "copydialog.h" CollectionDatesView::CollectionDatesView(QWidget *parent) : CollectionWidget(parent){ } @@ -77,3 +78,8 @@ void CollectionDatesView::populate(){ } enableSorting(Qt::DescendingOrder); } + +void CollectionDatesView::copyTo(){ + CopyDialog *cdlg = new CopyDialog(this); + cdlg->show(); +} diff --git a/collectiondatesview.h b/collectiondatesview.h index a55cf63..6845ea5 100644 --- a/collectiondatesview.h +++ b/collectiondatesview.h @@ -10,6 +10,7 @@ class CollectionDatesView : public CollectionWidget { public slots: virtual void populate(); + void copyTo(); }; #endif // COLLECTIONDATESVIEW_H diff --git a/copydialog.cpp b/copydialog.cpp new file mode 100644 index 0000000..f6da343 --- /dev/null +++ b/copydialog.cpp @@ -0,0 +1,53 @@ +#include +#include +#include +#include +#include + +#include "copydialog.h" + +CopyDialog::CopyDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f) { + setAttribute(Qt::WA_DeleteOnClose); + setWindowTitle(tr("Copy files")); + QGridLayout *dirGrid = new QGridLayout; + QLabel *srcL = new QLabel(tr("Source")); + dirGrid->addWidget(srcL, 0, 0); + mSrcE = new QLineEdit; + mSrcE->setReadOnly(true); + dirGrid->addWidget(mSrcE, 0, 1); + QPushButton *srcB = new QPushButton(QIcon::fromTheme("folder"), tr("...")); + dirGrid->addWidget(srcB, 0, 2); + QLabel *dstL = new QLabel(tr("Destination")); + dirGrid->addWidget(dstL, 1, 0); + mDstE = new QLineEdit; + mDstE->setReadOnly(true); + dirGrid->addWidget(mDstE, 1, 1); + QPushButton *dstB = new QPushButton(QIcon::fromTheme("folder"), tr("...")); + dirGrid->addWidget(dstB, 1, 2); + QLabel *folderL = new QLabel(tr("Folder Name")); + dirGrid->addWidget(folderL, 2, 0); + mFolderE = new QLineEdit; + dirGrid->addWidget(mFolderE, 2, 1); + QPushButton *refreshB = new QPushButton(QIcon::fromTheme("view-refresh"), QString()); + dirGrid->addWidget(refreshB, 2, 2); + QGroupBox *dirGB = new QGroupBox("Directories"); + dirGB->setLayout(dirGrid); + QHBoxLayout *resultL = new QHBoxLayout; + mResultL = new QLabel; + resultL->addWidget(mResultL); + QGroupBox *resultGB = new QGroupBox(tr("Result")); + resultGB->setLayout(resultL); + QHBoxLayout *buttonL = new QHBoxLayout; + QPushButton *copyB = new QPushButton(tr("Copy!")); + buttonL->addStretch(); + buttonL->addWidget(copyB); + QPushButton *closeB = new QPushButton(tr("Close")); + connect(closeB, &QPushButton::clicked, this, &CopyDialog::close); + buttonL->addWidget(closeB); + buttonL->addStretch(); + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(dirGB, Qt::AlignTop); + mainLayout->addWidget(resultGB, Qt::AlignVCenter); + mainLayout->addLayout(buttonL, Qt::AlignBottom); + setLayout(mainLayout); +} diff --git a/copydialog.h b/copydialog.h new file mode 100644 index 0000000..2d34094 --- /dev/null +++ b/copydialog.h @@ -0,0 +1,20 @@ +#ifndef COPYDIALOG_H +#define COPYDIALOG_H + +#include + +class QLineEdit; +class QLabel; + +class CopyDialog : public QDialog { + public: + explicit CopyDialog(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); + + private: + QLineEdit *mSrcE; + QLineEdit *mDstE; + QLineEdit *mFolderE; + QLabel *mResultL; +}; + +#endif // COPYDIALOG_H diff --git a/playerwidget.cpp b/playerwidget.cpp index 71c899b..cab33b9 100644 --- a/playerwidget.cpp +++ b/playerwidget.cpp @@ -206,6 +206,13 @@ void PlayerWidget::setupGui(QSplashScreen *splash){ curW->view()->addAction(deleteItemA); curW->view()->addAction(Helper::createSeparator(this)); } + // special case dates -> add copy to... + if(name == "dates"){ + QAction *copyToA = new QAction(QIcon::fromTheme("edit-copy"), tr("Copy to..."), this); + connect(copyToA, &QAction::triggered, datesView, &CollectionDatesView::copyTo); + curW->view()->addAction(copyToA); + curW->view()->addAction(Helper::createSeparator(this)); + } QAction *refreshA = new QAction(QIcon(":/refresh.png"), tr("Refresh view"), this); connect(refreshA, &QAction::triggered, [curW] { qApp->setOverrideCursor(Qt::BusyCursor); -- cgit v1.2.3-70-g09d2