23 #include <QApplication>
25 #include <QHBoxLayout>
26 #include <QKeySequence>
29 #include <QWindowStateChangeEvent>
32 #define BASE_WINDOW_WIDTH 1200
33 #define BASE_WINDOW_HEIGHT 740
34 #define BASE_WINDOW_MIN_HEIGHT 620
35 #define BASE_WINDOW_MIN_WIDTH 1100
50 QRect rec = QGuiApplication::primaryScreen()->geometry();
55 QSize(adaptedWidth, adaptedHeight),
66 QString windowTitle = QString::fromStdString(
gArgs.
GetArg(
"-windowtitle",
""));
67 if (windowTitle.isEmpty()) {
69 windowTitle += ((
enableWallet) ? tr(
"Wallet") : tr(
"Node"));
72 setWindowTitle(windowTitle);
74 QApplication::setWindowIcon(networkStyle->
getAppIcon());
80 QFrame* centralWidget =
new QFrame(
this);
83 QHBoxLayout* centralWidgetLayouot =
new QHBoxLayout();
84 centralWidget->setLayout(centralWidgetLayouot);
85 centralWidgetLayouot->setContentsMargins(0,0,0,0);
86 centralWidgetLayouot->setSpacing(0);
88 centralWidget->setProperty(
"cssClass",
"container");
89 centralWidget->setStyleSheet(
"padding:0px; border:none; margin:0px;");
93 centralWidgetLayouot->addWidget(
navMenu);
95 this->setCentralWidget(centralWidget);
96 this->setContentsMargins(0,0,0,0);
98 QFrame *container =
new QFrame(centralWidget);
99 container->setContentsMargins(0,0,0,0);
100 centralWidgetLayouot->addWidget(container);
103 QVBoxLayout *baseScreensContainer =
new QVBoxLayout(
this);
104 baseScreensContainer->setMargin(0);
105 baseScreensContainer->setSpacing(0);
106 baseScreensContainer->setContentsMargins(0,0,0,0);
107 container->setLayout(baseScreensContainer);
111 topBar->setContentsMargins(0,0,0,0);
112 baseScreensContainer->addWidget(
topBar);
116 QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
174 quitAction =
new QAction(QIcon(
":/icons/quit"), tr(
"E&xit"),
this);
175 quitAction->setStatusTip(tr(
"Quit application"));
176 quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
180 connect(
quitAction, &QAction::triggered, qApp, &QApplication::quit);
188 QShortcut *consoleShort =
new QShortcut(
this);
189 consoleShort->setKey(QKeySequence(
SHORT_KEY + Qt::Key_C));
190 connect(consoleShort, &QShortcut::activated, [
this](){
215 trayIcon =
new QSystemTrayIcon(
this);
323 if (reason == QSystemTrayIcon::Trigger) {
329 void PIVXGUI::macosDockIconActivated()
338 QMainWindow::changeEvent(e);
340 if (e->type() == QEvent::WindowStateChange) {
342 QWindowStateChangeEvent* wsevt =
static_cast<QWindowStateChangeEvent*
>(e);
343 if (!(wsevt->oldState() & Qt::WindowMinimized) && isMinimized()) {
344 QTimer::singleShot(0,
this, &PIVXGUI::hide);
346 }
else if ((wsevt->oldState() & Qt::WindowMinimized) && !isMinimized()) {
347 QTimer::singleShot(0,
this, &PIVXGUI::show);
360 QApplication::quit();
362 QMainWindow::showMinimized();
367 QMainWindow::closeEvent(event);
381 void PIVXGUI::message(
const QString& title,
const QString& message,
unsigned int style,
bool* ret)
390 if (!title.isEmpty()) {
395 msgType = tr(
"Error");
398 msgType = tr(
"Warning");
401 msgType = tr(
"Information");
404 msgType = tr(
"System Message");
423 (title.isEmpty() ? strTitle : title),
message,
"OK",
"CANCEL"
434 if (!msgType.isEmpty())
435 strTitle +=
" - " + msgType;
446 dialog->
setText(title, body, okBtn, cancelBtn);
447 dialog->adjustSize();
451 dialog->
setText(title, body, okBtn);
453 dialog->adjustSize();
457 bool ret = dialog->
isOk;
458 dialog->deleteLater();
555 this->setStyleSheet(css);
567 QMainWindow::resizeEvent(event);
581 if (!
op)
op =
new QLabel(
this);
583 op->setVisible(
false);
586 QColor bg(
"#000000");
589 bg = QColor(
"#00000000");
594 palette.setColor(QPalette::Window, bg);
595 op->setAutoFillBackground(
true);
596 op->setPalette(palette);
597 op->setWindowFlags(Qt::CustomizeWindowHint);
600 op->activateWindow();
601 op->resize(width(), height());
602 op->setVisible(
true);
618 dialog->deleteLater();
629 void PIVXGUI::setMNModel(
MNModel* _mnModel)
672 bool PIVXGUI::setCurrentWallet(
const QString&
name)
678 void PIVXGUI::removeAllWallets()
688 message(amount < 0 ? tr(
"Sent transaction") : tr(
"Incoming transaction"),
704 static bool ThreadSafeMessageBox(
PIVXGUI* gui,
const std::string& message,
const std::string& caption,
unsigned int style)
711 std::cout <<
"thread safe box: " << message << std::endl;
713 QMetaObject::invokeMethod(gui,
"message",
715 Q_ARG(QString, QString::fromStdString(caption)),
716 Q_ARG(QString, QString::fromStdString(message)),
717 Q_ARG(
unsigned int, style),
int64_t CAmount
Amount in PIV (Can be negative)
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
static QString formatWithUnit(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
Format as string (with unit)
Signals for UI communication.
@ BTN_MASK
Mask of all available buttons in CClientUIInterface::MessageBoxFlags This needs to be updated,...
@ MSG_INFORMATION
Predefined combinations for certain default usage cases.
@ MODAL
Force blocking, modal message box dialog (not just OS notification)
boost::signals2::signal< bool(const std::string &message, const std::string &caption, unsigned int style), boost::signals2::last_value< bool > > ThreadSafeMessageBox
Show message box.
Model for PIVX network client.
void message(const QString &title, const QString &message, unsigned int style, bool *ret=nullptr)
Fired when a message should be reported to the user.
void alertsChanged(const QString &warnings)
OptionsModel * getOptionsModel()
void setText(const QString &title="", const QString &message="", const QString &okBtnText="", const QString &cancelBtnText="")
Macintosh-specific dock icon handler.
static MacDockIconHandler * instance()
const QString & getTitleAddText() const
const QIcon & getAppIcon() const
Cross-platform desktop notification client.
@ Information
Informational message.
@ Critical
An error occurred.
@ Warning
Notify user of potential problem.
void notify(Class cls, const QString &title, const QString &text, const QIcon &icon=QIcon(), int millisTimeout=10000)
Show notification message.
bool getMinimizeOnClose()
MasterNodesWidget * masterNodesWidget
void createTrayIcon(const NetworkStyle *networkStyle)
Create system tray icon and notification.
QAction * toggleHideAction
bool execDialog(QDialog *dialog, int xDiv=3, int yDiv=5)
AddressesWidget * addressesWidget
std::unique_ptr< interfaces::Handler > m_handler_message_box
void unsubscribeFromCoreSignals()
Disconnect core signals from GUI client.
void showNormalIfMinimized(bool fToggleHidden=false)
Show window if hidden, unminimize when minimized, rise when obscured or show if hidden and fToggleHid...
void themeChanged(bool isLightTheme, QString &theme)
QSystemTrayIcon * trayIcon
void requestedRestart(QStringList args)
Restart handling.
void closeEvent(QCloseEvent *event) override
bool openStandardDialog(QString title="", QString body="", QString okBtn="OK", QString cancelBtn="CANCEL")
void detectShutdown()
called by a timer to check if ShutdownRequested()
void incomingTransaction(const QString &date, int unit, const CAmount &amount, const QString &type, const QString &address)
Show incoming transaction notification for new transactions.
void createActions(const NetworkStyle *networkStyle)
Create the main UI actions.
void changeEvent(QEvent *e) override
void messageInfo(const QString &message)
ClientModel * clientModel
void resizeEvent(QResizeEvent *event) override
void trayIconActivated(QSystemTrayIcon::ActivationReason reason)
Handle tray icon clicked.
void message(const QString &title, const QString &message, unsigned int style, bool *ret=nullptr)
Notify the user of an event from the core network or transaction handling code.
static const QString DEFAULT_WALLET
GovernanceWidget * governancewidget
void subscribeToCoreSignals()
Connect core signals to GUI client.
QStackedWidget * stackedContainer
ColdStakingWidget * coldStakingWidget
ReceiveWidget * receiveWidget
SettingsWidget * settingsWidget
PIVXGUI(const NetworkStyle *networkStyle, QWidget *parent=0)
void changeTheme(bool isLightTheme)
DashboardWidget * dashboard
void connectActions()
Here add every event connection.
void openNetworkMonitor()
void windowResizeEvent(QResizeEvent *event)
Notificator * notificator
void showTop(QWidget *view)
void setClientModel(ClientModel *clientModel)
Set the client model.
void openFAQ(SettingsFaqWidget::Section section=SettingsFaqWidget::Section::INTRO)
Open FAQ dialog.
void handleRestart(QStringList args)
Get restart command-line parameters and request restart.
void toggleHidden()
Simply calls showNormalIfMinimized(true) for use in SLOT() macro.
void createTrayIconMenu()
Create system tray menu (or setup the dock menu)
Local Bitcoin RPC console.
void setClientModel(ClientModel *model)
void setText(const QString &text)
void walletSynced(bool isSync)
void onShowHideColdStakingChanged(bool show)
void tierTwoSynced(bool isSync)
void themeChanged(bool isLight)
Interface to PIVX wallet from Qt view code.
void message(const QString &title, const QString &body, unsigned int style, bool *ret=nullptr)
CClientUIInterface uiInterface
bool isObscured(QWidget *w)
Qt::ConnectionType blockingGUIThreadConnection()
Get connection type to call object slot in GUI thread with invokeMethod.
QString loadStyleSheet()
Load global CSS theme.
void saveWindowGeometry(const QString &strSetting, QWidget *parent)
Save window size and position.
void bringToFront(QWidget *w)
void restoreWindowGeometry(const QString &strSetting, const QSize &defaultSize, QWidget *parent)
Restore window size and position.
std::unique_ptr< Handler > MakeHandler(boost::signals2::connection connection)
Return handler wrapping a boost signal connection.
#define BASE_WINDOW_WIDTH
#define BASE_WINDOW_MIN_HEIGHT
#define BASE_WINDOW_MIN_WIDTH
#define BASE_WINDOW_HEIGHT
bool openDialogWithOpaqueBackgroundFullScreen(QDialog *widget, PIVXGUI *gui)
bool openDialogWithOpaqueBackgroundY(QDialog *widget, PIVXGUI *gui, double posX, int posY, bool hideOpaqueBackground)
bool openDialogWithOpaqueBackground(QDialog *widget, PIVXGUI *gui, double posX)
bool openDialog(QDialog *widget, QWidget *gui)
void updateStyle(QWidget *widget)
bool bdisableSystemnotifications