summaryrefslogtreecommitdiffstatshomepage
path: root/Introduction.cpp
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2011-03-19 00:27:52 -0400
committerJason A. Donenfeld <Jason@zx2c4.com>2011-03-19 00:27:52 -0400
commitb52c82e9917b8ff27203eaa7c94d609f1c0dfb10 (patch)
treeac64801783f79263f90af42a9c64edc4c882383b /Introduction.cpp
parentPolish. (diff)
downloadAuthor-b52c82e9917b8ff27203eaa7c94d609f1c0dfb10.tar.xz
Author-b52c82e9917b8ff27203eaa7c94d609f1c0dfb10.zip
Prettier intro buttons.
Diffstat (limited to 'Introduction.cpp')
-rw-r--r--Introduction.cpp37
1 files changed, 25 insertions, 12 deletions
diff --git a/Introduction.cpp b/Introduction.cpp
index 6bb21d9..3a2a881 100644
--- a/Introduction.cpp
+++ b/Introduction.cpp
@@ -1,4 +1,5 @@
#include "Introduction.h"
+#include "CompositionButton.h"
#include <QPushButton>
#include <QVBoxLayout>
#include <QHBoxLayout>
@@ -14,6 +15,8 @@
#include <QFile>
#include <QApplication>
#include <QDialogButtonBox>
+#include <QScrollArea>
+#include <QDebug>
Introduction::Introduction(QWidget *parent) :
QDialog(parent)
@@ -57,22 +60,32 @@ Introduction::Introduction(QWidget *parent) :
if (s.contains(key))
sorter.insertMulti(s.value(key).toDateTime(), title);
}
- foreach (const QString &title, sorter.values()) {
- QPushButton *titleButton = new QPushButton(title);
- titleButton->setFont(font);
- connect(titleButton, SIGNAL(clicked()), this, SLOT(loadExisting()));
- existingCompositionBoxLayout->insertWidget(0, titleButton);
+ QMapIterator<QDateTime, QString> i(sorter);
+ while (i.hasNext()) {
+ i.next();
+ CompositionButton *button = new CompositionButton(i.value(), i.key());
+ connect(button, SIGNAL(selected()), this, SLOT(loadExisting()));
+ existingCompositionBoxLayout->insertWidget(0, button);
}
existingCompositionBoxLayout->addStretch();
- existingCompositionBox->setLayout(existingCompositionBoxLayout);
+
+ QScrollArea *scroller = new QScrollArea;
+ scroller->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
+ scroller->setFrameStyle(0);
+ scroller->setAlignment(Qt::AlignCenter);
+ QWidget *container = new QWidget;
+ container->setLayout(existingCompositionBoxLayout);
+ scroller->setWidget(container);
+ QVBoxLayout *scrollLayout = new QVBoxLayout;
+ scrollLayout->addWidget(scroller);
+ scrollLayout->addStretch();
+ existingCompositionBox->setLayout(scrollLayout);
layout->addWidget(existingCompositionBox);
+ setFixedWidth(600);
+ setMinimumHeight(200);
setLayout(layout);
}
-QSize Introduction::sizeHint() const
-{
- return QSize(450, 800);
-}
QString Introduction::title() const
{
if (m_title->text().trimmed().length() == 0)
@@ -110,10 +123,10 @@ QString Introduction::defaultName() const
}
void Introduction::loadExisting()
{
- QPushButton *button = qobject_cast<QPushButton*>(sender());
+ CompositionButton *button = qobject_cast<CompositionButton*>(sender());
if (!button)
return;
- m_title->setText(button->text());
+ m_title->setText(button->title());
accept();
}
void Introduction::about()