Part 4 of cherry-pick from refactor
ClosedPublic

Authored by laysrodrigues on Mar 10 2018, 1:15 PM.

Details

Summary

Add home buttons to toolbar of atcoreinstancewidget
Signed-off-by: Lays Rodrigues <laysrodriguessilva@gmail.com>

Refactor of buttons options

Removed the buttons(disconnect, print, pause...) and
used a QToolBar Instead.

Looks cleaner this way.

Signed-off-by: Lays Rodrigues <laysrodriguessilva@gmail.com>

Remove non needed if

Signed-off-by: Lays Rodrigues <laysrodriguessilva@gmail.com>

Set tab name from profile

When a printer is connected the tab name is the one
from the profile used for the connection.

Signed-off-by: Lays Rodrigues <laysrodriguessilva@gmail.com>

Diff Detail

Repository
R231 Atelier
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
laysrodrigues requested review of this revision.Mar 10 2018, 1:15 PM
laysrodrigues created this revision.
patrickelectric requested changes to this revision.Mar 10 2018, 6:34 PM
patrickelectric added inline comments.
src/mainwindow.cpp
33 ↗(On Diff #29150)

mainToolBar(nullptr)

src/widgets/atcoreinstancewidget.cpp
71

[m_core] or [&]

78

/s/this/m_core

125

[&]

132

[&]

134

brackets

150

[&]

src/widgets/atcoreinstancewidget.h
73 ↗(On Diff #29150)

const QString& name

This revision now requires changes to proceed.Mar 10 2018, 6:34 PM
laysrodrigues marked 6 inline comments as done.

Patricks fixes

Updating D11208: Part 4 of cherry-pick from refactor

Add home buttons to toolbar of atcoreinstancewidget

laysrodrigues planned changes to this revision.Mar 12 2018, 12:44 AM
laysrodrigues marked an inline comment as done.
patrickelectric requested changes to this revision.Mar 12 2018, 11:37 AM
patrickelectric added inline comments.
src/widgets/atcoreinstancewidget.cpp
113

If this is false the user will not be able to change the state, are you sure of that ?

114

And why the ! Here ?

137

Identation

src/widgets/atcoreinstancewidget.h
73 ↗(On Diff #29150)

Have you compiled this code ?
Cost is not a type

This revision now requires changes to proceed.Mar 12 2018, 11:37 AM

If needed I can push part4 to a repository so @rizzitello can do the fixes.

src/widgets/atcoreinstancewidget.cpp
113

@rizzitello This is your code, can you check @patrickelectric comment?

114

@rizzitello same here.

src/widgets/atcoreinstancewidget.h
73 ↗(On Diff #29150)

? I'm reading 'const'

laysrodrigues retitled this revision from Part 4 of cherry-pick from refactor Add home buttons to toolbar of atcoreinstancewidget to Part 4 of cherry-pick from refactor.Mar 12 2018, 12:05 PM
laysrodrigues edited the summary of this revision. (Show Details)
src/mainwindow.cpp
33 ↗(On Diff #29295)

why names with underscore ? That's not KDE code style.

src/widgets/atcoreinstancewidget.h
73 ↗(On Diff #29150)

5:17: error: ISO C++ forbids declaration of 'name' with no type [-fpermissive]
sorry, I was writing in the cell.
const is a keyword, not a type, should be const QString&, const float, const int`, not only const itself.

rizzitello added inline comments.Mar 12 2018, 12:29 PM
src/widgets/atcoreinstancewidget.cpp
114

This is not my code...

These are a few things I noticed during my short test.
This code did not build :(
There are still more errors here to solve after these..

src/widgets/atcoreinstancewidget.cpp
111

Remove Function.

123

auto disconnectAction = new QAction(style()->standardIcon(QStyle::SP_DialogCloseButton),i18n("Disconnect"));

127

you do not need to change the state AtCore will do that on its own.

127

Do not set the state for atcore , it will do it itself when you close the connection

131

printAction should be a private QAction* member of the class so you can change it how your trying without crashing..
Also suggest this for the below connect.

printAction = new QAction(style()->standardIcon(QStyle::SP_MediaPlay),i18n("Print"));
    connect(printAction, &QAction::triggered, [ & ](){
        if(m_core.state() == AtCore::BUSY) {
            pausePrint();
            printAction->setText(i18n("Resume Print"));
            printAction->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
            return;
        }
        if (m_core.state() == AtCore::IDLE){
                print();
        } else if (m_core.state() == AtCore::PAUSE) {
                m_core.resume();
        }
        printAction->setText(i18n("Pause"));
        printAction->setIcon(style()->standardIcon(QStyle::SP_MediaPause));
    });

This removes the need for the build actions function as all other actions do not use the set checked attribute.

144

Should be a member of the class if you are going to use it this way.

150

auto stopAction = new QAction(style()->standardIcon(QStyle::SP_MediaStop),i18n("Stop"));

159

auto disableMotorsAction = new QAction(style()->standardIcon(QStyle::SP_MediaStop),i18n("Disable Motors"));

168

initConnectsToAtCore();

170
if( fw != QString("Auto-Detect")){
            m_core.loadFirmwarePlugin(fw);
        }

If you don't provide a fw plugin to load atcore will automaticly attempt to auto detect.

src/widgets/atcoreinstancewidget.h
72 ↗(On Diff #29295)

QAction *printAction = nullptr;

73 ↗(On Diff #29295)

Remove this function No needed

rizzitello requested changes to this revision.Mar 13 2018, 2:25 AM
laysrodrigues marked 8 inline comments as done.Mar 13 2018, 11:56 AM
laysrodrigues added inline comments.
src/mainwindow.cpp
33 ↗(On Diff #29295)

This name comes from a previous commit that is already in master. So its not part of this review.
I can update this later in the future.

src/widgets/atcoreinstancewidget.cpp
114

Removed.

127
168

This method needs to be called on the constructor. Since the connection that calls this method is inside initConnectsToAtCore.
Was a mistake that I missed to add the method on the correct place.

src/widgets/atcoreinstancewidget.h
73 ↗(On Diff #29150)

sorry, didnt noticed that the QString was removed when I added the const &

laysrodrigues marked an inline comment as done.

Patrick and sith fixes

rizzitello added inline comments.Mar 13 2018, 12:50 PM
src/widgets/atcoreinstancewidget.cpp
131

Change m_printAction text and icons in the handlePrinterStatusChanged() function based on the new state

AtCore::BUSY is set for both the start print and resume actions.
AtCore::FinishedPrint is set when a print job finishes or gets stoped
AtCore::Pause is set when the job is paused.

145

Remove

149

We need icons made for some of our actions.

rizzitello requested changes to this revision.Mar 13 2018, 1:20 PM
This revision now requires changes to proceed.Mar 13 2018, 1:20 PM
laysrodrigues added inline comments.Mar 14 2018, 2:58 PM
src/widgets/atcoreinstancewidget.cpp
149

For a few icons I'm using this:
https://fontawesome.com/v4.7.0/icons/

We can see if some of those can fit to this, otherwise we can ask VDG to make ones.

rizzitello added inline comments.Mar 14 2018, 3:11 PM
src/widgets/atcoreinstancewidget.cpp
149

Font Awesome -1
Shipping icons made by VGD : +1..
We will address this later of course.

patrickelectric accepted this revision.Mar 14 2018, 4:37 PM
rizzitello added inline comments.Mar 15 2018, 12:02 AM
src/widgets/atcoreinstancewidget.cpp
131

this ^^

laysrodrigues planned changes to this revision.Mar 15 2018, 1:37 AM
laysrodrigues marked an inline comment as done.
rizzitello accepted this revision.Mar 15 2018, 1:56 AM
This revision is now accepted and ready to land.Mar 15 2018, 1:56 AM
This revision was automatically updated to reflect the committed changes.