diff --git a/CHANGELOG.md b/CHANGELOG.md index b89c9e6bf..59bb8e8cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Minor: Added image links to the badge context menu. (#2667) - Minor: Added a setting to hide Twitch Predictions badges. (#2668) - Minor: Optionally remove spaces between emotes, originally made for Mm2PL/Dankerino. (#2651) +- Minor: Improved UX of `Rename Tab` dialog. (#2713) - Bugfix: Added missing Copy/Open link context menu entries to emotes in Emote Picker. (#2670) - Bugfix: Fixed visual glitch with smooth scrolling. (#2084) - Bugfix: Clicking on split header focuses its split. (#2720) diff --git a/chatterino.pro b/chatterino.pro index d3114637c..778399a0a 100644 --- a/chatterino.pro +++ b/chatterino.pro @@ -276,7 +276,6 @@ SOURCES += \ src/widgets/dialogs/switcher/NewTabItem.cpp \ src/widgets/dialogs/switcher/QuickSwitcherPopup.cpp \ src/widgets/dialogs/switcher/SwitchSplitItem.cpp \ - src/widgets/dialogs/TextInputDialog.cpp \ src/widgets/dialogs/UpdateDialog.cpp \ src/widgets/dialogs/UserInfoPopup.cpp \ src/widgets/dialogs/WelcomeDialog.cpp \ @@ -533,7 +532,6 @@ HEADERS += \ src/widgets/dialogs/switcher/QuickSwitcherModel.hpp \ src/widgets/dialogs/switcher/QuickSwitcherPopup.hpp \ src/widgets/dialogs/switcher/SwitchSplitItem.hpp \ - src/widgets/dialogs/TextInputDialog.hpp \ src/widgets/dialogs/UpdateDialog.hpp \ src/widgets/dialogs/UserInfoPopup.hpp \ src/widgets/dialogs/WelcomeDialog.hpp \ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2f59b1cb1..39d9a0bf6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -342,8 +342,6 @@ set(SOURCE_FILES main.cpp widgets/dialogs/SelectChannelFiltersDialog.hpp widgets/dialogs/SettingsDialog.cpp widgets/dialogs/SettingsDialog.hpp - widgets/dialogs/TextInputDialog.cpp - widgets/dialogs/TextInputDialog.hpp widgets/dialogs/UpdateDialog.cpp widgets/dialogs/UpdateDialog.hpp widgets/dialogs/UserInfoPopup.cpp diff --git a/src/widgets/dialogs/TextInputDialog.cpp b/src/widgets/dialogs/TextInputDialog.cpp deleted file mode 100644 index f42c8fe93..000000000 --- a/src/widgets/dialogs/TextInputDialog.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include "widgets/dialogs/TextInputDialog.hpp" -#include - -namespace chatterino { - -TextInputDialog::TextInputDialog(QWidget *parent) - : QDialog(parent) - , vbox_(this) - , okButton_("OK") - , cancelButton_("Cancel") -{ - this->vbox_.addWidget(&lineEdit_); - this->vbox_.addLayout(&buttonBox_); - this->buttonBox_.addStretch(1); - this->buttonBox_.addWidget(&okButton_); - this->buttonBox_.addWidget(&cancelButton_); - - QObject::connect(&this->okButton_, SIGNAL(clicked()), this, - SLOT(okButtonClicked())); - QObject::connect(&this->cancelButton_, SIGNAL(clicked()), this, - SLOT(cancelButtonClicked())); - - this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - - this->setWindowFlags( - (this->windowFlags() & ~(Qt::WindowContextHelpButtonHint)) | - Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint); -} - -QString TextInputDialog::getText() const -{ - return this->lineEdit_.text(); -} - -void TextInputDialog::setText(const QString &text) -{ - this->lineEdit_.setText(text); -} - -void TextInputDialog::okButtonClicked() -{ - this->accept(); - this->close(); -} - -void TextInputDialog::cancelButtonClicked() -{ - this->reject(); - this->close(); -} - -void TextInputDialog::highlightText() -{ - this->lineEdit_.selectAll(); -} - -} // namespace chatterino diff --git a/src/widgets/dialogs/TextInputDialog.hpp b/src/widgets/dialogs/TextInputDialog.hpp deleted file mode 100644 index 2fa6f7291..000000000 --- a/src/widgets/dialogs/TextInputDialog.hpp +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include - -namespace chatterino { - -class TextInputDialog : public QDialog -{ - Q_OBJECT - -public: - TextInputDialog(QWidget *parent = nullptr); - - QString getText() const; - void setText(const QString &text); - - void highlightText(); - -private: - QVBoxLayout vbox_; - QLineEdit lineEdit_; - QHBoxLayout buttonBox_; - QPushButton okButton_; - QPushButton cancelButton_; - -private slots: - void okButtonClicked(); - void cancelButtonClicked(); -}; - -} // namespace chatterino diff --git a/src/widgets/helper/NotebookTab.cpp b/src/widgets/helper/NotebookTab.cpp index 66bd9ef4e..190dd9b35 100644 --- a/src/widgets/helper/NotebookTab.cpp +++ b/src/widgets/helper/NotebookTab.cpp @@ -10,7 +10,6 @@ #include "util/Helpers.hpp" #include "widgets/Notebook.hpp" #include "widgets/dialogs/SettingsDialog.hpp" -#include "widgets/dialogs/TextInputDialog.hpp" #include "widgets/splits/SplitContainer.hpp" #include @@ -54,16 +53,16 @@ NotebookTab::NotebookTab(Notebook *notebook) this->setMouseTracking(true); - this->menu_.addAction("Rename", [this]() { + this->menu_.addAction("Rename Tab", [this]() { this->showRenameDialog(); }); - this->menu_.addAction("Close", [=]() { + this->menu_.addAction("Close Tab", [=]() { this->notebook_->removePage(this->page); }); highlightNewMessagesAction_ = - new QAction("Enable highlights on new messages", &this->menu_); + new QAction("Mark Tab as Unread on New Messages", &this->menu_); highlightNewMessagesAction_->setCheckable(true); highlightNewMessagesAction_->setChecked(highlightEnabled_); QObject::connect(highlightNewMessagesAction_, &QAction::triggered, @@ -75,15 +74,48 @@ NotebookTab::NotebookTab(Notebook *notebook) void NotebookTab::showRenameDialog() { - TextInputDialog d(this); + auto dialog = new QDialog(this); - d.setWindowTitle("Choose tab title (Empty for default)"); - d.setText(this->getCustomTitle()); - d.highlightText(); + auto vbox = new QVBoxLayout; - if (d.exec() == QDialog::Accepted) + auto lineEdit = new QLineEdit; + lineEdit->setText(this->getCustomTitle()); + lineEdit->setPlaceholderText(this->getDefaultTitle()); + lineEdit->selectAll(); + + vbox->addWidget(new QLabel("Name:")); + vbox->addWidget(lineEdit); + vbox->addStretch(1); + + auto buttonBox = + new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + + vbox->addWidget(buttonBox); + dialog->setLayout(vbox); + + QObject::connect(buttonBox, &QDialogButtonBox::accepted, [dialog] { + dialog->accept(); + dialog->close(); + }); + + QObject::connect(buttonBox, &QDialogButtonBox::rejected, [dialog] { + dialog->reject(); + dialog->close(); + }); + + dialog->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + dialog->setMinimumSize(dialog->minimumSizeHint().width() + 50, + dialog->minimumSizeHint().height() + 10); + + dialog->setWindowFlags( + (dialog->windowFlags() & ~(Qt::WindowContextHelpButtonHint)) | + Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint); + + dialog->setWindowTitle("Rename Tab"); + + if (dialog->exec() == QDialog::Accepted) { - QString newTitle = d.getText(); + QString newTitle = lineEdit->text(); this->setCustomTitle(newTitle); } } diff --git a/src/widgets/splits/Split.cpp b/src/widgets/splits/Split.cpp index 7a4732271..897bf511c 100644 --- a/src/widgets/splits/Split.cpp +++ b/src/widgets/splits/Split.cpp @@ -24,7 +24,6 @@ #include "widgets/dialogs/QualityPopup.hpp" #include "widgets/dialogs/SelectChannelDialog.hpp" #include "widgets/dialogs/SelectChannelFiltersDialog.hpp" -#include "widgets/dialogs/TextInputDialog.hpp" #include "widgets/dialogs/UserInfoPopup.hpp" #include "widgets/helper/ChannelView.hpp" #include "widgets/helper/DebugPopup.hpp"