Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions TabToolbar.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
TEMPLATE = subdirs

SUBDIRS += \
TabToolbar \
examples/SaveQss \
examples/Test \
examples/TestNoJson

CONFIG += ordered
4 changes: 4 additions & 0 deletions TabToolbar/TabToolbar.pri
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
INCLUDEPATH += $$PWD/TabToolbar
DEPENDPATH += $$PWD/TabToolbar
include($$PWD/../common.pri)
LIBS += -L$${DESTDIR} -lTabToolbar
53 changes: 53 additions & 0 deletions TabToolbar/TabToolbar.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TEMPLATE = lib
DEFINES += TT_BUILDING_DLL

CONFIG += c++11

# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

# Default rules for deployment.
unix {
target.path = /usr/lib
}
!isEmpty(target.path): INSTALLS += target

SOURCES += \
../src/TabToolbar/Builder.cpp \
../src/TabToolbar/CompactToolButton.cpp \
../src/TabToolbar/Group.cpp \
../src/TabToolbar/Page.cpp \
../src/TabToolbar/StyleTools.cpp \
../src/TabToolbar/Styles.cpp \
../src/TabToolbar/SubGroup.cpp \
../src/TabToolbar/TabToolbar.cpp \
../src/TabToolbar/ToolButtonStyle.cpp

HEADERS += \
../include/TabToolbar/API.h \
../include/TabToolbar/Builder.h \
../include/TabToolbar/CompactToolButton.h \
../include/TabToolbar/Group.h \
../include/TabToolbar/Page.h \
../include/TabToolbar/StyleTools.h \
../include/TabToolbar/Styles.h \
../include/TabToolbar/SubGroup.h \
../include/TabToolbar/TabToolbar.h \
../include/TabToolbar/ToolButtonStyle.h

RESOURCES += \
../src/TabToolbar/StyleTemplate.qrc

include($$PWD/../common.pri)
20 changes: 20 additions & 0 deletions common.pri
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
CONFIG(debug, debug|release){
contains(QT_ARCH, i386) {
DESTDIR = $$PWD/x86/debug
}else {
DESTDIR = $$PWD/x64/debug
}
}else{
contains(QT_ARCH, i386) {
DESTDIR = $$PWD/x86/release
}else {
DESTDIR = $$PWD/x64/release
}
}

msvc {
QMAKE_CFLAGS += /utf-8
QMAKE_CXXFLAGS += /utf-8
}

INCLUDEPATH += $$PWD/include
19 changes: 19 additions & 0 deletions examples/SaveQss/SaveQss.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11

# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
main.cpp

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

include($$PWD/../../TabToolbar/TabToolbar.pri)
28 changes: 28 additions & 0 deletions examples/SaveQss/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <QApplication>
#include "TabToolbar/StyleTools.h"
#include "TabToolbar/Styles.h"
#include <QFile>

using namespace tt;

int main(int argc, char *argv[])
{
QApplication a(argc, argv);

QStringList styleNames = GetRegisteredStyles();
std::unique_ptr<StyleParams> pStyleParams;
QString appDirPath = QApplication::applicationDirPath();
for (const QString & styleName : styleNames)
{
pStyleParams.reset(CreateStyle(styleName).release());
QString styleSheet = GetSheetForStyle(*pStyleParams);

QFile qssFile(appDirPath + "/" + styleName + ".qss");
qssFile.open(QFile::WriteOnly);
qssFile.write(styleSheet.toLocal8Bit());
qssFile.close();
}

// int ret=a.exec();
return 0;
}
36 changes: 36 additions & 0 deletions examples/Test/Test.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11

# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

SOURCES += \
main.cpp \
mainwindow.cpp

HEADERS += \
mainwindow.h

FORMS += \
mainwindow.ui

RESOURCES += \
res.qrc

include($$PWD/../../TabToolbar/TabToolbar.pri)
36 changes: 36 additions & 0 deletions examples/TestNoJson/TestNoJson.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11

# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

SOURCES += \
main.cpp \
mainwindow.cpp

HEADERS += \
mainwindow.h

FORMS += \
mainwindow.ui

RESOURCES += \
res.qrc

include($$PWD/../../TabToolbar/TabToolbar.pri)
Binary file added examples/TestNoJson/icons/48px-AddTexture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/TestNoJson/icons/48px-Document-new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/TestNoJson/icons/48px-Document-open.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/TestNoJson/icons/48px-Document-save.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/TestNoJson/icons/48px-Edit-redo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/TestNoJson/icons/48px-Edit-undo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/TestNoJson/icons/48px-Go-bottom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/TestNoJson/icons/48px-Polypaint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/TestNoJson/icons/48px-Printer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/TestNoJson/icons/48px-System-log-out.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/TestNoJson/icons/48px-View-refresh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/TestNoJson/icons/48px-View-zoom-fit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/TestNoJson/icons/Flaps_mode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/TestNoJson/icons/Help-browser.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/TestNoJson/icons/Move_mode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/TestNoJson/icons/Scale.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/TestNoJson/icons/Select_mode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/TestNoJson/icons/close.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/TestNoJson/icons/light_bulb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/TestNoJson/icons/stupid_logo.png
28 changes: 28 additions & 0 deletions examples/TestNoJson/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
TabToolbar - a small utility library for Qt, providing tabbed toolbars
Copyright (C) 2018 Oleksii Sierov

TabToolbar is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

TabToolbar is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with TabToolbar. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QApplication>
#include "mainwindow.h"

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
CMainWindow w;
w.show();

return a.exec();
}
150 changes: 150 additions & 0 deletions examples/TestNoJson/mainwindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
/*
TabToolbar - a small utility library for Qt, providing tabbed toolbars
Copyright (C) 2018 Oleksii Sierov

TabToolbar is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

TabToolbar is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with TabToolbar. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QMenu>
#include <QCheckBox>
#include <QComboBox>
#include <QSpinBox>
#include <QLineEdit>
#include <QTextEdit>
#include <QLabel>
#include <QMessageBox>
#include <QPushButton>
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <TabToolbar/TabToolbar.h>
#include <TabToolbar/Page.h>
#include <TabToolbar/Group.h>
#include <TabToolbar/SubGroup.h>
#include <TabToolbar/StyleTools.h>
#include <TabToolbar/Builder.h>

CMainWindow::CMainWindow(QWidget* parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->statusBar->addPermanentWidget(new QLabel("Some fancy status."));

tt::TabToolbar* tabToolbar = new tt::TabToolbar(this, 75, 3);
addToolBar(Qt::TopToolBarArea, tabToolbar);

QMenu* dummyMenu = new QMenu(this);
dummyMenu->setObjectName("dummyMenu");
dummyMenu->addActions({ui->actionDummy});
dummyMenu->addSeparator();
dummyMenu->addAction(ui->actionHelp);

tabToolbar->AddPage("File");
static bool kek = true;
tt::Page* editPage = tabToolbar->AddPage("Edit");

tt::Group * editGroup1 = editPage->AddGroup("Styles");
tt::SubGroup * editGroup1sub1 = editGroup1->AddSubGroup(tt::SubGroup::Align::Yes);
QPushButton * nativeStyleButton = new QPushButton();
editGroup1sub1->AddWidget(nativeStyleButton);
QPushButton * defaultStyleButton = new QPushButton();
editGroup1sub1->AddWidget(defaultStyleButton);

editGroup1->AddSeparator();
QStringList styles = tt::GetRegisteredStyles();
for (int i = 0; i < styles.size(); i++)
{
const QString styleName = styles.at(i);
QPushButton* styleButton = new QPushButton(styleName, this);
QObject::connect(styleButton, &QPushButton::clicked,
[styleName, tabToolbar]() { tabToolbar->SetStyle(styleName); });
editGroup1->AddWidget(styleButton);
}

tt::RegisterStyle("NoStyle", []()
{
tt::StyleParams* params = new tt::StyleParams();
params->UseTemplateSheet = false;
params->AdditionalStyleSheet = "";
return params;
});
nativeStyleButton->setText("No Style");
QObject::connect(nativeStyleButton, &QPushButton::clicked,
[tabToolbar]() { tabToolbar->SetStyle("NoStyle"); });
defaultStyleButton->setText("Default");
QObject::connect(defaultStyleButton, &QPushButton::clicked,
[tabToolbar]() { tabToolbar->SetStyle(tt::GetDefaultStyle()); });

tt::Page* viewPage = tabToolbar->AddPage("View");
tt::Group* viewGroup1 = viewPage->AddGroup("Group 1");
tt::Group* viewGroup2 = viewPage->AddGroup("Group 2");
tt::Group* viewGroup3 = viewPage->AddGroup("Group 3");
viewGroup1->AddAction(QToolButton::DelayedPopup, ui->actionOpen);
viewGroup1->AddSeparator();
viewGroup1->AddAction(QToolButton::DelayedPopup, ui->actionSave);
viewGroup1->AddAction(QToolButton::DelayedPopup, ui->actionSaveAs);
viewGroup2->AddAction(QToolButton::InstantPopup, ui->actionPolypaint, dummyMenu);
viewGroup2->AddAction(QToolButton::InstantPopup, ui->actionScale, dummyMenu);
viewGroup2->AddSeparator();
QTextEdit* textEdit = new QTextEdit();
viewGroup2->AddWidget(textEdit);
textEdit->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Ignored);
textEdit->setMaximumWidth(100);
tt::SubGroup* viewGroup2sub1 = viewGroup2->AddSubGroup(tt::SubGroup::Align::Yes);
viewGroup2sub1->AddAction(QToolButton::DelayedPopup, ui->actionUndo);
viewGroup2sub1->AddAction(QToolButton::DelayedPopup, ui->actionRedo);
viewGroup2sub1->AddAction(QToolButton::InstantPopup, ui->actionClose, dummyMenu);
viewGroup3->AddAction(QToolButton::MenuButtonPopup, ui->actionSettings, dummyMenu);
tt::SubGroup* viewGroup3sub1 = viewGroup3->AddSubGroup(tt::SubGroup::Align::Yes);
viewGroup3sub1->AddHorizontalButtons({{QToolButton::DelayedPopup, ui->actionSave},
{QToolButton::InstantPopup, ui->actionPolypaint, dummyMenu},
{QToolButton::MenuButtonPopup, ui->actionSettings, dummyMenu}});

viewGroup3sub1->AddHorizontalButtons({{QToolButton::DelayedPopup, ui->actionUndo},
{QToolButton::DelayedPopup, ui->actionRedo},
{QToolButton::InstantPopup, ui->actionClose, dummyMenu}});
QCheckBox* checkBox = new QCheckBox("Check 1");
viewGroup3sub1->AddWidget(checkBox);

viewGroup3->AddSeparator();
tt::SubGroup* viewGroup3sub2 = viewGroup3->AddSubGroup(tt::SubGroup::Align::No);
QPushButton* pushButton = new QPushButton("Edit");
viewGroup3sub2->AddWidget(pushButton);
viewGroup3sub2->AddAction(QToolButton::DelayedPopup, ui->actionSaveAs);
QObject::connect(pushButton, &QPushButton::clicked, [editPage]()
{
if(kek)
editPage->hide();
else
editPage->show();
kek = !kek;
});

tt::Page* helpPage = tabToolbar->AddPage("Help");
tt::Group * helpGroup1 = helpPage->AddGroup("");
helpGroup1->AddAction(QToolButton::DelayedPopup, ui->actionHelp);

tabToolbar->SetSpecialTabEnabled(true);
tabToolbar->AddCornerAction(ui->actionHelp);
QObject::connect(tabToolbar, &tt::TabToolbar::SpecialTabClicked, this, [this]()
{
QMessageBox::information(this, "Kek", "Cheburek");
});

setWindowTitle("TabToolbar TestNoJson");
}

CMainWindow::~CMainWindow()
{
delete ui;
}
Loading