* added a about dialog

* quit RetroShare with rApp not more use qApp for quit, shutdown is now faster.
* added first retranslateUi for MainWindow
* changend Add Share string.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1944 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2009-12-31 02:23:02 +00:00
parent 82ebdc5bd7
commit e919981e00
11 changed files with 1100 additions and 25 deletions

View File

@ -130,6 +130,7 @@ HEADERS += rshare.h \
gui/mainpagestack.h \
gui/MainWindow.h \
gui/TurtleRouterDialog.h \
gui/AboutDialog.h \
gui/AddLinksDialog.h \
gui/LinksDialog.h \
gui/ForumsDialog.h \
@ -235,6 +236,7 @@ HEADERS += rshare.h \
FORMS += gui/StartDialog.ui \
gui/GenCertDialog.ui \
gui/AboutDialog.ui \
gui/AddLinksDialog.ui \
gui/NetworkDialog.ui \
gui/TransfersDialog.ui \
@ -290,6 +292,7 @@ FORMS += gui/StartDialog.ui \
SOURCES += main.cpp \
rshare.cpp \
gui/notifyqt.cpp \
gui/AboutDialog.cpp \
gui/DLListDelegate.cpp \
gui/ULListDelegate.cpp \
gui/StartDialog.cpp \

View File

@ -0,0 +1,717 @@
/****************************************************************
* This file is distributed under the following license:
*
* Copyright (c) 2009, RetroShare Team
* Copyright (C) 2008 Unipro, Russia (http://ugene.unipro.ru)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#include "AboutDialog.h"
#include "HelpDialog.h"
#include "rsiface/rsdisc.h"
#include "rsiface/rsiface.h"
#include <QtGui/QHBoxLayout>
#include <QtGui/QPainter>
#include <QtGui/QBrush>
#include <QtGui/QMessageBox>
#include <QtGui/QStyle>
#include <assert.h>
AboutDialog::AboutDialog(QWidget* parent)
:QDialog(parent)
{
setupUi(this);
QHBoxLayout* l = new QHBoxLayout();
l->setMargin(0);
l->addStretch(1);
l->addStretch(1);
frame->setContentsMargins(0, 0, 0, 0);
frame->setLayout(l);
tWidget = NULL;
installAWidget();
#ifdef Q_OS_WIN
setWindowFlags(windowFlags() | Qt::MSWindowsFixedSizeDialogHint);
#endif
}
void AboutDialog::installAWidget() {
assert(tWidget == NULL);
AWidget* aWidget = new AWidget();
QVBoxLayout* l = (QVBoxLayout*)frame->layout();
l->insertWidget(0, aWidget);
l->setStretchFactor(aWidget, 100);
}
void AboutDialog::installTWidget() {
assert(tWidget == NULL);
tWidget = new TBoard();
QLabel* npLabel = new NextPieceLabel(tWidget);
tWidget->setNextPieceLabel(npLabel);
QWidget* pan = new QWidget();
QVBoxLayout* vl = new QVBoxLayout(pan);
QLabel* topRecLabel = new QLabel(tr("Max score: %1").arg(tWidget->getMaxScore()));
QLabel* scoreLabel = new QLabel(pan);
QLabel* levelLabel = new QLabel(pan);
vl->addStretch();
vl->addWidget(topRecLabel);
vl->addStretch();
vl->addWidget(npLabel);
vl->addStretch();
vl->addWidget(scoreLabel);
vl->addWidget(levelLabel);
vl->addStretch();
QHBoxLayout* l = (QHBoxLayout*)frame->layout();
l->insertWidget(0, pan);
l->insertWidget(0, tWidget);
QRect cRect = frame->contentsRect();
int height = tWidget->heightForWidth(cRect.width());
tWidget->setFixedSize(cRect.width() * cRect.height() / height, cRect.height());
npLabel->setFixedSize(tWidget->squareWidth()*4, tWidget->squareHeight()*5);
l->setStretchFactor(tWidget, 100);
connect(tWidget, SIGNAL(scoreChanged(int)), SLOT(sl_scoreChanged(int)));
connect(tWidget, SIGNAL(levelChanged(int)), SLOT(sl_levelChanged(int)));
connect(this, SIGNAL(si_scoreChanged(QString)), scoreLabel, SLOT(setText(QString)));
connect(this, SIGNAL(si_levelChanged(QString)), levelLabel, SLOT(setText(QString)));
tWidget->setFocus();
tWidget->start();
}
void AboutDialog::switchPages() {
QLayoutItem* li = NULL;
QLayout* l = frame->layout();
while ((li = l->takeAt(0)) && li->widget()) {
li->widget()->deleteLater();
}
if (tWidget==NULL) {
installTWidget();
} else {
tWidget = NULL;
installAWidget();
}
updateTitle();
}
void AboutDialog::sl_scoreChanged(int sc) {
emit si_scoreChanged(tr("Score: %1").arg(sc));
}
void AboutDialog::sl_levelChanged(int level) {
emit si_levelChanged(tr("Level: %1").arg(level));
}
void AboutDialog::updateTitle() {
if (tWidget == NULL) {
setWindowTitle(tr("About RetroShare"));
} else {
setWindowTitle(tr("Have fun ;-)"));
}
}
void AboutDialog::keyPressEvent(QKeyEvent *e) {
if (e->key() == Qt::Key_T) {
switchPages();
} else if (tWidget!=NULL && (e->key() == Qt::Key_P || e->key() == Qt::Key_Pause)) {
tWidget->pause();
}
QDialog::keyPressEvent(e);
}
void AboutDialog::mousePressEvent(QMouseEvent *e) {
QPoint globalPos = mapToGlobal(e->pos());
QPoint framePos = frame->mapFromGlobal(globalPos);
if (frame->contentsRect().contains(framePos)) {
switchPages();
}
QDialog::mousePressEvent(e);
}
void AboutDialog::on_help_button_clicked()
{
static HelpDialog *helpdlg = new HelpDialog (this);
helpdlg->show();
}
AWidget::AWidget() {
setMouseTracking(true);
QImage image(":/images/about.png");
QPainter p(&image);
p.setPen(Qt::lightGray);
/* get libretroshare version */
std::map<std::string, std::string>::iterator vit;
std::map<std::string, std::string> versions;
const RsConfig &conf = rsiface->getConfig();
bool retv = rsDisc->getDiscVersions(versions);
if (retv && versions.end() != (vit = versions.find(conf.ownId)))
{
QString version = QString::fromStdString("RetroShare version : \n") + QString::fromStdString(vit->second);
p.drawText(QRect(10, 20, width()-10, 60), version);
}
p.end();
image1 = image2 = image;
setFixedSize(image1.size());
int w = image1.width();
int h = image1.height();
heightField1.resize(w*h);
heightField2.resize(w*h);
density = 5;
page = 0;
startTimer(15);
}
void AWidget::timerEvent(QTimerEvent* e) {
drawWater((QRgb*)image1.bits(), (QRgb*)image2.bits());
calcWater(page, density);
page ^= 1;
if (qrand() % 128 == 0) {
int r = 3 + qRound(qrand() * 4 / RAND_MAX);
int h = 300 + qrand() * 200 / RAND_MAX;
int x = 1 + r + qrand()%(image1.width() -2*r-1);
int y = 1 + r + qrand()%(image1.height()-2*r-1);
addBlob(x, y, r, h);
}
update();
QObject::timerEvent(e);
}
void AWidget::paintEvent(QPaintEvent* e) {
QWidget::paintEvent(e);
QPainter p(this);
p.drawImage(0, 0, image2);
}
void AWidget::mouseMoveEvent(QMouseEvent* e) {
QPoint point = e->pos();
addBlob(point.x() - 15,point.y(), 5, 400);
}
void AWidget::calcWater(int npage, int density) {
int w = image1.width();
int h = image1.height();
int count = w + 1;
// Set up the pointers
int *newptr;
int *oldptr;
if(npage == 0) {
newptr = &heightField1.front();
oldptr = &heightField2.front();
} else {
newptr = &heightField2.front();
oldptr = &heightField1.front();
}
for (int y = (h-1)*w; count < y; count += 2) {
for (int x = count+w-2; count < x; count++) {
// This does the eight-pixel method. It looks much better.
int newh = ((oldptr[count + w]
+ oldptr[count - w]
+ oldptr[count + 1]
+ oldptr[count - 1]
+ oldptr[count - w - 1]
+ oldptr[count - w + 1]
+ oldptr[count + w - 1]
+ oldptr[count + w + 1]
) >> 2 ) - newptr[count];
newptr[count] = newh - (newh >> density);
}
}
}
void AWidget::addBlob(int x, int y, int radius, int height) {
int w = image1.width();
int h = image1.height();
// Set up the pointers
int *newptr;
int *oldptr;
if (page == 0) {
newptr = &heightField1.front();
oldptr = &heightField2.front();
} else {
newptr = &heightField2.front();
oldptr = &heightField1.front();
}
int rquad = radius * radius;
int left=-radius, right = radius;
int top=-radius, bottom = radius;
// Perform edge clipping...
if (x - radius < 1) left -= (x-radius-1);
if (y - radius < 1) top -= (y-radius-1);
if (x + radius > w-1) right -= (x+radius-w+1);
if (y + radius > h-1) bottom-= (y+radius-h+1);
for(int cy = top; cy < bottom; cy++) {
int cyq = cy*cy;
for(int cx = left; cx < right; cx++) {
if (cx*cx + cyq < rquad) {
newptr[w*(cy+y) + (cx+x)] += height;
}
}
}
}
void AWidget::drawWater(QRgb* srcImage,QRgb* dstImage) {
int w = image1.width();
int h = image1.height();
int offset = w + 1;
int lIndex;
int lBreak = w * h;
int *ptr = &heightField1.front();
for (int y = (h-1)*w; offset < y; offset += 2) {
for (int x = offset+w-2; offset < x; offset++) {
int dx = ptr[offset] - ptr[offset+1];
int dy = ptr[offset] - ptr[offset+w];
lIndex = offset + w*(dy>>3) + (dx>>3);
if(lIndex < lBreak && lIndex > 0) {
QRgb c = srcImage[lIndex];
c = shiftColor(c, dx);
dstImage[offset] = c;
}
offset++;
dx = ptr[offset] - ptr[offset+1];
dy = ptr[offset] - ptr[offset+w];
lIndex = offset + w*(dy>>3) + (dx>>3);
if(lIndex < lBreak && lIndex > 0) {
QRgb c = srcImage[lIndex];
c = shiftColor(c, dx);
dstImage[offset] = c;
}
}
}
}
//////////////////////////////////////////////////////////////////////////
// T
TBoard::TBoard(QWidget *parent) {
Q_UNUSED(parent);
/* Create RshareSettings object */
_settings = new RshareSettings();
setFocusPolicy(Qt::StrongFocus);
isStarted = false;
isPaused = false;
clearBoard();
nextPiece.setRandomShape();
score = 0;
level = 0;
maxScore = _settings->value("/about/maxsc").toInt();
}
TBoard::~TBoard() {
int oldMax = _settings->value("/about/maxsc").toInt();
int newMax = qMax(maxScore, score);
if (oldMax < newMax) {
_settings->setValue("/about/maxsc", newMax);
}
}
int TBoard::heightForWidth ( int w ) const {
return qRound(BoardHeight * float(w)/BoardWidth);
}
void TBoard::start() {
if (isPaused) {
return;
}
isStarted = true;
isWaitingAfterLine = false;
numLinesRemoved = 0;
numPiecesDropped = 0;
maxScore = qMax(score, maxScore);
score = 0;
level = 1;
clearBoard();
emit linesRemovedChanged(numLinesRemoved);
emit scoreChanged(score);
emit levelChanged(level);
newPiece();
timer.start(timeoutTime(), this);
}
void TBoard::pause() {
if (!isStarted) {
return;
}
isPaused = !isPaused;
if (isPaused) {
timer.stop();
} else {
timer.start(timeoutTime(), this);
}
update();
}
void TBoard::paintEvent(QPaintEvent *event) {
QWidget::paintEvent(event);
QPainter painter(this);
painter.setPen(Qt::black);
painter.drawRect(frameRect());
QRect rect = boardRect();
painter.fillRect(rect, Qt::white);
if (isPaused) {
painter.drawText(rect, Qt::AlignCenter, tr("Pause"));
return;
}
int boardTop = rect.bottom() - BoardHeight*squareHeight();
for (int i = 0; i < BoardHeight; ++i) {
for (int j = 0; j < BoardWidth; ++j) {
TPiece::Shape shape = shapeAt(j, BoardHeight - i - 1);
if (shape != TPiece::NoShape) {
drawSquare(painter, rect.left() + j * squareWidth(), boardTop + i * squareHeight(), shape);
}
}
}
if (curPiece.shape() != TPiece::NoShape) {
for (int i = 0; i < 4; ++i) {
int x = curX + curPiece.x(i);
int y = curY - curPiece.y(i);
drawSquare(painter, rect.left() + x * squareWidth(), boardTop + (BoardHeight - y - 1) * squareHeight(), curPiece.shape());
}
}
}
void TBoard::keyPressEvent(QKeyEvent *event) {
if (!isStarted || isPaused || curPiece.shape() == TPiece::NoShape) {
QWidget::keyPressEvent(event);
return;
}
switch (event->key()) {
case Qt::Key_Left:
tryMove(curPiece, curX - 1, curY);
break;
case Qt::Key_Right:
tryMove(curPiece, curX + 1, curY);
break;
case Qt::Key_Down:
tryMove(curPiece.rotatedRight(), curX, curY);
break;
case Qt::Key_Up:
tryMove(curPiece.rotatedLeft(), curX, curY);
break;
case Qt::Key_Space:
dropDown();
break;
case Qt::Key_Control:
oneLineDown();
break;
default:
QWidget::keyPressEvent(event);
}
}
void TBoard::timerEvent(QTimerEvent *event) {
if (event->timerId() == timer.timerId()) {
if (isWaitingAfterLine) {
isWaitingAfterLine = false;
newPiece();
timer.start(timeoutTime(), this);
} else {
oneLineDown();
}
} else {
QWidget::timerEvent(event);
}
}
void TBoard::clearBoard() {
for (int i = 0; i < BoardHeight * BoardWidth; ++i) {
board[i] = TPiece::NoShape;
}
}
void TBoard::dropDown() {
int dropHeight = 0;
int newY = curY;
while (newY > 0) {
if (!tryMove(curPiece, curX, newY - 1)) {
break;
}
newY--;
dropHeight++;
}
pieceDropped(dropHeight);
}
void TBoard::oneLineDown() {
if (!tryMove(curPiece, curX, curY - 1))
pieceDropped(0);
}
void TBoard::pieceDropped(int dropHeight) {
for (int i = 0; i < 4; ++i) {
int x = curX + curPiece.x(i);
int y = curY - curPiece.y(i);
shapeAt(x, y) = curPiece.shape();
}
++numPiecesDropped;
if (numPiecesDropped % 50 == 0) {
++level;
timer.start(timeoutTime(), this);
emit levelChanged(level);
}
score += dropHeight + 7;
emit scoreChanged(score);
removeFullLines();
if (!isWaitingAfterLine) {
newPiece();
}
}
void TBoard::removeFullLines() {
int numFullLines = 0;
for (int i = BoardHeight - 1; i >= 0; --i) {
bool lineIsFull = true;
for (int j = 0; j < BoardWidth; ++j) {
if (shapeAt(j, i) == TPiece::NoShape) {
lineIsFull = false;
break;
}
}
if (lineIsFull) {
++numFullLines;
for (int k = i; k < BoardHeight - 1; ++k) {
for (int j = 0; j < BoardWidth; ++j) {
shapeAt(j, k) = shapeAt(j, k + 1);
}
}
for (int j = 0; j < BoardWidth; ++j) {
shapeAt(j, BoardHeight - 1) = TPiece::NoShape;
}
}
}
if (numFullLines > 0) {
numLinesRemoved += numFullLines;
score += 10 * numFullLines;
emit linesRemovedChanged(numLinesRemoved);
emit scoreChanged(score);
timer.start(500, this);
isWaitingAfterLine = true;
curPiece.setShape(TPiece::NoShape);
update();
}
}
void TBoard::newPiece() {
curPiece = nextPiece;
nextPiece.setRandomShape();
showNextPiece();
curX = BoardWidth / 2 + 1;
curY = BoardHeight - 1 + curPiece.minY();
if (!tryMove(curPiece, curX, curY)) {
curPiece.setShape(TPiece::NoShape);
timer.stop();
isStarted = false;
}
}
void TBoard::showNextPiece() {
if (!nextPieceLabel) {
return;
}
int dx = nextPiece.maxX() - nextPiece.minX() + 1;
int dy = nextPiece.maxY() - nextPiece.minY() + 1;
QPixmap pixmap(dx * squareWidth(), dy * squareHeight());
QPainter painter(&pixmap);
painter.fillRect(pixmap.rect(), nextPieceLabel->palette().background());
for (int i = 0; i < 4; ++i) {
int x = nextPiece.x(i) - nextPiece.minX();
int y = nextPiece.y(i) - nextPiece.minY();
drawSquare(painter, x * squareWidth(), y * squareHeight(), nextPiece.shape());
}
nextPieceLabel->setPixmap(pixmap);
}
bool TBoard::tryMove(const TPiece &newPiece, int newX, int newY) {
for (int i = 0; i < 4; ++i) {
int x = newX + newPiece.x(i);
int y = newY - newPiece.y(i);
if (x < 0 || x >= BoardWidth || y < 0 || y >= BoardHeight) {
return false;
}
if (shapeAt(x, y) != TPiece::NoShape) {
return false;
}
}
curPiece = newPiece;
curX = newX;
curY = newY;
update();
return true;
}
void TBoard::drawSquare(QPainter &painter, int x, int y, TPiece::Shape shape) {
static const QRgb colorTable[8] = { 0x000000, 0xCC6666, 0x66CC66, 0x6666CC, 0xCCCC66, 0xCC66CC, 0x66CCCC, 0xDAAA00};
QColor color = colorTable[int(shape)];
painter.fillRect(x + 1, y + 1, squareWidth() - 2, squareHeight() - 2, color);
painter.setPen(color.light());
painter.drawLine(x, y + squareHeight() - 1, x, y);
painter.drawLine(x, y, x + squareWidth() - 1, y);
painter.setPen(color.dark());
painter.drawLine(x + 1, y + squareHeight() - 1, x + squareWidth() - 1, y + squareHeight() - 1);
painter.drawLine(x + squareWidth() - 1, y + squareHeight() - 1, x + squareWidth() - 1, y + 1);
}
void TPiece::setRandomShape() {
setShape(TPiece::Shape(qrand() % 7 + 1));
}
void TPiece::setShape(TPiece::Shape shape) {
static const int coordsTable[8][4][2] = {
{ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } },
{ { 0, -1 }, { 0, 0 }, { -1, 0 }, { -1, 1 } },
{ { 0, -1 }, { 0, 0 }, { 1, 0 }, { 1, 1 } },
{ { 0, -1 }, { 0, 0 }, { 0, 1 }, { 0, 2 } },
{ { -1, 0 }, { 0, 0 }, { 1, 0 }, { 0, 1 } },
{ { 0, 0 }, { 1, 0 }, { 0, 1 }, { 1, 1 } },
{ { -1, -1 }, { 0, -1 }, { 0, 0 }, { 0, 1 } },
{ { 1, -1 }, { 0, -1 }, { 0, 0 }, { 0, 1 } }
};
for (int i = 0; i < 4 ; i++) {
for (int j = 0; j < 2; ++j) {
coords[i][j] = coordsTable[shape][i][j];
}
}
pieceShape = shape;
}
int TPiece::minX() const {
int min = coords[0][0];
for (int i = 1; i < 4; ++i) {
min = qMin(min, coords[i][0]);
}
return min;
}
int TPiece::maxX() const {
int max = coords[0][0];
for (int i = 1; i < 4; ++i) {
max = qMax(max, coords[i][0]);
}
return max;
}
int TPiece::minY() const {
int min = coords[0][1];
for (int i = 1; i < 4; ++i) {
min = qMin(min, coords[i][1]);
}
return min;
}
int TPiece::maxY() const {
int max = coords[0][1];
for (int i = 1; i < 4; ++i) {
max = qMax(max, coords[i][1]);
}
return max;
}
TPiece TPiece::rotatedLeft() const {
if (pieceShape == SquareShape) {
return *this;
}
TPiece result;
result.pieceShape = pieceShape;
for (int i = 0; i < 4; ++i) {
result.setX(i, y(i));
result.setY(i, -x(i));
}
return result;
}
TPiece TPiece::rotatedRight() const {
if (pieceShape == SquareShape) {
return *this;
}
TPiece result;
result.pieceShape = pieceShape;
for (int i = 0; i < 4; ++i) {
result.setX(i, -y(i));
result.setY(i, x(i));
}
return result;
}
NextPieceLabel::NextPieceLabel( QWidget* parent /*= 0*/ ) : QLabel(parent)
{
QPalette p = palette();
p.setColor(QPalette::Background, Qt::white);
setPalette(p);
setFrameShape(QFrame::Box);
setAlignment(Qt::AlignCenter);
setAutoFillBackground(true);
}

View File

@ -0,0 +1,208 @@
/****************************************************************
* This file is distributed under the following license:
*
* Copyright (c) 2009, RetroShare Team
* Copyright (C) 2008 Unipro, Russia (http://ugene.unipro.ru)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#ifndef _GB2_ABOUT_DIALOG_
#define _GB2_ABOUT_DIALOG_
#include "settings/rsharesettings.h"
#include "ui_AboutDialog.h"
#include <QtCore/QBasicTimer>
#include <QtCore/QPointer>
#include <QtGui/QDialog>
#include <QtGui/QLabel>
#include <QtGui/QPaintEvent>
#include <QtGui/QKeyEvent>
#include <QtGui/QMouseEvent>
class AWidget;
class TBoard;
class NextPieceLabel;
class AboutDialog : public QDialog, public Ui::AboutDialog
{
Q_OBJECT
public:
AboutDialog(QWidget *parent = 0);
private slots:
void sl_scoreChanged(int);
void sl_levelChanged(int);
void on_help_button_clicked();
signals:
void si_scoreChanged(QString);
void si_maxScoreChanged(QString);
void si_levelChanged(QString);
protected:
void keyPressEvent(QKeyEvent *event);
void mousePressEvent(QMouseEvent *event);
private:
void switchPages();
void installAWidget();
void installTWidget();
void updateTitle();
TBoard* tWidget;
};
//////////////////////////////////////////////////////////////////////////
// A
class AWidget : public QWidget {
Q_OBJECT
public:
AWidget();
protected:
void timerEvent(QTimerEvent* e);
void paintEvent(QPaintEvent* e);
void mouseMoveEvent(QMouseEvent* e);
private:
void calcWater(int npage, int density);
void addBlob(int x, int y, int radius, int height);
void drawWater(QRgb* srcImage, QRgb* dstImage);
static QRgb shiftColor(QRgb color,int shift) {
return qRgb(qBound(0, qRed(color) - shift, 255),
qBound(0, qGreen(color) - shift,255),
qBound(0, qBlue(color) - shift, 255));
}
int page;
int density;
QVector<int> heightField1;
QVector<int> heightField2;
QImage image1;
QImage image2;
};
//////////////////////////////////////////////////////////////////////////
// T
class TPiece {
public:
enum Shape { NoShape, ZShape, SShape, LineShape, TShape, SquareShape, LShape, MirroredLShape };
TPiece() { setShape(NoShape); }
void setRandomShape();
void setShape(Shape shape);
Shape shape() const { return pieceShape; }
int x(int index) const { return coords[index][0]; }
int y(int index) const { return coords[index][1]; }
int minX() const;
int maxX() const;
int minY() const;
int maxY() const;
TPiece rotatedLeft() const;
TPiece rotatedRight() const;
private:
void setX(int index, int x) { coords[index][0] = x; }
void setY(int index, int y) { coords[index][1] = y; }
Shape pieceShape;
int coords[4][2];
};
class TBoard : public QWidget {
Q_OBJECT
public:
TBoard(QWidget *parent = 0);
~TBoard();
int heightForWidth ( int w ) const;
int getScore() const {return score;}
int getMaxScore() const {return qMax(maxScore, score);}
int getLevel() const {return level;}
void setNextPieceLabel(QLabel *label) {nextPieceLabel = label;}
int squareWidth() const { return boardRect().width() / BoardWidth; }
int squareHeight() const { return boardRect().height() / BoardHeight; }
public slots:
void start();
void pause();
signals:
void scoreChanged(int score);
void levelChanged(int level);
void linesRemovedChanged(int numLines);
protected:
void paintEvent(QPaintEvent *event);
void keyPressEvent(QKeyEvent *event);
void timerEvent(QTimerEvent *event);
private:
enum { BoardWidth = 10, BoardHeight = 22 };
TPiece::Shape &shapeAt(int x, int y) { return board[(y * BoardWidth) + x]; }
int timeoutTime() const { return 1000 / (1 + level); }
QRect boardRect() const {return QRect(1, 1, width()-2, height()-2);}
QRect frameRect() const {return QRect(0, 0, width()-1, height()-1);}
void clearBoard();
void dropDown();
void oneLineDown();
void pieceDropped(int dropHeight);
void removeFullLines();
void newPiece();
void showNextPiece();
bool tryMove(const TPiece &newPiece, int newX, int newY);
void drawSquare(QPainter &painter, int x, int y, TPiece::Shape shape);
QBasicTimer timer;
QPointer<QLabel> nextPieceLabel;
bool isStarted;
bool isPaused;
bool isWaitingAfterLine;
TPiece curPiece;
TPiece nextPiece;
int curX;
int curY;
int numLinesRemoved;
int numPiecesDropped;
int score;
int maxScore;
int level;
TPiece::Shape board[BoardWidth * BoardHeight];
/** A RetroShare Settings object used for saving/loading settings */
RshareSettings *_settings;
};
class NextPieceLabel : public QLabel {
public:
NextPieceLabel(QWidget* parent = 0);
};
#endif

View File

@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AboutDialog</class>
<widget class="QDialog" name="AboutDialog">
<property name="windowModality">
<enum>Qt::NonModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>271</width>
<height>376</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>about_dialog_title</string>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="sizeGripEnabled">
<bool>false</bool>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>9</number>
</property>
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="help_button">
<property name="text">
<string>About</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="close_button">
<property name="text">
<string>close</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="images.qrc"/>
</resources>
<connections>
<connection>
<sender>close_button</sender>
<signal>clicked()</signal>
<receiver>AboutDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>243</x>
<y>281</y>
</hint>
<hint type="destinationlabel">
<x>145</x>
<y>187</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>548</width>
<height>458</height>
<width>590</width>
<height>521</height>
</rect>
</property>
<property name="sizePolicy">
@ -527,21 +527,34 @@
<property name="spacing">
<number>6</number>
</property>
<item row="0" column="0" colspan="3">
<item row="2" column="0" colspan="3">
<widget class="QTextBrowser" name="version">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>70</height>
</size>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QTextBrowser" name="about">
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Arial'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p align=&quot;center&quot; style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;&quot;&gt;&lt;/p&gt;
&lt;p align=&quot;justify&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;RetroShare is a Open Source cross-platform, &lt;/span&gt;&lt;/p&gt;
&lt;p align=&quot;justify&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;private and secure decentralised commmunication platform. &lt;/span&gt;&lt;/p&gt;
&lt;p align=&quot;justify&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;It lets you share securely your friends, &lt;/span&gt;&lt;/p&gt;
&lt;p align=&quot;justify&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;using a web-of-trust to authenticate peers and OpenSSL to encrypt all communication. &lt;/span&gt;&lt;/p&gt;
&lt;p align=&quot;justify&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;RetroShare provides filesharing, chat, messages and channels&lt;/span&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600;&quot;&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;img src=&quot;:/images/retrosharelogo2.png&quot; /&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt; font-weight:600;&quot;&gt;Usefull External Links to more information:&lt;/span&gt;&lt;/p&gt;
&lt;ul style=&quot;-qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; font-size:8pt;&quot; align=&quot;justify&quot; style=&quot; margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a href=&quot;http://retroshare.sourceforge.net&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;Retroshare Webpage&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
@ -555,8 +568,15 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QTextBrowser" name="version"/>
<item row="0" column="0">
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>

View File

@ -38,6 +38,7 @@
#include "MainWindow.h"
#include "MessengerWindow.h"
#include "HelpDialog.h"
#include "AboutDialog.h"
#include "gui/TurtleRouterDialog.h"
@ -184,7 +185,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
createPageAction(QIcon(IMAGE_FORUMS), tr("Forums"), grp));
ui.stackPages->add(linksDialog = new LinksDialog(ui.stackPages),
createPageAction(QIcon(IMAGE_LINKS), tr("Links Cloud"), grp));
createPageAction(QIcon(IMAGE_LINKS), tr("Links Cloud"), grp));
#else
@ -506,7 +507,7 @@ void MainWindow::doQuit()
}
else
rsicontrol->rsGlobalShutDown();
qApp->quit();
rApp->quit();
}
void MainWindow::closeEvent(QCloseEvent *e)
@ -531,7 +532,7 @@ void MainWindow::closeEvent(QCloseEvent *e)
else
{
rsicontrol->rsGlobalShutDown();
qApp->quit();
rApp->quit();
}
@ -616,8 +617,8 @@ void MainWindow::playFiles(QStringList files)
void MainWindow::showabout()
{
static HelpDialog *helpdlg = new HelpDialog(this);
helpdlg->show();
static AboutDialog *adlg = new AboutDialog(this);
adlg->exec();
}
/** Displays the help browser and displays the most recently viewed help
@ -637,6 +638,19 @@ void MainWindow::showHelpDialog(const QString &topic)
helpBrowser->showWindow(topic);
}
/** Called when the user changes the UI translation. */
void
MainWindow::retranslateUi()
{
ui.retranslateUi(this);
foreach (MainPage *page, ui.stackPages->pages()) {
page->retranslateUi();
}
foreach (QAction *action, ui.toolBar->actions()) {
action->setText(tr(qPrintable(action->data().toString()), "MainWindow"));
}
}
void MainWindow::setStyle()
{
QString standardSheet = "{background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,stop:0 <color1>, stop:1 <color2>);}";

View File

@ -44,6 +44,7 @@
#include "help/browser/helpbrowser.h"
#include "ui_MainWindow.h"
#include "gui/common/RWindow.h"
class PeerStatus;
class NATStatus;
@ -103,7 +104,13 @@ public slots:
void showWindow(Page page);
void playFiles(QStringList files);
void updateHashingInfo(const QString&) ;
void updateHashingInfo(const QString&) ;
protected:
void closeEvent(QCloseEvent *);
/** Called when the user changes the UI translation. */
virtual void retranslateUi();
private slots:
@ -123,7 +130,7 @@ private slots:
void showabout();
void openShareManager();
void displaySystrayMsg(const QString&,const QString&) ;
void displaySystrayMsg(const QString&,const QString&) ;
/** Displays the help browser and displays the most recently viewed help
* topic. */
@ -138,10 +145,6 @@ private slots:
/** Called when user attempts to quit via quit button*/
void doQuit();
protected:
void closeEvent(QCloseEvent *);
private slots:
private:

View File

@ -174,7 +174,7 @@ void ShareManager::addShareDirectory()
*/
QString qdir = QFileDialog::getExistingDirectory(this, tr("Add Shared Directory"), "",
QString qdir = QFileDialog::getExistingDirectory(this, tr("Select A Folder To Share"), "",
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
/* add it to the server */

View File

@ -1,5 +1,6 @@
<RCC>
<qresource prefix="/" >
<file>images/about.png</file>
<file>images/irkick.png</file>
<file>images/btn1.png</file>
<file>images/btn2.png</file>
@ -171,7 +172,7 @@
<file>images/flags/pl.png</file>
<file>images/flags/pt.png</file>
<file>images/flags/ru.png</file>
<file>images/flags/se.png</file>
<file>images/flags/sv.png</file>
<file>images/flags/sl.png</file>
<file>images/flags/tr.png</file>
<file>images/folder-draft.png</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 KiB

View File

@ -1,7 +1,7 @@
/****************************************************************
* This file is distributed under the following license:
*
* Copyright (c) 2006-2007, crypton
* This file is distributed under the following license:
*
* Copyright (c) 2006-2007, crypton
* Copyright (c) 2006, Matt Edman, Justin Hipple
*
* This program is free software; you can redistribute it and/or
@ -32,7 +32,7 @@ public:
/** Default Constructor */
MainPage(QWidget *parent = 0) : QWidget(parent) {}
virtual void retranslateUi() {}
};
#endif