Updates default stylesheet and demo app

This commit is contained in:
mfreiholz
2016-03-08 14:24:33 +01:00
parent 9bbc5e41a3
commit 34cf851e24
14 changed files with 195 additions and 89 deletions

View File

@@ -14,13 +14,41 @@ IconTitleWidget::IconTitleWidget(const QIcon& icon, const QString& title, QWidge
setLayout(l);
_iconLabel = new QLabel();
if (!icon.isNull())
_iconLabel->setPixmap(icon.pixmap(16, 16));
l->addWidget(_iconLabel);
_titleLabel = new QLabel();
_titleLabel->setText(title);
l->addWidget(_titleLabel, 1);
setIcon(icon);
setTitle(title);
}
void IconTitleWidget::setIcon(const QIcon& icon)
{
if (icon.isNull())
{
_iconLabel->setPixmap(QPixmap());
_iconLabel->setVisible(false);
}
else
{
_iconLabel->setPixmap(icon.pixmap(16, 16));
_iconLabel->setVisible(true);
}
}
void IconTitleWidget::setTitle(const QString& title)
{
if (title.isEmpty())
{
_titleLabel->setText(QString());
_titleLabel->setVisible(false);
}
else
{
_titleLabel->setText(title);
_titleLabel->setVisible(true);
}
}
void IconTitleWidget::polishUpdate()

View File

@@ -12,6 +12,10 @@ class IconTitleWidget : public QFrame
public:
explicit IconTitleWidget(const QIcon& icon, const QString& title, QWidget *parent = 0);
public slots:
void setIcon(const QIcon& icon);
void setTitle(const QString& title);
void polishUpdate();
public:

View File

@@ -4,59 +4,27 @@
#include "mainwindow.h"
int main(int argc, char *argv[])
static void initStyleSheet(QApplication& a)
{
QApplication a(argc, argv);
a.setQuitOnLastWindowClosed(true);
//Q_INIT_RESOURCE(ads);
// Load style sheet
// QFile f(":/stylesheets/default-windows.css");
QFile f(":/stylesheets/vendor-partsolutions.css");
QFile f(":/stylesheets/default-windows.css");
// QFile f(":/stylesheets/modern-windows.css");
// QFile f(":/stylesheets/vendor-partsolutions.css");
if (f.open(QFile::ReadOnly))
{
QByteArray ba = f.readAll();
f.close();
a.setStyleSheet(QString(ba));
}
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
//Q_INIT_RESOURCE(ads);
a.setQuitOnLastWindowClosed(true);
initStyleSheet(a);
MainWindow mw;
mw.show();
return a.exec();
}
// a.setStyleSheet(""
// " QSplitter::handle { border: 1px solid #000000; background: #000000; } "
// " ads--ContainerWidget { border: 1px solid #ff0000; background: #FFE6E6; padding: 6px; } "
// " ads--SectionWidget { border: 1px solid #00ff00; background: #E6FFE6; padding: 6px; } "
// " ads--SectionTitleWidget { border: 1px solid #0000ff; background: #E6E6FF; padding: 6px; } "
// " ads--SectionTitleWidget[activeTab=\"true\"] { border: 1px solid #0000ff; background: #9696FF; padding: 6px; } "
// " ads--SectionContentWidget { border: 1px solid #FFFF00; background: #FFFFE6; padding: 6px; } "
// );
//static void centerWidget(QWidget* widget)
//{
// if (widget)
// {
// QDesktopWidget deskWidget;
// const int screenIndex = deskWidget.primaryScreen();
// const QRect deskRect = deskWidget.availableGeometry(screenIndex);
// const int x = (deskRect.width() - widget->rect().width()) / 2;
// const int 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 int screenIndex = deskWidget.primaryScreen();
// const QRect deskRect = deskWidget.availableGeometry(screenIndex);
// const int w = (deskRect.width() / 100) * widthPC;
// const int h = (deskRect.height() / 100) * heightPC;
// widget->resize(w, h);
// }
//}

View File

@@ -47,6 +47,7 @@ static ADS_NS::SectionContent::RefPtr createCalendarSC(ADS_NS::ContainerWidget*
static ADS_NS::SectionContent::RefPtr createFileSystemTreeSC(ADS_NS::ContainerWidget* container)
{
QTreeView* w = new QTreeView();
w->setFrameShape(QFrame::NoFrame);
// QFileSystemModel* m = new QFileSystemModel(w);
// m->setRootPath(QDir::currentPath());
// w->setModel(m);
@@ -84,14 +85,8 @@ MainWindow::MainWindow(QWidget *parent) :
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->mainToolBar->hide();
ui->statusBar->hide();
#if QT_VERSION >= 0x050000
QObject::connect(ui->actionAddSectionContent, &QAction::triggered, this, &MainWindow::onActionAddSectionContentTriggered);
#else
QObject::connect(ui->actionAddSectionContent, SIGNAL(triggered(bool)), this, SLOT(onActionAddSectionContentTriggered()));
#endif
// ADS - Create main container (ContainerWidget).
_container = new ADS_NS::ContainerWidget();
_container->setOrientation(Qt::Vertical);
#if QT_VERSION >= 0x050000
@@ -101,6 +96,7 @@ MainWindow::MainWindow(QWidget *parent) :
#endif
setCentralWidget(_container);
// ADS - Adding some contents.
// Test #1: Use high-level public API
if (true)
{
@@ -111,17 +107,17 @@ MainWindow::MainWindow(QWidget *parent) :
sw = _container->addSectionContent(createCalendarSC(cw), sw, ADS_NS::RightDropArea);
sw = _container->addSectionContent(createFileSystemTreeSC(cw), sw, ADS_NS::CenterDropArea);
// _container->addSectionContent(createCalendarSC(_container));
// _container->addSectionContent(createLongTextLabelSC(_container));
// _container->addSectionContent(createLongTextLabelSC(_container));
// _container->addSectionContent(createLongTextLabelSC(_container));
_container->addSectionContent(createCalendarSC(_container));
_container->addSectionContent(createLongTextLabelSC(_container));
_container->addSectionContent(createLongTextLabelSC(_container));
_container->addSectionContent(createLongTextLabelSC(_container));
}
// Default window geometry
resize(800, 600);
// Restore window geometry and ContainerWidget state from last session
restoreGeometry(loadDataHelper("MainWindow"));
// ADS - Restore geometries and states of contents.
_container->restoreState(loadDataHelper("ContainerWidget"));
}

View File

@@ -14,15 +14,6 @@
<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">
@@ -33,12 +24,54 @@
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
<property name="title">
<string>File</string>
</property>
<addaction name="actionExit"/>
</widget>
<widget class="QMenu" name="menuView">
<property name="title">
<string>View</string>
</property>
<addaction name="actionDemo_1"/>
<addaction name="actionDemo_2"/>
<addaction name="actionDemo_3"/>
</widget>
<widget class="QMenu" name="menuAbout">
<property name="title">
<string>About</string>
</property>
</widget>
<addaction name="menuFile"/>
<addaction name="menuView"/>
<addaction name="menuAbout"/>
</widget>
<action name="actionAddSectionContent">
<property name="text">
<string>Add SectionContent</string>
</property>
</action>
<action name="actionDemo_1">
<property name="text">
<string>Demo 1</string>
</property>
</action>
<action name="actionDemo_2">
<property name="text">
<string>Demo 2</string>
</property>
</action>
<action name="actionDemo_3">
<property name="text">
<string>Demo 3</string>
</property>
</action>
<action name="actionExit">
<property name="text">
<string>Exit</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>