47 |
47 |
48 TitleUrlContainerItem::TitleUrlContainerItem(ChromeSnippet * snippet, ChromeWidget * chrome, QGraphicsItem * parent) |
48 TitleUrlContainerItem::TitleUrlContainerItem(ChromeSnippet * snippet, ChromeWidget * chrome, QGraphicsItem * parent) |
49 : NativeChromeItem(snippet, parent) |
49 : NativeChromeItem(snippet, parent) |
50 , m_chrome(chrome) |
50 , m_chrome(chrome) |
51 { |
51 { |
|
52 setObjectName("TitleUrl"); |
52 setProperties(); |
53 setProperties(); |
53 // Create the view port widget |
54 // Create the view port widget |
54 m_viewPort = new QGraphicsWidget(this); |
55 m_viewPort = new QGraphicsWidget(this); |
55 m_viewPort->setFlags(QGraphicsItem::ItemClipsChildrenToShape); |
56 m_viewPort->setFlags(QGraphicsItem::ItemClipsChildrenToShape); |
56 |
57 |
57 // Create title-url widget(still by the name UrlSearchItem) |
58 // Create title-url widget(still by the name UrlSearchItem) |
58 m_urlTileWidget = new GUrlSearchItem(snippet, chrome, m_viewPort); |
59 m_urlTileWidget = new GUrlSearchItem(snippet, chrome, m_viewPort); |
59 |
60 |
60 QPixmap dividerPixmap; |
61 QPixmap dividerPixmap; |
61 dividerPixmap.load(":/chrome/bedrockchrome/urlsearch.snippet/icons/URL_search_divider.png", "PNG"); |
62 dividerPixmap.load(":/urlsearch/URL_search_divider.png", "PNG"); |
62 m_dividerImage = new QGraphicsPixmapItem(dividerPixmap, m_viewPort); |
63 m_dividerImage = new QGraphicsPixmapItem(dividerPixmap, m_viewPort); |
63 |
64 |
64 QAction * backAction = new QAction(this); |
65 QAction * backAction = new QAction(this); |
65 connect(backAction, SIGNAL(triggered()), m_chrome, SIGNAL(goToBackground())); |
66 connect(backAction, SIGNAL(triggered()), m_chrome, SIGNAL(goToBackground())); |
66 |
67 backAction->setObjectName("BackAction"); |
67 m_backStepButton = new ActionButton(snippet, m_viewPort); |
68 |
|
69 m_backStepButton = new ActionButton(snippet, "BackStep", m_viewPort); |
68 m_backStepButton->setAction(backAction); |
70 m_backStepButton->setAction(backAction); |
69 m_backStepButton->setActiveOnPress(true); |
71 m_backStepButton->setActiveOnPress(true); |
70 m_backStepButton->addIcon(":/chrome/bedrockchrome/urlsearch.snippet/icons/backstep.png", QIcon::Normal); |
72 //m_backStepButton->addIcon(":/urlsearch/backstep.png", QIcon::Normal); |
71 m_backStepButton->addIcon(":/chrome/bedrockchrome/urlsearch.snippet/icons/backstep_pressed.png", QIcon::Active); |
73 m_backStepButton->addIcon(":/urlsearch/backstep_no_bg.png", QIcon::Normal); |
|
74 m_backStepButton->addIcon(":/urlsearch/backstep_pressed.png", QIcon::Active); |
72 |
75 |
73 // Monitor resize events. |
76 // Monitor resize events. |
74 safe_connect(m_chrome->renderer(), SIGNAL(chromeResized()), this, SLOT(onChromeResize())); |
77 safe_connect(m_chrome->renderer(), SIGNAL(chromeResized()), this, SLOT(onChromeResize())); |
75 safe_connect(m_urlTileWidget, SIGNAL(changeEditMode(bool)), this, SLOT(changeLayout(bool))); |
78 safe_connect(m_urlTileWidget, SIGNAL(changeEditMode(bool)), this, SLOT(changeLayout(bool))); |
|
79 safe_connect(m_urlTileWidget, SIGNAL(contextEvent(bool)), this, SIGNAL(contextEvent(bool))); |
76 } |
80 } |
77 |
81 |
78 TitleUrlContainerItem::~TitleUrlContainerItem() |
82 TitleUrlContainerItem::~TitleUrlContainerItem() |
79 { |
83 { |
80 |
84 |
81 } |
85 } |
82 |
86 |
|
87 void TitleUrlContainerItem::cut() |
|
88 { |
|
89 m_urlTileWidget->cut(); |
|
90 } |
|
91 |
|
92 void TitleUrlContainerItem::copy() |
|
93 { |
|
94 m_urlTileWidget->copy(); |
|
95 } |
|
96 |
|
97 void TitleUrlContainerItem::paste() |
|
98 { |
|
99 m_urlTileWidget->paste(); |
|
100 } |
|
101 |
|
102 void TitleUrlContainerItem::setContextMenuStatus(bool on) |
|
103 { |
|
104 m_urlTileWidget->setContextMenuStatus(on); |
|
105 } |
|
106 |
83 void TitleUrlContainerItem::setProperties() { |
107 void TitleUrlContainerItem::setProperties() { |
84 |
|
85 m_pen.setWidth(1); |
|
86 m_pen.setBrush(QBrush(QColor(Qt::black))); |
|
87 |
|
88 m_grad.setColorAt(0, BACKGROUND_GRADIENT_START); |
108 m_grad.setColorAt(0, BACKGROUND_GRADIENT_START); |
89 m_grad.setColorAt(1, BACKGROUND_GRADIENT_END); |
109 m_grad.setColorAt(1, BACKGROUND_GRADIENT_END); |
90 } |
110 } |
91 |
111 |
92 void TitleUrlContainerItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) |
112 void TitleUrlContainerItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget){ |
93 { |
|
94 Q_UNUSED(option) |
113 Q_UNUSED(option) |
95 Q_UNUSED(widget) |
114 Q_UNUSED(widget) |
96 |
115 |
97 painter->save(); |
116 painter->save(); |
98 |
117 |
|
118 qreal bounding_x = boundingRect().x(); |
|
119 qreal bounding_y = boundingRect().y(); |
|
120 qreal bounding_width = boundingRect().width(); |
|
121 qreal bounding_height = boundingRect().height(); |
|
122 |
|
123 |
|
124 // background |
99 painter->setRenderHint(QPainter::Antialiasing); |
125 painter->setRenderHint(QPainter::Antialiasing); |
100 painter->setPen(m_pen); |
126 painter->setPen(Qt::NoPen); |
101 if (snippet()->enabled()) { |
127 m_grad.setStart(bounding_x, bounding_y + bounding_height); |
102 painter->fillRect(boundingRect(), QBrush(m_grad)); |
128 m_grad.setFinalStop(bounding_x, bounding_y); |
103 } |
129 painter->fillRect(boundingRect(), QBrush(m_grad)); |
104 else { |
|
105 painter->fillRect(boundingRect(), QColor(Qt::gray)); |
|
106 painter->setOpacity(ChromeEffect::disabledOpacity); |
|
107 painter->fillRect(boundingRect(), ChromeEffect::disabledColor); |
|
108 } |
|
109 |
|
110 // top border |
130 // top border |
111 painter->setPen(QPen(QColor(53,53,53))); |
131 painter->setPen(QPen(QColor(53,53,53))); |
112 painter->drawLine(boundingRect().x(), boundingRect().y(), boundingRect().x() + boundingRect().width(), boundingRect().y()); |
132 painter->drawLine(bounding_x, bounding_y, bounding_x + bounding_width, bounding_y); |
113 // bottom border |
133 // bottom border |
114 painter->setPen(QPen(QColor(76,76,78))); |
134 painter->setPen(QPen(QColor(76,76,78))); |
115 painter->drawLine(boundingRect().x(), boundingRect().y() + boundingRect().height(), boundingRect().x() + boundingRect().width(), boundingRect().y() + boundingRect().height()); |
135 painter->drawLine(bounding_x, bounding_y + bounding_height, bounding_x + bounding_width, bounding_y + bounding_height); |
116 // right border |
136 // right border |
117 painter->setPen(QPen(QColor(0,0,0))); |
137 painter->setPen(QPen(QColor(0,0,0))); |
118 painter->drawLine(boundingRect().x() + boundingRect().width(), boundingRect().y(), boundingRect().x() + boundingRect().width(), boundingRect().y() + boundingRect().height()); |
138 painter->drawLine(bounding_x + bounding_width, bounding_y, bounding_x + bounding_width, bounding_y + bounding_height); |
119 // left border |
139 // left border |
120 painter->setPen(m_pen); |
140 painter->setPen(Qt::NoPen); |
121 QLinearGradient grad = QLinearGradient(); |
141 QLinearGradient grad = QLinearGradient(bounding_x, bounding_y, bounding_x, bounding_y + bounding_height); |
122 grad.setColorAt(0, QColor(41,41,41)); |
142 grad.setColorAt(0, QColor(41,41,41)); |
123 grad.setColorAt(0.5, QColor(83,83,84)); |
143 grad.setColorAt(0.5, QColor(83,83,84)); |
124 grad.setColorAt(1, QColor(2,2,2)); |
144 grad.setColorAt(1, QColor(2,2,2)); |
125 painter->fillRect(QRect(boundingRect().x(), boundingRect().y(), 1, boundingRect().height()), QBrush(grad)); |
145 painter->setBrush(QBrush(grad)); |
|
146 painter->drawLine(bounding_x, bounding_y, bounding_x, bounding_y + bounding_height); |
126 |
147 |
127 painter->restore(); |
148 painter->restore(); |
128 |
149 |
129 NativeChromeItem::paint(painter, option, widget); |
150 NativeChromeItem::paint(painter, option, widget); |
130 } |
151 } |