-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
49 changed files
with
2,015 additions
and
2,558 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,39 @@ | ||
# CustomTitlebar | ||
|
||
CustomTitlebar é um projeto cuja classe principal (NMainWindow) deriva da classe QMainWindow da biblioteca Qt. | ||
Ao derivar a janela principal da classe NMainWindow, você poderá desenvolver programas que usarão bordas personalizadas (não geradas pelo SO) - veja as capturas de tela para maiores detalhes. | ||
CustomTitlebar is a project where the main class (QCustomWindow) inherits its properties from QMainWindow, part of Qt Library. | ||
Inheriting the main window from the QCustomWindow class, will allow you to develop programs which will use customized borders (not generated by the OS) - have a look at the screenshots for major details. | ||
|
||
## Suporte e Documentação | ||
<p align="center"> | ||
<img src="/Screenshots/winNormal.png"> | ||
</p> | ||
|
||
Você poderá obter o suporte e documentação para o uso deste projeto em sua [página no site da Nintersoft](https://www.nintersoft.com/portfolio/custom-titlebar/) ou ainda em sua [página de documentação](https://docwiki.nintersoft.com/custom-titlebar/). | ||
|
||
## Características: | ||
- Redimensionável (100% funcional) | ||
- Botões personalizáveis | ||
- Atualização do título da janela (QMainWindow::setWindowTitle(QString)) funcionando; | ||
|
||
Código aberto CustomTitlebar | ||
- Você poderá baixar e fazer suas modificações à vontade, conforme a Licença Pública Mozilla (MPL) v2.0. | ||
- A licença está disponível na raiz da pasta do projeto. | ||
|
||
Caso importe este repositório para seu Git, por favor coloque um link para nossa página e as referências cabíveis à nossa equipe, além de manter o README original. | ||
## Support and Documentation | ||
|
||
Atenciosamente, | ||
Mauro Mascarenhas - Nintersoft. | ||
Docs elaboration is still in progress :( ... | ||
Should you have any doubts, do not hesitate in contacting me through [my email](mailto:[email protected]). | ||
|
||
## EN | ||
## Features: | ||
|
||
# CustomTitlebar | ||
- Customized stylesheet (light theme); | ||
- Resizeable (100% functional); | ||
- Window title update (QMainWindow::setWindowTitle(QString)) working properly; | ||
- Better performance (when compared to previous versions); | ||
- QTabWidgets and QDockWidgets working properly; | ||
- QMenuBar/menu widget can be through QCustomWindow methods (DO NOT CALL IT THROUGH ITS PARENT (QMAINWINDOW) METHODS); | ||
- Available as a Dynamically Linked Library (DLL). | ||
|
||
CustomTitlebar is a project where the main class (NMainWindow) inherits its properties from QMainWindow, which is part of Qt Library. | ||
Inheriting the main window from the NMainWindow class, will allow you to develop programs which will use customized borders (not generated by the OS) - have a look at the screenshots for major details. | ||
## Limitations: | ||
|
||
## Support and Documentation | ||
- It is not recommended to change QToolBar's stylesheet (after it has been added to the QCustomWindow's layout), since the auto-generated one plays and important role in the layout disposition; | ||
- Setting the menu bar/widget through QMainWindow's methods will possibly crash the application (so, it is not possible to generate it through Qt Designer). Should you do that, the window's titlebar is going to be removed and every reference to it is going to break (since the widget gets deleted); | ||
|
||
You are able to get the proper support and documentation in order to use this project on its [page at Nintersoft's website](https://www.nintersoft.com/en/portfolio/custom-titlebar/) or yet on its [documentation page](https://docwiki.nintersoft.com/en/custom-titlebar/). | ||
## Distribution (available versions): | ||
|
||
## Features: | ||
- Resizeable (100% functional) | ||
- BotõesCustomizable buttons | ||
- Window title update (QMainWindow::setWindowTitle(QString)) working properly; | ||
- [x] DLL + LIB + headers; | ||
- [x] Stactic linking/source files; | ||
- [ ] Qt Creator/Designer plugin; | ||
|
||
## CustomTitlebar open source code | ||
- You can download and make some modifications in the source code, according to Mozilla Public Licence v2.0. | ||
- The licence is available in the root of the project folder. | ||
|
||
If you clone this directory into yours, please insert a linkback to our webpage and the correct references to our team, also leaving the original README in your repository. | ||
|
||
Graciously, | ||
Mauro Mascarenhas - Nintersoft. | ||
- You can download and make modifications in the source code, accordingly to Mozilla Public Licence v2.0 terms. | ||
- The licence is available in the root of the project folder and must be always shipped with it. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
# Developer: Mauro Mascarenhas de Araújo | ||
# Contact: [email protected] | ||
# Licence: Mozilla Public Licence 2.0 | ||
# Date: 25 of December of 2019 | ||
# Date: 25 of August of 2020 | ||
# | ||
# Licence notice | ||
# | ||
|
@@ -43,5 +43,5 @@ HEADERS += testwindow.h | |
|
||
FORMS += testwindow.ui | ||
|
||
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/customtitlebar/ -lCustomTitlebar | ||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/customtitlebar/ -lCustomTitlebar | ||
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/customtitlebar/ -lQCustomTitlebar | ||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/customtitlebar/ -lQCustomTitlebar |
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/*------------------------------------------------- | ||
# | ||
# Project developed by Nintersoft team | ||
# Developer: Mauro Mascarenhas de Araújo | ||
# Contact: [email protected] | ||
# Licence: Mozilla Public Licence 2.0 | ||
# Date: 24 of August of 2020 | ||
# | ||
# Licence notice | ||
# | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
# | ||
------------------------------------------------- */ | ||
|
||
#ifndef QCUSTOMWINDOW_H | ||
#define QCUSTOMWINDOW_H | ||
|
||
#include <QtCore/qglobal.h> | ||
|
||
#if defined(QCUSTOMTITLEBAR_LIBRARY) | ||
# define QCUSTOMTITLEBARSHARED_EXPORT Q_DECL_EXPORT | ||
#else | ||
# define QCUSTOMTITLEBARSHARED_EXPORT Q_DECL_IMPORT | ||
#endif | ||
|
||
#include <QMenu> | ||
#include <QRect> | ||
#include <QPoint> | ||
#include <QObject> | ||
#include <QWidget> | ||
#include <QCursor> | ||
#include <QMenuBar> | ||
#include <QToolBar> | ||
#include <QStatusBar> | ||
#include <QMetaMethod> | ||
#include <QMetaObject> | ||
#include <QDockWidget> | ||
#include <QMainWindow> | ||
#include <QMouseEvent> | ||
#include <QVBoxLayout> | ||
|
||
#include "qtitlebar.h" | ||
|
||
class QCUSTOMTITLEBARSHARED_EXPORT QCustomWindow : public QMainWindow | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit QCustomWindow(QWidget *parent = nullptr); | ||
~QCustomWindow() override; | ||
|
||
QMenu * createPopupMenu() override; | ||
|
||
void setMenuBar(QMenuBar *menuBar); | ||
QMenuBar * menuBar() const; | ||
|
||
void setMenuWidget(QWidget *widget); | ||
QWidget * menuWidget() const; | ||
|
||
inline QTitleBar& titleBar() const { return *this->m_titleBar; } | ||
|
||
protected: | ||
const int RESIZE_LIMIT; | ||
|
||
bool event(QEvent *event) override; | ||
void mousePressEvent(QMouseEvent *event) override; | ||
void mouseReleaseEvent(QMouseEvent *event) override; | ||
bool eventFilter(QObject *watched, QEvent *event) override; | ||
|
||
void customMouseMoveEvent(QMouseEvent* event); | ||
|
||
private: | ||
bool init; | ||
|
||
QWidget *m_titleBarW; | ||
QWidget *m_menuWidget; | ||
QMenuBar *m_menuBar; | ||
QTitleBar *m_titleBar; | ||
|
||
QToolBar *m_leftBorder; | ||
QToolBar *m_rightBorder; | ||
QToolBar *m_bottomBorder; | ||
|
||
Qt::Edges m_lock; | ||
QPoint m_posCursor; | ||
|
||
QToolBar * generateBorder(Qt::ToolBarArea area, Qt::Orientation orientation); | ||
}; | ||
|
||
#endif // QCUSTOMWINDOW_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/*------------------------------------------------- | ||
# | ||
# Project developed by Nintersoft team | ||
# Developer: Mauro Mascarenhas de Araújo | ||
# Contact: [email protected] | ||
# Licence: Mozilla Public Licence 2.0 | ||
# Date: 24 of August of 2020 | ||
# | ||
# Licence notice | ||
# | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
# | ||
------------------------------------------------- */ | ||
|
||
#ifndef QTITLEBAR_H | ||
#define QTITLEBAR_H | ||
|
||
#include <QtCore/qglobal.h> | ||
|
||
#if defined(QCUSTOMTITLEBAR_LIBRARY) | ||
# define QCUSTOMTITLEBARSHARED_EXPORT Q_DECL_EXPORT | ||
#else | ||
# define QCUSTOMTITLEBARSHARED_EXPORT Q_DECL_IMPORT | ||
#endif | ||
|
||
#include <QSize> | ||
#include <QEvent> | ||
#include <QLabel> | ||
#include <QPoint> | ||
#include <QWidget> | ||
#include <QPainter> | ||
#include <QMainWindow> | ||
#include <QHBoxLayout> | ||
#include <QMouseEvent> | ||
#include <QPaintEvent> | ||
#include <QPushButton> | ||
#include <QStyleOption> | ||
|
||
#include <exception> | ||
|
||
namespace QCustomAttrs { | ||
enum WindowButton { | ||
Minimize = 0x01, | ||
Maximize = 0x02, | ||
Close = 0x04, | ||
All = Minimize | Maximize | Close | ||
}; | ||
|
||
Q_DECLARE_FLAGS(WindowButtons, WindowButton) | ||
Q_DECLARE_OPERATORS_FOR_FLAGS(WindowButtons) | ||
} | ||
|
||
class QCUSTOMTITLEBARSHARED_EXPORT QTitleBar : public QWidget | ||
{ | ||
Q_OBJECT | ||
Q_PROPERTY(QCustomAttrs::WindowButtons windowButtons READ windowButtons WRITE setWindowButtons) | ||
Q_CLASSINFO("custom_obj_type", "QTitleBar") | ||
public: | ||
explicit QTitleBar(QMainWindow *parent = nullptr); | ||
|
||
void setWindowButtons(QCustomAttrs::WindowButtons btns); | ||
inline QCustomAttrs::WindowButtons windowButtons() const { return this->m_frameButtons; } | ||
|
||
void setWindowButtonEnabled(QCustomAttrs::WindowButton btn, bool enabled = true); | ||
|
||
protected: | ||
void paintEvent(QPaintEvent *event) override; | ||
void mouseMoveEvent(QMouseEvent *event) override; | ||
void mousePressEvent(QMouseEvent *event) override; | ||
void mouseDoubleClickEvent(QMouseEvent *event) override; | ||
|
||
private: | ||
bool canMove; | ||
bool maximizing; | ||
|
||
QPoint m_pCursor; | ||
const QSize FRAME_BUTTON_SIZE; | ||
|
||
QWidget *m_parentWindow; | ||
|
||
QCustomAttrs::WindowButtons m_frameButtons; | ||
|
||
QLabel lbl_windowTitle; | ||
QHBoxLayout m_layout; | ||
QPushButton btn_minimize; | ||
QPushButton btn_maximize; | ||
QPushButton btn_close; | ||
|
||
signals: | ||
void requestClose(); | ||
void requestMaximize(); | ||
void requestMinimize(); | ||
}; | ||
|
||
#endif // QTITLEBAR_H |
Oops, something went wrong.