Commit 6db8e4f3 authored by philippe groarke's avatar philippe groarke

Search bar follows Yosemite style. Background test.

parent d684f986
......@@ -14,9 +14,11 @@ TEMPLATE = app
CONFIG += c++11
SOURCES += main.cpp\
mainwindow.cpp
mainwindow.cpp \
mysearchbar.cpp
HEADERS += mainwindow.h
HEADERS += mainwindow.h \
mysearchbar.h
FORMS += mainwindow.ui
......@@ -24,3 +26,6 @@ macx: LIBS += -L$$PWD/build/ -lqtsflphone
INCLUDEPATH += $$PWD/../sflphone/kde/src/lib
DEPENDPATH += $$PWD/../sflphone/kde/src/lib
RESOURCES += \
data.qrc
<RCC>
<qresource prefix="/">
<file>data/background_tile.png</file>
</qresource>
</RCC>
......@@ -112,3 +112,4 @@ void MainWindow::on_answer_button_clicked()
mainCall_->performAction(Call::Action::ACCEPT);
}
}
......@@ -45,6 +45,7 @@ private slots:
void on_answer_button_clicked();
private:
Ui::MainWindow *ui;
CallModel* callModel_{nullptr};
......
......@@ -6,14 +6,22 @@
<rect>
<x>0</x>
<y>0</y>
<width>766</width>
<height>597</height>
<width>860</width>
<height>480</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<property name="styleSheet">
<string notr="true">QMainWindow#MainWindow {
background-color: rgb(246, 246, 246);
}</string>
</property>
<widget class="QWidget" name="centralWidget">
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="spacing">
<number>0</number>
......@@ -32,14 +40,20 @@
</property>
<item>
<widget class="QSplitter" name="splitter">
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="handleWidth">
<number>0</number>
</property>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
......@@ -55,13 +69,30 @@
<number>10</number>
</property>
<item>
<widget class="QLineEdit" name="lineEdit">
<widget class="MySearchBar" name="lineEdit">
<property name="minimumSize">
<size>
<width>0</width>
<height>22</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(225, 225, 225);
border: 1px solid;
border-color: rgb(208, 208, 208);
border-radius: 4px;
color: rgb(160, 160, 160);
</string>
</property>
<property name="text">
<string/>
</property>
<property name="frame">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="placeholderText">
<string>Search</string>
</property>
......@@ -90,6 +121,18 @@
</item>
<item>
<widget class="QTreeView" name="contact_list">
<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="styleSheet">
<string notr="true">background-color: rgba(255,255,255, 0.0);</string>
</property>
......@@ -104,25 +147,14 @@
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QWidget" name="widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255,255,255);</string>
<property name="leftMargin">
<number>0</number>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLineEdit" name="call_number">
<property name="text">
......@@ -132,6 +164,9 @@
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
<item>
<widget class="QPushButton" name="call_button">
<property name="sizePolicy">
......@@ -165,6 +200,33 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QWidget" name="widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>460</width>
<height>0</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255,255,255);
background-image:url(:/data/background_tile.png);
background-repeat: repeat-x;
background-position: bottom;</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
......@@ -174,13 +236,20 @@
<rect>
<x>0</x>
<y>0</y>
<width>766</width>
<width>860</width>
<height>22</height>
</rect>
</property>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>MySearchBar</class>
<extends>QLineEdit</extends>
<header>mysearchbar.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
......
#include "mysearchbar.h"
MySearchBar::MySearchBar(QWidget *parent) : QLineEdit(parent)
{
QObject::connect(this, SIGNAL(editingFinished()), this, SLOT(changePlaceholderColor()));
QObject::connect(this, SIGNAL(textChanged(QString)), this, SLOT(changePlaceholderColor()));
QObject::connect(this, SIGNAL(), this, SLOT(changePlaceholderColor()));
}
MySearchBar::~MySearchBar()
{
}
void MySearchBar::focusInEvent(QFocusEvent* e)
{
if (text().count() <= 0) {
setAlignment(Qt::AlignLeft);
setStyleSheet("background-color: rgb(225, 225, 225);"
"border: 1px solid;"
"border-color: rgb(208, 208, 208);"
"border-radius: 4px;"
"color: rgb(160, 160, 160);");
QLineEdit::focusInEvent(e);
}
}
//// SLOTS ////
// TODO: Animate Search placeholder.
void MySearchBar::changePlaceholderColor()
{
if (text().count() <= 0) { // placeholder
setAlignment(Qt::AlignHCenter);
setStyleSheet("background-color: rgb(225, 225, 225);"
"border: 1px solid;"
"border-color: rgb(208, 208, 208);"
"border-radius: 4px;"
"color: rgb(160, 160, 160);");
} else { // usertext
setAlignment(Qt::AlignLeft);
setStyleSheet("background-color: rgb(225, 225, 225);"
"border: 1px solid;"
"border-color: rgb(208, 208, 208);"
"border-radius: 4px;"
"color: rgb(45, 45, 45);");
}
}
#ifndef MYSEARCHBAR_H
#define MYSEARCHBAR_H
#include <QWidget>
#include <QLineEdit>
#include <QDebug>
class MySearchBar : public QLineEdit
{
Q_OBJECT
public:
explicit MySearchBar(QWidget *parent = 0);
~MySearchBar();
virtual void focusInEvent(QFocusEvent*);
private slots:
void changePlaceholderColor();
};
#endif // MYSEARCHBAR_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment