Skip to content

Commit 182edc6

Browse files
committed
Created ui file for OutputDialog
1 parent 19eb70e commit 182edc6

File tree

13 files changed

+353
-208
lines changed

13 files changed

+353
-208
lines changed

notifier/octopi-notifier/mainwindow.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,6 @@ void MainWindow::doSystemUpgrade()
349349
m_actionSystemUpgrade->setEnabled(false);
350350

351351
OutputDialog *dlg = new OutputDialog(this);
352-
dlg->setFrameShape(QFrame::NoFrame);
353352

354353
if (m_debugInfo)
355354
dlg->setDebugMode(true);

notifier/octopi-notifier/octopi-notifier.pro

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ OBJECTS_DIR += ../build-octopi-notifier
3434
MOC_DIR += ../build-octopi-notifier
3535
UI_DIR += ../build-octopi-notifier
3636

37+
# so that .ui files can find headers
38+
# no matter where they’re included from
39+
INCLUDEPATH += ../..
40+
3741
HEADERS += \
3842
mainwindow.h \
3943
outputdialog.h \
@@ -78,7 +82,10 @@ ALPM_BACKEND{
7882
}
7983

8084
FORMS += ../../ui/transactiondialog.ui \
81-
../../ui/optionsdialog.ui
85+
../../ui/searchlineedit.ui \
86+
../../ui/searchbar.ui \
87+
../../ui/optionsdialog.ui \
88+
ui/outputdialog.ui
8289

8390
RESOURCES += \
8491
../../resources.qrc

notifier/octopi-notifier/outputdialog.cpp

Lines changed: 27 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020

2121
#include "outputdialog.h"
22+
#include "ui_outputdialog.h"
2223
#include "../../src/pacmanexec.h"
2324
#include "../../src/searchbar.h"
2425
#include "../../src/uihelper.h"
@@ -37,8 +38,11 @@
3738
/*
3839
* The obligatory constructor...
3940
*/
40-
OutputDialog::OutputDialog(QWidget *parent): QDialog(parent)
41+
OutputDialog::OutputDialog(QWidget *parent):
42+
QDialog(parent),
43+
ui(new Ui::OutputDialog)
4144
{
45+
ui->setupUi(this);
4246
init();
4347
m_upgradeRunning = false;
4448
m_debugInfo = false;
@@ -52,49 +56,20 @@ void OutputDialog::setDebugMode(bool newValue)
5256
m_debugInfo = newValue;
5357
}
5458

55-
QFrame::Shape OutputDialog::frameShape()
56-
{
57-
return m_textBrowser->frameShape();
58-
}
59-
60-
void OutputDialog::setFrameShape(QFrame::Shape shape)
61-
{
62-
m_textBrowser->setFrameShape(shape);
63-
}
64-
6559
/*
6660
* Let's build the main widgets...
6761
*/
6862
void OutputDialog::init()
6963
{
70-
this->resize(650, 500);
71-
72-
setWindowTitle(QCoreApplication::translate("MainWindow", "System upgrade"));
7364
setWindowIcon(IconHelper::getIconSystemUpgrade());
74-
m_mainLayout = new QVBoxLayout(this);
75-
m_textBrowser = new QTextBrowser(this);
76-
m_progressBar = new QProgressBar(this);
77-
78-
m_textBrowser->setGeometry(QRect(0, 0, 650, 500));
79-
80-
m_mainLayout->addWidget(m_textBrowser);
81-
82-
m_searchBar = new SearchBar(this);
83-
connect(m_searchBar, SIGNAL(textChanged(QString)), this, SLOT(onSearchBarTextChanged(QString)));
84-
connect(m_searchBar, SIGNAL(closed()), this, SLOT(onSearchBarClosed()));
85-
connect(m_searchBar, SIGNAL(findNext()), this, SLOT(onSearchBarFindNext()));
86-
connect(m_searchBar, SIGNAL(findPrevious()), this, SLOT(onSearchBarFindPrevious()));
87-
m_mainLayout->addWidget(m_progressBar);
88-
m_mainLayout->addWidget(m_searchBar);
89-
m_mainLayout->setSpacing(0);
90-
m_mainLayout->setSizeConstraint(QLayout::SetMinimumSize);
91-
m_mainLayout->setContentsMargins(2, 2, 2, 2);
9265

93-
m_progressBar->setMinimum(0);
94-
m_progressBar->setMaximum(100);
95-
m_progressBar->setValue(0);
96-
m_progressBar->close();
97-
m_searchBar->show();
66+
connect(ui->m_searchBar, SIGNAL(textChanged(QString)), this, SLOT(onSearchBarTextChanged(QString)));
67+
connect(ui->m_searchBar, SIGNAL(closed()), this, SLOT(onSearchBarClosed()));
68+
connect(ui->m_searchBar, SIGNAL(findNext()), this, SLOT(onSearchBarFindNext()));
69+
connect(ui->m_searchBar, SIGNAL(findPrevious()), this, SLOT(onSearchBarFindPrevious()));
70+
ui->m_searchBar->show();
71+
72+
ui->m_progressBar->close();
9873
}
9974

10075
/*
@@ -147,53 +122,53 @@ void OutputDialog::reject()
147122
*/
148123
void OutputDialog::onPencertange(int percentage)
149124
{
150-
if (percentage > 0 && !m_progressBar->isVisible()) m_progressBar->show();
151-
m_progressBar->setValue(percentage);
125+
if (percentage > 0 && !ui->m_progressBar->isVisible()) ui->m_progressBar->show();
126+
ui->m_progressBar->setValue(percentage);
152127
}
153128

154129
/*
155130
* Helper method to position the text cursor always in the end of doc
156131
*/
157132
void OutputDialog::positionTextEditCursorAtEnd()
158133
{
159-
QTextCursor tc = m_textBrowser->textCursor();
134+
QTextCursor tc = ui->m_textBrowser->textCursor();
160135
tc.clearSelection();
161136
tc.movePosition(QTextCursor::End);
162-
m_textBrowser->setTextCursor(tc);
137+
ui->m_textBrowser->setTextCursor(tc);
163138
}
164139

165140
/*
166141
* A helper method which writes the given string to the textbrowser
167142
*/
168143
void OutputDialog::writeToTabOutput(const QString &msg, TreatURLLinks treatURLLinks)
169144
{
170-
utils::writeToTextBrowser(m_textBrowser, msg, treatURLLinks);
145+
utils::writeToTextBrowser(ui->m_textBrowser, msg, treatURLLinks);
171146
}
172147

173148
/*
174149
* Slot called whenever PacmanExec emits a new output
175150
*/
176151
void OutputDialog::onWriteOutput(const QString &output)
177152
{
178-
utils::positionTextEditCursorAtEnd(m_textBrowser);
179-
m_textBrowser->insertHtml(output);
180-
m_textBrowser->ensureCursorVisible();
153+
utils::positionTextEditCursorAtEnd(ui->m_textBrowser);
154+
ui->m_textBrowser->insertHtml(output);
155+
ui->m_textBrowser->ensureCursorVisible();
181156
}
182157

183158
/*
184159
* Helper method to find the given "findText" in a TextEdit
185160
*/
186161
bool OutputDialog::textInTabOutput(const QString& findText)
187162
{
188-
return (utils::strInQTextEdit(m_textBrowser, findText));
163+
return (utils::strInQTextEdit(ui->m_textBrowser, findText));
189164
}
190165

191166
/*
192167
* Slot called whenever PacmanExec finishes its job
193168
*/
194169
void OutputDialog::pacmanProcessFinished(int exitCode, QProcess::ExitStatus exitStatus)
195170
{
196-
m_progressBar->close();
171+
ui->m_progressBar->close();
197172

198173
if ((exitCode == 0) && exitStatus == QProcess::NormalExit)
199174
{
@@ -226,31 +201,31 @@ void OutputDialog::pacmanProcessFinished(int exitCode, QProcess::ExitStatus exit
226201
*/
227202
void OutputDialog::onSearchBarTextChanged(QString strToSearch)
228203
{
229-
utils::searchBarTextChangedInTextBrowser(m_textBrowser, m_searchBar, strToSearch);
204+
utils::searchBarTextChangedInTextBrowser(ui->m_textBrowser, ui->m_searchBar, strToSearch);
230205
}
231206

232207
/*
233208
* User closed the search bar
234209
*/
235210
void OutputDialog::onSearchBarClosed()
236211
{
237-
utils::searchBarClosedInTextBrowser(m_textBrowser, m_searchBar);
212+
utils::searchBarClosedInTextBrowser(ui->m_textBrowser, ui->m_searchBar);
238213
}
239214

240215
/*
241216
* User requested next found string
242217
*/
243218
void OutputDialog::onSearchBarFindNext()
244219
{
245-
utils::searchBarFindNextInTextBrowser(m_textBrowser, m_searchBar);
220+
utils::searchBarFindNextInTextBrowser(ui->m_textBrowser, ui->m_searchBar);
246221
}
247222

248223
/*
249224
* User requested previous found string
250225
*/
251226
void OutputDialog::onSearchBarFindPrevious()
252227
{
253-
utils::searchBarFindPreviousInTextBrowser(m_textBrowser, m_searchBar);
228+
utils::searchBarFindPreviousInTextBrowser(ui->m_textBrowser, ui->m_searchBar);
254229
}
255230

256231
/*
@@ -277,7 +252,7 @@ void OutputDialog::keyPressEvent(QKeyEvent *ke)
277252
{
278253
if(ke->key() == Qt::Key_F && ke->modifiers() == Qt::ControlModifier)
279254
{
280-
m_searchBar->show();
255+
ui->m_searchBar->show();
281256
}
282257
else if(ke->key() == Qt::Key_Escape)
283258
{

notifier/octopi-notifier/outputdialog.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ class QWidget;
3737
class QCloseEvent;
3838
class QKeyEvent;
3939

40+
namespace Ui {
41+
class OutputDialog;
42+
}
43+
4044
class OutputDialog : public QDialog
4145
{
4246
Q_OBJECT
4347

44-
Q_PROPERTY(QFrame::Shape frameShape READ frameShape WRITE setFrameShape USER true)
45-
4648
private:
47-
QTextBrowser *m_textBrowser;
48-
QProgressBar *m_progressBar;
49-
QVBoxLayout *m_mainLayout;
49+
Ui::OutputDialog *ui;
5050
PacmanExec *m_pacmanExec;
5151
SearchBar *m_searchBar;
5252
bool m_upgradeRunning;
@@ -77,12 +77,10 @@ private slots:
7777
public:
7878
explicit OutputDialog(QWidget *parent = 0);
7979
void setDebugMode(bool newValue);
80-
QFrame::Shape frameShape();
8180

8281
public slots:
8382
void show();
8483
void reject();
85-
void setFrameShape(QFrame::Shape shape);
8684
};
8785

8886
#endif // OUTPUTDIALOG_H
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>OutputDialog</class>
4+
<widget class="QDialog" name="OutputDialog">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>650</width>
10+
<height>550</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>System upgrade</string>
15+
</property>
16+
<property name="windowIcon">
17+
<iconset theme="go-up">
18+
<normaloff>.</normaloff>.</iconset>
19+
</property>
20+
<layout class="QVBoxLayout" name="m_mainLayout">
21+
<property name="spacing">
22+
<number>0</number>
23+
</property>
24+
<property name="sizeConstraint">
25+
<enum>QLayout::SetMinimumSize</enum>
26+
</property>
27+
<property name="leftMargin">
28+
<number>0</number>
29+
</property>
30+
<property name="topMargin">
31+
<number>0</number>
32+
</property>
33+
<property name="rightMargin">
34+
<number>0</number>
35+
</property>
36+
<property name="bottomMargin">
37+
<number>0</number>
38+
</property>
39+
<item>
40+
<widget class="QTextBrowser" name="m_textBrowser">
41+
<property name="frameShape">
42+
<enum>QFrame::NoFrame</enum>
43+
</property>
44+
</widget>
45+
</item>
46+
<item>
47+
<widget class="QProgressBar" name="m_progressBar">
48+
<property name="minimum">
49+
<number>0</number>
50+
</property>
51+
<property name="maximum">
52+
<number>100</number>
53+
</property>
54+
<property name="value">
55+
<number>0</number>
56+
</property>
57+
</widget>
58+
</item>
59+
<item>
60+
<widget class="SearchBar" name="m_searchBar" native="true"/>
61+
</item>
62+
</layout>
63+
</widget>
64+
<customwidgets>
65+
<customwidget>
66+
<class>SearchBar</class>
67+
<extends>QWidget</extends>
68+
<header>src/searchbar.h</header>
69+
<container>1</container>
70+
</customwidget>
71+
</customwidgets>
72+
<resources/>
73+
<connections/>
74+
</ui>

octopi.pro

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ HEADERS += src/QtSolutions/qtsingleapplication.h \
4747
src/terminal.h \
4848
src/pacmanexec.h \
4949
src/constants.h \
50-
src/optionsdialog.h
50+
src/optionsdialog.h
5151

5252
ALPM_BACKEND{
5353
HEADERS += src/alpmbackend.h
@@ -83,7 +83,7 @@ SOURCES += src/QtSolutions/qtsingleapplication.cpp \
8383
src/utils.cpp \
8484
src/terminal.cpp \
8585
src/pacmanexec.cpp \
86-
src/optionsdialog.cpp
86+
src/optionsdialog.cpp
8787

8888
ALPM_BACKEND{
8989
SOURCES += src/alpmbackend.cpp
@@ -92,7 +92,9 @@ ALPM_BACKEND{
9292
FORMS += ui/mainwindow.ui \
9393
ui/transactiondialog.ui \
9494
ui/multiselectiondialog.ui \
95-
ui/optionsdialog.ui
95+
ui/optionsdialog.ui \
96+
ui/searchbar.ui \
97+
ui/searchlineedit.ui
9698

9799
RESOURCES += resources.qrc
98100

0 commit comments

Comments
 (0)