mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 20:48:52 +03:00
parent
3c1f9696df
commit
622fc3f9c3
4 changed files with 40 additions and 3 deletions
|
@ -11,6 +11,16 @@ static const int fontSize = 12;
|
||||||
static const int emojiSize = 14;
|
static const int emojiSize = 14;
|
||||||
static const int headerFontSize = 21;
|
static const int headerFontSize = 21;
|
||||||
|
|
||||||
|
// Window geometry.
|
||||||
|
namespace window
|
||||||
|
{
|
||||||
|
static const int height = 600;
|
||||||
|
static const int width = 1066;
|
||||||
|
|
||||||
|
static const int minHeight = 600;
|
||||||
|
static const int minWidth = 950;
|
||||||
|
}
|
||||||
|
|
||||||
// Button settings.
|
// Button settings.
|
||||||
namespace btn
|
namespace btn
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,6 +39,7 @@ public:
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
static MainWindow *instance();
|
static MainWindow *instance();
|
||||||
|
void saveCurrentWindowSize();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
|
@ -63,6 +64,7 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool hasActiveUser();
|
bool hasActiveUser();
|
||||||
|
void restoreWindowSize();
|
||||||
|
|
||||||
static MainWindow *instance_;
|
static MainWindow *instance_;
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
|
|
||||||
#include <QLayout>
|
#include <QLayout>
|
||||||
|
@ -35,10 +36,11 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
setObjectName("MainWindow");
|
setObjectName("MainWindow");
|
||||||
setStyleSheet("QWidget#MainWindow {background-color: #f9f9f9}");
|
setStyleSheet("QWidget#MainWindow {background-color: #f9f9f9}");
|
||||||
|
|
||||||
resize(1066, 600); // 16:9 ratio
|
restoreWindowSize();
|
||||||
setMinimumSize(QSize(950, 600));
|
setMinimumSize(QSize(conf::window::minWidth, conf::window::minHeight));
|
||||||
|
|
||||||
QFont font("Open Sans", 12);
|
QFont font("Open Sans");
|
||||||
|
font.setPixelSize(conf::fontSize);
|
||||||
font.setStyleStrategy(QFont::PreferAntialias);
|
font.setStyleStrategy(QFont::PreferAntialias);
|
||||||
setFont(font);
|
setFont(font);
|
||||||
|
|
||||||
|
@ -95,6 +97,27 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::restoreWindowSize()
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
int savedWidth = settings.value("window/width").toInt();
|
||||||
|
int savedheight = settings.value("window/height").toInt();
|
||||||
|
|
||||||
|
if (savedWidth == 0 || savedheight == 0)
|
||||||
|
resize(conf::window::width, conf::window::height);
|
||||||
|
else
|
||||||
|
resize(savedWidth, savedheight);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::saveCurrentWindowSize()
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
QSize current = size();
|
||||||
|
|
||||||
|
settings.setValue("window/width", current.width());
|
||||||
|
settings.setValue("window/height", current.height());
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::removeOverlayProgressBar()
|
void MainWindow::removeOverlayProgressBar()
|
||||||
{
|
{
|
||||||
QTimer *timer = new QTimer(this);
|
QTimer *timer = new QTimer(this);
|
||||||
|
|
|
@ -70,5 +70,7 @@ int main(int argc, char *argv[])
|
||||||
w.move(x, y);
|
w.move(x, y);
|
||||||
w.show();
|
w.show();
|
||||||
|
|
||||||
|
QObject::connect(&app, &QApplication::aboutToQuit, &w, &MainWindow::saveCurrentWindowSize);
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue