Commit afecac50 authored by WINTZ Julien's avatar WINTZ Julien

Merge branch 'develop' into feature/menu

parents 583f0fff 97769cd0
......@@ -15,7 +15,6 @@
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/examples)
add_subdirectory(dtkWidgetsOverlayPaneItems)
add_subdirectory(dtkWidgetsStylesheetParser)
add_subdirectory(dtkWidgetsScroller)
add_subdirectory(dtkWidgetsLayout)
add_subdirectory(dtkWidgetsMenu)
......
## Version: $Id$
##
######################################################################
##
### Commentary:
##
######################################################################
##
### Change Log:
##
######################################################################
##
### Code:
project(dtkWidgetsOverlayPaneItemsManager)
## #################################################################
## Sources
## #################################################################
set(${PROJECT_NAME}_SOURCES main.cpp)
set(${PROJECT_NAME}_SOURCES_QRC main.qrc)
## #################################################################
## Build rules
## #################################################################
qt5_add_resources(${PROJECT_NAME}_SOURCES_RCC ${${PROJECT_NAME}_SOURCES_QRC})
add_executable(${PROJECT_NAME}
${${PROJECT_NAME}_SOURCES}
${${PROJECT_NAME}_SOURCES_RCC})
target_link_libraries(${PROJECT_NAME} Qt5::Core)
target_link_libraries(${PROJECT_NAME} Qt5::Widgets)
target_link_libraries(${PROJECT_NAME} dtkFonts)
target_link_libraries(${PROJECT_NAME} dtkWidgets)
######################################################################
### CMakeLists.txt ends here
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#include <QtCore>
#include <QtWidgets>
#include <dtkFonts>
#include <dtkWidgets>
// ///////////////////////////////////////////////////////////////////
//
// ///////////////////////////////////////////////////////////////////
QString dtkReadFile(const QString& path)
{
QFile file(path);
if(!file.open(QIODevice::ReadOnly))
return QString();
QString contents = file.readAll();
file.close();
return contents;
}
// ///////////////////////////////////////////////////////////////////
//
// ///////////////////////////////////////////////////////////////////
class dummy : public QFrame
{
Q_OBJECT
public:
dummy(void);
~dummy(void) {}
protected:
void resizeEvent(QResizeEvent *event);
private:
dtkWidgetsOverlayPane *pane_1;
dtkWidgetsOverlayPane *pane_2;
dtkWidgetsOverlayPaneItem *item_1;
dtkWidgetsOverlayPaneItem *item_2;
dtkWidgetsOverlayPaneSlider *slide_1;
dtkWidgetsOverlayPaneManager *pane_manager;
dtkWidgetsHUD *hud;
};
dummy::dummy(void) : QFrame()
{
QFrame *frame_1 = new QFrame(this);
QFrame *frame_2 = new QFrame(this);
QFrame *frame_3 = new QFrame(this);
QFrame *frame_4 = new QFrame(this);
QFrame *frame_5 = new QFrame(this);
frame_1->setStyleSheet("background: #ff0000;"); frame_1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
frame_2->setStyleSheet("background: #ffff00;"); frame_2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
frame_3->setStyleSheet("background: #ffffff;"); frame_3->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
frame_4->setStyleSheet("background: #00ff00;"); frame_4->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
frame_5->setStyleSheet("background: #00ffff;"); frame_5->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
this->item_1 = new dtkWidgetsOverlayPaneItem(this);
this->item_1->setTitle("Item 1");
this->item_1->addWidget(frame_1);
this->item_2 = new dtkWidgetsOverlayPaneItem(this);
this->item_2->setTitle("Item 2");
this->item_2->addWidget(frame_2);
this->slide_1 = new dtkWidgetsOverlayPaneSlider(this);
this->slide_1->setTitle("Slide 1");
this->slide_1->addSlide(fa::dotcircleo, frame_3);
this->slide_1->addSlide(fa::dotcircleo, frame_4);
this->slide_1->addSlide(fa::dotcircleo, frame_5);
this->pane_1 = new dtkWidgetsOverlayPane(this);
this->pane_1->addWidget(this->item_1);
this->pane_1->addWidget(this->item_2);
this->pane_1->addWidget(this->slide_1);
this->pane_2 = new dtkWidgetsOverlayPane(this, fa::bank);
this->pane_2->addWidget(this->slide_1);
this->pane_manager = new dtkWidgetsOverlayPaneManager();
this->pane_manager->addPane(this->pane_1);
this->pane_manager->addPane(this->pane_2);
this->hud = new dtkWidgetsHUD(this);
// this->pane_1->toggle();
}
void dummy::resizeEvent(QResizeEvent *event)
{
this->hud->resize(event->size());
this->pane_1->setFixedHeight(event->size().height());
this->pane_2->setFixedHeight(event->size().height());
}
// ///////////////////////////////////////////////////////////////////
//
// ///////////////////////////////////////////////////////////////////
int main(int argc, char **argv)
{
QApplication application(argc, argv);
dummy *window = new dummy;
window->resize(1024, 600);
window->show();
window->raise();
window->setStyleSheet(dtkReadFile(":main.qss"));
return application.exec();
}
// ///////////////////////////////////////////////////////////////////
#include "main.moc"
//
// main.cpp ends here
<!DOCTYPE RCC>
<RCC version="1.0">
<qresource>
<file>main.qss</file>
</qresource>
</RCC>
/*
;; Version: $Id$
;;
*/
/* Commentary:
;;
*/
/* Change Log:
;;
*/
/* Code: */
QScrollArea {
background: transparent;
}
QScrollArea > QWidget > QWidget {
background: transparent;
}
QScrollArea > QWidget > QScrollBar {
background: palette(base);
}
QScrollBar:horizontal {
background: transparent;
height: 6px;
margin: 0px 0px 0px 0px;
}
QScrollBar::handle:horizontal {
background: #cccccc;
border: 1px solid #cccccc;
border-radius: 2px;
min-height: 20px;
}
QScrollBar::add-line:horizontal {
height: 0px;
}
QScrollBar::sub-line:horizontal {
height: 0px;
}
QScrollBar::up-arrow:horizontal, QScrollBar::down-arrow:horizontal {
width: 0px;
height: 0px;
background: none;
}
QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {
background: none;
}
QScrollBar:vertical {
background: transparent;
width: 6px;
margin: 0px 0px 0px 0px;
}
QScrollBar::handle:vertical {
background: #cccccc;
border: 1px solid #cccccc;
border-radius: 2px;
min-height: 20px;
}
QScrollBar::add-line:vertical {
height: 0px;
}
QScrollBar::sub-line:vertical {
height: 0px;
}
QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical {
width: 0px;
height: 0px;
background: none;
}
QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
background: none;
}
QToolButton {
border: none;
}
/* *****************************************************************
;;
;; ******************************************************************/
dtkWidgetsOverlayPaneItemHeader
{
background: "#88181818";
}
/* *****************************************************************
;;
;; ******************************************************************/
dummy
{
background: "#aaaaff";
}
/* main.qss ends here */
## Version: $Id$
##
######################################################################
##
### Commentary:
##
######################################################################
##
### Change Log:
##
######################################################################
##
### Code:
project(dtkWidgetsStylesheetParser)
## #################################################################
## Sources
## #################################################################
set(${PROJECT_NAME}_SOURCES main.cpp)
## #################################################################
## Build rules
## #################################################################
add_executable(${PROJECT_NAME} ${${PROJECT_NAME}_SOURCES})
target_link_libraries(${PROJECT_NAME} Qt5::Core)
target_link_libraries(${PROJECT_NAME} dtkWidgets)
######################################################################
### CMakeLists.txt ends here
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#include <QtCore>
#include <QtDebug>
#include <dtkWidgets/dtkWidgetsStylesheetParser>
int main(int argc, char **argv)
{
QCoreApplication application(argc, argv);
application.setApplicationName("dtkWidgetsStylesheetParser");
application.setApplicationVersion("0.1");
QCommandLineOption verboseOption(QStringList() << "v" << "verbose", "Print retrieved <key, value> hash.");
QCommandLineParser parser;
parser.setApplicationDescription("dtk stylesheet parser that converts .qless into .qss");
parser.addHelpOption();
parser.addPositionalArgument("source", QCoreApplication::translate("main", "Source file to convert."));
parser.addOption(verboseOption);
parser.process(application);
const QStringList arguments = parser.positionalArguments();
if (arguments.count() < 1) {
parser.showHelp();
return 0;
}
dtkWidgetsStylesheetParser stylesheet_parser;
qDebug() << stylesheet_parser.parse(arguments.first()).toStdString().c_str();
if (parser.isSet(verboseOption)) {
qDebug() << "";
qDebug() << "Retrieved variables:";
qDebug() << "";
qDebug() << stylesheet_parser.values();
}
return 0;
}
//
// main.cpp ends here
# Version: $Id$
#
#
# Commentary:
#
#
# Change Log:
#
#
# Code:
name: dtk-widgets
channels:
- dtk
dependencies:
- qt >=5.9.0
- dtk-fonts
- dtk-log
#
# dtk-visualization.yaml ends here
......@@ -62,8 +62,6 @@ set(${PROJECT_NAME}_HEADERS
dtkWidgetsOverlayRope.h
dtkWidgetsSettings
dtkWidgetsSettings.h
dtkWidgetsStylesheetParser
dtkWidgetsStylesheetParser.h
dtkWidgetsWidget
dtkWidgetsWidget.h)
......@@ -89,7 +87,6 @@ set(${PROJECT_NAME}_SOURCES
dtkWidgetsOverlayPaneSlider.cpp
dtkWidgetsOverlayRope.cpp
dtkWidgetsSettings.cpp
dtkWidgetsStylesheetParser.cpp
dtkWidgetsWidget.cpp)
## #################################################################
......
......@@ -19,5 +19,4 @@
#include "dtkWidgetsOverlayPaneSlider.h"
#include "dtkWidgetsOverlayRope.h"
#include "dtkWidgetsSettings.h"
#include "dtkWidgetsStylesheetParser.h"
#include "dtkWidgetsWidget.h"
#include "dtkWidgetsStylesheetParser.h"
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#include "dtkWidgetsStylesheetParser.h"
class dtkWidgetsStylesheetParserPrivate
{
public:
QHash<QString, QString> values;
};
dtkWidgetsStylesheetParser::dtkWidgetsStylesheetParser(void)
{
d = new dtkWidgetsStylesheetParserPrivate;
}
dtkWidgetsStylesheetParser::~dtkWidgetsStylesheetParser(void)
{
delete d;
}
QString dtkWidgetsStylesheetParser::parse(const QString& path)
{
QString source;
QString destination;
QFile stylesheet(path);
if(!stylesheet.open(QIODevice::ReadOnly)) {
qCritical() << Q_FUNC_INFO << "Cannot open file" << path;
return QString();
}
QTextStream stream(&stylesheet);
QString line;
QRegularExpression expression("^;; (?<key>@([a-z])+(\\d)*(\\-)*([a-z])*):\\s*(?<value>#(.)+);$");
while(stream.readLineInto(&line)) {
QRegularExpressionMatch match = expression.match(line);
if (match.hasMatch())
d->values.insert(match.captured("key"), match.captured("value"));
}
stream.seek(0);
destination = stylesheet.readAll();
stylesheet.close();
for(int i = 0; i < d->values.count(); i++)
destination.replace(d->values.keys().at(i), d->values.values().at(i));
return destination;
}
const QHash<QString, QString> &dtkWidgetsStylesheetParser::values(void) const
{
return d->values;
}
//
// dtkWidgetsStylesheetParser.cpp ends here
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#pragma once
#include <QtCore>
#include <dtkWidgetsExport>
class DTKWIDGETS_EXPORT dtkWidgetsStylesheetParser : public QObject
{
Q_OBJECT
public:
dtkWidgetsStylesheetParser(void);
~dtkWidgetsStylesheetParser(void);
public slots:
QString parse(const QString&);
public:
const QHash<QString, QString> &values(void) const;
private:
class dtkWidgetsStylesheetParserPrivate *d;
};
//
// dtkWidgetsStylesheetParser.h ends here
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment