mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-30 18:43:55 -07:00
Add button to open replays folder (#5352)
This commit is contained in:
parent
7a5704beaa
commit
e3d651668c
2 changed files with 44 additions and 5 deletions
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QDesktopServices>
|
||||||
#include <QFileSystemModel>
|
#include <QFileSystemModel>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
|
@ -23,6 +24,7 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
|
#include <QUrl>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
TabReplays::TabReplays(TabSupervisor *_tabSupervisor, AbstractClient *_client) : Tab(_tabSupervisor), client(_client)
|
TabReplays::TabReplays(TabSupervisor *_tabSupervisor, AbstractClient *_client) : Tab(_tabSupervisor), client(_client)
|
||||||
|
|
@ -40,13 +42,27 @@ TabReplays::TabReplays(TabSupervisor *_tabSupervisor, AbstractClient *_client) :
|
||||||
localDirView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
localDirView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||||
localDirView->header()->setSortIndicator(0, Qt::AscendingOrder);
|
localDirView->header()->setSortIndicator(0, Qt::AscendingOrder);
|
||||||
|
|
||||||
leftToolBar = new QToolBar;
|
// Left side layout
|
||||||
|
/* put an invisible dummy QToolBar in the leftmost column so that the main toolbar is centered.
|
||||||
|
* Really ugly workaround, but I couldn't figure out the proper way to make it centered */
|
||||||
|
QToolBar *dummyToolBar = new QToolBar(this);
|
||||||
|
QSizePolicy sizePolicy = dummyToolBar->sizePolicy();
|
||||||
|
sizePolicy.setRetainSizeWhenHidden(true);
|
||||||
|
dummyToolBar->setSizePolicy(sizePolicy);
|
||||||
|
dummyToolBar->setVisible(false);
|
||||||
|
|
||||||
|
leftToolBar = new QToolBar(this);
|
||||||
leftToolBar->setOrientation(Qt::Horizontal);
|
leftToolBar->setOrientation(Qt::Horizontal);
|
||||||
leftToolBar->setIconSize(QSize(32, 32));
|
leftToolBar->setIconSize(QSize(32, 32));
|
||||||
QHBoxLayout *leftToolBarLayout = new QHBoxLayout;
|
|
||||||
leftToolBarLayout->addStretch();
|
QToolBar *leftRightmostToolBar = new QToolBar(this);
|
||||||
leftToolBarLayout->addWidget(leftToolBar);
|
leftRightmostToolBar->setOrientation(Qt::Horizontal);
|
||||||
leftToolBarLayout->addStretch();
|
leftRightmostToolBar->setIconSize(QSize(32, 32));
|
||||||
|
|
||||||
|
QGridLayout *leftToolBarLayout = new QGridLayout;
|
||||||
|
leftToolBarLayout->addWidget(dummyToolBar, 0, 0, Qt::AlignLeft);
|
||||||
|
leftToolBarLayout->addWidget(leftToolBar, 0, 1, Qt::AlignHCenter);
|
||||||
|
leftToolBarLayout->addWidget(leftRightmostToolBar, 0, 2, Qt::AlignRight);
|
||||||
|
|
||||||
QVBoxLayout *leftVbox = new QVBoxLayout;
|
QVBoxLayout *leftVbox = new QVBoxLayout;
|
||||||
leftVbox->addWidget(localDirView);
|
leftVbox->addWidget(localDirView);
|
||||||
|
|
@ -54,6 +70,7 @@ TabReplays::TabReplays(TabSupervisor *_tabSupervisor, AbstractClient *_client) :
|
||||||
leftGroupBox = new QGroupBox;
|
leftGroupBox = new QGroupBox;
|
||||||
leftGroupBox->setLayout(leftVbox);
|
leftGroupBox->setLayout(leftVbox);
|
||||||
|
|
||||||
|
// Right side layout
|
||||||
rightToolBar = new QToolBar;
|
rightToolBar = new QToolBar;
|
||||||
rightToolBar->setOrientation(Qt::Horizontal);
|
rightToolBar->setOrientation(Qt::Horizontal);
|
||||||
rightToolBar->setIconSize(QSize(32, 32));
|
rightToolBar->setIconSize(QSize(32, 32));
|
||||||
|
|
@ -70,10 +87,12 @@ TabReplays::TabReplays(TabSupervisor *_tabSupervisor, AbstractClient *_client) :
|
||||||
rightGroupBox = new QGroupBox;
|
rightGroupBox = new QGroupBox;
|
||||||
rightGroupBox->setLayout(rightVbox);
|
rightGroupBox->setLayout(rightVbox);
|
||||||
|
|
||||||
|
// combine layouts
|
||||||
QHBoxLayout *hbox = new QHBoxLayout;
|
QHBoxLayout *hbox = new QHBoxLayout;
|
||||||
hbox->addWidget(leftGroupBox);
|
hbox->addWidget(leftGroupBox);
|
||||||
hbox->addWidget(rightGroupBox);
|
hbox->addWidget(rightGroupBox);
|
||||||
|
|
||||||
|
// Left side actions
|
||||||
aOpenLocalReplay = new QAction(this);
|
aOpenLocalReplay = new QAction(this);
|
||||||
aOpenLocalReplay->setIcon(QPixmap("theme:icons/view"));
|
aOpenLocalReplay->setIcon(QPixmap("theme:icons/view"));
|
||||||
connect(aOpenLocalReplay, SIGNAL(triggered()), this, SLOT(actOpenLocalReplay()));
|
connect(aOpenLocalReplay, SIGNAL(triggered()), this, SLOT(actOpenLocalReplay()));
|
||||||
|
|
@ -88,6 +107,11 @@ TabReplays::TabReplays(TabSupervisor *_tabSupervisor, AbstractClient *_client) :
|
||||||
aDeleteLocalReplay->setIcon(QPixmap("theme:icons/remove_row"));
|
aDeleteLocalReplay->setIcon(QPixmap("theme:icons/remove_row"));
|
||||||
connect(aDeleteLocalReplay, SIGNAL(triggered()), this, SLOT(actDeleteLocalReplay()));
|
connect(aDeleteLocalReplay, SIGNAL(triggered()), this, SLOT(actDeleteLocalReplay()));
|
||||||
|
|
||||||
|
aOpenReplaysFolder = new QAction(this);
|
||||||
|
aOpenReplaysFolder->setIcon(qApp->style()->standardIcon(QStyle::SP_DirOpenIcon));
|
||||||
|
connect(aOpenReplaysFolder, &QAction::triggered, this, &TabReplays::actOpenReplaysFolder);
|
||||||
|
|
||||||
|
// Right side actions
|
||||||
aOpenRemoteReplay = new QAction(this);
|
aOpenRemoteReplay = new QAction(this);
|
||||||
aOpenRemoteReplay->setIcon(QPixmap("theme:icons/view"));
|
aOpenRemoteReplay->setIcon(QPixmap("theme:icons/view"));
|
||||||
connect(aOpenRemoteReplay, SIGNAL(triggered()), this, SLOT(actOpenRemoteReplay()));
|
connect(aOpenRemoteReplay, SIGNAL(triggered()), this, SLOT(actOpenRemoteReplay()));
|
||||||
|
|
@ -102,10 +126,14 @@ TabReplays::TabReplays(TabSupervisor *_tabSupervisor, AbstractClient *_client) :
|
||||||
aDeleteRemoteReplay->setIcon(QPixmap("theme:icons/remove_row"));
|
aDeleteRemoteReplay->setIcon(QPixmap("theme:icons/remove_row"));
|
||||||
connect(aDeleteRemoteReplay, SIGNAL(triggered()), this, SLOT(actDeleteRemoteReplay()));
|
connect(aDeleteRemoteReplay, SIGNAL(triggered()), this, SLOT(actDeleteRemoteReplay()));
|
||||||
|
|
||||||
|
// Add actions to toolbars
|
||||||
leftToolBar->addAction(aOpenLocalReplay);
|
leftToolBar->addAction(aOpenLocalReplay);
|
||||||
leftToolBar->addAction(aRenameLocal);
|
leftToolBar->addAction(aRenameLocal);
|
||||||
leftToolBar->addAction(aNewLocalFolder);
|
leftToolBar->addAction(aNewLocalFolder);
|
||||||
leftToolBar->addAction(aDeleteLocalReplay);
|
leftToolBar->addAction(aDeleteLocalReplay);
|
||||||
|
|
||||||
|
leftRightmostToolBar->addAction(aOpenReplaysFolder);
|
||||||
|
|
||||||
rightToolBar->addAction(aOpenRemoteReplay);
|
rightToolBar->addAction(aOpenRemoteReplay);
|
||||||
rightToolBar->addAction(aDownload);
|
rightToolBar->addAction(aDownload);
|
||||||
rightToolBar->addAction(aKeep);
|
rightToolBar->addAction(aKeep);
|
||||||
|
|
@ -127,8 +155,10 @@ void TabReplays::retranslateUi()
|
||||||
rightGroupBox->setTitle(tr("Server replay storage"));
|
rightGroupBox->setTitle(tr("Server replay storage"));
|
||||||
|
|
||||||
aOpenLocalReplay->setText(tr("Watch replay"));
|
aOpenLocalReplay->setText(tr("Watch replay"));
|
||||||
|
aRenameLocal->setText(tr("Rename"));
|
||||||
aNewLocalFolder->setText(tr("New folder"));
|
aNewLocalFolder->setText(tr("New folder"));
|
||||||
aDeleteLocalReplay->setText(tr("Delete"));
|
aDeleteLocalReplay->setText(tr("Delete"));
|
||||||
|
aOpenReplaysFolder->setText(tr("Open replays folder"));
|
||||||
aOpenRemoteReplay->setText(tr("Watch replay"));
|
aOpenRemoteReplay->setText(tr("Watch replay"));
|
||||||
aDownload->setText(tr("Download replay"));
|
aDownload->setText(tr("Download replay"));
|
||||||
aKeep->setText(tr("Toggle expiration lock"));
|
aKeep->setText(tr("Toggle expiration lock"));
|
||||||
|
|
@ -233,6 +263,12 @@ void TabReplays::actDeleteLocalReplay()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TabReplays::actOpenReplaysFolder()
|
||||||
|
{
|
||||||
|
QString dir = localDirModel->rootPath();
|
||||||
|
QDesktopServices::openUrl(QUrl::fromLocalFile(dir));
|
||||||
|
}
|
||||||
|
|
||||||
void TabReplays::actRemoteDoubleClick(const QModelIndex &curRight)
|
void TabReplays::actRemoteDoubleClick(const QModelIndex &curRight)
|
||||||
{
|
{
|
||||||
if (serverDirView->getReplay(curRight)) {
|
if (serverDirView->getReplay(curRight)) {
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ private:
|
||||||
QGroupBox *leftGroupBox, *rightGroupBox;
|
QGroupBox *leftGroupBox, *rightGroupBox;
|
||||||
|
|
||||||
QAction *aOpenLocalReplay, *aRenameLocal, *aNewLocalFolder, *aDeleteLocalReplay;
|
QAction *aOpenLocalReplay, *aRenameLocal, *aNewLocalFolder, *aDeleteLocalReplay;
|
||||||
|
QAction *aOpenReplaysFolder;
|
||||||
QAction *aOpenRemoteReplay, *aDownload, *aKeep, *aDeleteRemoteReplay;
|
QAction *aOpenRemoteReplay, *aDownload, *aKeep, *aDeleteRemoteReplay;
|
||||||
|
|
||||||
void downloadNodeAtIndex(const QModelIndex &curLeft, const QModelIndex &curRight);
|
void downloadNodeAtIndex(const QModelIndex &curLeft, const QModelIndex &curRight);
|
||||||
|
|
@ -37,6 +38,8 @@ private slots:
|
||||||
void actNewLocalFolder();
|
void actNewLocalFolder();
|
||||||
void actDeleteLocalReplay();
|
void actDeleteLocalReplay();
|
||||||
|
|
||||||
|
void actOpenReplaysFolder();
|
||||||
|
|
||||||
void actRemoteDoubleClick(const QModelIndex &curLeft);
|
void actRemoteDoubleClick(const QModelIndex &curLeft);
|
||||||
void actOpenRemoteReplay();
|
void actOpenRemoteReplay();
|
||||||
void openRemoteReplayFinished(const Response &r);
|
void openRemoteReplayFinished(const Response &r);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue