0
0
mirror of https://github.com/yse/easy_profiler.git synced 2024-12-26 16:11:02 +08:00

refactor and windowheader title

This commit is contained in:
Victor Zarubkin 2019-11-27 19:08:55 +03:00
parent 7637243b43
commit b29113f70b
3 changed files with 17 additions and 1 deletions

View File

@ -69,7 +69,6 @@ BookmarkEditor::BookmarkEditor(size_t bookmarkIndex, bool isNew, QWidget* parent
, m_isNewBookmark(isNew) , m_isNewBookmark(isNew)
{ {
setAttribute(Qt::WA_DeleteOnClose, true); setAttribute(Qt::WA_DeleteOnClose, true);
//setWindowFlags(Qt::Dialog);
setSizeGripEnabled(EASY_GLOBALS.use_custom_window_header); setSizeGripEnabled(EASY_GLOBALS.use_custom_window_header);
const auto& bookmark = EASY_GLOBALS.bookmarks[m_bookmarkIndex]; const auto& bookmark = EASY_GLOBALS.bookmarks[m_bookmarkIndex];
@ -135,6 +134,8 @@ BookmarkEditor::BookmarkEditor(size_t bookmarkIndex, bool isNew, QWidget* parent
const WindowHeader::Buttons buttons {WindowHeader::MaximizeButton | WindowHeader::CloseButton}; const WindowHeader::Buttons buttons {WindowHeader::MaximizeButton | WindowHeader::CloseButton};
auto header = new WindowHeader(isNew ? "New bookmark" : "Edit bookmark", buttons, *this); auto header = new WindowHeader(isNew ? "New bookmark" : "Edit bookmark", buttons, *this);
mainLayout->addWidget(header, 0, Qt::AlignTop); mainLayout->addWidget(header, 0, Qt::AlignTop);
#else
setWindowTitle(isNew ? "New bookmark" : "Edit bookmark");
#endif #endif
mainLayout->addWidget(content, 1); mainLayout->addWidget(content, 1);

View File

@ -74,6 +74,8 @@ WindowHeader::WindowHeader(const QString& title, Buttons buttons, QWidget& paren
{ {
auto parent = &parentRef; auto parent = &parentRef;
parent->setWindowTitle(title);
m_title->installEventFilter(this); m_title->installEventFilter(this);
m_pixmap->installEventFilter(this); m_pixmap->installEventFilter(this);
@ -181,6 +183,12 @@ WindowHeader::~WindowHeader()
void WindowHeader::setTitle(const QString& title) void WindowHeader::setTitle(const QString& title)
{ {
m_title->setText(title); m_title->setText(title);
parentWidget()->setWindowTitle(title);
}
QString WindowHeader::title() const
{
return m_title->text();
} }
void WindowHeader::setWindowIcon(const QIcon& icon) void WindowHeader::setWindowIcon(const QIcon& icon)

View File

@ -97,6 +97,13 @@ public:
setTitle(title); setTitle(title);
} }
QString title() const;
QString windowTitle() const
{
return title();
}
private slots: private slots:
void onWindowStateChanged(); void onWindowStateChanged();