mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Refactored Rename Tab dialog and its context menu (#2713)
* Added placeholder to tab rename dialog's input
* Always set placeholder to default tab name.
* Renamed context menu entries, updated popup
* Removed TextInputDialog class, slight popup fix
* Forgot to rename variable (no fun allowed 😥)
* forsenT
* Made use of QDialogButtonBox
* Added changelog entry
This commit is contained in:
parent
b614ce1cd8
commit
f7506d495f
7 changed files with 43 additions and 108 deletions
|
@ -7,6 +7,7 @@
|
||||||
- Minor: Added image links to the badge context menu. (#2667)
|
- Minor: Added image links to the badge context menu. (#2667)
|
||||||
- Minor: Added a setting to hide Twitch Predictions badges. (#2668)
|
- Minor: Added a setting to hide Twitch Predictions badges. (#2668)
|
||||||
- Minor: Optionally remove spaces between emotes, originally made for Mm2PL/Dankerino. (#2651)
|
- 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: Added missing Copy/Open link context menu entries to emotes in Emote Picker. (#2670)
|
||||||
- Bugfix: Fixed visual glitch with smooth scrolling. (#2084)
|
- Bugfix: Fixed visual glitch with smooth scrolling. (#2084)
|
||||||
- Bugfix: Clicking on split header focuses its split. (#2720)
|
- Bugfix: Clicking on split header focuses its split. (#2720)
|
||||||
|
|
|
@ -276,7 +276,6 @@ SOURCES += \
|
||||||
src/widgets/dialogs/switcher/NewTabItem.cpp \
|
src/widgets/dialogs/switcher/NewTabItem.cpp \
|
||||||
src/widgets/dialogs/switcher/QuickSwitcherPopup.cpp \
|
src/widgets/dialogs/switcher/QuickSwitcherPopup.cpp \
|
||||||
src/widgets/dialogs/switcher/SwitchSplitItem.cpp \
|
src/widgets/dialogs/switcher/SwitchSplitItem.cpp \
|
||||||
src/widgets/dialogs/TextInputDialog.cpp \
|
|
||||||
src/widgets/dialogs/UpdateDialog.cpp \
|
src/widgets/dialogs/UpdateDialog.cpp \
|
||||||
src/widgets/dialogs/UserInfoPopup.cpp \
|
src/widgets/dialogs/UserInfoPopup.cpp \
|
||||||
src/widgets/dialogs/WelcomeDialog.cpp \
|
src/widgets/dialogs/WelcomeDialog.cpp \
|
||||||
|
@ -533,7 +532,6 @@ HEADERS += \
|
||||||
src/widgets/dialogs/switcher/QuickSwitcherModel.hpp \
|
src/widgets/dialogs/switcher/QuickSwitcherModel.hpp \
|
||||||
src/widgets/dialogs/switcher/QuickSwitcherPopup.hpp \
|
src/widgets/dialogs/switcher/QuickSwitcherPopup.hpp \
|
||||||
src/widgets/dialogs/switcher/SwitchSplitItem.hpp \
|
src/widgets/dialogs/switcher/SwitchSplitItem.hpp \
|
||||||
src/widgets/dialogs/TextInputDialog.hpp \
|
|
||||||
src/widgets/dialogs/UpdateDialog.hpp \
|
src/widgets/dialogs/UpdateDialog.hpp \
|
||||||
src/widgets/dialogs/UserInfoPopup.hpp \
|
src/widgets/dialogs/UserInfoPopup.hpp \
|
||||||
src/widgets/dialogs/WelcomeDialog.hpp \
|
src/widgets/dialogs/WelcomeDialog.hpp \
|
||||||
|
|
|
@ -342,8 +342,6 @@ set(SOURCE_FILES main.cpp
|
||||||
widgets/dialogs/SelectChannelFiltersDialog.hpp
|
widgets/dialogs/SelectChannelFiltersDialog.hpp
|
||||||
widgets/dialogs/SettingsDialog.cpp
|
widgets/dialogs/SettingsDialog.cpp
|
||||||
widgets/dialogs/SettingsDialog.hpp
|
widgets/dialogs/SettingsDialog.hpp
|
||||||
widgets/dialogs/TextInputDialog.cpp
|
|
||||||
widgets/dialogs/TextInputDialog.hpp
|
|
||||||
widgets/dialogs/UpdateDialog.cpp
|
widgets/dialogs/UpdateDialog.cpp
|
||||||
widgets/dialogs/UpdateDialog.hpp
|
widgets/dialogs/UpdateDialog.hpp
|
||||||
widgets/dialogs/UserInfoPopup.cpp
|
widgets/dialogs/UserInfoPopup.cpp
|
||||||
|
|
|
@ -1,57 +0,0 @@
|
||||||
#include "widgets/dialogs/TextInputDialog.hpp"
|
|
||||||
#include <QSizePolicy>
|
|
||||||
|
|
||||||
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
|
|
|
@ -1,36 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
#include <QHBoxLayout>
|
|
||||||
#include <QLineEdit>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QString>
|
|
||||||
#include <QVBoxLayout>
|
|
||||||
|
|
||||||
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
|
|
|
@ -10,7 +10,6 @@
|
||||||
#include "util/Helpers.hpp"
|
#include "util/Helpers.hpp"
|
||||||
#include "widgets/Notebook.hpp"
|
#include "widgets/Notebook.hpp"
|
||||||
#include "widgets/dialogs/SettingsDialog.hpp"
|
#include "widgets/dialogs/SettingsDialog.hpp"
|
||||||
#include "widgets/dialogs/TextInputDialog.hpp"
|
|
||||||
#include "widgets/splits/SplitContainer.hpp"
|
#include "widgets/splits/SplitContainer.hpp"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
@ -54,16 +53,16 @@ NotebookTab::NotebookTab(Notebook *notebook)
|
||||||
|
|
||||||
this->setMouseTracking(true);
|
this->setMouseTracking(true);
|
||||||
|
|
||||||
this->menu_.addAction("Rename", [this]() {
|
this->menu_.addAction("Rename Tab", [this]() {
|
||||||
this->showRenameDialog();
|
this->showRenameDialog();
|
||||||
});
|
});
|
||||||
|
|
||||||
this->menu_.addAction("Close", [=]() {
|
this->menu_.addAction("Close Tab", [=]() {
|
||||||
this->notebook_->removePage(this->page);
|
this->notebook_->removePage(this->page);
|
||||||
});
|
});
|
||||||
|
|
||||||
highlightNewMessagesAction_ =
|
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_->setCheckable(true);
|
||||||
highlightNewMessagesAction_->setChecked(highlightEnabled_);
|
highlightNewMessagesAction_->setChecked(highlightEnabled_);
|
||||||
QObject::connect(highlightNewMessagesAction_, &QAction::triggered,
|
QObject::connect(highlightNewMessagesAction_, &QAction::triggered,
|
||||||
|
@ -75,15 +74,48 @@ NotebookTab::NotebookTab(Notebook *notebook)
|
||||||
|
|
||||||
void NotebookTab::showRenameDialog()
|
void NotebookTab::showRenameDialog()
|
||||||
{
|
{
|
||||||
TextInputDialog d(this);
|
auto dialog = new QDialog(this);
|
||||||
|
|
||||||
d.setWindowTitle("Choose tab title (Empty for default)");
|
auto vbox = new QVBoxLayout;
|
||||||
d.setText(this->getCustomTitle());
|
|
||||||
d.highlightText();
|
|
||||||
|
|
||||||
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);
|
this->setCustomTitle(newTitle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include "widgets/dialogs/QualityPopup.hpp"
|
#include "widgets/dialogs/QualityPopup.hpp"
|
||||||
#include "widgets/dialogs/SelectChannelDialog.hpp"
|
#include "widgets/dialogs/SelectChannelDialog.hpp"
|
||||||
#include "widgets/dialogs/SelectChannelFiltersDialog.hpp"
|
#include "widgets/dialogs/SelectChannelFiltersDialog.hpp"
|
||||||
#include "widgets/dialogs/TextInputDialog.hpp"
|
|
||||||
#include "widgets/dialogs/UserInfoPopup.hpp"
|
#include "widgets/dialogs/UserInfoPopup.hpp"
|
||||||
#include "widgets/helper/ChannelView.hpp"
|
#include "widgets/helper/ChannelView.hpp"
|
||||||
#include "widgets/helper/DebugPopup.hpp"
|
#include "widgets/helper/DebugPopup.hpp"
|
||||||
|
|
Loading…
Reference in a new issue