added select channel dialog

This commit is contained in:
fourtf
2018-04-18 09:12:29 +02:00
parent 043823120f
commit 3446a623f5
29 changed files with 1295 additions and 69 deletions
+15 -19
View File
@@ -12,6 +12,7 @@
#include "widgets/helper/searchpopup.hpp"
#include "widgets/helper/shortcut.hpp"
#include "widgets/qualitypopup.hpp"
#include "widgets/selectchanneldialog.hpp"
#include "widgets/splitcontainer.hpp"
#include "widgets/textinputdialog.hpp"
#include "widgets/window.hpp"
@@ -180,28 +181,23 @@ bool Split::getModerationMode() const
return this->moderationMode;
}
bool Split::showChangeChannelPopup(const char *dialogTitle, bool empty)
void Split::showChangeChannelPopup(const char *dialogTitle, bool empty,
std::function<void(bool)> callback)
{
// create new input dialog and execute it
TextInputDialog dialog(this);
dialog.setWindowTitle(dialogTitle);
SelectChannelDialog *dialog = new SelectChannelDialog();
if (!empty) {
dialog.setText(this->channel->name);
dialog.highlightText();
dialog->setSelectedChannel(this->getChannel());
}
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->show();
dialog->closed.connect([=] {
if (dialog->hasSeletedChannel()) {
this->setChannel(dialog->getSelectedChannel());
this->parentPage.refreshTitle();
}
if (dialog.exec() == QDialog::Accepted) {
QString newChannelName = dialog.getText().trimmed();
this->setChannel(providers::twitch::TwitchServer::getInstance().addChannel(newChannelName));
this->parentPage.refreshTitle();
return true;
}
return false;
callback(dialog->hasSeletedChannel());
});
}
void Split::layoutMessages()
@@ -290,7 +286,7 @@ void Split::doCloseSplit()
void Split::doChangeChannel()
{
this->showChangeChannelPopup("Change channel");
this->showChangeChannelPopup("Change channel", false, [](bool) {});
auto popup = this->findChildren<QDockWidget *>();
if (popup.size() && popup.at(0)->isVisible() && !popup.at(0)->isFloating()) {
popup.at(0)->hide();