mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
missing new files
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3011 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
5b4985e3d3
commit
fa05813283
135
retroshare-gui/src/gui/settings/NewTag.cpp
Normal file
135
retroshare-gui/src/gui/settings/NewTag.cpp
Normal file
@ -0,0 +1,135 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2006 - 2009, RetroShre Team
|
||||
*
|
||||
* 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 "NewTag.h"
|
||||
|
||||
#include <QColorDialog>
|
||||
|
||||
/** Default constructor */
|
||||
NewTag::NewTag(std::map<int, TagItem> &Items, int nId /*= 0*/, QWidget *parent, Qt::WFlags flags)
|
||||
: QDialog(parent, flags), m_Items(Items)
|
||||
{
|
||||
/* Invoke Qt Designer generated QObject setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
m_nId = nId;
|
||||
|
||||
connect(ui.okButton, SIGNAL(clicked()), this, SLOT(OnOK()));
|
||||
connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(OnCancel()));
|
||||
connect(ui.colorButton, SIGNAL(clicked()), this, SLOT(setTagColor()));
|
||||
|
||||
connect(ui.lineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(textChanged(const QString &)));
|
||||
|
||||
ui.okButton->setEnabled(false);
|
||||
|
||||
if (m_nId) {
|
||||
TagItem &Item = m_Items [m_nId];
|
||||
ui.lineEdit->setText(Item.text);
|
||||
m_Color = Item.color;
|
||||
|
||||
if (m_nId < 0) {
|
||||
// standard tag
|
||||
ui.lineEdit->setEnabled(false);
|
||||
}
|
||||
} else {
|
||||
m_Color = 0;
|
||||
}
|
||||
|
||||
showColor (m_Color);
|
||||
}
|
||||
|
||||
void NewTag::closeEvent (QCloseEvent * event)
|
||||
{
|
||||
QDialog::closeEvent(event);
|
||||
}
|
||||
|
||||
void NewTag::OnOK()
|
||||
{
|
||||
TagItem Item;
|
||||
Item.text = ui.lineEdit->text();
|
||||
Item.color = m_Color;
|
||||
|
||||
if (m_nId == 0) {
|
||||
// calculate new id
|
||||
m_nId = 1;
|
||||
std::map<int, TagItem>::iterator Item;
|
||||
for (Item = m_Items.begin(); Item != m_Items.end(); Item++) {
|
||||
if (Item->first + 1 > m_nId) {
|
||||
m_nId = Item->first + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_Items [m_nId] = Item;
|
||||
|
||||
setResult(QDialog::Accepted);
|
||||
hide();
|
||||
}
|
||||
|
||||
void NewTag::OnCancel()
|
||||
{
|
||||
setResult(QDialog::Rejected);
|
||||
hide();
|
||||
}
|
||||
|
||||
void NewTag::textChanged(const QString &text)
|
||||
{
|
||||
bool bEnabled = true;
|
||||
|
||||
if (text.isEmpty()) {
|
||||
bEnabled = false;
|
||||
} else {
|
||||
// check for existing text
|
||||
std::map<int, TagItem>::iterator Item;
|
||||
for (Item = m_Items.begin(); Item != m_Items.end(); Item++) {
|
||||
if (m_nId && Item->first == m_nId) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Item->second._delete) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Item->second.text == text) {
|
||||
bEnabled = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ui.okButton->setEnabled(bEnabled);
|
||||
}
|
||||
|
||||
void NewTag::setTagColor()
|
||||
{
|
||||
bool ok;
|
||||
QRgb color = QColorDialog::getRgba(m_Color, &ok, this);
|
||||
if (ok) {
|
||||
m_Color = color;
|
||||
showColor (m_Color);
|
||||
}
|
||||
}
|
||||
|
||||
void NewTag::showColor(QRgb color)
|
||||
{
|
||||
QPixmap pxm(16,16);
|
||||
pxm.fill(QColor(m_Color));
|
||||
ui.colorButton->setIcon(pxm);
|
||||
}
|
75
retroshare-gui/src/gui/settings/NewTag.h
Normal file
75
retroshare-gui/src/gui/settings/NewTag.h
Normal file
@ -0,0 +1,75 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2006 - 2010, RetroShare Team
|
||||
*
|
||||
* 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 _NEWTAG_H
|
||||
#define _NEWTAG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include "ui_NewTag.h"
|
||||
|
||||
class TagItem
|
||||
{
|
||||
public:
|
||||
TagItem()
|
||||
{
|
||||
_delete = false;
|
||||
};
|
||||
|
||||
QString text;
|
||||
QRgb color;
|
||||
|
||||
bool _delete; // for internal use
|
||||
};
|
||||
|
||||
class NewTag : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/** Default constructor */
|
||||
NewTag(std::map<int, TagItem> &Items, int nId = 0, QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||
|
||||
int m_nId;
|
||||
|
||||
protected:
|
||||
void closeEvent (QCloseEvent * event);
|
||||
|
||||
private slots:
|
||||
void OnOK();
|
||||
void OnCancel();
|
||||
|
||||
void textChanged(const QString &);
|
||||
|
||||
void setTagColor();
|
||||
|
||||
private:
|
||||
void showColor(QRgb color);
|
||||
|
||||
std::map<int, TagItem> &m_Items;
|
||||
QRgb m_Color;
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::NewTag ui;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
123
retroshare-gui/src/gui/settings/NewTag.ui
Normal file
123
retroshare-gui/src/gui/settings/NewTag.ui
Normal file
@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>NewTag</class>
|
||||
<widget class="QDialog" name="NewTag">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>320</width>
|
||||
<height>105</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>367777</width>
|
||||
<height>367777</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>New Tag</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1" colspan="5">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Tag Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="4">
|
||||
<widget class="QLineEdit" name="lineEdit"/>
|
||||
</item>
|
||||
<item row="1" column="5">
|
||||
<widget class="QPushButton" name="colorButton">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>135</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QPushButton" name="okButton">
|
||||
<property name="text">
|
||||
<string>OK</string>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="4" colspan="2">
|
||||
<widget class="QPushButton" name="cancelButton">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<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"/>
|
||||
<include location="../images.qrc"/>
|
||||
<include location="../images.qrc"/>
|
||||
<include location="../images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Reference in New Issue
Block a user