annotate src/findwidget.cpp @ 678:c0b46d0514a7 scale

Incomplete scaling updates. Should do this differently
author Chris Cannam
date Thu, 06 Dec 2018 14:55:45 +0000
parents ae67ea0af696
children
rev   line source
Chris@556 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@556 2
Chris@556 3 /*
Chris@556 4 EasyMercurial
Chris@556 5
Chris@556 6 Based on HgExplorer by Jari Korhonen
Chris@556 7 Copyright (c) 2010 Jari Korhonen
Chris@644 8 Copyright (c) 2013 Chris Cannam
Chris@644 9 Copyright (c) 2013 Queen Mary, University of London
Chris@556 10
Chris@556 11 This program is free software; you can redistribute it and/or
Chris@556 12 modify it under the terms of the GNU General Public License as
Chris@556 13 published by the Free Software Foundation; either version 2 of the
Chris@556 14 License, or (at your option) any later version. See the file
Chris@556 15 COPYING included with this distribution for more information.
Chris@556 16 */
Chris@556 17
Chris@556 18 #include "findwidget.h"
Chris@556 19
Chris@556 20 #include <QGridLayout>
Chris@556 21 #include <QLabel>
Chris@556 22 #include <QLineEdit>
Chris@556 23 #include <QToolButton>
Chris@556 24
Chris@556 25 FindWidget::FindWidget(QWidget *parent) :
Chris@556 26 QWidget(parent)
Chris@556 27 {
Chris@556 28 QGridLayout *layout = new QGridLayout;
Chris@558 29 layout->setMargin(0);
Chris@556 30 setLayout(layout);
Chris@556 31
Chris@556 32 QToolButton *button = new QToolButton();
Chris@556 33 layout->addWidget(button, 0, 0);
Chris@556 34 button->setText(tr("Find..."));
Chris@556 35 button->setToolButtonStyle(Qt::ToolButtonTextOnly);
sam@626 36 button->setShortcut(tr("Ctrl+F"));
Chris@556 37 connect(button, SIGNAL(clicked()), this, SLOT(buttonPressed()));
Chris@556 38
Chris@556 39 m_lineEdit = new QLineEdit();
Chris@556 40 layout->addWidget(m_lineEdit, 0, 1);
Chris@556 41
Chris@556 42 m_lineEdit->setFixedWidth(100);
Chris@556 43 m_lineEdit->hide();
Chris@556 44
Chris@558 45 int h = m_lineEdit->sizeHint().height();
Chris@558 46 int h0 = button->sizeHint().height();
Chris@558 47 if (h > h0) button->setFixedHeight(h);
Chris@558 48
Chris@556 49 connect(m_lineEdit, SIGNAL(textChanged(const QString &)),
Chris@556 50 this, SIGNAL(findTextChanged(QString)));
Chris@556 51 }
Chris@556 52
Chris@556 53 FindWidget::~FindWidget()
Chris@556 54 {
Chris@556 55 }
Chris@556 56
Chris@556 57 void
Chris@556 58 FindWidget::buttonPressed()
Chris@556 59 {
Chris@556 60 QAbstractButton *button = qobject_cast<QAbstractButton *>(sender());
Chris@556 61 if (!button) return;
Chris@556 62 if (m_lineEdit->isVisible()) {
sam@626 63 m_lineEdit->hide();
sam@626 64 button->setText(tr("Find..."));
Chris@557 65 if (m_lineEdit->text() != "") {
Chris@557 66 emit findTextChanged("");
Chris@557 67 }
Chris@556 68 } else {
sam@626 69 m_lineEdit->show();
Chris@558 70 m_lineEdit->setFocus(Qt::OtherFocusReason);
sam@626 71 button->setText(tr("Find:"));
Chris@557 72 if (m_lineEdit->text() != "") {
Chris@557 73 emit findTextChanged(m_lineEdit->text());
Chris@557 74 }
Chris@556 75 }
Chris@556 76 }
Chris@556 77