Added new setting for the position and the margin of the toaster.

Cleaned translation of the toaster GUI.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3906 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-12-10 21:49:38 +00:00
parent 4b16ffcc83
commit 3ecb987a4e
11 changed files with 497 additions and 352 deletions

View file

@ -52,10 +52,6 @@
* #define NOTIFY_DEBUG
****/
#define TOASTER_MARGIN_X 10 // 10 pixels of x margin
#define TOASTER_MARGIN_Y 10 // 10 pixels of y margin
class Toaster
{
public:
@ -596,12 +592,28 @@ void NotifyQt::startWaitingToasters()
QDesktopWidget *desktop = QApplication::desktop();
QRect desktopGeometry = desktop->availableGeometry(desktop->primaryScreen());
/* From bottom */
toaster->startPos = QPoint(desktopGeometry.right() - size.width() - TOASTER_MARGIN_X, desktopGeometry.bottom());
toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.bottom() - size.height() - TOASTER_MARGIN_Y);
/* From top */
// toaster->startPos = QPoint(desktopGeometry.right() - size.width() - TOASTER_MARGIN_X, desktopGeometry.top() - size.height());
// toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.top() + TOASTER_MARGIN_Y);
RshareSettings::enumToasterPosition position = Settings->getToasterPosition();
QPoint margin = Settings->getToasterMargin();
switch (position) {
case RshareSettings::TOASTERPOS_TOPLEFT:
toaster->startPos = QPoint(desktopGeometry.left() + margin.x(), desktopGeometry.top() - size.height());
toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.top() + margin.y());
break;
case RshareSettings::TOASTERPOS_TOPRIGHT:
toaster->startPos = QPoint(desktopGeometry.right() - size.width() - margin.x(), desktopGeometry.top() - size.height());
toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.top() + margin.y());
break;
case RshareSettings::TOASTERPOS_BOTTOMLEFT:
toaster->startPos = QPoint(desktopGeometry.left() + margin.x(), desktopGeometry.bottom());
toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.bottom() - size.height() - margin.y());
break;
case RshareSettings::TOASTERPOS_BOTTOMRIGHT: // default
default:
toaster->startPos = QPoint(desktopGeometry.right() - size.width() - margin.x(), desktopGeometry.bottom());
toaster->endPos = QPoint(toaster->startPos.x(), desktopGeometry.bottom() - size.height() - margin.y());
break;
}
/* Initialize widget */
toaster->widget->move(toaster->startPos);
@ -681,8 +693,12 @@ void NotifyQt::runningTick()
toaster->widget->move(newPos + diff);
diff += newPos - toaster->startPos;
/* This is only correct when moving the toaster from bottom */
toaster->widget->setMask(QRegion(0, 0, toaster->widget->width(), qAbs(toaster->startPos.y() - newPos.y())));
QRect mask = QRect(0, 0, toaster->widget->width(), qAbs(toaster->startPos.y() - newPos.y()));
if (newPos.y() > toaster->startPos.y()) {
/* Toaster is moving from top */
mask.moveTop(toaster->widget->height() - (newPos.y() - toaster->startPos.y()));
}
toaster->widget->setMask(QRegion(mask));
switch (operation) {
case NOTHING:

View file

@ -118,6 +118,13 @@ NotifyPage::save(QString &errmsg)
Settings->setAddFeedsAtEnd(ui.addFeedsAtEnd->isChecked());
int index = ui.comboBoxToasterPosition->currentIndex();
if (index != -1) {
Settings->setToasterPosition((RshareSettings::enumToasterPosition) ui.comboBoxToasterPosition->itemData(index).toInt());
}
Settings->setToasterMargin(QPoint(ui.spinBoxToasterXMargin->value(), ui.spinBoxToasterYMargin->value()));
load();
return true;
}
@ -158,8 +165,30 @@ void NotifyPage::load()
ui.trayNotify_CombinedIcon->setChecked(traynotifyflags & TRAYNOTIFY_COMBINEDICON);
ui.addFeedsAtEnd->setChecked(Settings->getAddFeedsAtEnd());
}
RshareSettings::enumToasterPosition toasterPosition = Settings->getToasterPosition();
ui.comboBoxToasterPosition->clear();
QMap<int, QString> toasterPositions;
toasterPositions[RshareSettings::TOASTERPOS_TOPLEFT] = tr("Top Left");
toasterPositions[RshareSettings::TOASTERPOS_TOPRIGHT] = tr("Top Right");
toasterPositions[RshareSettings::TOASTERPOS_BOTTOMLEFT] = tr("Bottom Left");
toasterPositions[RshareSettings::TOASTERPOS_BOTTOMRIGHT] = tr("Bottom Right");
QMap<int, QString>::iterator it;
int index = 0;
for (it = toasterPositions.begin(); it != toasterPositions.end(); it++, index++) {
ui.comboBoxToasterPosition->addItem(it.value(), it.key());
if (it.key() == toasterPosition) {
ui.comboBoxToasterPosition->setCurrentIndex(index);
}
}
QPoint margin = Settings->getToasterMargin();
ui.spinBoxToasterXMargin->setValue(margin.x());
ui.spinBoxToasterYMargin->setValue(margin.y());
}
/** Loads the settings for this page */
void NotifyPage::updateStatus()

View file

@ -683,6 +683,85 @@
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QLabel" name="labelToasterPosition">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Position</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="3">
<widget class="QComboBox" name="comboBoxToasterPosition">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelToasterXMargin">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>X Margin</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="spinBoxToasterXMargin">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>20</number>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="labelToasterYMargin">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Y Margin</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QSpinBox" name="spinBoxToasterYMargin">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>20</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>

View file

@ -331,6 +331,26 @@ bool RshareSettings::getChatSendMessageWithCtrlReturn()
return valueFromGroup("Chat", "SendMessageWithCtrlReturn", false).toBool();
}
RshareSettings::enumToasterPosition RshareSettings::getToasterPosition()
{
return (enumToasterPosition) value("ToasterPosition", TOASTERPOS_BOTTOMRIGHT).toInt();
}
void RshareSettings::setToasterPosition(enumToasterPosition position)
{
setValue("ToasterPosition", position);
}
QPoint RshareSettings::getToasterMargin()
{
return value("ToasterMargin", QPoint(10, 10)).toPoint();
}
void RshareSettings::setToasterMargin(QPoint margin)
{
setValue("ToasterMargin", margin);
}
void RshareSettings::setChatSendMessageWithCtrlReturn(bool bValue)
{
setValueToGroup("Chat", "SendMessageWithCtrlReturn", bValue);

View file

@ -66,6 +66,14 @@ public:
LASTDIR_BLOGS
};
enum enumToasterPosition
{
TOASTERPOS_TOPLEFT,
TOASTERPOS_TOPRIGHT,
TOASTERPOS_BOTTOMLEFT,
TOASTERPOS_BOTTOMRIGHT
};
public:
/* create settings object */
static void Create ();
@ -141,6 +149,12 @@ public:
bool getChatSendMessageWithCtrlReturn();
void setChatSendMessageWithCtrlReturn(bool bValue);
enumToasterPosition getToasterPosition();
void setToasterPosition(enumToasterPosition position);
QPoint getToasterMargin();
void setToasterMargin(QPoint margin);
/* chat font */
QString getChatScreenFont();
void setChatScreenFont(const QString &font);

View file

@ -10,21 +10,6 @@
<height>100</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string/>
</property>
<widget class="QLabel" name="labelTitle">
<property name="geometry">
<rect>
@ -195,7 +180,7 @@
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="background">
<property name="geometry">
<rect>
<x>0</x>
@ -204,14 +189,11 @@
<height>100</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/toaster/backgroundtoaster.png</pixmap>
</property>
</widget>
<zorder>label_2</zorder>
<zorder>background</zorder>
<zorder>labelTitle</zorder>
<zorder>startButton</zorder>
<zorder>lblTitle</zorder>
@ -224,9 +206,6 @@
</tabstops>
<resources>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -10,27 +10,6 @@
<height>100</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string/>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="QLabel" name="namelabel">
<property name="geometry">
<rect>
@ -44,7 +23,7 @@
<string/>
</property>
</widget>
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="background">
<property name="geometry">
<rect>
<x>0</x>
@ -53,9 +32,6 @@
<height>100</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/toaster/backgroundtoaster.png</pixmap>
</property>
@ -219,11 +195,6 @@ color: black;</string>
</tabstops>
<resources>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -39,8 +39,7 @@ OnlineToaster::OnlineToaster(const std::string &peerId, const QString &name, con
ui.messageLabel->setText(name);
ui.pixmaplabel->setPixmap(avatar);
WidgetBackgroundImage::setBackgroundImage(ui.windowFrame, ":images/toaster/backgroundtoaster.png", WidgetBackgroundImage::AdjustSize);
resize(300, 100);
WidgetBackgroundImage::setBackgroundImage(ui.windowFrame, ":images/toaster/backgroundtoaster.png", WidgetBackgroundImage::AdjustNone);
play();
}

View file

@ -1,253 +1,252 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OnlineToaster</class>
<widget class="QWidget" name="OnlineToaster">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>300</width>
<height>100</height>
</rect>
</property>
<layout class="QGridLayout">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QFrame" name="windowFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<layout class="QGridLayout">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>6</number>
</property>
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="0" column="3">
<widget class="QPushButton" name="closeButton">
<property name="minimumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/closenormal.png</normaloff>:/images/closenormal.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>22</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/rstray3.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<pointsize>9</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>RetroShare</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QGridLayout">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>9</number>
</property>
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="1" column="1" rowspan="2">
<widget class="QLabel" name="messageLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="0" rowspan="4">
<widget class="QLabel" name="pixmaplabel">
<property name="minimumSize">
<size>
<width>70</width>
<height>70</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>70</width>
<height>70</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QLabel#pixmaplabel{
border: 2px solid #238;
border-radius: 4px;}
</string>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/user/personal64.png</pixmap>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="messageButton">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: #238;</string>
</property>
<property name="text">
<string>Friend Online</string>
</property>
</widget>
</item>
<item row="3" column="1">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="2" column="0">
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>100</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>closeButton</tabstop>
</tabstops>
<resources>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OnlineToaster</class>
<widget class="QWidget" name="OnlineToaster">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>300</width>
<height>100</height>
</rect>
</property>
<layout class="QGridLayout">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QFrame" name="windowFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<layout class="QGridLayout">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>6</number>
</property>
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="0" column="3">
<widget class="QPushButton" name="closeButton">
<property name="minimumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/closenormal.png</normaloff>:/images/closenormal.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>22</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/rstray3.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<pointsize>9</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true">RetroShare</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QGridLayout">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>9</number>
</property>
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="1" column="1" rowspan="2">
<widget class="QLabel" name="messageLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="0" rowspan="4">
<widget class="QLabel" name="pixmaplabel">
<property name="minimumSize">
<size>
<width>70</width>
<height>70</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>70</width>
<height>70</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QLabel#pixmaplabel{
border: 2px solid #238;
border-radius: 4px;}
</string>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/user/personal64.png</pixmap>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="messageButton">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: #238;</string>
</property>
<property name="text">
<string>Friend Online</string>
</property>
</widget>
</item>
<item row="3" column="1">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="2" column="0">
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>100</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>closeButton</tabstop>
</tabstops>
<resources>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>