так ядро готово
This commit is contained in:
parent
cb81d46717
commit
c38f00cd5a
@ -25,10 +25,12 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
|||||||
|
|
||||||
SOURCES += main.cpp\
|
SOURCES += main.cpp\
|
||||||
boss.cpp \
|
boss.cpp \
|
||||||
pcore.cpp
|
pcore.cpp \
|
||||||
|
conmenu.cpp
|
||||||
|
|
||||||
HEADERS += boss.h \
|
HEADERS += boss.h \
|
||||||
pcore.h
|
pcore.h \
|
||||||
|
conmenu.h
|
||||||
|
|
||||||
DISTFILES += \
|
DISTFILES += \
|
||||||
README.md
|
README.md
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE QtCreatorProject>
|
<!DOCTYPE QtCreatorProject>
|
||||||
<!-- Written by QtCreator 4.2.0, 2017-12-17T11:28:59. -->
|
<!-- Written by QtCreator 4.2.0, 2017-12-17T19:49:45. -->
|
||||||
<qtcreator>
|
<qtcreator>
|
||||||
<data>
|
<data>
|
||||||
<variable>EnvironmentId</variable>
|
<variable>EnvironmentId</variable>
|
||||||
@ -62,7 +62,7 @@
|
|||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.7.1 MSVC2015_64bit</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.7.1 MSVC2015_64bit</value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.7.1 MSVC2015_64bit</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.7.1 MSVC2015_64bit</value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.57.win64_msvc2015_64_kit</value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.57.win64_msvc2015_64_kit</value>
|
||||||
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
|
||||||
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||||
|
|||||||
36
boss.cpp
36
boss.cpp
@ -1,8 +1,11 @@
|
|||||||
#include "boss.h"
|
#include "boss.h"
|
||||||
|
#include <QtGui>
|
||||||
|
|
||||||
boss::boss(QWidget *parent)
|
boss::boss(QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
{
|
{
|
||||||
|
cnm = new conmenu();
|
||||||
|
|
||||||
trayIco = new QSystemTrayIcon(this);
|
trayIco = new QSystemTrayIcon(this);
|
||||||
connect(trayIco, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(ia(QSystemTrayIcon::ActivationReason)));
|
connect(trayIco, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(ia(QSystemTrayIcon::ActivationReason)));
|
||||||
QIcon temp = QIcon(":/lock.png");
|
QIcon temp = QIcon(":/lock.png");
|
||||||
@ -16,7 +19,10 @@ boss::boss(QWidget *parent)
|
|||||||
*/
|
*/
|
||||||
void boss::ttt()
|
void boss::ttt()
|
||||||
{
|
{
|
||||||
|
cnm->close();
|
||||||
|
QRect *gg = mcm();
|
||||||
|
cnm->move(gg->x(),gg->y());
|
||||||
|
cnm->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,8 +51,32 @@ boss::~boss()
|
|||||||
* @brief boss::mcm
|
* @brief boss::mcm
|
||||||
* @return позицию иконки в трее (x,y,width,height)
|
* @return позицию иконки в трее (x,y,width,height)
|
||||||
*/
|
*/
|
||||||
QRect boss::mcm()
|
QRect *boss::mcm()
|
||||||
{
|
{
|
||||||
QRect *temp;
|
int sw, sh;//разрешение
|
||||||
|
int ew, eh;//размеры менюхи
|
||||||
|
int tx, ty;//позиция иконки в трее
|
||||||
|
|
||||||
|
QRect sg = QGuiApplication::primaryScreen()->geometry();
|
||||||
|
sw = sg.width(); sh = sg.height();//длина и ширина разришения
|
||||||
|
ew = cnm->width(); eh = cnm->height();//длина и ширина менюхи
|
||||||
|
QRect ss = trayIco->geometry();
|
||||||
|
tx = ss.x(); ty = ss.y();//позиция иконки
|
||||||
|
QRect *temp = new QRect(0,0,0,0);
|
||||||
|
|
||||||
|
int px = 30;
|
||||||
|
temp->setX(((tx-ew-px)<0) ? (tx+px) : (tx-ew-px));//если менюха по x пойдет слишком влево(за пределы) то двигаем вправо если нет то пускай так и будет
|
||||||
|
temp->setX(((tx+px+ew)>sw) ? (tx-ew-px) : (tx+px));//если ненюха но x будет уходить вправо(за пределы) то двигаем влево на всю длинну ели нет то так и будет
|
||||||
|
/*
|
||||||
|
*30 является неким отступом
|
||||||
|
* размеры менюхи задаються в conmenu.cpp на 48 строке **resize(200,500)
|
||||||
|
* 1) например if tx(15)-ew(200)-30<0 then tx(15)+30 else tx(15)-ew(200)-30 для случаев с левостроронним треем
|
||||||
|
* 2)например if tx(1000)+30+ew(200)>sw(1024) then tx(1000)-ew(200)-30 else tx(1000)+30 для случеев с правостороним треем
|
||||||
|
*/
|
||||||
|
int py = 0;
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
py = 5;
|
||||||
|
#endif
|
||||||
|
temp->setY(((ty+eh)>sh) ? (ty-eh-py) : (ty+py));//если трей слишком внизу то подымаем вверх или пускай так и будет
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|||||||
4
boss.h
4
boss.h
@ -1,6 +1,7 @@
|
|||||||
#ifndef BOSS_H
|
#ifndef BOSS_H
|
||||||
#define BOSS_H
|
#define BOSS_H
|
||||||
|
|
||||||
|
#include "conmenu.h"
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QSystemTrayIcon>
|
#include <QSystemTrayIcon>
|
||||||
|
|
||||||
@ -12,9 +13,10 @@ public:
|
|||||||
boss(QWidget *parent = 0);
|
boss(QWidget *parent = 0);
|
||||||
~boss();
|
~boss();
|
||||||
private:
|
private:
|
||||||
|
conmenu *cnm;
|
||||||
QSystemTrayIcon *trayIco;
|
QSystemTrayIcon *trayIco;
|
||||||
QRect *mcm();
|
QRect *mcm();
|
||||||
private slots;
|
private slots:
|
||||||
void ttt();
|
void ttt();
|
||||||
void ia(QSystemTrayIcon::ActivationReason reason);
|
void ia(QSystemTrayIcon::ActivationReason reason);
|
||||||
};
|
};
|
||||||
|
|||||||
76
conmenu.cpp
Normal file
76
conmenu.cpp
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
#include "conmenu.h"
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QtGui>
|
||||||
|
#include <QBoxLayout>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QFrame>
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
|
conmenu::conmenu()
|
||||||
|
{
|
||||||
|
this->setWindowFlags(Qt::FramelessWindowHint | Qt::Popup);//будь всплывайкой
|
||||||
|
this->setStyleSheet("background-color:#444");//общий задний фон
|
||||||
|
|
||||||
|
QVBoxLayout *boss = new QVBoxLayout(this);//main init
|
||||||
|
boss->setSizeConstraint(QLayout::SetMaximumSize);//растянуть полностью
|
||||||
|
boss->setMargin(0);//нахуй все пренудительные отступы
|
||||||
|
|
||||||
|
cont = new QHBoxLayout(this);//инициализация слоя для контента
|
||||||
|
core = new PCore();//инициализация ядра-хранилища(локального)
|
||||||
|
|
||||||
|
core->addPass(tr("domain"),tr("lUserName"),tr("infa(url, path, other desc)"),tr("pass(2r3tgwe454hb3f4)"));//временая костыля
|
||||||
|
|
||||||
|
//инициализация класса входа и отображения окна
|
||||||
|
|
||||||
|
boss->addLayout(cont);
|
||||||
|
boss->addStretch();
|
||||||
|
|
||||||
|
QFrame *vline = new QFrame();
|
||||||
|
QFrame *hline = new QFrame();
|
||||||
|
|
||||||
|
hline->setFrameShape(QFrame::HLine);//делаем горизонтальную полоску
|
||||||
|
boss->addWidget(hline);//сразу ресуем её
|
||||||
|
|
||||||
|
QHBoxLayout *buttons = new QHBoxLayout(this);//слой двух кнопок (exit and settings)
|
||||||
|
buttons->setMargin(0);
|
||||||
|
QPushButton *tt;
|
||||||
|
tt = sBut(buttons, tr("Settings"));
|
||||||
|
connect(tt, SIGNAL(clicked(bool)), this, SLOT(sets()));//вызывает меню настроек
|
||||||
|
|
||||||
|
vline->setFrameShape(QFrame::VLine);//разделитель двух кнопок
|
||||||
|
buttons->addWidget(vline);
|
||||||
|
|
||||||
|
tt = sBut(buttons, tr("Exit"));
|
||||||
|
connect(tt, SIGNAL(clicked(bool)), qApp, SLOT(quit()));//вырубает прогу
|
||||||
|
boss->addLayout(buttons);
|
||||||
|
|
||||||
|
setLayout(boss);
|
||||||
|
resize(200,500);//ну тут и для дауна должно быть понятно
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QPushButton *conmenu::sBut(QBoxLayout *bb, const QString &name)
|
||||||
|
{
|
||||||
|
QPushButton *nb = new QPushButton(name, this);
|
||||||
|
nb->setAttribute(Qt::WA_TranslucentBackground);//прунудительная поддержка альфы
|
||||||
|
nb->setStyleSheet(""
|
||||||
|
"border: none; "
|
||||||
|
"margin: 0px;"
|
||||||
|
"padding:5px 0px;"
|
||||||
|
"");//нахуй все бордюры и отступы
|
||||||
|
bb->addWidget(nb);
|
||||||
|
return nb;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief conmenu::sets вызывает слой настроек
|
||||||
|
*/
|
||||||
|
void conmenu::sets()
|
||||||
|
{
|
||||||
|
qDebug()<<"Settings";//но пока тут заглушка
|
||||||
|
}
|
||||||
|
|
||||||
|
conmenu::~conmenu()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
26
conmenu.h
Normal file
26
conmenu.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#ifndef CONMENU_H
|
||||||
|
#define CONMENU_H
|
||||||
|
|
||||||
|
#include "pcore.h"
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
|
||||||
|
class QBoxLayout;
|
||||||
|
class QHBoxLayout;
|
||||||
|
|
||||||
|
class conmenu : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
conmenu();
|
||||||
|
~conmenu();
|
||||||
|
protected:
|
||||||
|
PCore *core;
|
||||||
|
QHBoxLayout *cont;
|
||||||
|
QPushButton *sBut(QBoxLayout *bb, const QString &name);
|
||||||
|
private slots:
|
||||||
|
void sets();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CONMENU_H
|
||||||
@ -33,12 +33,12 @@ void PCore::addPass(QString domain, QString UName, QString Desc, QString Pass)
|
|||||||
|
|
||||||
void PCore::addPass(QString domain, QString UName, QString Pass)
|
void PCore::addPass(QString domain, QString UName, QString Pass)
|
||||||
{
|
{
|
||||||
this->addPass(domain, UName, tr("No Desc"), Pass);
|
this->addPass(domain, UName, "No Desc", Pass);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PCore::addPass(QString domain, QString Pass)
|
void PCore::addPass(QString domain, QString Pass)
|
||||||
{
|
{
|
||||||
this->addPass(domain, tr("Anonymous"), tr("No Desc"), Pass);
|
addPass(domain, "Anonymous", "No Desc", Pass);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<LSites *> *PCore::getASP()
|
QList<LSites *> *PCore::getASP()
|
||||||
|
|||||||
Reference in New Issue
Block a user