summaryrefslogtreecommitdiffstats
path: root/mainwindow.cpp
diff options
context:
space:
mode:
authorRoopesh Chander <roop@forwardbias.in>2009-11-04 00:15:44 +0530
committerRoopesh Chander <roop@forwardbias.in>2009-11-04 00:15:44 +0530
commit87520cca02b418bbb4ee5ee8e638f55798cf4267 (patch)
treeacbee1a5940963f939c51d33cae02f584ae46142 /mainwindow.cpp
parent8c2ca37ae9ad2d273fe85e28eeceb236083333b9 (diff)
as hhartz said, why mainwindow?
Diffstat (limited to 'mainwindow.cpp')
-rw-r--r--mainwindow.cpp44
1 files changed, 14 insertions, 30 deletions
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 8634f3a..229af63 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -13,10 +13,8 @@
#include "searchlineedit.h"
MainWindow::MainWindow(QWidget *parent) :
- QMainWindow(parent),
- ui(new Ui::MainWindow)
+ GraphicsView(parent)
{
- ui->setupUi(this);
initGraphicsView();
initScrapBoard();
initBrowser();
@@ -31,15 +29,13 @@ MainWindow::MainWindow(QWidget *parent) :
}
void MainWindow::initGraphicsView() {
- m_graphicsView = new GraphicsView(this);
- setCentralWidget(m_graphicsView);
- m_graphicsView->setMouseTracking(true);
+ setMouseTracking(true);
QGraphicsScene *gs = new QGraphicsScene;
- m_graphicsView->setScene(gs);
+ setScene(gs);
}
void MainWindow::initScrapBoard() {
- QGraphicsScene *gs = m_graphicsView->scene();
+ QGraphicsScene *gs = scene();
createScrapsToolbar(gs);
}
@@ -47,7 +43,7 @@ void MainWindow::initScrapBoard() {
void MainWindow::addScrap(QUrl url, QRect scrapRect, QPoint position, qreal xScale, qreal yScale) {
WebScrap *webscrap = new WebScrap(url, scrapRect);
webscrap->setRefreshInterval(1000 * 60 * 60); // 1 hour
- WebScrapContainer *container = new WebScrapContainer(webscrap, m_graphicsView->scene(), xScale, yScale);
+ WebScrapContainer *container = new WebScrapContainer(webscrap, scene(), xScale, yScale);
container->setPos(position - webscrap->pos());
connect(container, SIGNAL(frameClicked()), SLOT(bubbleUpScrap()));
connect(container, SIGNAL(removeSelf()), SLOT(removeSenderScrap()));
@@ -59,15 +55,15 @@ void MainWindow::addScrap(QUrl url, QRect scrapRect, QPoint position, qreal xSca
}
void MainWindow::initBrowser() {
- m_webView = new WebView(m_graphicsView->scene());
+ m_webView = new WebView(scene());
m_webView->setZValue(-1);
- m_graphicsView->setCentralWidget(m_webView);
+ setCentralWidget(m_webView);
m_webView->load(QUrl("http://news.google.com/"));
connect(m_webView, SIGNAL(loadFinished(bool)), SLOT(adjustLocation()));
connect(m_webView, SIGNAL(titleChanged(const QString&)), SLOT(adjustTitle()));
connect(m_webView, SIGNAL(scrapAdded(QUrl,QRect,QPoint)), SLOT(addScrap(QUrl, QRect, QPoint)));
connect(m_webView, SIGNAL(scrapAdded(QUrl,QRect,QPoint)), SLOT(showScraps()));
- createBrowserToolbar(m_graphicsView->scene());
+ createBrowserToolbar(scene());
m_browserToolbar->setFillLevelBrush(QColor(50, 50, 200, 50));
connect(m_webView->page(), SIGNAL(loadProgress(int)), m_browserToolbar, SLOT(setFillLevel(int)));
}
@@ -139,18 +135,6 @@ MainWindow::~MainWindow()
delete ui;
}
-void MainWindow::changeEvent(QEvent *e)
-{
- QMainWindow::changeEvent(e);
- switch (e->type()) {
- case QEvent::LanguageChange:
- ui->retranslateUi(this);
- break;
- default:
- break;
- }
-}
-
void MainWindow::changeLocation()
{
QUrl url = QWebView::guessUrlFromString(m_addressBar->text());
@@ -209,7 +193,7 @@ QAbstractAnimation* MainWindow::createScrapsAnim(const Movement move, QObject *p
}
if (move == Leave) {
scrap->setData(WebScrapContainer::Position, scrap->pos());
- moveAnim->setEndValue(m_graphicsView->sceneRect().center() + flyOffset);
+ moveAnim->setEndValue(sceneRect().center() + flyOffset);
moveAnim->setEasingCurve(QEasingCurve::InCubic);
}
allScrapsAnim->addAnimation(moveAnim);
@@ -221,13 +205,13 @@ QAbstractAnimation* MainWindow::createBrowserAnim(const Movement move, QObject *
QPropertyAnimation *moveAnim = new QPropertyAnimation(m_webView, "pos", parent);
moveAnim->setDuration(1000);
if (move == Enter) {
- m_webView->setPos(m_graphicsView->sceneRect().topLeft() - QPointF(3000, 0));
+ m_webView->setPos(sceneRect().topLeft() - QPointF(3000, 0));
m_webView->show();
- moveAnim->setEndValue(m_graphicsView->sceneRect().topLeft());
+ moveAnim->setEndValue(sceneRect().topLeft());
moveAnim->setEasingCurve(QEasingCurve::OutCubic);
}
if (move == Leave) {
- moveAnim->setEndValue(m_graphicsView->sceneRect().topLeft() - QPointF(3000, 0));
+ moveAnim->setEndValue(sceneRect().topLeft() - QPointF(3000, 0));
connect(moveAnim, SIGNAL(finished()), m_webView, SLOT(hide()));
moveAnim->setEasingCurve(QEasingCurve::InCubic);
}
@@ -293,7 +277,7 @@ void MainWindow::removeSenderScrap() {
if (sender())
scrap = qobject_cast<QGraphicsWidget*>(sender());
if (scrap) {
- m_graphicsView->scene()->removeItem(scrap);
+ scene()->removeItem(scrap);
for (int i = 0; i < m_scraps.count(); i++) {
if (m_scraps.at(i) == scrap) {
m_scraps.removeAt(i);
@@ -359,7 +343,7 @@ void MainWindow::saveSettings() {
m_settings->setValue("topLeft", scrap->scrapRect().topLeft());
m_settings->setValue("size", scrap->scrapRect().size());
QPointF containerPos = container->pos();
- if (!m_graphicsView->sceneRect().contains(containerPos))
+ if (!sceneRect().contains(containerPos))
containerPos = container->data(WebScrapContainer::Position).toPoint();
m_settings->setValue("pos", containerPos + scrap->pos());
m_settings->setValue("xScale", container->scrapScale()->xScale());