Project

General

Profile

moonstone.diff

Jim Turner, May 27, 2023 05:19

View differences:

src/moonstone/main_window.cc
21 21
#include <QCloseEvent>
22 22
#include <QSplitter>
23 23
#include <QToolButton>
24
#include <QPushButton>
25
#include <QLayout>
24 26

  
25 27
#include <libaudcore/drct.h>
26 28
#include <libaudcore/i18n.h>
......
39 41

  
40 42
namespace Moonstone {
41 43

  
44

  
42 45
MainWindow::MainWindow() :
43 46
    m_center_widget(new QWidget(this)),
44 47
    m_center_layout(audqt::make_vbox(m_center_widget, 0)),
......
46 49
    m_playlist_tabs(new PlaylistTabs),
47 50
    m_playlists_view(new PlaylistsView)
48 51
{
49
    resize(1000, 600);
52
    int x = aud_get_int ("qtui", "moonstone_x");
53
    int y = aud_get_int ("qtui", "moonstone_y");
54
    int width = aud_get_int ("qtui", "moonstone_w");
55
    int height = aud_get_int ("qtui", "moonstone_h");
56
    if (x > 0 || y > 0)
57
        this->move (x, y);
58
    if (width < 100 && height < 100)
59
        this->resize(1000, 600);
60
    else
61
        this->resize(width, height);
62

  
63
    m_is_shaded = aud_get_bool("qtui", "moonstone_shaded");
50 64

  
51 65
    setCentralWidget(m_center_widget);
52 66

  
67
    auto shade_button = new QToolButton (this);
68
    shade_button->setIcon (QIcon::fromTheme ("go-top"));
69
    shade_button->setToolTip("Shade");
70
    shade_button->setFocusPolicy(Qt::NoFocus);
71

  
72

  
53 73
    auto slider = new TimeSlider(this);
54 74

  
55 75
    const ToolBarItem items[] = {
76
        ToolBarCustom(shade_button),
77
        ToolBarAction("preferences-system", N_("Settings"), N_("Settings"),
78
                      []() { audqt::prefswin_show(); }),
56 79
#if 0
57 80
        ToolBarAction("edit-find", N_("Search Library"), N_("Search Library"),
58 81
                      toggle_search_tool, &m_search_action),
59
#endif
60 82
        ToolBarAction("document-open", N_("Open Files"), N_("Open Files"),
61 83
                      []() { audqt::fileopener_show(audqt::FileMode::Open); }),
84
#endif
62 85
        ToolBarAction("list-add", N_("Add Files"), N_("Add Files"),
63 86
                      []() { audqt::fileopener_show(audqt::FileMode::Add); }),
64 87
        ToolBarSeparator(),
......
88 111
        ToolBarAction(
89 112
            "media-playlist-shuffle", N_("Shuffle"), N_("Shuffle"),
90 113
            [](bool on) { aud_set_bool("shuffle", on); }, &m_shuffle_action),
91
        ToolBarCustom(audqt::volume_button_new(this))};
114
        ToolBarCustom(audqt::volume_button_new(this)),
115
        ToolBarSeparator(),
116
        ToolBarAction("application-exit", N_("Quit"), N_("Quit"),
117
                      aud_quit)
118
    };
92 119

  
93 120
    m_toolbar = new ToolBar(this, items);
94 121
    m_infobar = new InfoBar(this, m_toolbar);
......
100 127
    m_splitter->addWidget(m_playlist_tabs);
101 128
    m_splitter->setStretchFactor(1, 2);
102 129

  
130
    connect (shade_button, & QToolButton::clicked, [this] () {
131
        int x = this->geometry().x();
132
        int y = this->geometry().y();
133
        int width = this->geometry().width ();
134
        int height = this->geometry().height ();
135

  
136
        m_is_shaded = ! m_is_shaded;
137
        if (m_is_shaded)
138
        {
139
            int shaded_height = m_infobar->geometry().height();
140
            aud_set_int ("qtui", "moonstone_h", height);
141
            aud_set_int ("qtui", "moonstone_w", width);
142
            m_playlists_view->setVisible(false);
143
            m_splitter->hide();
144
            this->update();
145
            this->resize(width, shaded_height);
146
            updateGeometry();
147
            adjustSize();
148
            update();
149
            resize(width, shaded_height);
150
            aud_set_bool("qtui", "moonstone_shaded", true);
151
        }
152
        else
153
        {
154
            m_playlists_view->setVisible(true);
155
            m_splitter->show();
156
            height = aud_get_int("qtui", "moonstone_h");
157
            this->resize(width, height);
158
            updateGeometry();
159
            adjustSize();
160
            update();
161
            resize(width, height);
162
            aud_set_bool("qtui", "moonstone_shaded", false);
163
            aud_set_int("qtui", "moonstone_h", height);
164
            aud_set_int("qtui", "moonstone_w", width);
165
        }
166
        aud_set_int("qtui", "moonstone_x", x);
167
        aud_set_int("qtui", "moonstone_y", y);
168
    });
169

  
103 170
    update_toggles();
171
    width = this->geometry().width();
172
    height = this->geometry().height();
173
    aud_set_int("qtui", "moonstone_h", height);
174
    aud_set_int("qtui", "moonstone_w", width);
175
    if (m_is_shaded)
176
    {
177
        int shaded_height = m_infobar->geometry().height();
178
        m_playlists_view->setVisible(false);
179
        m_splitter->hide();
180
        this->update();
181
        this->resize(width, shaded_height);
182
        updateGeometry();
183
        adjustSize();
184
        update();
185
        resize(width, shaded_height);
186
        aud_set_bool("qtui", "moonstone_shaded", true);
187
    }
104 188
}
105 189

  
106 190
void MainWindow::closeEvent(QCloseEvent * e)
107 191
{
108 192
    bool handled = false;
109 193

  
194
AUDERR("--MOONSTONE CLOSE EVENT--\n");
195
    aud_set_int("qtui", "moonstone_x", this->geometry().x());
196
    aud_set_int("qtui", "moonstone_h", this->geometry().y());
197
    aud_set_int("qtui", "moonstone_h", this->geometry().width());
198
    if (! m_is_shaded)
199
        aud_set_int("qtui", "moonstone_h", this->geometry().height());
200

  
110 201
    hook_call("window close", &handled);
111 202

  
112 203
    if (!handled)
src/moonstone/main_window.h
43 43
    MainWindow();
44 44

  
45 45
private:
46
    bool m_is_shaded;
46 47
    QWidget * m_center_widget;
47 48
    QVBoxLayout * m_center_layout;
48 49
    InfoBar * m_infobar;
src/moonstone/tool_bar.cc
64 64
    }
65 65

  
66 66
    setStyleSheet("QToolBar { background: rgba(255, 255, 255, 0.6); }");
67
    setIconSize(QSize(18, 18));
68
    setFixedHeight(24);
67 69
}
68 70

  
69 71
}