mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-20 12:24:24 -04:00
-fixed RWindow
-MainWindow uses now RWindow for storing size and position -added stringlist header for GeneralDialog git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@688 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
2f30ee6b1d
commit
483118daec
8 changed files with 34 additions and 32 deletions
|
@ -102,7 +102,7 @@
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
|
MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
|
||||||
: QMainWindow(parent, flags)
|
: RWindow("MainWindow", parent, flags)
|
||||||
{
|
{
|
||||||
/* Invoke the Qt Designer generated QObject setup routine */
|
/* Invoke the Qt Designer generated QObject setup routine */
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
|
@ -59,7 +59,7 @@ class SMPlayer;
|
||||||
|
|
||||||
class PeerStatus;
|
class PeerStatus;
|
||||||
|
|
||||||
class MainWindow : public QMainWindow
|
class MainWindow : public RWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
#include "rshare.h"
|
#include "rshare.h"
|
||||||
#include "GeneralDialog.h"
|
#include "GeneralDialog.h"
|
||||||
|
#include <util/stringutil.h>
|
||||||
#include <QSystemTrayIcon>
|
#include <QSystemTrayIcon>
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
|
@ -60,9 +61,7 @@ GeneralDialog::~GeneralDialog()
|
||||||
/** Saves the changes on this page */
|
/** Saves the changes on this page */
|
||||||
bool
|
bool
|
||||||
GeneralDialog::save(QString &errmsg)
|
GeneralDialog::save(QString &errmsg)
|
||||||
{
|
{
|
||||||
Q_UNUSED(errmsg);
|
|
||||||
|
|
||||||
_settings->setValue(QString::fromUtf8("StartMinimized"), startMinimized());
|
_settings->setValue(QString::fromUtf8("StartMinimized"), startMinimized());
|
||||||
|
|
||||||
_settings->setRunRetroshareOnBoot(
|
_settings->setRunRetroshareOnBoot(
|
||||||
|
@ -74,11 +73,9 @@ GeneralDialog::save(QString &errmsg)
|
||||||
/** Loads the settings for this page */
|
/** Loads the settings for this page */
|
||||||
void
|
void
|
||||||
GeneralDialog::load()
|
GeneralDialog::load()
|
||||||
{
|
{
|
||||||
|
|
||||||
ui.chkRunRetroshareAtSystemStartup->setChecked(
|
ui.chkRunRetroshareAtSystemStartup->setChecked(
|
||||||
_settings->runRetroshareOnBoot());
|
_settings->runRetroshareOnBoot());
|
||||||
|
|
||||||
|
|
||||||
ui.checkStartMinimized->setChecked(_settings->value(QString::fromUtf8("StartMinimized"), false).toBool());
|
ui.checkStartMinimized->setChecked(_settings->value(QString::fromUtf8("StartMinimized"), false).toBool());
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
#ifndef _GENERALDIALOG_H
|
#ifndef _GENERALDIALOG_H
|
||||||
#define _GENERALDIALOG_H
|
#define _GENERALDIALOG_H
|
||||||
|
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
@ -54,7 +55,7 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** A RetroShare Settings object used for saving/loading settings */
|
/** A RetroShare Settings object used for saving/loading settings */
|
||||||
RshareSettings* _settings;
|
RshareSettings *_settings;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,11 +23,11 @@
|
||||||
|
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
#include <QSize>
|
#include <QSize>
|
||||||
#include <QPalette>
|
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QKeySequence>
|
#include <QKeySequence>
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
|
#include <rshare.h>
|
||||||
#include "rwindow.h"
|
#include "rwindow.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,8 +36,7 @@ RWindow::RWindow(QString name, QWidget *parent, Qt::WFlags flags)
|
||||||
: QMainWindow(parent, flags)
|
: QMainWindow(parent, flags)
|
||||||
{
|
{
|
||||||
_name = name;
|
_name = name;
|
||||||
_settings = new RshareSettings();
|
_settings = new RSettings(name);
|
||||||
_previouslyShown = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Destructor. */
|
/** Destructor. */
|
||||||
|
@ -51,8 +50,7 @@ RWindow::~RWindow()
|
||||||
void
|
void
|
||||||
RWindow::setShortcut(QString shortcut, const char *slot)
|
RWindow::setShortcut(QString shortcut, const char *slot)
|
||||||
{
|
{
|
||||||
QShortcut *s = new QShortcut(QKeySequence(shortcut), this, slot, 0);
|
rApp->createShortcut(QKeySequence(shortcut), this, this, slot);
|
||||||
Q_UNUSED(s);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Saves the size and location of the window. */
|
/** Saves the size and location of the window. */
|
||||||
|
@ -73,7 +71,10 @@ RWindow::restoreWindowState()
|
||||||
{
|
{
|
||||||
#if QT_VERSION >= 0x040200
|
#if QT_VERSION >= 0x040200
|
||||||
QByteArray geometry = getSetting("Geometry", QByteArray()).toByteArray();
|
QByteArray geometry = getSetting("Geometry", QByteArray()).toByteArray();
|
||||||
restoreGeometry(geometry);
|
if (geometry.isEmpty())
|
||||||
|
adjustSize();
|
||||||
|
else
|
||||||
|
restoreGeometry(geometry);
|
||||||
#else
|
#else
|
||||||
QRect screen = QDesktopWidget().availableGeometry();
|
QRect screen = QDesktopWidget().availableGeometry();
|
||||||
|
|
||||||
|
@ -115,25 +116,14 @@ void
|
||||||
RWindow::setVisible(bool visible)
|
RWindow::setVisible(bool visible)
|
||||||
{
|
{
|
||||||
if (visible) {
|
if (visible) {
|
||||||
/* If this is the first time this window is shown, restore its window
|
|
||||||
* position and size. */
|
|
||||||
if (!_previouslyShown) {
|
|
||||||
#if !defined (Q_WS_WIN)
|
|
||||||
/* Use the standard palette on non-Windows, overriding whatever was
|
|
||||||
* specified in the .ui file for this dialog. */
|
|
||||||
setPalette(QPalette());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
restoreWindowState();
|
|
||||||
_previouslyShown = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Bring the window to the top, if it's already open. Otherwise, make the
|
/* Bring the window to the top, if it's already open. Otherwise, make the
|
||||||
* window visible. */
|
* window visible. */
|
||||||
if (isVisible()) {
|
if (isVisible()) {
|
||||||
activateWindow();
|
activateWindow();
|
||||||
setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
|
setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
|
||||||
raise();
|
raise();
|
||||||
|
} else {
|
||||||
|
restoreWindowState();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Save the last size and position of this window. */
|
/* Save the last size and position of this window. */
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <gui/Preferences/rsharesettings.h>
|
#include <gui/Preferences/rsettings.h>
|
||||||
|
|
||||||
|
|
||||||
class RWindow : public QMainWindow
|
class RWindow : public QMainWindow
|
||||||
|
@ -68,8 +68,7 @@ signals:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString _name; /**< Name associated with this window. */
|
QString _name; /**< Name associated with this window. */
|
||||||
RshareSettings* _settings; /**< Object used to store window properties */
|
RSettings* _settings; /**< Object used to store window properties */
|
||||||
bool _previouslyShown; /**< True if show() has been called for this window. */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
#include <QShortcut>
|
||||||
#include <QStyleFactory>
|
#include <QStyleFactory>
|
||||||
#include <gui/common/vmessagebox.h>
|
#include <gui/common/vmessagebox.h>
|
||||||
#include <gui/common/html.h>
|
#include <gui/common/html.h>
|
||||||
|
@ -413,4 +414,12 @@ Rshare::log(Log::LogLevel level, QString msg)
|
||||||
return _log.log(level, msg);
|
return _log.log(level, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Creates and binds a shortcut such that when <b>key</b> is pressed in
|
||||||
|
* <b>sender</b>'s context, <b>receiver</b>'s <b>slot</b> will be called. */
|
||||||
|
void
|
||||||
|
Rshare::createShortcut(const QKeySequence &key, QWidget *sender,
|
||||||
|
QWidget *receiver, const char *slot)
|
||||||
|
{
|
||||||
|
QShortcut *s = new QShortcut(key, sender);
|
||||||
|
connect(s, SIGNAL(activated()), receiver, slot);
|
||||||
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QKeySequence>
|
||||||
|
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "gui/Preferences/rsharesettings.h"
|
#include "gui/Preferences/rsharesettings.h"
|
||||||
|
@ -106,6 +107,11 @@ public:
|
||||||
* running() will be emitted when the event loop has started. */
|
* running() will be emitted when the event loop has started. */
|
||||||
static int run();
|
static int run();
|
||||||
|
|
||||||
|
/** Creates and binds a shortcut such that when <b>key</b> is pressed in
|
||||||
|
* <b>sender</b>'s context, <b>receiver</b>'s <b>slot</b> will be called. */
|
||||||
|
static void createShortcut(const QKeySequence &key, QWidget *sender,
|
||||||
|
QWidget *receiver, const char *slot);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/** Emitted when the application is running and the main event loop has
|
/** Emitted when the application is running and the main event loop has
|
||||||
* started. */
|
* started. */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue