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:
@@ -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
|
||||
Reference in New Issue
Block a user