Init commit for GitHub.

This commit is contained in:
mfreiholz
2015-12-09 12:21:38 +01:00
commit 343c5cc727
40 changed files with 1961 additions and 0 deletions
@@ -0,0 +1,32 @@
#include "icontitlewidget.h"
#include <QIcon>
#include <QString>
#include <QBoxLayout>
#include <QLabel>
#include <QStyle>
IconTitleWidget::IconTitleWidget(const QIcon& icon, const QString& title, QWidget *parent) :
QFrame(parent)
{
auto l = new QBoxLayout(QBoxLayout::LeftToRight);
l->setContentsMargins(0, 0, 0, 0);
setLayout(l);
auto titleIcon = new QLabel();
if (icon.isNull())
{
titleIcon->setPixmap(style()->standardIcon(QStyle::SP_MessageBoxInformation).pixmap(16, 16));
}
else
{
titleIcon->setPixmap(icon.pixmap(16, 16));
}
l->addWidget(titleIcon);
auto titleText = new QLabel(title);
auto titleFont = titleText->font();
titleFont.setBold(true);
titleText->setFont(titleFont);
l->addWidget(titleText, 1);
}
@@ -0,0 +1,19 @@
#ifndef ICONTITLEWIDGET_H
#define ICONTITLEWIDGET_H
#include <QFrame>
class QIcon;
class QString;
class IconTitleWidget : public QFrame
{
Q_OBJECT
public:
explicit IconTitleWidget(const QIcon& icon, const QString& title, QWidget *parent = 0);
signals:
public slots:
};
#endif // ICONTITLEWIDGET_H
+70
View File
@@ -0,0 +1,70 @@
#include <QString>
#include <QRect>
#include <QApplication>
#include <QDesktopWidget>
#include "mainwindow.h"
static void centerWidget(QWidget* widget)
{
if (widget)
{
QDesktopWidget deskWidget;
const auto screenIndex = deskWidget.primaryScreen();
const auto deskRect = deskWidget.availableGeometry(screenIndex);
const auto x = (deskRect.width() - widget->rect().width()) / 2;
const auto y = (deskRect.height() - widget->rect().height()) / 2;
widget->move(x, y);
}
}
static void resizeWidgetPerCent(QWidget* widget, qreal widthPC, qreal heightPC)
{
if (widget && widthPC >= 0.0 && heightPC >= 0.0)
{
QDesktopWidget deskWidget;
const auto screenIndex = deskWidget.primaryScreen();
const auto deskRect = deskWidget.availableGeometry(screenIndex);
const auto w = (deskRect.width() / 100) * widthPC;
const auto h = (deskRect.height() / 100) * heightPC;
widget->resize(w, h);
}
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
a.setQuitOnLastWindowClosed(true);
Q_INIT_RESOURCE(ads);
// Development style.
// a.setStyleSheet(""
// " QSplitter::handle { border: 1px solid #000000; background: #000000; } "
// " ads--ContainerWidget { border: 1px solid #ff0000; background: #FFE6E6; } "
// " ads--SectionWidget { border: 1px solid #00ff00; background: #E6FFE6; } "
// " ads--SectionTitleWidget { border: 1px solid #0000ff; background: #E6E6FF; } "
// " ads--SectionTitleWidget[activeTab=\"true\"] { border: 1px solid #0000ff; background: #9696FF; } "
// " ads--SectionContentWidget { border: 1px solid #FFFF00; background: #FFFFE6; } "
// );
// PARTsolutions style.
a.setStyleSheet(""
" QSplitter::handle:vertical { image: url(:/img/splitter-horizontal.png); } "
" QSplitter::handle:horizontal { image: url(:/img/splitter-vertical.png); } "
" ads--ContainerWidget { border: 0; background: #9ab6ca; } "
" ads--SectionWidget { border-width: 1px; border-color: #ffffff; border-style: solid; background: #7c9eb3; padding: 0; margin: 0; } "
" ads--SectionTitleWidget { border-right: 1px solid #E7F3F8; background: #7c9eb3; } "
" ads--SectionTitleWidget[activeTab=\"true\"] { border: 1px solid #E7F3F8; background: #E7F3F8; } "
" ads--SectionTitleWidget IconTitleWidget QLabel { color: #000000; } "
" ads--SectionContentWidget { border: 0px solid #E7F3F8; background: #ffffff; } "
" ads--FloatingWidget QPushButton { background: #E7F3F8; } "
);
MainWindow mw;
resizeWidgetPerCent(&mw, 60, 80);
centerWidget(&mw);
mw.show();
return a.exec();
}
@@ -0,0 +1,98 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QTime>
#include <QLabel>
#include <QTextEdit>
#include <QCalendarWidget>
#include <QFrame>
#include <QTreeView>
#include <QFileSystemModel>
#include "ads/container_widget.h"
#include "ads/section_widget.h"
#include "ads/section_content.h"
#include "icontitlewidget.h"
///////////////////////////////////////////////////////////////////////
static int CONTENT_COUNT = 0;
static ads::SectionContent::RefPtr createLongTextLabelSC()
{
auto w = new QLabel();
w->setWordWrap(true);
w->setAlignment(Qt::AlignTop | Qt::AlignLeft);
w->setText(QString("Lorem Ipsum ist ein einfacher Demo-Text für die Print- und Schriftindustrie. Lorem Ipsum ist in der Industrie bereits der Standard Demo-Text seit 1500, als ein unbekannter Schriftsteller eine Hand voll Wörter nahm und diese durcheinander warf um ein Musterbuch zu erstellen. Es hat nicht nur 5 Jahrhunderte überlebt, sondern auch in Spruch in die elektronische Schriftbearbeitung geschafft (bemerke, nahezu unverändert). Bekannt wurde es 1960, mit dem erscheinen von Letrase, welches Passagen von Lorem Ipsum enhielt, so wie Desktop Software wie Aldus PageMaker - ebenfalls mit Lorem Ipsum."));
return ads::SectionContent::newSectionContent(new IconTitleWidget(QIcon(), QString("Title %1").arg(++CONTENT_COUNT)), w);
}
static ads::SectionContent::RefPtr createCalendarSC()
{
auto w = new QCalendarWidget();
return ads::SectionContent::newSectionContent(new IconTitleWidget(QIcon(), QString("Title %1").arg(++CONTENT_COUNT)), w);
}
static ads::SectionContent::RefPtr createTreeSC()
{
auto m = new QFileSystemModel();
m->setRootPath(QDir::currentPath());
auto w = new QTreeView();
w->setModel(m);
return ads::SectionContent::newSectionContent(new IconTitleWidget(QIcon(), QString("Title %1").arg(++CONTENT_COUNT)), w);
}
///////////////////////////////////////////////////////////////////////
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QObject::connect(ui->actionAddSectionContent, &QAction::triggered, this, &MainWindow::onActionAddSectionContentTriggered);
// CREATE SOME TESTING DOCKS
_container = new ads::ContainerWidget();
_container->setOrientation(Qt::Vertical);
setCentralWidget(_container);
auto leftSection = new ads::SectionWidget(_container);
leftSection->addContent(createLongTextLabelSC());
_container->addSection(leftSection);
auto middleSection = new ads::SectionWidget(_container);
middleSection->addContent(createCalendarSC());
_container->addSection(middleSection);
auto middleBottom = new ads::SectionWidget(_container);
middleBottom->addContent(createLongTextLabelSC());
_container->addSection(middleBottom);
// _container->splitSections(middleSection, middleBottom, Qt::Vertical);
auto rightSection = new ads::SectionWidget(_container);
rightSection->addContent(createLongTextLabelSC());
_container->addSection(rightSection);
// auto middleTopRight = new ads::SectionWidget(_container);
// middleTopRight->addContent(createLongTextLabelSC());
// _container->splitSections(middleSection, middleTopRight);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::onActionAddSectionContentTriggered()
{
return;
// auto titleWidget = new IconTitleWidget(QIcon(), QString("Title"));
// auto contentWidget = createRandomWidget(-1, -1);
// auto content = ads::SectionContent::newSectionContent(titleWidget, contentWidget);
// auto section = new ads::SectionWidget(_container);
// _container->addSection(section);
// section->addContent(content);
}
@@ -0,0 +1,31 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "ads/ads.h"
namespace Ui {
class MainWindow;
}
ADS_NAMESPACE_BEGIN
class ContainerWidget;
ADS_NAMESPACE_END
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
virtual ~MainWindow();
private slots:
void onActionAddSectionContentTriggered();
private:
Ui::MainWindow *ui;
ads::ContainerWidget* _container;
};
#endif // MAINWINDOW_H
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralWidget"/>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="actionAddSectionContent"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>21</height>
</rect>
</property>
</widget>
<action name="actionAddSectionContent">
<property name="text">
<string>Add SectionContent</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>